Search in sources :

Example 16 with DataAccessException

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

the class UserDataAccessRest method getUser.

public UserVO getUser(String cuid) throws DataAccessException {
    try {
        String pathWithArgs = "Users/" + cuid;
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "User?format=json&cuid=" + cuid + "&withRoles=true";
        String response = invokeResourceService(pathWithArgs);
        JSONObject jsonObj = new JSONObject(response);
        if (jsonObj.has("status"))
            // user not found -- no privileges
            return new UserVO(cuid);
        else
            return new UserVO(jsonObj);
    } catch (FileNotFoundException ex) {
        return null;
    } 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) UserVO(com.centurylink.mdw.model.value.user.UserVO) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 17 with DataAccessException

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

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

the class UserDataAccessRest method getRoleNames.

public List<String> getRoleNames() throws DataAccessException {
    try {
        String pathWithArgs = "Roles?format=json";
        String response = invokeResourceService(pathWithArgs);
        RoleList roleList = new RoleList(response);
        List<String> roleNames = new ArrayList<String>();
        for (UserRoleVO role : roleList.getItems()) {
            roleNames.add(role.getName());
        }
        return roleNames;
    } 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) UserRoleVO(com.centurylink.mdw.model.value.user.UserRoleVO) RoleList(com.centurylink.mdw.model.value.user.RoleList) ArrayList(java.util.ArrayList) IOException(java.io.IOException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 19 with DataAccessException

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

the class WorkflowAccessRest method getAttributes.

public Map<String, String> getAttributes(String ownerType, long ownerId) throws DataAccessException, IOException {
    try {
        String pathWithArgs = "Attributes?format=json&ownerType=" + ownerType + "&ownerId=" + ownerId;
        String attrsJson = getServer().invokeResourceService(pathWithArgs);
        JSONObject attrs = new JSONObject(attrsJson);
        String[] names = JSONObject.getNames(attrs);
        if (names == null)
            return null;
        Map<String, String> attributes = new HashMap<String, String>();
        for (String name : names) attributes.put(name, attrs.getString(name));
        return attributes;
    } catch (JSONException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONException(org.json.JSONException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 20 with DataAccessException

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

the class WorkflowAccessRest method updateAttributes.

public void updateAttributes(String ownerType, long ownerId, Map<String, String> attributes) throws DataAccessException {
    try {
        JSONObject attrsJson = new JSONObject();
        for (String name : attributes.keySet()) attrsJson.put(name, attributes.get(name));
        if (getServer().getSchemaVersion() >= 6000) {
            try {
                getServer().post("Attributes/" + ownerType + "/" + ownerId, attrsJson.toString(2));
            } catch (IOException ex) {
                throw new DataAccessOfflineException("Unable to connect to " + getServer().getServiceUrl(), ex);
            }
        } else {
            Map<String, String> params = getStandardParams();
            params.put("ownerType", ownerType);
            params.put("ownerId", String.valueOf(ownerId));
            ActionRequest actionRequest = new ActionRequest("UpdateAttributes", params);
            actionRequest.addJson("attributes", attrsJson);
            invokeActionService(actionRequest.getJson().toString(2));
        }
    } catch (JSONException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONObject(org.json.JSONObject) ActionRequest(com.centurylink.mdw.common.service.ActionRequest) JSONException(org.json.JSONException) IOException(java.io.IOException) 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