1 package org.kuali.ole.sip2.sip2Response;
2
3 import org.apache.commons.lang3.StringUtils;
4 import org.kuali.ole.response.OLESIP2Response;
5 import org.kuali.ole.common.MessageUtil;
6 import org.kuali.ole.common.OLESIP2Util;
7 import org.kuali.ole.sip2.constants.OLESIP2Constants;
8 import org.kuali.ole.sip2.requestParser.OLESIP2FeePaidRequestParser;
9
10
11
12
13 public class OLESIP2FeePaidResponse extends OLESIP2Response {
14
15 public OLESIP2FeePaidResponse() {
16 code = OLESIP2Constants.FEE_PAID_RESPONSE;
17 }
18
19 public String getFeePaidResponse(String message, OLESIP2FeePaidRequestParser sip2FeePaidRequestParser) {
20 StringBuilder sip2FeePaidResponseBuilder = new StringBuilder();
21 sip2FeePaidResponseBuilder.append(code);
22 if (message.equalsIgnoreCase(OLESIP2Constants.FEE_PAID)) {
23 sip2FeePaidResponseBuilder.append(OLESIP2Util.bool2Char(true));
24 } else {
25 sip2FeePaidResponseBuilder.append(OLESIP2Util.bool2Char(false));
26 }
27 sip2FeePaidResponseBuilder.append(MessageUtil.getSipDateTime());
28 sip2FeePaidResponseBuilder.append(OLESIP2Constants.INSTITUTION_ID_CODE);
29 sip2FeePaidResponseBuilder.append(sip2FeePaidRequestParser.getInstitutionId() != null ? sip2FeePaidRequestParser.getInstitutionId() : "");
30 sip2FeePaidResponseBuilder.append(OLESIP2Constants.SPLIT+
31 OLESIP2Constants.PATRON_IDENTIFIER_CODE);
32 sip2FeePaidResponseBuilder.append(sip2FeePaidRequestParser.getPatronIdentifier());
33 if (StringUtils.isNotBlank(sip2FeePaidRequestParser.getTransactionId())) {
34 sip2FeePaidResponseBuilder.append(OLESIP2Constants.SPLIT+
35 OLESIP2Constants.TRANSACTION_ID_CODE);
36 sip2FeePaidResponseBuilder.append(sip2FeePaidRequestParser.getTransactionId());
37 }
38 if (StringUtils.isNotBlank(message)) {
39 sip2FeePaidResponseBuilder.append(OLESIP2Constants.SPLIT+
40 OLESIP2Constants.SCREEN_MSG_CODE);
41 sip2FeePaidResponseBuilder.append(message);
42 } else {
43 sip2FeePaidResponseBuilder.append(OLESIP2Constants.SPLIT+
44 OLESIP2Constants.SCREEN_MSG_CODE);
45 sip2FeePaidResponseBuilder.append(OLESIP2Constants.SERVICE_ERROR);
46 }
47 if (StringUtils.isNotBlank(sip2FeePaidRequestParser.getSequenceNum())) {
48 sip2FeePaidResponseBuilder.append(OLESIP2Constants.SPLIT+
49 OLESIP2Constants.SEQUENCE_NUM_CODE);
50 sip2FeePaidResponseBuilder.append(sip2FeePaidRequestParser.getSequenceNum());
51 sip2FeePaidResponseBuilder.append(MessageUtil.computeChecksum(sip2FeePaidResponseBuilder.toString()));
52 }
53 return sip2FeePaidResponseBuilder.toString() + '\r';
54 }
55 }
56