Search in sources :

Example 1 with CustomMetadataException

use of org.alfresco.module.org_alfresco_module_rm.admin.CustomMetadataException in project records-management by Alfresco.

the class CustomPropertyDefinitionPost method executeImpl.

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    JSONObject json = null;
    Map<String, Object> ftlModel = null;
    try {
        json = new JSONObject(new JSONTokener(req.getContent().getContent()));
        try {
            ftlModel = createPropertyDefinition(req, json);
        } catch (CustomMetadataException e) {
            status.setCode(Status.STATUS_BAD_REQUEST);
            ftlModel = new HashMap<String, Object>();
            ftlModel.put(MESSAGE, e.getMessage());
        }
    } catch (IOException iox) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
    } catch (JSONException je) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
    }
    return ftlModel;
}
Also used : JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) IOException(java.io.IOException) CustomMetadataException(org.alfresco.module.org_alfresco_module_rm.admin.CustomMetadataException)

Example 2 with CustomMetadataException

use of org.alfresco.module.org_alfresco_module_rm.admin.CustomMetadataException in project records-management by Alfresco.

the class CustomPropertyDefinitionPut method executeImpl.

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    JSONObject json = null;
    Map<String, Object> ftlModel = null;
    try {
        json = new JSONObject(new JSONTokener(req.getContent().getContent()));
        try {
            ftlModel = handlePropertyDefinitionUpdate(req, json);
        } catch (CustomMetadataException e) {
            status.setCode(Status.STATUS_BAD_REQUEST);
            ftlModel = new HashMap<String, Object>();
            ftlModel.put(MESSAGE, e.getMessage());
        }
    } catch (IOException iox) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
    } catch (JSONException je) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
    }
    return ftlModel;
}
Also used : JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) IOException(java.io.IOException) CustomMetadataException(org.alfresco.module.org_alfresco_module_rm.admin.CustomMetadataException)

Aggregations

IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 CustomMetadataException (org.alfresco.module.org_alfresco_module_rm.admin.CustomMetadataException)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 JSONTokener (org.json.JSONTokener)2 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)2