1 package org.kuali.ole.sip2.sip2Response;
2
3 import org.apache.commons.lang3.StringUtils;
4 import org.kuali.ole.sip2.constants.OLESIP2Constants;
5 import org.kuali.ole.sip2.requestParser.OLESIP2ItemStatusUpdateRequestParser;
6 import org.kuali.ole.sip2.sip2Server.MessageUtil;
7 import org.kuali.ole.sip2.sip2Server.StringUtil;
8
9
10
11
12 public class OLESIP2ItemStatusUpdateResponse extends OLESIP2Response {
13 public OLESIP2ItemStatusUpdateResponse() {
14 code = OLESIP2Constants.ITEM_STATUS_UPDATE_RESPONSE;
15 }
16
17 public String getOLESIP2ItemStatusUpdateResponse(String requestData, OLESIP2ItemStatusUpdateRequestParser olesip2ItemStatusUpdateRequestParser) {
18
19 StringBuilder builder = new StringBuilder();
20 String[] requestDataArray = requestData.split("\\|");
21 builder.append(this.code);
22 builder.append(StringUtil.bool2Int(false));
23 builder.append(MessageUtil.getSipDateTime());
24 builder.append(OLESIP2Constants.ITEM_IDENTIFIER_CODE);
25 for (String data : requestDataArray) {
26 if (data.startsWith(OLESIP2Constants.ITEM_IDENTIFIER_CODE)) {
27 builder.append((data.replaceFirst(OLESIP2Constants.ITEM_IDENTIFIER_CODE, "")).trim());
28 }
29 }
30 builder.append(OLESIP2Constants.SPLIT+
31 OLESIP2Constants.SCREEN_MSG_CODE);
32 builder.append(OLESIP2Constants.ITEM_SERVICE_NOT_SUPPORTED);
33 for (String data : requestDataArray) {
34 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
35 builder.append(OLESIP2Constants.SPLIT+
36 OLESIP2Constants.SEQUENCE_NUM_CODE);
37 builder.append(data.substring(2, 5));
38 builder.append(MessageUtil.computeChecksum(builder.toString()));
39 }
40 }
41 return builder.toString() + '\r';
42 }
43 }