Skip to content

Instantly share code, notes, and snippets.

@axeda
axeda / postbody.html
Created June 14, 2012 14:33
Post Body HTML and Javascript
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Scripto Post Body Demo</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="refresh" content="3600">
@axeda
axeda / ServiceMax09142011.groovy
Created September 14, 2011 20:01
ServiceMax Integration with the Axeda Platform
import org.apache.commons.httpclient.Credentials
import org.apache.commons.httpclient.HostConfiguration
import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.UsernamePasswordCredentials
import org.apache.commons.httpclient.auth.AuthScope
import org.apache.commons.httpclient.methods.GetMethod
import org.apache.commons.httpclient.methods.PostMethod
import org.apache.commons.httpclient.NameValuePair
import org.apache.commons.httpclient.*;
import java.util.*;
@axeda
axeda / HttpBuilderTimeouts.groovy
Last active June 28, 2022 19:08
Connection Timeouts with HttpBuilder
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
int TENSECONDS = 10*1000;
int THIRTYSECONDS = 30*1000;
HTTPBuilder builder = new HTTPBuilder('http://www.axeda.com')
//HTTPBuilder has no direct methods to add timeouts. We have to add them to the HttpParams of the underlying HttpClient
@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 / 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 / HttpBuilder.groovy
Created August 3, 2012 20:10
HTTPBuilder Demo
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
http = new HTTPBuilder('http://ajax.googleapis.com')
// perform a GET request, expecting JSON response data
http.request( GET, JSON){
uri.path = '/ajax/services/search/web'
uri.query = [ v: '1.0', q: 'Axeda Corp.' ]
headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8/10 Firefox/3.0.4'
@axeda
axeda / EmailAttachment.groovy
Last active January 9, 2019 12:40
Emails an attachment using bytes from a FileInfo
import com.axeda.drm.util.Emailer;
import com.axeda.drm.sdk.contact.Email
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import static com.axeda.sdk.v2.dsl.Bridges.*
import com.axeda.services.v2.FileInfoCriteria
import org.apache.commons.io.IOUtils
import java.security.MessageDigest
try {
@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 / 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 / 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