use of com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage in project mdw-designer by CenturyLinkCloud.
the class Server method getErrorMessageFromResponse.
public String getErrorMessageFromResponse(String response) throws XmlException {
MDWStatusMessageDocument statusMessageDoc = MDWStatusMessageDocument.Factory.parse(response, Compatibility.namespaceOptions());
MDWStatusMessage statusMessage = statusMessageDoc.getMDWStatusMessage();
if (// indicate success
statusMessage.getStatusCode() == 0)
// indicate success
return "";
else
return statusMessage.getStatusMessage();
}
use of com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage in project mdw-designer by CenturyLinkCloud.
the class ProcessLaunchConfiguration method launchProcess.
protected void launchProcess(WorkflowProcess process, String masterRequestId, String owner, Long ownerId, boolean synchronous, String responseVarName, Map<String, String> parameters, Long activityId, boolean showLogs, boolean liveView) {
List<VariableValue> variableValues = new ArrayList<>();
for (Map.Entry<String, String> var : parameters.entrySet()) {
VariableVO variableVO = process.getVariable(var.getKey());
if (var.getValue().length() > 0) {
VariableTypeVO varType = process.getProject().getDataAccess().getVariableType(variableVO.getVariableType());
variableValues.add(new VariableValue(variableVO, varType, var.getValue()));
}
}
DesignerProxy designerProxy = process.getProject().getDesignerProxy();
try {
if (showLogs || liveView) {
watch = true;
LogWatcher logWatcher = designerProxy.getLogWatcher(MdwPlugin.getDisplay());
if (logWatcher.isRunning()) {
MdwPlugin.getDisplay().syncExec(new Runnable() {
public void run() {
String message = "Live View is already monitoring an existing instance. Disconnect to monitor new instance?";
watch = MessageDialog.openConfirm(MdwPlugin.getDisplay().getActiveShell(), "Live View", message);
}
});
}
if (watch) {
logWatcher.shutdown();
logWatcher.setMasterRequestId(masterRequestId);
logWatcher.setProcess(process);
logWatcher.startup(liveView);
}
}
if (synchronous) {
String response = designerProxy.launchSynchronousProcess(process, masterRequestId, owner, ownerId, variableValues, responseVarName);
if (isWriteToConsole())
writeToConsole("Process Launch Response", response + "\n");
} else {
MDWStatusMessage statusMsg = designerProxy.launchProcess(process, masterRequestId, owner, ownerId, variableValues, activityId);
if (isWriteToConsole())
writeToConsole("Process Launch Response", statusMsg.getStatusMessage() + "\n");
}
} catch (Exception ex) {
showError(ex, "Launch Process", process.getProject());
}
}
use of com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage in project mdw-designer by CenturyLinkCloud.
the class RestfulServer method invokeService.
public MDWStatusMessageDocument invokeService(String request) throws DataAccessException, RemoteException {
String response = null;
try {
// append to Services context root since sometimes only Services/* are excluded from CT auth
HttpHelper httpHelper = getHttpHelper(getMdwWebUrl() + "/Services/REST");
httpHelper.setConnectTimeout(getConnectTimeout());
httpHelper.setReadTimeout(getReadTimeout());
response = httpHelper.post(request);
MDWStatusMessageDocument statusMessageDoc;
if (response.startsWith("{")) {
StatusMessage statusMessage = new StatusMessage(new JSONObject(response));
statusMessageDoc = statusMessage.getStatusDocument();
} else {
statusMessageDoc = MDWStatusMessageDocument.Factory.parse(response, Compatibility.namespaceOptions());
}
MDWStatusMessage statusMessage = statusMessageDoc.getMDWStatusMessage();
if (statusMessage.getStatusCode() == -3) {
// event handler not registered
throw new RemoteException("No event handler is registered for instance-level actions on: " + getMdwWebUrl());
} else if (statusMessage.getStatusCode() != 0) {
throw new RemoteException("Error response from server: " + statusMessage.getStatusMessage());
}
return statusMessageDoc;
} catch (RemoteException ex) {
// don't fall through to IOException catch block
throw ex;
} catch (SocketTimeoutException ex) {
throw new DataAccessOfflineException("Timeout after " + getReadTimeout() + " ms", ex);
} catch (IOException ex) {
throw new DataAccessOfflineException("Unable to connect to " + getMdwWebUrl(), ex);
} catch (JSONException ex) {
throw new DataAccessException("Unparsable JSON response:\n" + response);
} catch (XmlException ex) {
throw new DataAccessException("Unparsable XML response:\n" + response);
}
}
use of com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method validateEngineCallResponse.
protected JSONObject validateEngineCallResponse(String response) throws ValidationException, XmlException, JSONException {
MDWStatusMessageDocument statusMessageDoc;
if (response.startsWith("{")) {
StatusMessage statusMessage = new StatusMessage(new JSONObject(response));
statusMessageDoc = statusMessage.getStatusDocument();
} else {
statusMessageDoc = MDWStatusMessageDocument.Factory.parse(response, Compatibility.namespaceOptions());
}
MDWStatusMessage statusMessage = statusMessageDoc.getMDWStatusMessage();
if (statusMessage.getStatusCode() == -3) {
// event handler not registered
throw new ValidationException("No event handler is registered for regression test actions");
} else if (statusMessage.getStatusCode() != 0) {
throw new ValidationException("Error response from server: " + statusMessage.getStatusMessage());
}
if (statusMessage.getStatusMessage().startsWith("{"))
return new JSONObject(statusMessage.getStatusMessage());
else
return null;
}
Aggregations