Search in sources :

Example 1 with ActionRequestMessage

use of com.centurylink.mdw.common.service.types.ActionRequestMessage in project mdw-designer by CenturyLinkCloud.

the class UserDataAccessRest method auditLogUserAction.

public void auditLogUserAction(final UserActionVO userAction) throws DataAccessException {
    // certain actions need to be logged on the server
    // TODO: this should actually be done on the server side, but currently many services don't require username
    Action action = userAction.getAction();
    Entity entity = userAction.getEntity();
    if (action == Action.Run || action == Action.Send || action == Action.Retry || action == Action.Proceed || action == Action.Import || entity == Entity.ProcessInstance || entity == Entity.ActivityInstance || entity == Entity.VariableInstance) {
        if (isOnline()) {
            // run in background thread
            new Thread(new Runnable() {

                public void run() {
                    try {
                        ActionRequestMessage actionRequest = new ActionRequestMessage();
                        actionRequest.setAction("AuditLog");
                        actionRequest.addParameter("appName", "MDW Designer");
                        JSONObject msgJson = actionRequest.getJson();
                        msgJson.put(userAction.getJsonName(), userAction.getJson());
                        invokeActionService(msgJson.toString(2));
                    } catch (Exception ex) {
                        // silent
                        ex.printStackTrace();
                    }
                }
            }).start();
        }
    }
}
Also used : Entity(com.centurylink.mdw.model.value.user.UserActionVO.Entity) Action(com.centurylink.mdw.model.value.user.UserActionVO.Action) JSONObject(org.json.JSONObject) ActionRequestMessage(com.centurylink.mdw.common.service.types.ActionRequestMessage) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException)

Example 2 with ActionRequestMessage

use of com.centurylink.mdw.common.service.types.ActionRequestMessage 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 3 with ActionRequestMessage

use of com.centurylink.mdw.common.service.types.ActionRequestMessage 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)

Aggregations

DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 ActionRequestMessage (com.centurylink.mdw.common.service.types.ActionRequestMessage)3 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)3 IOException (java.io.IOException)3 XmlException (org.apache.xmlbeans.XmlException)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)1 Action (com.centurylink.mdw.model.value.user.UserActionVO.Action)1 Entity (com.centurylink.mdw.model.value.user.UserActionVO.Entity)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1