Search in sources :

Example 1 with MDWStatusMessage

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();
}
Also used : MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument)

Example 2 with MDWStatusMessage

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());
    }
}
Also used : VariableValue(com.centurylink.mdw.plugin.designer.model.VariableValue) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with MDWStatusMessage

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);
    }
}
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 4 with MDWStatusMessage

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;
}
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

MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)4 MDWStatusMessageDocument (com.centurylink.mdw.bpm.MDWStatusMessageDocument)3 StatusMessage (com.centurylink.mdw.common.service.types.StatusMessage)2 JSONObject (org.json.JSONObject)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 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)1 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)1 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)1 VariableValue (com.centurylink.mdw.plugin.designer.model.VariableValue)1 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 RemoteException (java.rmi.RemoteException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 XmlException (org.apache.xmlbeans.XmlException)1 CoreException (org.eclipse.core.runtime.CoreException)1