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 OLESIP2BlockPatronRequestParser extends OLESIP2RequestParser {
10
11 private static final Logger LOG = Logger.getLogger(OLESIP2BlockPatronRequestParser.class);
12
13 private Boolean cardRetained;
14 private String blockedCardMessage;
15
16 public OLESIP2BlockPatronRequestParser(String requestData) {
17 this.parseBlockPatron(requestData);
18 }
19
20 public void parseBlockPatron(String requestData) {
21
22 LOG.info("Entry OLESIP2BlockPatronRequestParser.parseBlockPatron(String requestData)");
23 String[] requestDataArray = requestData.split("\\|");
24 try {
25 for (String data : requestDataArray) {
26 if (data.startsWith(OLESIP2Constants.BLOCK_PATRON_REQUEST)) {
27 code = data.substring(0, 2);
28 cardRetained = charToBool(data.charAt(2));
29 transactionDate = data.substring(3, 21);
30 institutionId = data.substring(23);
31 }
32 if (data.startsWith(OLESIP2Constants.BLOCKED_CARD_MSG)) {
33 blockedCardMessage = (data.replaceFirst(OLESIP2Constants.BLOCKED_CARD_MSG, "")).trim();
34 }
35 if (data.startsWith(OLESIP2Constants.PATRON_IDENTIFIER_CODE)) {
36 patronIdentifier = (data.replaceFirst(OLESIP2Constants.PATRON_IDENTIFIER_CODE, "")).trim();
37 }
38 if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) {
39 terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim();
40 }
41 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
42 sequenceNum = data.substring(2, 5);
43 checkSum = data.substring(5);
44 }
45 }
46 } catch (Exception e) {
47 LOG.error(e.getMessage(), e);
48 }
49 LOG.info("Exit OLESIP2BlockPatronRequestParser.parseBlockPatron(String requestData)");
50 }
51
52 public Boolean getCardRetained() {
53 return cardRetained;
54 }
55
56 public void setCardRetained(Boolean cardRetained) {
57 this.cardRetained = cardRetained;
58 }
59
60 public String getBlockedCardMessage() {
61 return blockedCardMessage;
62 }
63
64 public void setBlockedCardMessage(String blockedCardMessage) {
65 this.blockedCardMessage = blockedCardMessage;
66 }
67 }