Search in sources :

Example 11 with Request

use of org.collectionspace.chain.csp.webui.main.Request in project application by collectionspace.

the class StructuredDateParser method run.

@Override
public void run(Object in, String[] tail) throws UIException {
    UIRequest request = ((Request) in).getUIRequest();
    String displayDate = request.getRequestArgument("displayDate");
    JSONObject output = new JSONObject();
    StructuredDateInternal structuredDate = null;
    StructuredDateFormatException formatException = null;
    try {
        structuredDate = StructuredDateInternal.parse(displayDate);
    } catch (StructuredDateFormatException e) {
        formatException = e;
    }
    try {
        if (formatException != null) {
            // The convention in app layer error responses appears to be to
            // send a boolean isError, and an array of error messages.
            output.put("isError", true);
            output.put("messages", new String[] { "Unrecognized date format", formatException.getMessage() });
        }
        if (structuredDate != null) {
            String tenantDomain = request.getTenant();
            output.put("structuredDate", structuredDateToJSON(tenantDomain, structuredDate));
        }
    } catch (JSONException e) {
        throw new UIException("Error building JSON", e);
    }
    request.sendJSONResponse(output);
}
Also used : StructuredDateFormatException(org.collectionspace.services.structureddate.StructuredDateFormatException) JSONObject(org.json.JSONObject) UIRequest(org.collectionspace.csp.api.ui.UIRequest) Request(org.collectionspace.chain.csp.webui.main.Request) StructuredDateInternal(org.collectionspace.services.structureddate.StructuredDateInternal) JSONException(org.json.JSONException) UIException(org.collectionspace.csp.api.ui.UIException) UIRequest(org.collectionspace.csp.api.ui.UIRequest)

Example 12 with Request

use of org.collectionspace.chain.csp.webui.main.Request in project application by collectionspace.

the class VocabRedirector method run.

public void run(Object in, String[] tail) throws UIException {
    Request q = (Request) in;
    redirect(q.getCache(), q.getStorage(), q.getUIRequest(), tail);
}
Also used : UIRequest(org.collectionspace.csp.api.ui.UIRequest) Request(org.collectionspace.chain.csp.webui.main.Request)

Example 13 with Request

use of org.collectionspace.chain.csp.webui.main.Request in project application by collectionspace.

the class WebAutoComplete method run.

public void run(Object in, String[] tail) throws UIException {
    Request q = (Request) in;
    autocomplete(q.getCache(), q.getStorage(), q.getUIRequest());
}
Also used : UIRequest(org.collectionspace.csp.api.ui.UIRequest) Request(org.collectionspace.chain.csp.webui.main.Request)

Example 14 with Request

use of org.collectionspace.chain.csp.webui.main.Request in project application by collectionspace.

the class UserDetailsCreateUpdate method run.

public void run(Object in, String[] tail) throws UIException {
    Request q = (Request) in;
    store_set(q.getStorage(), q.getUIRequest(), StringUtils.join(tail, "/"));
}
Also used : UIRequest(org.collectionspace.csp.api.ui.UIRequest) Request(org.collectionspace.chain.csp.webui.main.Request)

Example 15 with Request

use of org.collectionspace.chain.csp.webui.main.Request in project application by collectionspace.

the class UserDetailsDelete method run.

public void run(Object in, String[] tail) throws UIException {
    Request q = (Request) in;
    store_delete(q.getStorage(), q.getUIRequest(), StringUtils.join(tail, "/"));
}
Also used : UIRequest(org.collectionspace.csp.api.ui.UIRequest) Request(org.collectionspace.chain.csp.webui.main.Request)

Aggregations

Request (org.collectionspace.chain.csp.webui.main.Request)36 UIRequest (org.collectionspace.csp.api.ui.UIRequest)34 JSONObject (org.json.JSONObject)5 CacheTermList (org.collectionspace.chain.csp.webui.nuispec.CacheTermList)2 UIException (org.collectionspace.csp.api.ui.UIException)2 UISession (org.collectionspace.csp.api.ui.UISession)1 StructuredDateFormatException (org.collectionspace.services.structureddate.StructuredDateFormatException)1 StructuredDateInternal (org.collectionspace.services.structureddate.StructuredDateInternal)1 JSONException (org.json.JSONException)1