use of com.centurylink.mdw.dataaccess.DataAccessOfflineException in project mdw-designer by CenturyLinkCloud.
the class ServerAccessRest method isOnline.
public boolean isOnline() throws DataAccessException {
if (serverOnline == null) {
try {
server.getAppSummary();
serverOnline = true;
} catch (IOException ex) {
serverOnline = false;
serverOfflineException = new DataAccessOfflineException("Server unavailable: " + getServiceBaseUrl(), ex);
} catch (Exception ex) {
throw new DataAccessException("Error communicating with server: " + ex.getMessage(), ex);
}
}
return serverOnline;
}
use of com.centurylink.mdw.dataaccess.DataAccessOfflineException in project mdw-designer by CenturyLinkCloud.
the class UserDataAccessRest method getAllGroups.
public List<UserGroupVO> getAllGroups(boolean includeDeleted) throws DataAccessException {
try {
String pathWithArgs = "Workgroups?format=json";
if (includeDeleted)
pathWithArgs += "&includeDeleted=true";
String response = invokeResourceService(pathWithArgs);
return new WorkgroupList(response).getItems();
} catch (IOException ex) {
throw new DataAccessOfflineException(ex.getMessage(), ex);
} catch (Exception ex) {
throw new DataAccessException(ex.getMessage(), ex);
}
}
use of com.centurylink.mdw.dataaccess.DataAccessOfflineException 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.dataaccess.DataAccessOfflineException 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.dataaccess.DataAccessOfflineException 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