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 CheckinItemRequestHandler extends RequestHandler {
14
15 public Map parseRequest(JSONObject jsonObject) throws JSONException {
16 String itemBarcode = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.ITEM_BARCODE);
17 String operatorId = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.OPERATOR_ID);
18
19 String requestFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.REQUEST_FORMAT_TYPE);
20 String responseFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.RESPONSE_FORMAT_TYPE);
21
22 Map checkinParameters = new HashMap();
23 checkinParameters.put("itemBarcode", itemBarcode);
24 checkinParameters.put("operatorId", operatorId);
25 checkinParameters.put("requestFormatType", requestFormatType);
26 checkinParameters.put("responseFormatType", responseFormatType);
27 return checkinParameters;
28 }
29
30 public String getStringValueFromJsonObject(JSONObject jsonObject, String key) {
31 String returnValue = null;
32 try {
33 returnValue = jsonObject.getString(key);
34 } catch (JSONException e) {
35 e.printStackTrace();
36 }
37 return returnValue;
38 }
39
40 }
41