Search in sources :

Example 46 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException 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 47 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class CacheRefresh method doRefresh.

public void doRefresh(boolean silent, final boolean includeDynamicJava) {
    try {
        if (silent) {
            if (workflowProject.isUpdateServerCache()) {
                // run as background job
                new Job("MDW Cache Refresh: " + restfulServer.getMdwWebUrl()) {

                    protected IStatus run(IProgressMonitor monitor) {
                        try {
                            CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
                            refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
                            timer.stopAndLog();
                        } catch (Exception ex) {
                            if (MdwPlugin.getSettings().isLogConnectErrors())
                                PluginMessages.log(ex);
                        }
                        return Status.OK_STATUS;
                    }
                }.schedule();
            }
        } else {
            String progressMsg = "Refreshing Caches and Properties for '" + workflowProject.getLabel() + "'";
            String errorMsg = "Refresh Cache";
            DesignerRunner designerRunner = new DesignerRunner(progressMsg, errorMsg, workflowProject) {

                public void perform() throws ValidationException, DataAccessException, RemoteException {
                    try {
                        CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
                        refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
                        timer.stopAndLog();
                    } catch (Exception ex) {
                        PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
                    }
                }
            };
            designerRunner.run();
            if (refreshStatusMessage == null) {
                PluginMessages.uiError(workflowProject.getName() + " Refresh Caches and Properties failed.  Make sure baseline event handlers are registered.", REFRESH_CACHES, workflowProject);
            } else if (refreshStatusMessage.getMDWStatusMessage().getStatusCode() != 0) {
                String message = refreshStatusMessage.getMDWStatusMessage().getStatusMessage();
                PluginMessages.uiMessage(workflowProject.getName() + " Refresh Caches and Properties:\n" + message, "Refresh Caches", workflowProject, PluginMessages.INFO_MESSAGE);
            }
        }
    } catch (Exception ex) {
        if (!silent)
            PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Job(org.eclipse.core.runtime.jobs.Job) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException)

Example 48 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method engineCall.

public String engineCall(String serverUrl, String request, Map<String, String> headers) throws RemoteException, DataAccessException {
    String response;
    if (serverUrl == null)
        throw new DataAccessException("No server specified");
    if (serverUrl.startsWith("iiop:")) {
        response = sendEjbMessage(serverUrl, request);
    } else if (serverUrl.startsWith(HTTP) || serverUrl.startsWith("https:")) {
        if (request.startsWith("<env:Envelope"))
            response = sendSoapMessage(serverUrl, request, headers);
        else
            response = sendRestfulMessage(serverUrl, request, headers);
    } else if (serverUrl.startsWith("rmi:")) {
        response = sendRmiMessage(serverUrl, request);
    } else
        throw new DataAccessException("Illegal server url: " + serverUrl);
    return response;
}
Also used : DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 49 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method skipActivity.

public void skipActivity(Long activityId, Long activityInstId, String compCode) throws DataAccessException, XmlException, IOException {
    if (currentServer.isSchemaVersion61()) {
        ((RestfulServer) currentServer).skipActivityInstance(activityInstId, ActivityResultCodeConstant.RESULT_PROCEED, compCode);
    } else {
        String request = currentServer.buildSkipActivityInstanceRequest(activityId, activityInstId, compCode, false);
        String response = this.engineCall(request);
        try {
            String result = currentServer.getErrorMessageFromResponse(response);
            if (result == null || result.length() > 0)
                throw new RemoteException(result);
            auditLog(Action.Proceed, Entity.ActivityInstance, activityInstId, compCode);
        } catch (XmlException e) {
            throw new DataAccessException("Response is not an MDWStatusMessage");
        }
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 50 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getTaskInstances.

private List<TaskInstanceVO> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, Long activityId, List<TaskInstanceVO> allTaskInstances) throws DataAccessException {
    List<TaskInstanceVO> taskInstances = new ArrayList<>();
    for (TaskInstanceVO taskInstance : allTaskInstances) {
        String secondaryOwner = taskInstance.getSecondaryOwnerType();
        if (OwnerType.DOCUMENT.equals(secondaryOwner) || "EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner)) {
            String formDataString = null;
            if (OwnerType.DOCUMENT.equals(secondaryOwner))
                formDataString = rtinfo.getDocument(taskInstance.getSecondaryOwnerId()).getContent();
            else if ("EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner))
                formDataString = rtinfo.getExternalEventDetails(taskInstance.getSecondaryOwnerId());
            FormDataDocument formDataDoc = new FormDataDocument();
            try {
                formDataDoc.load(formDataString);
                for (ActivityInstanceVO activityInstance : processInstance.getActivityInstances(activityId)) {
                    if (activityInstance.getId().equals(formDataDoc.getActivityInstanceId()))
                        taskInstances.add(taskInstance);
                }
            } catch (MbengException ex) {
                throw new DataAccessException(-1, ex.getMessage(), ex);
            }
        } else {
            // task instance secondary owner is work transition instance
            Long workTransInstId = taskInstance.getSecondaryOwnerId();
            for (WorkTransitionInstanceVO transitionInstance : processInstance.getTransitions()) {
                if (transitionInstance.getTransitionInstanceID().equals(workTransInstId)) {
                    Long transitionId = transitionInstance.getTransitionID();
                    WorkTransitionVO workTrans = process.getWorkTransition(transitionId);
                    if (workTrans == null && process.getSubProcesses() != null) {
                        for (ProcessVO subproc : process.getSubProcesses()) {
                            workTrans = subproc.getWorkTransition(transitionId);
                            if (workTrans != null)
                                break;
                        }
                    }
                    if (workTrans != null && workTrans.getToWorkId().equals(activityId))
                        taskInstances.add(taskInstance);
                }
            }
        }
    }
    return taskInstances;
}
Also used : MbengException(com.qwest.mbeng.MbengException) WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) FormDataDocument(com.centurylink.mdw.model.FormDataDocument) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Aggregations

DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)61 IOException (java.io.IOException)32 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)25 JSONException (org.json.JSONException)21 XmlException (org.apache.xmlbeans.XmlException)19 RemoteException (java.rmi.RemoteException)18 JSONObject (org.json.JSONObject)12 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)10 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)10 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)8 FileNotFoundException (java.io.FileNotFoundException)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)6 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)5 Graph (com.centurylink.mdw.designer.display.Graph)4 SubGraph (com.centurylink.mdw.designer.display.SubGraph)4 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)4 File (java.io.File)4 MDWStatusMessageDocument (com.centurylink.mdw.bpm.MDWStatusMessageDocument)3