diff --git a/pom.xml b/pom.xml
index 2cc400f..3a8266f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.joget.marketplace
enhanced-json-tool
bundle
- 7.0.0
+ 7.0.1
enhanced-json-tool
http://www.joget.org
@@ -84,11 +84,21 @@
httpclient
[4.5.13,)
+
+ org.apache.httpcomponents
+ httpmime
+ 4.5.13
+
org.beanshell
bsh
2.0b4
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.3
+
diff --git a/src/main/java/org/joget/marketplace/EnhancedJsonTool.java b/src/main/java/org/joget/marketplace/EnhancedJsonTool.java
index 838a973..2eec87d 100644
--- a/src/main/java/org/joget/marketplace/EnhancedJsonTool.java
+++ b/src/main/java/org/joget/marketplace/EnhancedJsonTool.java
@@ -2,21 +2,35 @@
import bsh.Interpreter;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.HttpMultipartMode;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
@@ -25,8 +39,15 @@
import org.joget.apps.app.service.AppPluginUtil;
import org.joget.apps.app.service.AppService;
import org.joget.apps.app.service.AppUtil;
+import org.apache.http.Header;
+import org.apache.http.HeaderElement;
+import org.joget.apps.app.service.CustomURLDataSource;
+import org.joget.apps.form.model.Element;
+import org.joget.apps.form.model.Form;
+import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
+import org.joget.apps.form.service.FileUtil;
import org.joget.apps.form.service.FormUtil;
import org.joget.commons.util.LogUtil;
import org.joget.commons.util.StringUtil;
@@ -53,7 +74,7 @@ public String getDescription() {
}
public String getVersion() {
- return "7.0.0";
+ return "7.0.1";
}
public String getLabel() {
@@ -68,18 +89,24 @@ public String getPropertyOptions() {
AppDefinition appDef = AppUtil.getCurrentAppDefinition();
String appId = appDef.getId();
String appVersion = appDef.getVersion().toString();
- Object[] arguments = new Object[]{appId, appVersion};
+ Object[] arguments = new Object[]{appId, appVersion, appId, appVersion, appId, appVersion};
String json = AppUtil.readPluginResource(getClass().getName(), "/properties/enhancedJsonTool.json", arguments, true, MESSAGE_PATH);
return json;
}
public Object execute(Map properties) {
+ AppDefinition appDef = AppUtil.getCurrentAppDefinition();
WorkflowAssignment wfAssignment = (WorkflowAssignment) properties.get("workflowAssignment");
-
+ ApplicationContext ac = AppUtil.getApplicationContext();
+ WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");
+
String jsonUrl = (String) properties.get("jsonUrl");
CloseableHttpClient client = null;
HttpRequestBase request = null;
+ String jsonResponse = "";
+ Map object = null;
+
try {
client = HttpClients.createDefault();
@@ -117,6 +144,135 @@ public Object execute(Map properties) {
if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
LogUtil.info(EnhancedJsonTool.class.getName(), "Custom JSON Payload : " + getPropertyString("customPayload"));
}
+ } else {
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ Object[] paramsValues = (Object[]) properties.get("params");
+ for (Object o : paramsValues) {
+ Map mapping = (HashMap) o;
+ String name = mapping.get("name").toString();
+ String value = mapping.get("value").toString();
+ //urlParameters.add(new BasicNameValuePair(name, WorkflowUtil.processVariable(value, "", wfAssignment)));
+ builder.addPart(name, new StringBody(value, ContentType.MULTIPART_FORM_DATA));
+ if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
+ LogUtil.info(EnhancedJsonTool.class.getName(), "Adding param " + name + " : " + value);
+ }
+ }
+
+ if( (properties.get("attachmentFormDefId") != null && !properties.get("attachmentFormDefId").toString().isEmpty())
+ || (properties.get("attachmentFiles") != null && !properties.get("attachmentFiles").toString().isEmpty()) ) {
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+ }
+
+ //handle file upload from form
+ String formDefId = (String) properties.get("attachmentFormDefId");
+ Object[] fields = null;
+ if (properties.get("attachmentFields") instanceof Object[]){
+ fields = (Object[]) properties.get("attachmentFields");
+ }
+ if (formDefId != null && !formDefId.isEmpty() && fields != null && fields.length > 0) {
+ AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
+
+ FormData formData = new FormData();
+ String primaryKey = appService.getOriginProcessId(wfAssignment.getProcessId());
+ formData.setPrimaryKeyValue(primaryKey);
+ Form loadForm = appService.viewDataForm(appDef.getId(), appDef.getVersion().toString(), formDefId, null, null, null, formData, null, null);
+
+ for (Object o : fields) {
+ Map mapping = (HashMap) o;
+ String fieldId = mapping.get("field").toString();
+ String parameterName = (String) mapping.get("parameterName");
+
+ try {
+ Element el = FormUtil.findElement(fieldId, loadForm, formData);
+ String value = FormUtil.getElementPropertyValue(el, formData);
+ if (value.contains("/web/client/app/") && value.contains("/form/download/")) {
+ value = retrieveFileNames(value, appDef.getAppId(), formDefId, primaryKey);
+ }
+ if (value != null && !value.isEmpty()) {
+ String values[] = value.split(";");
+ for (String v : values) {
+ if (!v.isEmpty()) {
+ File file = FileUtil.getFile(v, loadForm, primaryKey);
+ if (file != null && file.exists()) {
+ if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
+ LogUtil.info(EnhancedJsonTool.class.getName(), "Attaching file " + v);
+ }
+ FileBody fileBody = new FileBody(file);
+ builder.addPart(parameterName, fileBody);
+ }
+ }
+ }
+ }
+ } catch(Exception e){
+ LogUtil.info(EnhancedJsonTool.class.getName(), "Attach file from form failed from field \"" + fieldId + "\" in form \"" + formDefId + "\"");
+ }
+ }
+ }
+
+ //handle file upload from url/path
+ Object[] files = null;
+ if (properties.get("attachmentFiles") instanceof Object[]){
+ files = (Object[]) properties.get("attachmentFiles");
+ }
+ if (files != null && files.length > 0) {
+ for (Object o : files) {
+ Map mapping = (HashMap) o;
+ String path = mapping.get("path").toString();
+ String parameterName = mapping.get("parameterName").toString();
+ String type = mapping.get("type").toString();
+
+ try {
+ if ("system".equals(type)) {
+ if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
+ LogUtil.info(EnhancedJsonTool.class.getName(), "Attaching file path " + path);
+ }
+ File file = new File(path);
+ FileBody fileBody = new FileBody(file);
+ builder.addPart(parameterName, fileBody);
+ } else if("url".equals(type)) {
+ if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
+ LogUtil.info(EnhancedJsonTool.class.getName(), "Attaching URL path " + path);
+ }
+ URL u = new URL(path);
+ CustomURLDataSource c = new CustomURLDataSource(u);
+ builder.addBinaryBody(parameterName, c.getInputStream().readAllBytes(), ContentType.create(c.getContentType()), c.getName());
+
+ }
+ } catch(Exception e){
+ LogUtil.error(EnhancedJsonTool.class.getName(), e, "File attachment failed from path \"" + path + "\"");
+ }
+ }
+ }
+
+ HttpEntity entity = builder.build();
+ ((HttpPost) request).setEntity(entity);
+ }
+ }else if ("put".equalsIgnoreCase(getPropertyString("requestType"))) {
+ request = new HttpPut(jsonUrl);
+
+ if ("jsonPayload".equals(getPropertyString("postMethod"))) {
+ JSONObject obj = new JSONObject();
+ Object[] paramsValues = (Object[]) properties.get("params");
+ for (Object o : paramsValues) {
+ Map mapping = (HashMap) o;
+ String name = mapping.get("name").toString();
+ String value = mapping.get("value").toString();
+ obj.accumulate(name, WorkflowUtil.processVariable(value, "", wfAssignment));
+ }
+
+ StringEntity requestEntity = new StringEntity(obj.toString(4), "UTF-8");
+ ((HttpPut) request).setEntity(requestEntity);
+ request.setHeader("Content-type", "application/json");
+ if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
+ LogUtil.info(EnhancedJsonTool.class.getName(), "JSON Payload : " + obj.toString(4));
+ }
+ } else if ("custom".equals(getPropertyString("postMethod"))) {
+ StringEntity requestEntity = new StringEntity(getPropertyString("customPayload"), "UTF-8");
+ ((HttpPut) request).setEntity(requestEntity);
+ request.setHeader("Content-type", "application/json");
+ if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
+ LogUtil.info(EnhancedJsonTool.class.getName(), "Custom JSON Payload : " + getPropertyString("customPayload"));
+ }
} else {
List urlParameters = new ArrayList();
Object[] paramsValues = (Object[]) properties.get("params");
@@ -129,9 +285,9 @@ public Object execute(Map properties) {
LogUtil.info(EnhancedJsonTool.class.getName(), "Adding param " + name + " : " + value);
}
}
- ((HttpPost) request).setEntity(new UrlEncodedFormEntity(urlParameters, "UTF-8"));
+ ((HttpPut) request).setEntity(new UrlEncodedFormEntity(urlParameters, "UTF-8"));
}
- } else {
+ }else {
request = new HttpGet(jsonUrl);
}
@@ -153,39 +309,141 @@ public Object execute(Map properties) {
LogUtil.info(EnhancedJsonTool.class.getName(), jsonUrl + " returned with status : " + response.getStatusLine().getStatusCode());
}
- if (!"true".equalsIgnoreCase(getPropertyString("noResponse"))) {
- String jsonResponse = EntityUtils.toString(response.getEntity(), "UTF-8");
- if (jsonResponse != null && !jsonResponse.isEmpty()) {
- if (jsonResponse.startsWith("[") && jsonResponse.endsWith("]")) {
- jsonResponse = "{ \"response\" : " + jsonResponse + " }";
- }
- if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
- LogUtil.info(EnhancedJsonTool.class.getName(), jsonResponse);
- }
- Map object = PropertyUtil.getProperties(new JSONObject(jsonResponse));
+ String responseType = getPropertyString("responseType");
+
+ if ( !responseType.isEmpty() && response.getStatusLine().getStatusCode() >= 200 && response.getStatusLine().getStatusCode() <= 300 ) {
+
+ if(responseType.equalsIgnoreCase("JSON")){
+ //if(response.getEntity().getContentType().getValue().equalsIgnoreCase("application/json")){
+ jsonResponse = EntityUtils.toString(response.getEntity(), "UTF-8");
+ String jsonResponseFormatted = jsonResponse;
+ if (jsonResponseFormatted != null && !jsonResponseFormatted.isEmpty()) {
+ if (jsonResponseFormatted.startsWith("[") && jsonResponseFormatted.endsWith("]")) {
+ jsonResponseFormatted = "{ \"response\" : " + jsonResponseFormatted + " }";
+ }
+
+ if( !jsonResponseFormatted.startsWith("{") && !jsonResponseFormatted.endsWith("}")){
+ jsonResponseFormatted = "{ \"response\" : " + jsonResponseFormatted + " }";
+ }
+
+ if ("true".equalsIgnoreCase(getPropertyString("debugMode"))) {
+ LogUtil.info(EnhancedJsonTool.class.getName(), jsonResponseFormatted);
+ }
+ object = PropertyUtil.getProperties(new JSONObject(jsonResponseFormatted));
+
+ //Added ability to format response via bean shell in configuration
+ if ("true".equalsIgnoreCase(getPropertyString("enableFormatResponse"))) {
+ properties.put("data", object);
+
+ String script = (String) properties.get("script");
- //Added ability to format response via bean shell in configuration
- if ("true".equalsIgnoreCase(getPropertyString("enableFormatResponse"))) {
- properties.put("data", object);
-
- String script = (String) properties.get("script");
+ Map replaceMap = new HashMap();
+ replaceMap.put("\n", "\\\\n");
- Map replaceMap = new HashMap();
- replaceMap.put("\n", "\\\\n");
+ script = WorkflowUtil.processVariable(script, "", wfAssignment, "", replaceMap);
- script = WorkflowUtil.processVariable(script, "", wfAssignment, "", replaceMap);
+ object = (Map) executeScript(script, properties);
+ }
+
+ storeToForm(wfAssignment, properties, object);
+ storeToWorkflowVariable(wfAssignment, properties, object);
- object = (Map) executeScript(script, properties);
}
+ }else{
+ //assume binary
- storeToForm(wfAssignment, properties, object);
- storeToWorkflowVariable(wfAssignment, properties, object);
+ //attempt to get filename
+ String fileName = "";
+ try{
+ Header header = response.getFirstHeader("Content-Disposition");
+ HeaderElement[] helelms = header.getElements();
+ if (helelms.length > 0) {
+ HeaderElement helem = helelms[0];
+ NameValuePair nmv = helem.getParameterByName("filename");
+ if (nmv != null) {
+ fileName = nmv.getValue();
+ }
+ }
+ }catch(Exception ex){
+ LogUtil.info(getClass().getName(), "Cannot get file name automatically");
+ }
- return object;
+ if(fileName.isEmpty()){
+ String[] n = request.getURI().getPath().split("/");
+ fileName = n[n.length-1];
+ }
+
+ if(fileName.isEmpty()){
+ fileName = "downloaded";
+ }
+
+ //save filename into existing form row record
+ AppService appService = (AppService) ac.getBean("appService");
+ String recordId = appService.getOriginProcessId(wfAssignment.getProcessId());
+ String formDefId = (String) properties.get("storeAttachmentFormDefId");
+ String fileUploadID = properties.get("storeAttachmentFieldID").toString();
+
+ FormRowSet rowSet = new FormRowSet();
+ FormRow row = new FormRow();
+
+ if(!recordId.isEmpty()){
+ recordId = UuidGenerator.getInstance().getUuid();
+ row = new FormRow();
+ row.put(fileUploadID, fileName);
+ }else{
+ rowSet = appService.loadFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, recordId);
+ row = rowSet.get(0);
+ rowSet.remove(0);
+ }
+ row.put(fileUploadID, fileName);
+ rowSet.add(0, row);
+
+ appService.storeFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, rowSet, recordId);
+
+ //save actual file into wflow folder
+ String tableName = appService.getFormTableName(appDef, formDefId);
+ String filePath = FileUtil.getUploadPath(tableName, wfAssignment.getProcessId());
+
+ File file = new File(filePath);
+ file.mkdirs();
+
+ filePath = filePath + fileName;
+
+ FileOutputStream fos = null;
+ try (InputStream is = response.getEntity().getContent()) {
+ fos = new FileOutputStream(new File(filePath));
+ int inByte;
+ while((inByte = is.read()) != -1){
+ fos.write(inByte);
+ }
+ }catch(Exception ex){
+ LogUtil.error(getClass().getName(), ex, "Cannot save file");
+ }finally{
+ fos.close();
+ }
}
}
+
+ if( !getPropertyString("responseStatusWorkflowVariable").isEmpty() ){
+ workflowManager.activityVariable(wfAssignment.getActivityId(), getPropertyString("saveStatusToWorkflowVariable"), response.getStatusLine().getStatusCode());
+ }
+
+ if( !getPropertyString("responseStatusFormDefId").isEmpty() ){
+ storeStatusToForm(wfAssignment, properties, String.valueOf(response.getStatusLine().getStatusCode()), jsonResponse );
+ }
+
+ return object;
+
} catch (Exception ex) {
LogUtil.error(getClass().getName(), ex, "");
+
+ if( !getPropertyString("saveStatusToWorkflowVariable").isEmpty() ){
+ workflowManager.activityVariable(wfAssignment.getActivityId(), getPropertyString("saveStatusToWorkflowVariable"), ex.toString());
+ }
+ if( !getPropertyString("responseStatusFormDefId").isEmpty() ){
+ storeStatusToForm(wfAssignment, properties, ex.toString() + " - " + ex.getMessage(), jsonResponse);
+ }
+
} finally {
try {
if (request != null) {
@@ -201,7 +459,44 @@ public Object execute(Map properties) {
return null;
}
+
+ protected void storeStatusToForm(WorkflowAssignment wfAssignment, Map properties, String status, String jsonResponse) {
+ String formDefId = (String) properties.get("responseStatusFormDefId");
+ String statusField = (String) properties.get("responseStatusStatusField");
+ String responseDataField = (String) properties.get("responseStatusResponseDataField");
+ String idField = (String) properties.get("responseStatusIdField");
+ Object[] fieldMapping = (Object[]) properties.get("responseStatusFieldMapping");
+
+ if (formDefId != null && formDefId.trim().length() > 0) {
+ ApplicationContext ac = AppUtil.getApplicationContext();
+ AppService appService = (AppService) ac.getBean("appService");
+ AppDefinition appDef = (AppDefinition) properties.get("appDef");
+ FormRowSet rowSet = new FormRowSet();
+ FormRow row = new FormRow();
+
+ if(!responseDataField.isEmpty()){
+ row.put(responseDataField, jsonResponse);
+ }
+
+ if(!idField.isEmpty()){
+ row.put(idField, appService.getOriginProcessId(wfAssignment.getProcessId()));
+ }else{
+ row.setId(appService.getOriginProcessId(wfAssignment.getProcessId()));
+ }
+
+ for(Object obj : fieldMapping){
+ Map map = (Map) obj;
+ row.put(map.get("field").toString(), map.get("value").toString());
+ }
+
+ row.put(statusField, status);
+ rowSet.add(row);
+
+ appService.storeFormData(appDef.getId(), appDef.getVersion().toString(), formDefId, rowSet, null);
+ }
+ }
+
protected void storeToForm(WorkflowAssignment wfAssignment, Map properties, Map object) {
String formDefId = (String) properties.get("formDefId");
if (formDefId != null && formDefId.trim().length() > 0) {
@@ -213,7 +508,7 @@ protected void storeToForm(WorkflowAssignment wfAssignment, Map properties, Map
String multirowBaseObjectName = (String) properties.get("multirowBaseObject");
FormRowSet rowSet = new FormRowSet();
-
+
if (multirowBaseObjectName != null && multirowBaseObjectName.trim().length() > 0 && getObjectFromMap(multirowBaseObjectName, object) != null && getObjectFromMap(multirowBaseObjectName, object).getClass().isArray()) {
Object[] baseObjectArray = (Object[]) getObjectFromMap(multirowBaseObjectName, object);
if (baseObjectArray != null && baseObjectArray.length > 0) {
@@ -361,4 +656,18 @@ protected Object executeScript(String script, Map properties) {
return null;
}
}
+
+ //copied from AppUtil
+ protected String retrieveFileNames(String content, String appId, String formId, String primaryKey) {
+ Set values = new HashSet();
+
+ Pattern pattern = Pattern.compile("
]*src=\"[^\"]*/web/client/app/"+StringUtil.escapeRegex(appId)+"/form/download/"+StringUtil.escapeRegex(formId)+"/"+StringUtil.escapeRegex(primaryKey)+"/([^\"]*)\\.\"[^>]*>");
+ Matcher matcher = pattern.matcher(content);
+ while (matcher.find()) {
+ String fileName = matcher.group(1);
+ values.add(fileName);
+ }
+
+ return String.join(";", values);
+ }
}
diff --git a/src/main/resources/messages/enhancedJsonTool.properties b/src/main/resources/messages/enhancedJsonTool.properties
index abb0369..6580665 100644
--- a/src/main/resources/messages/enhancedJsonTool.properties
+++ b/src/main/resources/messages/enhancedJsonTool.properties
@@ -2,4 +2,22 @@ app.enhancedjsontool.pluginLabel=Enhanced Json Tool
app.enhancedjsontool.pluginDesc=Just like the default bundled JSON Tool that reads a JSON feed URL, with additional ability to alter the response via bean shell before inserting formatted data into form data table or workflow variable.
app.enhancedjsontool.formatResponse=Format Response
app.enhancedjsontool.enableFormatResponse=Enable Response Formatting
-app.enhancedjsontool.script.desc=Injected variables : Map data
Expects to return a Map object of formatted response
\ No newline at end of file
+app.enhancedjsontool.script.desc=Injected variables : Map data
Expects to return a Map object of formatted response
+app.jsontool.saveResponseStatus=Store Response Status
+app.jsontool.responseStatusWorkflowVariable=Workflow Variable to Store Response Status
+app.jsontool.responseStatusFormDefId.desc=Recommended to use a child form with foreign key to main record as in a single JSON call, data may be returned successfully but fails in parsing to JSON format.
+app.jsontool.responseStatusIdField=Response Field ID
+app.jsontool.responseStatusIdField.desc=Fill in to use as foreign key to main record. Leave it blank to save form record ID into column "ID". When it is blank and there are multiple logs, logs will be overwritten and only the last entry will be visible.
+app.jsontool.responseStatusStatusField=Response Status Field
+app.jsontool.requestType.put=PUT
+app.jsontool.payloadType=Payload Type
+app.jsontool.value=Value
+app.jsontool.responseStatusResponseDataField=Response Data Field
+app.enhancedJsonTool.responseType=Response Type
+app.enhancedJsonTool.responseType.JSON=JSON
+app.enhancedJsonTool.responseType.file=File
+app.enhancedJsonTool.responseType.noResponse=No Response
+app.enhancedJsonTool.sendAttachments=Send Attachments
+app.enhancedJsonTool.storeAttachments=Store Attachment
+app.enhancedJsonTool.storeAttachmentsField=File Upload Field
+app.enhancedJsonTool.sendAttachments.attachmentFields.desc=Choose file upload field. Multiple files supported.
\ No newline at end of file
diff --git a/src/main/resources/properties/enhancedJsonTool.json b/src/main/resources/properties/enhancedJsonTool.json
index c0d6f78..d72405e 100644
--- a/src/main/resources/properties/enhancedJsonTool.json
+++ b/src/main/resources/properties/enhancedJsonTool.json
@@ -1,177 +1,371 @@
-[{
- title : '@@app.jsontool.config@@',
- properties : [{
- name : 'jsonUrl',
- label : '@@app.jsontool.jsonUrl@@',
- type : 'textfield',
- required : 'True'
- },
- {
- name : 'requestType',
- label : '@@app.jsontool.requestType@@',
- type : 'selectbox',
- value : '',
- options : [{
- value : '',
- label : '@@app.jsontool.requestType.get@@'
- },
- {
- value : 'post',
- label : '@@app.jsontool.requestType.post@@'
- }]
- },
- {
- name : 'postMethod',
- label : '@@app.jsontool.postMethod@@',
- type : 'selectbox',
- value : '',
- options : [{
- value : '',
- label : '@@app.jsontool.postMethod.parameters@@'
- },
- {
- value : 'jsonPayload',
- label : '@@app.jsontool.postMethod.jsonPayload@@'
- },
- {
- value : 'custom',
- label : '@@app.jsontool.postMethod.customJsonPayload@@'
- }],
- control_field: 'requestType',
- control_value: 'post',
- control_use_regex: 'false'
- },
- {
- name : 'params',
- label : '@@app.jsontool.postMethod.parameters@@',
- type : 'grid',
- columns : [{
- key : 'name',
- label : '@@app.jsontool.name@@'
- },{
- key : 'value',
- label : '@@app.jsontool.value@@'
- }],
- control_field: 'postMethod',
- control_value: '^((?!custom).)*$',
- control_use_regex: 'true'
- },
- {
- name:'customPayload',
- label:'@@app.jsontool.postMethod.customJsonPayload@@',
- type : 'codeeditor',
- mode : 'json',
- control_field: 'postMethod',
- control_value: 'custom',
- control_use_regex: 'false',
- required:'true'
- },
- {
- name : 'headers',
- label : '@@app.jsontool.header@@',
- type : 'grid',
- columns : [{
- key : 'name',
- label : '@@app.jsontool.name@@'
- },{
- key : 'value',
- label : '@@app.jsontool.value@@'
- }]
- },
- {
- name : 'noResponse',
- label : '@@app.jsontool.noResponse@@',
- type : 'checkbox',
- options : [{
- value : 'true',
- label : ''
- }]
- },
- {
- name : 'debugMode',
- label : '@@app.jsontool.debugMode@@',
- description : '@@app.jsontool.debugMode.desc@@',
- type : 'checkbox',
- options : [{
- value : 'true',
- label : ''
- }]
- }]
-},
-{
- title : '@@app.enhancedjsontool.formatResponse@@',
- properties : [{
- name : 'enableFormatResponse',
- label : '@@app.enhancedjsontool.enableFormatResponse@@',
- type : 'checkbox',
- options : [{
- value : 'true',
- label : ''
- }]
- },
- {
- name : 'script',
- label : '@@app.beanshelltool.script@@',
- description : '@@app.enhancedjsontool.script.desc@@',
- type : 'codeeditor',
- mode : 'java',
- control_field: 'enableFormatResponse',
- control_value: 'true',
- control_use_regex: 'false'
- }],
- control_field: 'noResponse',
- control_value: '',
- control_use_regex: 'false'
-},
-{
- title : '@@app.jsontool.storeToForm@@',
- properties : [{
- name : 'formDefId',
- label : '@@app.jsontool.formId@@',
- type : 'selectbox',
- options_ajax : '[CONTEXT_PATH]/web/json/console/app/%s/%s/forms/options'
- },
- {
- name : 'multirowBaseObject',
- label : '@@app.jsontool.baseJsonObject@@',
- type : 'textfield'
- },
- {
- name : 'fieldMapping',
- label : '@@app.jsontool.fieldMapping@@',
- type : 'grid',
- columns : [{
- key : 'field',
- label : '@@app.jsontool.fieldName@@',
- options_ajax_on_change : 'formDefId',
- options_ajax : '[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options'
- },
- {
- key : 'jsonObjectName',
- label : '@@app.jsontool.jsonObjectName@@'
- }]
- }],
- control_field: 'noResponse',
- control_value: '',
- control_use_regex: 'false'
-},
-{
- title : '@@app.jsontool.storeToWorkflowVariable@@',
- properties : [{
- name : 'wfVariableMapping',
- label : '@@app.jsontool.workflowVariableMapping@@',
- type : 'grid',
- columns : [{
- key : 'variable',
- label : '@@app.jsontool.workflowVariable@@',
- options_ajax : '[CONTEXT_PATH]/web/json/console/app[APP_PATH]/workflowVariable/options'
- },
- {
- key : 'jsonObjectName',
- label : '@@app.jsontool.jsonObjectName@@'
- }]
- }],
- control_field: 'noResponse',
- control_value: '',
- control_use_regex: 'false'
-}]
\ No newline at end of file
+[
+ {
+ "title":"@@app.jsontool.config@@",
+ "properties":[
+ {
+ "name":"jsonUrl",
+ "label":"@@app.jsontool.jsonUrl@@",
+ "type":"textfield",
+ "required":"True"
+ },
+ {
+ "name":"requestType",
+ "label":"@@app.jsontool.requestType@@",
+ "type":"selectbox",
+ "value":"",
+ "options":[
+ {
+ "value":"",
+ "label":"@@app.jsontool.requestType.get@@"
+ },
+ {
+ "value":"post",
+ "label":"@@app.jsontool.requestType.post@@"
+ },
+ {
+ "value":"put",
+ "label":"@@app.jsontool.requestType.put@@"
+ }
+ ]
+ },
+ {
+ "name":"postMethod",
+ "label":"@@app.jsontool.payloadType@@",
+ "type":"selectbox",
+ "value":"",
+ "options":[
+ {
+ "value":"",
+ "label":"@@app.jsontool.postMethod.parameters@@"
+ },
+ {
+ "value":"jsonPayload",
+ "label":"@@app.jsontool.postMethod.jsonPayload@@"
+ },
+ {
+ "value":"custom",
+ "label":"@@app.jsontool.postMethod.customJsonPayload@@"
+ }
+ ],
+ "control_field":"requestType",
+ "control_value":"post|put",
+ "control_use_regex":"true"
+ },
+ {
+ "name":"params",
+ "label":"@@app.jsontool.postMethod.parameters@@",
+ "type":"grid",
+ "columns":[
+ {
+ "key":"name",
+ "label":"@@app.jsontool.name@@"
+ },
+ {
+ "key":"value",
+ "label":"@@app.jsontool.value@@"
+ }
+ ],
+ "control_field":"postMethod",
+ "control_value":"^((?!custom).)*$",
+ "control_use_regex":"true"
+ },
+ {
+ "name":"customPayload",
+ "label":"@@app.jsontool.postMethod.customJsonPayload@@",
+ "type":"codeeditor",
+ "mode":"json",
+ "control_field":"postMethod",
+ "control_value":"custom",
+ "control_use_regex":"false",
+ "required":"true"
+ },
+ {
+ "name":"headers",
+ "label":"@@app.jsontool.header@@",
+ "type":"grid",
+ "columns":[
+ {
+ "key":"name",
+ "label":"@@app.jsontool.name@@"
+ },
+ {
+ "key":"value",
+ "label":"@@app.jsontool.value@@"
+ }
+ ]
+ },
+ {
+ "name":"responseType",
+ "label":"@@app.enhancedJsonTool.responseType@@",
+ "type":"selectbox",
+ "options":[
+ {
+ "value":"JSON",
+ "label":"@@app.enhancedJsonTool.responseType.JSON@@"
+ },
+ {
+ "value":"File",
+ "label":"@@app.enhancedJsonTool.responseType.file@@"
+ },
+ {
+ "value":"",
+ "label":"@@app.enhancedJsonTool.responseType.noResponse@@"
+ }
+ ]
+ },
+ {
+ "name":"debugMode",
+ "label":"@@app.jsontool.debugMode@@",
+ "description":"@@app.jsontool.debugMode.desc@@",
+ "type":"checkbox",
+ "options":[
+ {
+ "value":"true",
+ "label":""
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "title":"@@app.enhancedJsonTool.sendAttachments@@",
+ "properties":[
+ {
+ "name":"attachmentFormDefId",
+ "label":"@@app.emailtool.form@@",
+ "type":"selectbox",
+ "options_ajax":"[CONTEXT_PATH]/web/json/console/app[APP_PATH]/forms/options"
+ },
+ {
+ "name":"attachmentFields",
+ "label":"@@app.emailtool.fields@@",
+ "description":"@@app.enhancedJsonTool.sendAttachments.attachmentFields.desc@@",
+ "type":"grid",
+ "columns":[
+ {
+ "key":"parameterName",
+ "label":"Parameter @@app.jsontool.name@@"
+ },
+ {
+ "key":"field",
+ "label":"@@app.emailtool.fieldId@@",
+ "options_ajax_on_change" : "formDefId:attachmentFormDefId",
+ "options_ajax" : "[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options"
+ }
+
+ ]
+ },
+ {
+ "name":"attachmentFiles",
+ "label":"@@app.emailtool.files@@",
+ "type":"grid",
+ "columns":[
+ {
+ "key":"parameterName",
+ "label":"Parameter @@app.jsontool.name@@"
+ },
+ {
+ "key":"path",
+ "label":"@@app.emailtool.path@@"
+ },
+ {
+ "key":"type",
+ "label":"@@app.emailtool.pathType@@",
+ "options":[
+ {
+ "value":"system",
+ "label":"@@app.emailtool.pathType.system@@"
+ },
+ {
+ "value":"url",
+ "label":"@@app.emailtool.pathType.url@@"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "control_field":"postMethod",
+ "control_value":"",
+ "control_use_regex":"false"
+ },
+ {
+ "title":"@@app.enhancedJsonTool.storeAttachments@@",
+ "properties":[
+ {
+ "name":"storeAttachmentFormDefId",
+ "label":"@@app.emailtool.form@@",
+ "type":"selectbox",
+ "options_ajax":"[CONTEXT_PATH]/web/json/console/app/%s/%s/forms/options",
+ "description":"@@app.jsontool.responseStatusFormDefId.desc@@"
+ },
+ {
+ "name":"storeAttachmentFieldID",
+ "label":"@@app.enhancedJsonTool.storeAttachmentsField@@",
+ "type":"selectbox",
+ "description" : "@@app.jsontool.responseStatusIdField.desc@@",
+ "options_ajax_on_change" : "formDefId:storeAttachmentFormDefId",
+ "options_ajax" : "[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options"
+ }
+ ],
+ "control_field":"responseType",
+ "control_value":"File",
+ "control_use_regex":"false"
+ },
+ {
+ "title":"@@app.enhancedjsontool.formatResponse@@",
+ "properties":[
+ {
+ "name":"enableFormatResponse",
+ "label":"@@app.enhancedjsontool.enableFormatResponse@@",
+ "type":"checkbox",
+ "options":[
+ {
+ "value":"true",
+ "label":""
+ }
+ ]
+ },
+ {
+ "name":"script",
+ "label":"@@app.beanshelltool.script@@",
+ "description":"@@app.enhancedjsontool.script.desc@@",
+ "type":"codeeditor",
+ "mode":"java",
+ "control_field":"enableFormatResponse",
+ "control_value":"true",
+ "control_use_regex":"false",
+ "value":""
+ }
+ ],
+ "control_field":"responseType",
+ "control_value":"JSON",
+ "control_use_regex":"false"
+ },
+ {
+ "title":"@@app.jsontool.storeToForm@@",
+ "properties":[
+ {
+ "name":"formDefId",
+ "label":"@@app.jsontool.formId@@",
+ "type":"selectbox",
+ "options_ajax":"[CONTEXT_PATH]/web/json/console/app/%s/%s/forms/options"
+ },
+ {
+ "name":"multirowBaseObject",
+ "label":"@@app.jsontool.baseJsonObject@@",
+ "type":"textfield"
+ },
+ {
+ "name":"fieldMapping",
+ "label":"@@app.jsontool.fieldMapping@@",
+ "type":"grid",
+ "columns":[
+ {
+ "key":"field",
+ "label":"@@app.jsontool.fieldName@@",
+ "options_ajax_on_change":"formDefId",
+ "options_ajax":"[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options"
+ },
+ {
+ "key":"jsonObjectName",
+ "label":"@@app.jsontool.jsonObjectName@@"
+ }
+ ]
+ }
+ ],
+ "control_field":"responseType",
+ "control_value":"JSON",
+ "control_use_regex":"false"
+ },
+ {
+ "title":"@@app.jsontool.storeToWorkflowVariable@@",
+ "properties":[
+ {
+ "name":"wfVariableMapping",
+ "label":"@@app.jsontool.workflowVariableMapping@@",
+ "type":"grid",
+ "columns":[
+ {
+ "key":"variable",
+ "label":"@@app.jsontool.workflowVariable@@",
+ "options_ajax":"[CONTEXT_PATH]/web/json/console/app[APP_PATH]/workflowVariable/options"
+ },
+ {
+ "key":"jsonObjectName",
+ "label":"@@app.jsontool.jsonObjectName@@"
+ }
+ ]
+ }
+ ],
+ "control_field":"responseType",
+ "control_value":"JSON",
+ "control_use_regex":"false"
+ },
+ {
+ "title":"@@app.jsontool.saveResponseStatus@@",
+ "properties":[
+ {
+ "name":"responseStatusWorkflowVariable",
+ "label":"@@app.jsontool.responseStatusWorkflowVariable@@",
+ "type":"textfield"
+ },
+ {
+ "name":"responseStatusFormDefId",
+ "label":"@@app.emailtool.form@@",
+ "type":"selectbox",
+ "options_ajax":"[CONTEXT_PATH]/web/json/console/app/%s/%s/forms/options",
+ "description":"@@app.jsontool.responseStatusFormDefId.desc@@"
+ },
+ {
+ "name":"responseStatusIdField",
+ "label":"@@app.jsontool.responseStatusIdField@@",
+ "type":"selectbox",
+ "description" : "@@app.jsontool.responseStatusIdField.desc@@",
+ "options_ajax_on_change" : "formDefId:responseStatusFormDefId",
+ "options_ajax" : "[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options",
+ "control_field": "responseStatusFormDefId",
+ "control_value": ".+",
+ "control_use_regex": "true"
+ },
+ {
+ "name":"responseStatusResponseDataField",
+ "label":"@@app.jsontool.responseStatusResponseDataField@@",
+ "type":"selectbox",
+ "options_ajax_on_change" : "formDefId:responseStatusFormDefId",
+ "options_ajax" : "[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options",
+ "control_field": "responseStatusFormDefId",
+ "control_value": ".+",
+ "control_use_regex": "true"
+ },
+ {
+ "name":"responseStatusStatusField",
+ "label":"@@app.jsontool.responseStatusStatusField@@",
+ "type":"selectbox",
+ "required":"True",
+ "options_ajax_on_change" : "formDefId:responseStatusFormDefId",
+ "options_ajax" : "[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options",
+ "control_field": "responseStatusFormDefId",
+ "control_value": ".+",
+ "control_use_regex": "true"
+ },
+ {
+ "name":"responseStatusFieldMapping",
+ "label":"@@app.jsontool.fieldMapping@@",
+ "type":"grid",
+ "columns":[
+ {
+ "key":"field",
+ "label":"@@app.jsontool.fieldName@@",
+ "options_ajax_on_change":"formDefId:responseStatusFormDefId",
+ "options_ajax":"[CONTEXT_PATH]/web/json/console/app[APP_PATH]/form/columns/options"
+ },
+ {
+ "key":"value",
+ "label":"@@app.jsontool.value@@"
+ }
+ ]
+ }
+ ]
+ }
+]
\ No newline at end of file