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/30/15. 012 */ 013public class PatronBlockRequestHandler 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 String blockedCardMessage = getStringValueFromJsonObject(jsonObject, "blockedCardMessage"); 019 020 String requestFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.REQUEST_FORMAT_TYPE); 021 String responseFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.RESPONSE_FORMAT_TYPE); 022 023 Map lookupUserParameters = new HashMap(); 024 lookupUserParameters.put("patronBarcode", patronBarcode); 025 lookupUserParameters.put("operatorId", operatorId); 026 lookupUserParameters.put("blockedCardMessage", blockedCardMessage); 027 lookupUserParameters.put("requestFormatType", requestFormatType); 028 lookupUserParameters.put("responseFormatType", responseFormatType); 029 return lookupUserParameters; 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}