001package org.kuali.ole.sip2.requestParser;
002
003import org.apache.log4j.Logger;
004import org.kuali.ole.sip2.constants.OLESIP2Constants;
005
006/**
007 * Created by gayathria on 2/12/14.
008 */
009public class OLESIP2ItemStatusUpdateRequestParser extends OLESIP2RequestParser {
010
011
012    private static final Logger LOG = Logger.getLogger(OLESIP2ItemStatusUpdateRequestParser.class);
013
014    public OLESIP2ItemStatusUpdateRequestParser(String requestData) {
015        this.parseItemStatusUpdateRequest(requestData);
016    }
017
018    public void parseItemStatusUpdateRequest(String requestData) {
019
020        LOG.info("Entry OLESIP2ItemStatusUpdateRequestParser.parseItemStatusUpdate(String requestData)");
021        String[] requestDataArray = requestData.split("\\|");
022        for (String data : requestDataArray) {
023            LOG.info(data);
024            if (data.startsWith(OLESIP2Constants.CHECKOUT_REQUEST)) {
025                code = data.substring(0, 2);
026                transactionDate = data.substring(2, 20);
027                institutionId = data.substring(22);
028            }
029            if (data.startsWith(OLESIP2Constants.ITEM_IDENTIFIER_CODE)) {
030                itemIdentifier = (data.replaceFirst(OLESIP2Constants.ITEM_IDENTIFIER_CODE, "")).trim();
031            }
032            if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) {
033                terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim();
034            }
035            if (data.startsWith(OLESIP2Constants.ITEM_PROPERTIES_CODE)) {
036                itemProperties = (data.replaceFirst(OLESIP2Constants.ITEM_PROPERTIES_CODE, "")).trim();
037            }
038            if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
039                sequenceNum = data.substring(2, 5);
040                checkSum = data.substring(5);
041            }
042        }
043        LOG.info("Exit OLESIP2ItemStatusUpdateRequestParser.parseItemStatusUpdate(String requestData)");
044    }
045
046
047}