Search in sources :

Example 1 with StatusMessage

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);
}
Also used : JSONObject(org.json.JSONObject) XmlException(org.apache.xmlbeans.XmlException) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) JSONException(org.json.JSONException) StatusMessage(com.centurylink.mdw.common.service.types.StatusMessage)

Example 2 with StatusMessage

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);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONException(org.json.JSONException) IOException(java.io.IOException) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) StatusMessage(com.centurylink.mdw.common.service.types.StatusMessage) SocketTimeoutException(java.net.SocketTimeoutException) JSONObject(org.json.JSONObject) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) XmlException(org.apache.xmlbeans.XmlException) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument) RemoteException(java.rmi.RemoteException) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 3 with StatusMessage

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);
    }
}
Also used : JSONObject(org.json.JSONObject) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) Parameter(com.centurylink.mdw.service.Parameter) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) StatusMessage(com.centurylink.mdw.common.service.types.StatusMessage) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 4 with StatusMessage

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;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) JSONObject(org.json.JSONObject) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) StatusMessage(com.centurylink.mdw.common.service.types.StatusMessage)

Aggregations

StatusMessage (com.centurylink.mdw.common.service.types.StatusMessage)4 JSONObject (org.json.JSONObject)4 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)3 MDWStatusMessageDocument (com.centurylink.mdw.bpm.MDWStatusMessageDocument)2 XmlException (org.apache.xmlbeans.XmlException)2 JSONException (org.json.JSONException)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)1 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)1 ActionRequestDocument (com.centurylink.mdw.service.ActionRequestDocument)1 Parameter (com.centurylink.mdw.service.Parameter)1 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 RemoteException (java.rmi.RemoteException)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1