1 package org.kuali.ole.sip2.requestParser;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.sip2.constants.OLESIP2Constants;
5
6
7
8
9 public class OLESIP2CheckOutRequestParser extends OLESIP2RequestParser {
10
11 private static final Logger LOG = Logger.getLogger(OLESIP2CheckOutRequestParser.class);
12 private Boolean scRenewalPolicy;
13 private Boolean noBlock;
14 private String nbDueDate;
15 private Boolean cancel;
16
17 public OLESIP2CheckOutRequestParser(String requestData) {
18 this.parseCheckoutRequest(requestData);
19 }
20
21 public void parseCheckoutRequest(String requestData) {
22
23 LOG.info("Entry OLESIP2CheckOutRequestParser.parseCheckoutRequest(String requestData)");
24 String[] requestDataArray = requestData.split("\\|");
25
26 try {
27 for (String data : requestDataArray) {
28 LOG.info(data);
29 if (data.startsWith(OLESIP2Constants.CHECKOUT_REQUEST)) {
30 code = data.substring(0, 2);
31 scRenewalPolicy = charToBool(data.charAt(2));
32 noBlock = charToBool(data.charAt(3));
33 transactionDate = data.substring(4, 22);
34 nbDueDate = data.substring(22, 40);
35 institutionId = data.substring(42);
36 }
37 if (data.startsWith(OLESIP2Constants.PATRON_IDENTIFIER_CODE)) {
38 patronIdentifier = (data.replaceFirst(OLESIP2Constants.PATRON_IDENTIFIER_CODE, "")).trim();
39 }
40 if (data.startsWith(OLESIP2Constants.ITEM_IDENTIFIER_CODE)) {
41 itemIdentifier = (data.replaceFirst(OLESIP2Constants.ITEM_IDENTIFIER_CODE, "")).trim();
42 }
43 if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) {
44 terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim();
45 }
46 if (data.startsWith(OLESIP2Constants.ITEM_PROPERTIES_CODE)) {
47 itemProperties = (data.replaceFirst(OLESIP2Constants.ITEM_PROPERTIES_CODE, "")).trim();
48 }
49 if (data.startsWith(OLESIP2Constants.PATRON_PWD_CODE)) {
50 patronPassword = (data.replaceFirst(OLESIP2Constants.PATRON_PWD_CODE, "")).trim();
51 }
52 if (data.startsWith(OLESIP2Constants.FEE_ACKNOWLEDGED_CODE)) {
53 feeAcknowledged = charToBool(data.charAt(2));
54 }
55 if (data.startsWith(OLESIP2Constants.CANCEL_CODE)) {
56 cancel = charToBool(data.charAt(2));
57 }
58 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
59 sequenceNum = data.substring(2, 5);
60 checkSum = data.substring(5);
61 }
62 }
63 } catch (Exception e) {
64 LOG.error(e.getMessage(), e);
65
66 }
67 LOG.info("Exit OLESIP2CheckOutRequestParser.parseCheckoutRequest(String requestData)");
68 }
69
70 public Boolean getScRenewalPolicy() {
71 return scRenewalPolicy;
72 }
73
74 public void setScRenewalPolicy(Boolean scRenewalPolicy) {
75 this.scRenewalPolicy = scRenewalPolicy;
76 }
77
78 public Boolean getNoBlock() {
79 return noBlock;
80 }
81
82 public void setNoBlock(Boolean noBlock) {
83 this.noBlock = noBlock;
84 }
85
86 public String getNbDueDate() {
87 return nbDueDate;
88 }
89
90 public void setNbDueDate(String nbDueDate) {
91 this.nbDueDate = nbDueDate;
92 }
93
94 public Boolean getCancel() {
95 return cancel;
96 }
97
98 public void setCancel(Boolean cancel) {
99 this.cancel = cancel;
100 }
101 }