View Javadoc
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   * Created by gayathria on 15/12/14.
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          builder.append(this.code);
21          builder.append(StringUtil.bool2Int(false));
22          builder.append(MessageUtil.getSipDateTime());
23          builder.append("AB");
24          builder.append(olesip2ItemStatusUpdateRequestParser.getItemIdentifier());
25          builder.append("|AF");
26          builder.append("Item Status Update Service - Not supported in OLE");
27          if (StringUtils.isNotBlank(olesip2ItemStatusUpdateRequestParser.getSequenceNum())) {
28              builder.append("|AY");
29              builder.append(olesip2ItemStatusUpdateRequestParser.getSequenceNum());
30              builder.append(org.kuali.ole.sip2.common.MessageUtil.computeChecksum(olesip2ItemStatusUpdateRequestParser.toString()));
31          }
32          return builder.toString() + '\r';*/
33          StringBuilder builder = new StringBuilder();
34          String[] requestDataArray = requestData.split("\\|");
35          builder.append(this.code);
36          builder.append(StringUtil.bool2Int(false));
37          builder.append(MessageUtil.getSipDateTime());
38          builder.append(OLESIP2Constants.ITEM_IDENTIFIER_CODE);
39          for (String data : requestDataArray) {
40              if (data.startsWith(OLESIP2Constants.ITEM_IDENTIFIER_CODE)) {
41                  builder.append((data.replaceFirst(OLESIP2Constants.ITEM_IDENTIFIER_CODE, "")).trim());
42              }
43          }
44          builder.append(OLESIP2Constants.SPLIT+
45                  OLESIP2Constants.SCREEN_MSG_CODE);
46          builder.append(OLESIP2Constants.ITEM_SERVICE_NOT_SUPPORTED);
47          for (String data : requestDataArray) {
48              if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
49                  builder.append(OLESIP2Constants.SPLIT+
50                          OLESIP2Constants.SEQUENCE_NUM_CODE);
51                  builder.append(data.substring(2, 5));
52                  builder.append(MessageUtil.computeChecksum(builder.toString()));
53              }
54          }
55          System.out.println(builder.toString());
56  
57  
58          return builder.toString() + '\r';
59      }
60  }