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 OLESIP2RenewRequestParser extends OLESIP2RequestParser {
10
11 private Boolean thirdPartyAllowed;
12 private Boolean noBlock;
13 private String nbDueDate;
14 private String titleIdentifier;
15
16 private static final Logger LOG = Logger.getLogger(OLESIP2RenewRequestParser.class);
17
18
19 public OLESIP2RenewRequestParser(String requestData) {
20 this.parseRenewRequest(requestData);
21 }
22
23
24 public void parseRenewRequest(String requestData) {
25 LOG.info("Entry OLESIP2RenewRequestParser.parseRenewRequest(String requestData)");
26
27 LOG.info(requestData);
28
29 String[] requestDataArray = requestData.split("\\|");
30 try {
31 for (String data : requestDataArray) {
32 LOG.info(data);
33 if (data.startsWith(OLESIP2Constants.RENEW_REQUEST)) {
34 code = data.substring(0, 2);
35 thirdPartyAllowed = charToBool(data.charAt(2));
36 noBlock = charToBool(data.charAt(3));
37 transactionDate = data.substring(4, 22);
38 nbDueDate = data.substring(22, 40);
39 institutionId = data.substring(42) != null && !data.substring(42).equalsIgnoreCase("") ? data.substring(42) : "";
40 }
41 if (data.startsWith(OLESIP2Constants.PATRON_IDENTIFIER_CODE)) {
42 patronIdentifier = (data.replaceFirst(OLESIP2Constants.PATRON_IDENTIFIER_CODE, "")).trim();
43 }
44 if (data.startsWith(OLESIP2Constants.PATRON_PWD_CODE)) {
45 patronPassword = (data.replaceFirst(OLESIP2Constants.PATRON_PWD_CODE, "")).trim();
46 }
47 if (data.startsWith(OLESIP2Constants.ITEM_IDENTIFIER_CODE)) {
48 itemIdentifier = (data.replaceFirst(OLESIP2Constants.ITEM_IDENTIFIER_CODE, "")).trim();
49 }
50 if (data.startsWith(OLESIP2Constants.TITLE_IDENTIFIER_CODE)) {
51 titleIdentifier = (data.replaceFirst(OLESIP2Constants.TITLE_IDENTIFIER_CODE, "")).trim();
52 }
53 if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) {
54 terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim();
55 }
56 if (data.startsWith(OLESIP2Constants.ITEM_PROPERTIES_CODE)) {
57 itemProperties = (data.replaceFirst(OLESIP2Constants.ITEM_PROPERTIES_CODE, "")).trim();
58 }
59 if (data.startsWith(OLESIP2Constants.FEE_ACKNOWLEDGED_CODE)) {
60 feeAcknowledged = charToBool(data.charAt(2));
61 }
62 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
63 sequenceNum = data.substring(2, 5);
64 checkSum = data.substring(5);
65 }
66 }
67 } catch (Exception e) {
68 LOG.error(e.getMessage(), e);
69 }
70 LOG.info("Exit OLESIP2RenewRequestParser.parseRenewRequest(String requestData)");
71
72 }
73
74 public Boolean getThirdPartyAllowed() {
75 return thirdPartyAllowed;
76 }
77
78 public void setThirdPartyAllowed(Boolean thirdPartyAllowed) {
79 this.thirdPartyAllowed = thirdPartyAllowed;
80 }
81
82 public Boolean getNoBlock() {
83 return noBlock;
84 }
85
86 public void setNoBlock(Boolean noBlock) {
87 this.noBlock = noBlock;
88 }
89
90 public String getNbDueDate() {
91 return nbDueDate;
92 }
93
94 public void setNbDueDate(String nbDueDate) {
95 this.nbDueDate = nbDueDate;
96 }
97
98 public String getTitleIdentifier() {
99 return titleIdentifier;
100 }
101
102 public void setTitleIdentifier(String titleIdentifier) {
103 this.titleIdentifier = titleIdentifier;
104 }
105 }