Skip to content

Instantly share code, notes, and snippets.

@axeda
axeda / ClassScaffold.groovy
Created May 7, 2014 14:43
Class Scaffold
public class MyClass {
// do not put stateful properties in here - I do NOT maintain state
static final MyClass INSTANCE = new MyClass();
final className = "com.axeda.enablement.MyClass"
MyClass()
{
if(MyClass.INSTANCE != null)
{
throw new RuntimeException("There is already an instance of the MyClass. Please use MyClass.INSTANCE to obtain an instance")
}
@axeda
axeda / TestScaffold.groovy
Last active November 18, 2021 12:10
Scaffold for Tests
import groovy.util.GroovyTestCase
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.RESTClient
import groovy.json.JsonOutput
import groovy.util.XmlSlurper
import groovy.xml.MarkupBuilder
import groovyx.net.http.Method
import org.apache.http.HttpEntity
@axeda
axeda / ReturnSerializer.groovy
Created April 26, 2014 23:15
Serializes custom object output into JSON or XML depending on the content type, just give it a map
import groovy.xml.StreamingMarkupBuilder
import net.sf.json.JSONObject
import groovy.xml.XmlUtil
class ReturnSerializer {
static final ReturnSerializer INSTANCE = new ReturnSerializer();
final className = "com.axeda.innovation.ReturnSerializer"
ReturnSerializer() {
if(ReturnSerializer.INSTANCE != null) {
@axeda
axeda / UserGroupPrivilegesForUser.groovy
Last active August 29, 2015 13:57
Get Privileges for UserGroups of User
import net.sf.json.JSONObject
import com.axeda.drm.sdk.user.UserGroupFinder
import com.axeda.drm.sdk.Context
import com.axeda.platform.sdk.v1.services.ServiceFactory
import com.axeda.drm.sdk.user.User
import com.axeda.drm.sdk.user.UserFinder
/**
* UserGroupPrivilegesForUser.groovy
*
@axeda
axeda / GetModel_Or_Asset_Alarms.groovy
Created February 25, 2014 15:17
Get Model Or Asset Alarms and Details
import com.axeda.common.sdk.id.Identifier
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.audit.AuditCategory
import com.axeda.drm.sdk.audit.AuditMessage
import com.axeda.drm.sdk.scripto.Request
import groovy.json.*
import net.sf.json.JSONObject
import java.net.URLDecoder
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.CustomObjectCriteria
@axeda
axeda / HelloExtendedListsAndMaps.groovy
Created September 23, 2013 14:05
Illustrates Simple Map/List Persistence to Extended Map/List
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.ExtendedMap
import com.axeda.services.v2.ExtendedMapCriteria
import com.axeda.services.v2.ExtendedList
import com.axeda.services.v2.ExtendedListCriteria
import com.axeda.services.v2.FindExtendedMapResult
import com.axeda.services.v2.FindExtendedListResult
import com.axeda.services.v2.NamedValue
@axeda
axeda / OutboundSFTP.groovy
Created September 13, 2013 19:53
Transfers file to SFTP server
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.scripto.Request
import com.axeda.drm.sdk.audit.AuditCategory
import com.axeda.drm.sdk.audit.AuditMessage
import com.axeda.drm.sdk.contact.Location
import com.axeda.drm.sdk.contact.Organization
import com.axeda.drm.sdk.data.UploadedFile
import com.axeda.drm.sdk.device.Device
import com.axeda.drm.sdk.rules.ActionContext
import com.axeda.drm.util.Emailer
@axeda
axeda / OutboundFTP.groovy
Last active January 9, 2019 12:40
Sends a FileInfo out by FTP
import com.axeda.drm.sdk.Context
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.drm.sdk.scripto.Request
import com.axeda.drm.sdk.device.Device
import com.axeda.drm.sdk.device.DeviceFinder
import org.apache.commons.net.ftp.*
import groovy.json.*
import net.sf.json.JSONObject
import com.axeda.drm.sdk.device.Model
import com.axeda.drm.sdk.device.ModelFinder
@axeda
axeda / SimpleDownloadFile.groovy
Last active December 23, 2015 00:09
Simple DownloadFile
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.*
import com.axeda.sdk.v2.exception.*
import com.axeda.drm.sdk.scripto.Request
def response = fileInfoBridge.getFileData(parameters.fileId)
def contentType = parameters.type ?: 'image/jpg'
return ['Content': response, 'Content-Disposition': contentType, 'Content-Type':contentType]
@axeda
axeda / SimpleStoreFile.groovy
Created September 13, 2013 14:36
Simple File Upload using the FileStore
import com.axeda.drm.sdk.Context
import com.axeda.drm.sdk.data.*
import com.axeda.drm.sdk.device.*
import com.axeda.drm.sdk.mobilelocation.CurrentMobileLocationFinder
import com.axeda.drm.sdk.mobilelocation.MobileLocation
import com.axeda.drm.sdk.mobilelocation.MobileLocationFinder
import com.axeda.sdk.v2.bridge.FileInfoBridge
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.ExecutionResult
import com.axeda.services.v2.FileInfo