001package org.kuali.asr.handler; 002 003import org.codehaus.jettison.json.JSONException; 004import org.codehaus.jettison.json.JSONObject; 005import org.kuali.ole.ncip.bo.OLENCIPConstants; 006 007import java.util.HashMap; 008import java.util.Map; 009 010/** 011 * Created by chenchulakshmig on 8/27/15. 012 */ 013public class CheckinItemRequestHandler extends RequestHandler { 014 015 public Map parseRequest(JSONObject jsonObject) throws JSONException { 016 String itemBarcode = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.ITEM_BARCODE); 017 String operatorId = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.OPERATOR_ID); 018 String deleteIndicator = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.DELETE_INDICATOR); 019 020 String requestFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.REQUEST_FORMAT_TYPE); 021 String responseFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.RESPONSE_FORMAT_TYPE); 022 023 Map checkinParameters = new HashMap(); 024 checkinParameters.put("itemBarcode", itemBarcode); 025 checkinParameters.put("operatorId", operatorId); 026 checkinParameters.put("deleteIndicator", deleteIndicator); 027 checkinParameters.put("requestFormatType", requestFormatType); 028 checkinParameters.put("responseFormatType", responseFormatType); 029 return checkinParameters; 030 } 031 032 public String getStringValueFromJsonObject(JSONObject jsonObject, String key) { 033 String returnValue = null; 034 try { 035 returnValue = jsonObject.getString(key); 036 } catch (JSONException e) { 037 e.printStackTrace(); 038 } 039 return returnValue; 040 } 041 042} 043