View Javadoc
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   * Created by chenchulakshmig on 9/30/15.
12   */
13  public class PatronBlockRequestHandler extends RequestHandler {
14  
15      public Map parseRequest(JSONObject jsonObject) throws JSONException {
16          String patronBarcode = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.PATRON_BARCODE);
17          String operatorId = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.OPERATOR_ID);
18          String blockedCardMessage = getStringValueFromJsonObject(jsonObject, "blockedCardMessage");
19  
20          String requestFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.REQUEST_FORMAT_TYPE);
21          String responseFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.RESPONSE_FORMAT_TYPE);
22  
23          Map lookupUserParameters = new HashMap();
24          lookupUserParameters.put("patronBarcode", patronBarcode);
25          lookupUserParameters.put("operatorId", operatorId);
26          lookupUserParameters.put("blockedCardMessage", blockedCardMessage);
27          lookupUserParameters.put("requestFormatType", requestFormatType);
28          lookupUserParameters.put("responseFormatType", responseFormatType);
29          return lookupUserParameters;
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  }