001package org.kuali.ole.sip2.response;
002
003import org.kuali.ole.sip2.sip2Server.MessageUtil;
004import org.kuali.ole.sip2.sip2Server.StringUtil;
005
006/**
007 * Created by gayathria on 15/12/14.
008 */
009public class OLESIP2ItemStatusUpdateTurnedOffResponse extends OLESIP2TurnedOffResponse {
010
011    public OLESIP2ItemStatusUpdateTurnedOffResponse() {
012        code = "20";
013    }
014
015    public String getOLESIP2ItemStatusUpdateTurnedOffResponse(String requestData) {
016
017        StringBuilder builder = new StringBuilder();
018        String[] requestDataArray = requestData.split("\\|");
019        builder.append(this.code);
020        builder.append(StringUtil.bool2Int(false));
021        builder.append(MessageUtil.getSipDateTime());
022        builder.append("AB");
023        for (String data : requestDataArray) {
024            if (data.startsWith("AB")) {
025                builder.append((data.replaceFirst("AB", "")).trim());
026            }
027        }
028        builder.append("|AF");
029        builder.append("Item Status Update Service - Not supported in OLE");
030        for (String data : requestDataArray) {
031            if (data.startsWith("AY")) {
032                builder.append("|AY");
033                builder.append(data.substring(2, 5));
034                builder.append(MessageUtil.computeChecksum(builder.toString()));
035            }
036        }
037        return builder.toString() + '\r';
038    }
039}