use of com.centurylink.mdw.common.service.types.StatusMessage in project mdw-designer by CenturyLinkCloud.
the class ActivityInstanceDialog method createButtonsForButtonBar.
protected void createButtonsForButtonBar(Composite parent) {
if (mode.equals(Mode.VIEW)) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
return;
}
if (mode.equals(Mode.RETRY)) {
retryButton = createButton(parent, -1, "Retry", false);
retryButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
statusMessage = activity.getProject().getDesignerProxy().retryActivityInstance(activity, activityInstanceVO);
}
});
if (statusMessage == null || statusMessage.trim().length() == 0)
MessageDialog.openInformation(getShell(), "Retry Activity", "Activity instance: " + activityInstanceVO.getId() + " retried");
else if (statusMessage.startsWith("{")) {
try {
JSONObject json = new JSONObject(statusMessage);
StatusMessage status = null;
if (json.has("status"))
status = new StatusMessage(json);
if (status.getCode() == 0)
MessageDialog.openInformation(getShell(), "Retry Activity", "Activity instance: " + activityInstanceVO.getId() + " retried");
else
MessageDialog.openError(getShell(), "Retry Activity", status.getMessage());
} catch (JSONException e1) {
MessageDialog.openError(getShell(), "Retry Activity", statusMessage);
} catch (XmlException e1) {
MessageDialog.openError(getShell(), "Retry Activity", statusMessage);
}
} else
MessageDialog.openError(getShell(), "Retry Activity", statusMessage);
close();
}
});
if (!activity.getProcess().isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
retryButton.setEnabled(false);
}
if (mode.equals(Mode.SKIP)) {
skipButton = createButton(parent, -1, "Proceed", false);
skipButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
statusMessage = activity.getProject().getDesignerProxy().skipActivityInstance(activity, activityInstanceVO, completionCode);
}
});
if (statusMessage == null || statusMessage.trim().length() == 0)
MessageDialog.openInformation(getShell(), "Skip Activity", "Activity instance: " + activityInstanceVO.getId() + " skipped with completion code: " + completionCode + ".");
if (statusMessage.startsWith("{")) {
try {
JSONObject json = new JSONObject(statusMessage);
StatusMessage status = null;
if (json.has("status"))
status = new StatusMessage(json);
if (status.getCode() == 0)
MessageDialog.openInformation(getShell(), "Skip Activity", "Activity instance: " + activityInstanceVO.getId() + " skipped with completion code: " + completionCode + ".");
else
MessageDialog.openError(getShell(), "Skip Activity", status.getMessage());
} catch (JSONException e1) {
MessageDialog.openError(getShell(), "Skip Activity", statusMessage);
} catch (XmlException e1) {
MessageDialog.openError(getShell(), "Skip Activity", statusMessage);
}
} else
MessageDialog.openError(getShell(), "Skip Activity", statusMessage);
close();
}
});
if (!activity.getProcess().isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
skipButton.setEnabled(false);
}
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
}
use of com.centurylink.mdw.common.service.types.StatusMessage 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.common.service.types.StatusMessage in project mdw-designer by CenturyLinkCloud.
the class RestfulServer method launchProcess.
public MDWStatusMessageDocument launchProcess(Long processId, String masterRequestId, String owner, Long ownerId, Map<VariableVO, String> variables, Long activityId, boolean oldFormat) throws DataAccessException, XmlException, JSONException, IOException {
if (isSchemaVersion61()) {
String response = launchProcess(processId, masterRequestId, owner, ownerId, variables);
StatusMessage statusMessage = new StatusMessage(new JSONObject(response));
return statusMessage.getStatusDocument();
} else {
ActionRequestDocument actionRequestDoc = getLaunchProcessBaseDoc(processId, masterRequestId, owner, ownerId);
for (VariableVO variableVO : variables.keySet()) {
Parameter parameter = actionRequestDoc.getActionRequest().getAction().addNewParameter();
parameter.setName(variableVO.getVariableName());
parameter.setType(variableVO.getVariableType());
String stringValue = variables.get(variableVO);
parameter.setStringValue(stringValue);
}
if (activityId != null) {
Parameter parameter = actionRequestDoc.getActionRequest().getAction().addNewParameter();
parameter.setName("mdw.ActivityId");
parameter.setStringValue(activityId.toString());
}
String request;
if (oldFormat)
request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
else
request = actionRequestDoc.xmlText(getXmlOptions());
return invokeService(request);
}
}
use of com.centurylink.mdw.common.service.types.StatusMessage 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