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