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/22/15.
12   */
13  public class LookupUserRequestHandler 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  
19          String requestFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.REQUEST_FORMAT_TYPE);
20          String responseFormatType = getStringValueFromJsonObject(jsonObject, OLENCIPConstants.RESPONSE_FORMAT_TYPE);
21  
22          Map lookupUserParameters = new HashMap();
23          lookupUserParameters.put("patronBarcode", patronBarcode);
24          lookupUserParameters.put("operatorId", operatorId);
25          lookupUserParameters.put("requestFormatType", requestFormatType);
26          lookupUserParameters.put("responseFormatType", responseFormatType);
27          return lookupUserParameters;
28      }
29  
30      public String getStringValueFromJsonObject(JSONObject jsonObject, String key) {
31          String returnValue = null;
32          try {
33              returnValue = jsonObject.getString(key);
34          } catch (JSONException e) {
35              e.printStackTrace();
36          }
37          return returnValue;
38      }
39  
40  }