// make variable global execution.setVariable("results", S('[]')) SequenceFlow_15dip2q // make variables local to loop execution.setVariable("analysis", 0, "terms_loop"); execution.setVariable('tweets', S('[]'), "terms_loop"); var results = execution.getVariable("results"); var term = execution.getVariable("term"); var analysis = execution.getVariable("analysis"); var termStr = term.prop('term').value(); // this is for dictionary //results.prop(termStr, analysis); // this is for list var item = {}; item["name"] = termStr; item["sentiment"] = analysis; results.append(item) execution.setVariable("results", S(results)) SequenceFlow_15dip2q SequenceFlow_1j2y6tv http://analysis:8081/ POST application/json application/json ${tweets.toString()} var response = connector.getVariable("response"); response.trim() http-connector SequenceFlow_0g6bfz6 SequenceFlow_1bz7zx2 var term = execution.getVariable("term"); 'http://twitter:8084/search/tweets.json?q='+term.prop('term').value() GET application/json var response = connector.getVariable("response"); S(response); http-connector SequenceFlow_0f6v4j4 SequenceFlow_0g6bfz6 SequenceFlow_0f6v4j4 SequenceFlow_1bz7zx2 SequenceFlow_0jebdb9 http://reporting:8083/generatePDF/ POST application/pdf application/json ${results.toString()} var response = connector.getVariable("response"); // from nodejs base64 package var lookup = [] var revLookup = [] var javaByteArray = Java.type('byte[]') var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i] revLookup[code.charCodeAt(i)] = i } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup['-'.charCodeAt(0)] = 62 revLookup['_'.charCodeAt(0)] = 63 function getLens (b64) { var len = b64.length if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf('=') if (validLen === -1) validLen = len var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4) return [validLen, placeHoldersLen] } function _byteLength (b64, validLen, placeHoldersLen) { return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { var tmp var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] var arr = new javaByteArray(_byteLength(b64, validLen, placeHoldersLen)) var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen for (var i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[curByte++] = (tmp >> 16) & 0xFF arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 1) { tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } return arr } var source = "kP/+kA=="; var decoded = toByteArray(source); //decoded var file = Java.type('org.camunda.bpm.engine.variable.Variables').fileValue("pdfTest").file(toByteArray(response)).mimeType('application/pdf').create() file http-connector SequenceFlow_1j2y6tv SequenceFlow_14nqu0e SequenceFlow_14nqu0e SequenceFlow_0jebdb9