Search in sources :

Example 71 with UIException

use of org.collectionspace.csp.api.ui.UIException in project application by collectionspace.

the class UserRolesRead method store_get.

private void store_get(Storage storage, UIRequest request, String path) throws UIException {
    // Get the data
    JSONObject outputJSON = getJSON(storage, path);
    try {
        outputJSON.put("csid", path);
    } catch (JSONException e1) {
        throw new UIException("Cannot add csid", e1);
    }
    // Write the requested JSON out
    request.sendJSONResponse(outputJSON);
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) UIException(org.collectionspace.csp.api.ui.UIException)

Example 72 with UIException

use of org.collectionspace.csp.api.ui.UIException in project application by collectionspace.

the class UserRolesSearchList method search_or_list.

private void search_or_list(Storage storage, UIRequest ui, String param, String pageSize, String pageNum) throws UIException {
    try {
        JSONObject restriction = new JSONObject();
        String key = "items";
        if (param != null) {
            restriction.put("screenName", param);
            key = "results";
        }
        if (pageSize != null) {
            restriction.put("pageSize", pageSize);
        }
        if (pageNum != null) {
            restriction.put("pageNum", pageNum);
        }
        JSONObject data = storage.getPathsJSON(base, restriction);
        String[] paths = (String[]) data.get("listItems");
        for (int i = 0; i < paths.length; i++) {
            if (paths[i].startsWith(base + "/"))
                paths[i] = paths[i].substring((base + "/").length());
        }
        JSONObject resultsObject = new JSONObject();
        resultsObject = pathsToJSON(storage, base, paths, key);
        ui.sendJSONResponse(resultsObject);
    } catch (JSONException e) {
        throw new UIException("JSONException during autocompletion", e);
    } catch (ExistException e) {
        throw new UIException("ExistException during autocompletion", e);
    } catch (UnimplementedException e) {
        throw new UIException("UnimplementedException during autocompletion", e);
    } catch (UnderlyingStorageException x) {
        UIException uiexception = new UIException(x.getMessage(), x.getStatus(), x.getUrl(), x);
        ui.sendJSONResponse(uiexception.getJSON());
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) UIException(org.collectionspace.csp.api.ui.UIException) ExistException(org.collectionspace.csp.api.persistence.ExistException) UnderlyingStorageException(org.collectionspace.csp.api.persistence.UnderlyingStorageException) UnimplementedException(org.collectionspace.csp.api.persistence.UnimplementedException)

Aggregations

UIException (org.collectionspace.csp.api.ui.UIException)72 JSONObject (org.json.JSONObject)51 JSONException (org.json.JSONException)50 ExistException (org.collectionspace.csp.api.persistence.ExistException)39 UnderlyingStorageException (org.collectionspace.csp.api.persistence.UnderlyingStorageException)39 UnimplementedException (org.collectionspace.csp.api.persistence.UnimplementedException)39 JSONArray (org.json.JSONArray)19 IOException (java.io.IOException)10 Record (org.collectionspace.chain.csp.schema.Record)7 Instance (org.collectionspace.chain.csp.schema.Instance)6 ConfigException (org.collectionspace.chain.csp.config.ConfigException)5 Field (org.collectionspace.chain.csp.schema.Field)4 FieldSet (org.collectionspace.chain.csp.schema.FieldSet)4 UIRequest (org.collectionspace.csp.api.ui.UIRequest)4 MessageDigest (java.security.MessageDigest)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)3 AdminData (org.collectionspace.chain.csp.schema.AdminData)3 Structure (org.collectionspace.chain.csp.schema.Structure)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2