Search in sources :

Example 56 with DataAccessException

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

the class RuntimeDataAccessRest method getExternalMessage.

// used by designer for displaying adapter raw message content
public ExternalMessageVO getExternalMessage(Long activityId, Long activityInstId, Long eventInstId) throws DataAccessException {
    try {
        String pathWithArgs = "Requests";
        if (eventInstId != null)
            pathWithArgs += "/" + eventInstId;
        else
            pathWithArgs += "?ownerId=" + activityInstId + "&type=outboundRequests";
        if (!getServer().isSchemaVersion61()) {
            pathWithArgs = "ExternalMessageInstance?format=json&activityId=" + activityId + "&activityInstId=" + activityInstId;
            if (eventInstId != null)
                pathWithArgs += "&eventInstId=" + eventInstId;
        }
        String response = invokeResourceService(pathWithArgs);
        return new ExternalMessageVO(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) ExternalMessageVO(com.centurylink.mdw.model.value.event.ExternalMessageVO) 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 57 with DataAccessException

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

the class RuntimeDataAccessRest method deleteProcessInstances.

public int deleteProcessInstances(List<Long> processInstanceIds) throws DataAccessException {
    try {
        List<ProcessInstanceVO> instances = new ArrayList<ProcessInstanceVO>();
        for (Long id : processInstanceIds) instances.add(new ProcessInstanceVO(id));
        ProcessList processList = new ProcessList(ProcessList.PROCESS_INSTANCES, instances);
        if (getServer().getSchemaVersion() >= 6000) {
            try {
                getServer().delete("Processes", processList.getJson().toString(2));
            } catch (IOException ex) {
                throw new DataAccessOfflineException("Unable to connect to " + getServer().getServiceUrl(), ex);
            }
        } else {
            ActionRequestMessage actionRequest = new ActionRequestMessage();
            actionRequest.setAction("DeleteProcessInstances");
            actionRequest.addParameter("appName", "MDW Designer");
            JSONObject msgJson = actionRequest.getJson();
            msgJson.put(processList.getJsonName(), processList.getJson());
            invokeActionService(msgJson.toString(2));
        }
        return processList.getCount();
    } catch (XmlException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    } catch (JSONException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONObject(org.json.JSONObject) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) XmlException(org.apache.xmlbeans.XmlException) ArrayList(java.util.ArrayList) ActionRequestMessage(com.centurylink.mdw.common.service.types.ActionRequestMessage) JSONException(org.json.JSONException) IOException(java.io.IOException) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 58 with DataAccessException

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

the class RuntimeDataAccessRest method deleteProcessInstancesForProcess.

public int deleteProcessInstancesForProcess(Long processId) throws DataAccessException {
    try {
        if (getServer().getSchemaVersion() >= 6000) {
            try {
                getServer().delete("Processes?processId=" + processId, null);
            } catch (IOException ex) {
                throw new DataAccessOfflineException("Unable to connect to " + getServer().getServiceUrl(), ex);
            }
        } else {
            ActionRequestMessage actionRequest = new ActionRequestMessage();
            actionRequest.setAction("DeleteProcessInstances");
            actionRequest.addParameter("appName", "MDW Designer");
            actionRequest.addParameter("processId", String.valueOf(processId));
            invokeActionService(actionRequest.getJson().toString(2));
        }
        // not used
        return 0;
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ActionRequestMessage(com.centurylink.mdw.common.service.types.ActionRequestMessage) 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 59 with DataAccessException

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

the class RuntimeDataAccessRest method hasProcessInstances.

public boolean hasProcessInstances(Long processId) throws DataAccessException {
    try {
        String pathWithArgs = "Processes?processId=" + processId + "&pageSize=1";
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "ProcessInstances?format=json&pageSize=1&processId=" + processId;
        String response = invokeResourceService(pathWithArgs);
        return new ProcessList(ProcessList.PROCESS_INSTANCES, response).getCount() > 0;
    } 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 60 with DataAccessException

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

the class RuntimeDataAccessRest method getProcessInstanceBase.

public ProcessInstanceVO getProcessInstanceBase(Long processInstanceId) throws DataAccessException {
    try {
        String pathWithArgs = "Processes/" + processInstanceId + "?shallow=true";
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "ProcessInstance?format=json&shallow=true&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)

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