Search in sources :

Example 1 with DataAccessOfflineException

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;
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) IOException(java.io.IOException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 2 with DataAccessOfflineException

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);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) WorkgroupList(com.centurylink.mdw.model.value.user.WorkgroupList) 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 3 with DataAccessOfflineException

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);
    }
}
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 4 with DataAccessOfflineException

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);
    }
}
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 5 with DataAccessOfflineException

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

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