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