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
10 public class OLESIP2CheckInRequestParser extends OLESIP2RequestParser {
11
12 private static final Logger LOG = Logger.getLogger(OLESIP2CheckInRequestParser.class);
13
14 private String returnDate;
15 private String currentLocation;
16 private Boolean noBlock;
17 private Boolean cancel;
18
19 public OLESIP2CheckInRequestParser(String requestData) {
20 this.parseCheckInRequest(requestData);
21 }
22
23 public void parseCheckInRequest(String requestData) {
24
25 LOG.info("Entry OLESIP2CheckInRequestParser.parseCheckinRequest(String requestData)");
26 String[] requestDataArray = requestData.split("\\|");
27 try {
28
29 for (String data : requestDataArray) {
30 if (data.startsWith(OLESIP2Constants.CHECK_IN_REQUEST)) {
31 code = data.substring(0, 2);
32 noBlock = charToBool(data.charAt(2));
33 transactionDate = data.substring(3, 21);
34 returnDate = data.substring(21, 39);
35 currentLocation = data.substring(41);
36 }
37 if (data.startsWith(OLESIP2Constants.INSTITUTION_ID_CODE)) {
38 institutionId = (data.replaceFirst(OLESIP2Constants.INSTITUTION_ID_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.CANCEL_CODE)) {
50 cancel = charToBool(data.charAt(2));
51 }
52 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
53 sequenceNum = data.substring(2, 5);
54 checkSum = data.substring(5);
55 }
56 }
57 } catch (Exception e) {
58 LOG.error(e.getMessage(), e);
59
60 }
61 LOG.info("Exit OLESIP2CheckInRequestParser.parseCheckInRequest(String requestData)");
62 }
63
64 public String getReturnDate() {
65 return returnDate;
66 }
67
68 public void setReturnDate(String returnDate) {
69 this.returnDate = returnDate;
70 }
71
72 public String getCurrentLocation() {
73 return currentLocation;
74 }
75
76 public void setCurrentLocation(String currentLocation) {
77 this.currentLocation = currentLocation;
78 }
79
80 public Boolean getNoBlock() {
81 return noBlock;
82 }
83
84 public void setNoBlock(Boolean noBlock) {
85 this.noBlock = noBlock;
86 }
87
88 public Boolean getCancel() {
89 return cancel;
90 }
91
92 public void setCancel(Boolean cancel) {
93 this.cancel = cancel;
94 }
95 }