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 9/22/15. 012 */ 013public class LookupUserRequestHandler extends RequestHandler { 014 015 public Map parseRequest(JSONObject jsonObject) throws JSONException { 016 String patronBarcode = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.PATRON_BARCODE); 017 String operatorId = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.OPERATOR_ID); 018 019 String requestFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.REQUEST_FORMAT_TYPE); 020 String responseFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.RESPONSE_FORMAT_TYPE); 021 022 Map lookupUserParameters = new HashMap(); 023 lookupUserParameters.put("patronBarcode", patronBarcode); 024 lookupUserParameters.put("operatorId", operatorId); 025 lookupUserParameters.put("requestFormatType", requestFormatType); 026 lookupUserParameters.put("responseFormatType", responseFormatType); 027 return lookupUserParameters; 028 } 029 030 public String getStringValueFromJsonObject(JSONObject jsonObject, String key) { 031 String returnValue = null; 032 try { 033 returnValue = jsonObject.getString(key); 034 } catch (JSONException e) { 035 e.printStackTrace(); 036 } 037 return returnValue; 038 } 039 040}