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 10/11/14. 008 */ 009public class OLESIP2RenewTurnedOffResponse extends OLESIP2TurnedOffResponse { 010 public OLESIP2RenewTurnedOffResponse() { 011 code = "30"; 012 } 013 014 public String getOLESIP2RenewTurnedOffResponse(String requestData) { 015 StringBuilder renewResponseBuilder = new StringBuilder(); 016 String[] requestDataArray = requestData.split("\\|"); 017 renewResponseBuilder.append(code); 018 019 renewResponseBuilder.append(StringUtil.bool2Int(false)); 020 renewResponseBuilder.append(StringUtil.bool2Char(false)); 021 renewResponseBuilder.append("U"); 022 renewResponseBuilder.append(StringUtil.bool2Char(false)); 023 024 renewResponseBuilder.append(MessageUtil.getSipDateTime()); 025 renewResponseBuilder.append("AO"); 026 027 renewResponseBuilder.append("|AA"); 028 for (String data : requestDataArray) { 029 if (data.startsWith("|AA")) { 030 renewResponseBuilder.append((data.replaceFirst("AA", "")).trim()); 031 } 032 } 033 renewResponseBuilder.append("|AB"); 034 035 renewResponseBuilder.append("|AJ"); 036 037 renewResponseBuilder.append("|AH"); 038 039 renewResponseBuilder.append("|AFRenew Service Currently turned Off"); 040 041 for (String data : requestDataArray) { 042 if (data.startsWith("AY")) { 043 renewResponseBuilder.append("|AY"); 044 renewResponseBuilder.append(data.substring(2, 5)); 045 renewResponseBuilder.append(MessageUtil.computeChecksum(renewResponseBuilder.toString())); 046 } 047 } 048 049 return renewResponseBuilder.toString() + '\r'; 050 } 051}