Search in sources :

Example 16 with DataAccessOfflineException

use of com.centurylink.mdw.dataaccess.DataAccessOfflineException 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 17 with DataAccessOfflineException

use of com.centurylink.mdw.dataaccess.DataAccessOfflineException 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 18 with DataAccessOfflineException

use of com.centurylink.mdw.dataaccess.DataAccessOfflineException 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 19 with DataAccessOfflineException

use of com.centurylink.mdw.dataaccess.DataAccessOfflineException 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 20 with DataAccessOfflineException

use of com.centurylink.mdw.dataaccess.DataAccessOfflineException 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

DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)21 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)19 IOException (java.io.IOException)19 XmlException (org.apache.xmlbeans.XmlException)14 JSONException (org.json.JSONException)14 JSONObject (org.json.JSONObject)7 FileNotFoundException (java.io.FileNotFoundException)4 RemoteException (java.rmi.RemoteException)4 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)3 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)3 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)3 ActionRequestMessage (com.centurylink.mdw.common.service.types.ActionRequestMessage)2 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)2 ProgressMonitor (com.centurylink.mdw.common.utilities.timer.ProgressMonitor)2 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)2 SwtProgressMonitor (com.centurylink.mdw.plugin.designer.SwtProgressMonitor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2