001package org.kuali.ole.sip2.sip2Response; 002 003import org.apache.commons.lang.StringUtils; 004import org.kuali.ole.sip2.common.MessageUtil; 005import org.kuali.ole.sip2.constants.OLESIP2Constants; 006import org.kuali.ole.sip2.requestParser.OLESIP2EndPatronSessionRequestParser; 007 008/** 009 * Created by gayathria on 2/12/14. 010 */ 011public class OLESIP2EndPatronSessionResponse extends OLESIP2Response { 012 public OLESIP2EndPatronSessionResponse() { 013 code = OLESIP2Constants.END_PATRON_SESSION_RESPONSE; 014 } 015 016 public String getEndPatronSession(OLESIP2EndPatronSessionRequestParser sip2EndPatronSessionRequestParser) { 017 018 StringBuilder endPatronSessionStringBuilder = new StringBuilder(); 019 endPatronSessionStringBuilder.append(code); 020 endPatronSessionStringBuilder.append(OLESIP2Constants.Y); 021 endPatronSessionStringBuilder.append(MessageUtil.getSipDateTime()); 022 endPatronSessionStringBuilder.append(OLESIP2Constants.INSTITUTION_ID_CODE); 023 endPatronSessionStringBuilder.append(StringUtils.isNotBlank(sip2EndPatronSessionRequestParser.getInstitutionId()) ? sip2EndPatronSessionRequestParser.getInstitutionId() : ""); 024 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+ 025 OLESIP2Constants.PATRON_IDENTIFIER_CODE); 026 endPatronSessionStringBuilder.append(sip2EndPatronSessionRequestParser.getPatronIdentifier()); 027 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+ 028 OLESIP2Constants.SCREEN_MSG_CODE); 029 endPatronSessionStringBuilder.append(OLESIP2Constants.PATRON_SESSION_END); 030 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+ 031 OLESIP2Constants.PRINT_LINE_CODE); 032 endPatronSessionStringBuilder.append(OLESIP2Constants.PATRON_SESSION_END); 033 if (StringUtils.isNotBlank(sip2EndPatronSessionRequestParser.getSequenceNum())) { 034 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+ 035 OLESIP2Constants.SEQUENCE_NUM_CODE); 036 endPatronSessionStringBuilder.append(sip2EndPatronSessionRequestParser.getSequenceNum()); 037 endPatronSessionStringBuilder.append(MessageUtil.computeChecksum(endPatronSessionStringBuilder.toString())); 038 } 039 040 return endPatronSessionStringBuilder.toString() + '\r'; 041 } 042}