001package org.kuali.ole.sip2.requestParser; 002 003import org.apache.log4j.Logger; 004import org.kuali.ole.request.OLESIP2RequestParser; 005import org.kuali.ole.sip2.constants.OLESIP2Constants; 006 007/** 008 * Created by gayathria on 2/12/14. 009 */ 010public class OLESIP2BlockPatronRequestParser extends OLESIP2RequestParser { 011 012 private static final Logger LOG = Logger.getLogger(OLESIP2BlockPatronRequestParser.class); 013 014 private Boolean cardRetained; 015 private String blockedCardMessage; 016 017 public OLESIP2BlockPatronRequestParser(String requestData) { 018 this.parseBlockPatron(requestData); 019 } 020 021 public void parseBlockPatron(String requestData) { 022 023 LOG.info("Entry OLESIP2BlockPatronRequestParser.parseBlockPatron(String requestData)"); 024 String[] requestDataArray = requestData.split("\\|"); 025 try { 026 for (String data : requestDataArray) { 027 if (data.startsWith(OLESIP2Constants.BLOCK_PATRON_REQUEST)) { 028 code = data.substring(0, 2); 029 cardRetained = charToBool(data.charAt(2)); 030 transactionDate = data.substring(3, 21); 031 institutionId = data.substring(23); 032 } 033 if (data.startsWith(OLESIP2Constants.BLOCKED_CARD_MSG)) { 034 blockedCardMessage = (data.replaceFirst(OLESIP2Constants.BLOCKED_CARD_MSG, "")).trim(); 035 } 036 if (data.startsWith(OLESIP2Constants.PATRON_IDENTIFIER_CODE)) { 037 patronIdentifier = (data.replaceFirst(OLESIP2Constants.PATRON_IDENTIFIER_CODE, "")).trim(); 038 } 039 if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) { 040 terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim(); 041 } 042 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) { 043 sequenceNum = data.substring(2, 5); 044 checkSum = data.substring(5); 045 } 046 } 047 } catch (Exception e) { 048 LOG.error(e.getMessage(), e); 049 } 050 LOG.info("Exit OLESIP2BlockPatronRequestParser.parseBlockPatron(String requestData)"); 051 } 052 053 public Boolean getCardRetained() { 054 return cardRetained; 055 } 056 057 public void setCardRetained(Boolean cardRetained) { 058 this.cardRetained = cardRetained; 059 } 060 061 public String getBlockedCardMessage() { 062 return blockedCardMessage; 063 } 064 065 public void setBlockedCardMessage(String blockedCardMessage) { 066 this.blockedCardMessage = blockedCardMessage; 067 } 068}