Search in sources :

Example 21 with DataAccessException

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

the class WorkflowAccessRest method getProcess.

public ProcessVO getProcess(long processId, boolean json) throws DataAccessException {
    try {
        if (json) {
            String processJson = getServer().invokeResourceService("Workflow?id=" + processId);
            JSONObject jsonObj = new JSONObject(processJson);
            ProcessVO process = new ProcessVO(jsonObj);
            process.setPackageName(jsonObj.getString("package"));
            process.setPackageVersion(jsonObj.getString("packageVersion"));
            process.setId(jsonObj.getLong("id"));
            return process;
        } else {
            String pkgXml = getServer().invokeResourceService("Processes?id=" + processId);
            ProcessImporter importer = DataAccess.getProcessImporter(DataAccess.currentSchemaVersion);
            PackageVO pkg = importer.importPackage(pkgXml);
            ProcessVO process = pkg.getProcesses().get(0);
            process.setPackageName(pkg.getName());
            process.setPackageVersion(pkg.getVersionString());
            process.setId(processId);
            return process;
        }
    } catch (Exception ex) {
        throw new DataAccessException("Error retrieving process: " + processId, ex);
    }
}
Also used : JSONObject(org.json.JSONObject) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ProcessImporter(com.centurylink.mdw.dataaccess.ProcessImporter) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 22 with DataAccessException

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

the class RuntimeDataAccessRest method getProcessInstanceList.

public ProcessList getProcessInstanceList(Map<String, String> criteria, Map<String, String> variables, int pageIndex, int pageSize, String orderBy) throws DataAccessException {
    try {
        String pathWithArgs = "Processes?mdw-app=designer";
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "ProcessInstances?format=json";
        String criteriaParams = queryParams(criteria);
        if (criteriaParams.length() > 0)
            pathWithArgs += "&" + criteriaParams;
        String varParams = queryParams(variables);
        if (varParams.length() > 0)
            pathWithArgs += "&" + varParams;
        if (pageIndex > 0)
            pathWithArgs += "&pageIndex=" + pageIndex;
        if (pageSize != 0)
            pathWithArgs += "&pageSize=" + pageSize;
        if (orderBy != null) {
            pathWithArgs += "&orderBy=" + URLEncoder.encode(orderBy.trim(), "UTF-8");
        }
        String response = invokeResourceService(pathWithArgs);
        return new ProcessList(ProcessList.PROCESS_INSTANCES, response);
    } catch (IOException ex) {
        throw new DataAccessOfflineException(ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) IOException(java.io.IOException) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 23 with DataAccessException

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

the class RuntimeDataAccessRest method getProcessInstanceAll.

public ProcessInstanceVO getProcessInstanceAll(Long processInstanceId) throws DataAccessException {
    try {
        String pathWithArgs = "Processes/" + processInstanceId;
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "ProcessInstance?format=json&instanceId=" + processInstanceId;
        String response = invokeResourceService(pathWithArgs);
        return new ProcessInstanceVO(new JSONObject(response));
    } catch (IOException ex) {
        throw new DataAccessOfflineException(ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONObject(org.json.JSONObject) IOException(java.io.IOException) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 24 with DataAccessException

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

the class RuntimeDataAccessRest method getTaskInstancesForProcessInstance.

public List<TaskInstanceVO> getTaskInstancesForProcessInstance(Long processInstanceId) throws DataAccessException {
    try {
        if (getServer().getSchemaVersion() >= 6000) {
            String path = "Tasks?processInstanceId=" + processInstanceId;
            String response = invokeResourceService(path);
            return new TaskList(TaskList.TASKS, response).getItems();
        } else {
            String path = "ProcessTasks?format=json&processInstanceId=" + processInstanceId;
            String response = invokeResourceService(path);
            return new TaskList(TaskList.PROCESS_TASKS, response).getItems();
        }
    } catch (IOException ex) {
        throw new DataAccessOfflineException(ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) TaskList(com.centurylink.mdw.common.task.TaskList) IOException(java.io.IOException) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 25 with DataAccessException

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

the class RuntimeDataAccessRest method getProcessInstanceCallHierarchy.

public LinkedProcessInstance getProcessInstanceCallHierarchy(Long processInstanceId) throws DataAccessException {
    try {
        String pathWithArgs = "Processes?mdw-app=designer&callHierarchyFor=" + processInstanceId;
        String response;
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "ProcessInstances?format=json&callHierarchyFor=" + processInstanceId;
        response = invokeResourceService(pathWithArgs);
        return new LinkedProcessInstance(response);
    } catch (IOException ex) {
        throw new DataAccessOfflineException(ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) IOException(java.io.IOException) LinkedProcessInstance(com.centurylink.mdw.model.value.process.LinkedProcessInstance) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) 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