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);
}
}
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();
}
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations