1 package org.kuali.ole.ncip.service.impl;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.asr.handler.LookupUserResponseHandler;
5 import org.kuali.ole.OLEConstants;
6 import org.kuali.ole.deliver.controller.checkout.CircUtilController;
7 import org.kuali.ole.deliver.service.ParameterValueResolver;
8 import org.kuali.ole.deliver.util.DroolsResponse;
9 import org.kuali.ole.bo.OLEItemFines;
10 import org.kuali.ole.bo.OLEUserPrivilege;
11 import org.kuali.ole.utility.OleStopWatch;
12 import org.kuali.rice.core.api.config.property.ConfigContext;
13
14 import java.util.ArrayList;
15 import java.util.Map;
16
17
18
19
20 public class Sip2LookupUserServiceImpl extends LookupUserServiceImpl {
21
22 @Override
23 public String prepareResponse() {
24
25 switch (responseFormatType) {
26 case ("XML"):
27 response = ((LookupUserResponseHandler) getResponseHandler()).marshalObjectToSIP2Xml(getOleLookupUser());
28 break;
29 case ("JSON"):
30 response = getResponseHandler().marshalObjectToJson(getOleLookupUser());
31 break;
32 }
33
34 return response;
35 }
36
37 @Override
38 public String getOperatorId(String operatorId) {
39 return ParameterValueResolver.getInstance().getParameter(OLEConstants
40 .APPL_ID_OLE, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, operatorId);
41 }
42
43 @Override
44 public void validatePatron() {
45 OleStopWatch oleStopWatch = new OleStopWatch();
46 oleStopWatch.start();
47 ArrayList<Object> facts = new ArrayList<>();
48 facts.add(getOlePatronDocument());
49 DroolsResponse droolsResponse = new DroolsResponse();
50 facts.add(droolsResponse);
51 new CircUtilController().fireRules(facts, null, "lookup-user-sip2");
52
53 if (StringUtils.isBlank(droolsResponse.getErrorMessage().getErrorMessage())) {
54 getOleLookupUser().setValidPatron(true);
55 } else {
56 getOleLookupUser().setValidPatron(false);
57 }
58 }
59
60 @Override
61 public boolean isRenewalInfoNeeded() {
62 return false;
63 }
64
65 @Override
66 public OLEUserPrivilege getStatusPrivilege() {
67 return null;
68 }
69
70 @Override
71 protected void processErrorResponseForOperator() {
72 getOleLookupUser().setCode("001");
73 getOleLookupUser().setMessage(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.CIRCULATION_DESK_NOT_MAPPED_OPERATOR));
74 }
75
76 @Override
77 protected void processErrorResponseForPatron() {
78 getOleLookupUser().setCode("002");
79 getOleLookupUser().setMessage(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.NO_PATRON_INFO));
80 }
81
82 @Override
83 protected void processSuccessResponseForLookupUser() {
84 getOleLookupUser().setCode("000");
85 getOleLookupUser().setMessage(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.RTRVD_SUCCESS));
86 }
87
88 @Override
89 protected void processSuccessResponseForItemFine(OLEItemFines oleItemFines) {
90 oleItemFines.setCode("000");
91 oleItemFines.setMessage(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.RTRVD_SUCCESS));
92 }
93
94 @Override
95 protected void processInfoForItemFine(OLEItemFines oleItemFines) {
96 oleItemFines.setCode("005");
97 oleItemFines.setMessage(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.NO_FINE));
98 }
99
100 @Override
101 protected boolean nameInformationDesired() {
102 return true;
103 }
104
105 @Override
106 protected boolean userAddressInformationDesired() {
107 return true;
108 }
109
110 @Override
111 protected boolean userPrivilegeDesired() {
112 return false;
113 }
114
115 @Override
116 protected boolean loanedItemsDesired() {
117 return true;
118 }
119
120 @Override
121 protected boolean requestedItemsDesired() {
122 return true;
123 }
124
125 @Override
126 protected boolean userFiscalAccountDesired() {
127 return true;
128 }
129
130 @Override
131 protected void preProcess(Map lookupUserParameters) {
132
133 }
134 }