Search in sources :

Example 1 with ActionRequest

use of com.centurylink.mdw.common.service.ActionRequest 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)1 ActionRequest (com.centurylink.mdw.common.service.ActionRequest)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 IOException (java.io.IOException)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1