1 package org.kuali.ole.sip2.sip2Response;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.sip2.common.MessageUtil;
5 import org.kuali.ole.sip2.constants.OLESIP2Constants;
6 import org.kuali.ole.sip2.requestParser.OLESIP2EndPatronSessionRequestParser;
7
8
9
10
11 public class OLESIP2EndPatronSessionResponse extends OLESIP2Response {
12 public OLESIP2EndPatronSessionResponse() {
13 code = OLESIP2Constants.END_PATRON_SESSION_RESPONSE;
14 }
15
16 public String getEndPatronSession(OLESIP2EndPatronSessionRequestParser sip2EndPatronSessionRequestParser) {
17
18 StringBuilder endPatronSessionStringBuilder = new StringBuilder();
19 endPatronSessionStringBuilder.append(code);
20 endPatronSessionStringBuilder.append(OLESIP2Constants.Y);
21 endPatronSessionStringBuilder.append(MessageUtil.getSipDateTime());
22 endPatronSessionStringBuilder.append(OLESIP2Constants.INSTITUTION_ID_CODE);
23 endPatronSessionStringBuilder.append(StringUtils.isNotBlank(sip2EndPatronSessionRequestParser.getInstitutionId()) ? sip2EndPatronSessionRequestParser.getInstitutionId() : "");
24 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+
25 OLESIP2Constants.PATRON_IDENTIFIER_CODE);
26 endPatronSessionStringBuilder.append(sip2EndPatronSessionRequestParser.getPatronIdentifier());
27 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+
28 OLESIP2Constants.SCREEN_MSG_CODE);
29 endPatronSessionStringBuilder.append(OLESIP2Constants.PATRON_SESSION_END);
30 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+
31 OLESIP2Constants.PRINT_LINE_CODE);
32 endPatronSessionStringBuilder.append(OLESIP2Constants.PATRON_SESSION_END);
33 if (StringUtils.isNotBlank(sip2EndPatronSessionRequestParser.getSequenceNum())) {
34 endPatronSessionStringBuilder.append(OLESIP2Constants.SPLIT+
35 OLESIP2Constants.SEQUENCE_NUM_CODE);
36 endPatronSessionStringBuilder.append(sip2EndPatronSessionRequestParser.getSequenceNum());
37 endPatronSessionStringBuilder.append(MessageUtil.computeChecksum(endPatronSessionStringBuilder.toString()));
38 }
39
40 return endPatronSessionStringBuilder.toString() + '\r';
41 }
42 }