1 package org.kuali.ole.sip2.response;
2
3
4 import org.kuali.ole.sip2.sip2Server.MessageUtil;
5 import org.kuali.ole.sip2.sip2Server.StringUtil;
6
7
8
9
10 public class OLESIP2CheckOutTurnedOffResponse extends OLESIP2TurnedOffResponse {
11
12 public OLESIP2CheckOutTurnedOffResponse() {
13 this.code = "12";
14 }
15
16 public String getOLESIP2CheckOutTurnedOffResponse(String requestData) {
17
18 String[] requestDataArray = requestData.split("\\|");
19 StringBuilder checkOutResponseBuilder = new StringBuilder();
20 checkOutResponseBuilder.append(code);
21
22 checkOutResponseBuilder.append(StringUtil.bool2Int(false));
23 checkOutResponseBuilder.append(StringUtil.bool2Char(false));
24 checkOutResponseBuilder.append("U");
25 checkOutResponseBuilder.append(StringUtil.bool2Char(false));
26
27 checkOutResponseBuilder.append(MessageUtil.getSipDateTime());
28 checkOutResponseBuilder.append("AO");
29
30 checkOutResponseBuilder.append("|AA");
31 for (String data : requestDataArray) {
32 if (data.startsWith("AA")) {
33 checkOutResponseBuilder.append((data.replaceFirst("AA", "")).trim());
34 }
35 }
36 checkOutResponseBuilder.append("|AB");
37 for (String data : requestDataArray) {
38 if (data.startsWith("AB")) {
39 checkOutResponseBuilder.append((data.replaceFirst("AB", "")).trim());
40 }
41 }
42
43 checkOutResponseBuilder.append("|AJ");
44 checkOutResponseBuilder.append("|AH");
45
46
47 checkOutResponseBuilder.append("|AFCheckOut service is currently turned off");
48
49
50 for (String data : requestDataArray) {
51 if (data.startsWith("AY")) {
52 checkOutResponseBuilder.append("|AY");
53 checkOutResponseBuilder.append(data.substring(2, 5));
54 checkOutResponseBuilder.append(MessageUtil.computeChecksum(checkOutResponseBuilder.toString()));
55 }
56 }
57
58 return checkOutResponseBuilder.toString() + '\r';
59
60 }
61 }