1 package org.kuali.asr.handler;
2
3 import org.codehaus.jettison.json.JSONException;
4 import org.codehaus.jettison.json.JSONObject;
5 import org.kuali.ole.ncip.bo.OLENCIPConstants;
6
7 import java.util.HashMap;
8 import java.util.Map;
9
10
11
12
13 public class ItemInfoRequestHandler extends RequestHandler {
14
15 public Map parseRequest(JSONObject jsonObject) throws JSONException {
16 String itemIdentifier = getStringValueFromJsonObject(jsonObject, "itemIdentifier");
17
18 String requestFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.REQUEST_FORMAT_TYPE);
19 String responseFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.RESPONSE_FORMAT_TYPE);
20
21 Map lookupUserParameters = new HashMap();
22 lookupUserParameters.put("itemIdentifier", itemIdentifier);
23 lookupUserParameters.put("requestFormatType", requestFormatType);
24 lookupUserParameters.put("responseFormatType", responseFormatType);
25 return lookupUserParameters;
26 }
27
28 public String getStringValueFromJsonObject(JSONObject jsonObject, String key) {
29 String returnValue = null;
30 try {
31 returnValue = jsonObject.getString(key);
32 } catch (JSONException e) {
33 e.printStackTrace();
34 }
35 return returnValue;
36 }
37 }