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