package af.message; import java.util.ArrayList; import af.instatnce.EC02Instance; import af.instatnce.EQXRawInstance; import af.interfaces.EQXMsg; import ec02.af.abstracts.AbstractAF; import ec02.af.data.EquinoxRawData; import ec02.af.data.KeyObject; public class EC02Builder { private EC02Instance ec02Ins = null; private AbstractAF abstractAF = null; private EquinoxRawData eqxRawData =null; private EC02MSGBuilder msgBuilder = null; public void setEquinoxRawData(AbstractAF abstractAF, EC02Instance ec02Ins){ this.abstractAF = abstractAF; this.ec02Ins = ec02Ins; } public void setEquinoxRawData(EquinoxRawData eqxRawData, AbstractAF abstractAF, EC02Instance ec02Ins){ this.eqxRawData = eqxRawData; this.abstractAF = abstractAF; this.ec02Ins = ec02Ins; } public ArrayList getHTTPRequest(ArrayList eqxRawList){ ArrayList eqxRawDataList = new ArrayList(); for (int i = 0; i < eqxRawList.size(); i++) { eqxRawList.get(i).setType(EQXMsg.REQUEST); this.msgBuilder = new EC02MSGBuilder(eqxRawList.get(i)); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke() + i); eqxRawDataList.add(this.msgBuilder.getHttpMessage()); } String timeoutConf = this.abstractAF.getUtils().getHmWarmConfig().get("HTTP-timeout").get(0); String timeout = (timeoutConf == null) ? this.ec02Ins.getAbstractAF().getUtils().getHmWarmConfig().get("Default-timeout").get(0) : timeoutConf; this.ec02Ins.setTimeout(timeout); return eqxRawDataList; } public ArrayList getBRequest(ArrayList eqxRawList){ ArrayList eqxRawDataList = new ArrayList(); for (int i = 0; i < eqxRawList.size(); i++) { eqxRawList.get(i).setType(EQXMsg.REQUEST); this.msgBuilder = new EC02MSGBuilder(eqxRawList.get(i)); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke() + i); eqxRawDataList.add(this.msgBuilder.getHttpMessage()); } String timeoutConf = this.abstractAF.getUtils().getHmWarmConfig().get("HTTP-B-timeout").get(0); String timeout = (timeoutConf == null) ? this.ec02Ins.getAbstractAF().getUtils().getHmWarmConfig().get("B-timeout").get(0) : timeoutConf; this.ec02Ins.setTimeout(timeout); return eqxRawDataList; } public EquinoxRawData getHTTPResponse(EQXRawInstance eqxRaw,String invoke){ eqxRaw.setType(EQXMsg.RESPONSE); this.msgBuilder = new EC02MSGBuilder(eqxRaw); this.msgBuilder.setInvoke(invoke); return this.msgBuilder.getHttpMessage(); } public ArrayList getLDAPRequest(ArrayList eqxRawList){ ArrayList eqxRawDataList = new ArrayList(); for (int i = 0; i < eqxRawList.size(); i++) { eqxRawList.get(i).setType(EQXMsg.REQUEST); this.msgBuilder = new EC02MSGBuilder(eqxRawList.get(i)); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke() + i); eqxRawDataList.add(this.msgBuilder.getLdapMessage()); } String timeoutConf = this.abstractAF.getUtils().getHmWarmConfig().get("LDAP-timeout").get(0); String timeout = (timeoutConf == null) ? this.ec02Ins.getAbstractAF().getUtils().getHmWarmConfig().get("Default-timeout").get(0) : timeoutConf; this.ec02Ins.setTimeout(timeout); return eqxRawDataList; } public EquinoxRawData getLDAPResponse(EQXRawInstance eqxRaw){ eqxRaw.setType(EQXMsg.RESPONSE); this.msgBuilder = new EC02MSGBuilder(eqxRaw); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke()); return this.msgBuilder.getLdapMessage(); } public ArrayList getDiameterRequest(ArrayList eqxRawList){ ArrayList eqxRawDataList = new ArrayList(); for (int i = 0; i < eqxRawList.size(); i++) { eqxRawList.get(i).setType(EQXMsg.REQUEST); this.msgBuilder = new EC02MSGBuilder(eqxRawList.get(i)); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke() + i); eqxRawDataList.add(this.msgBuilder.getDiameterMessage()); } String timeoutConf = this.abstractAF.getUtils().getHmWarmConfig().get("Diameter-timeout").get(0); String timeout = (timeoutConf == null) ? this.ec02Ins.getAbstractAF().getUtils().getHmWarmConfig().get("Default-timeout").get(0) : timeoutConf; this.ec02Ins.setTimeout(timeout); return eqxRawDataList; } public EquinoxRawData getDiameterResponse(EQXRawInstance eqxRaw){ eqxRaw.setType(EQXMsg.RESPONSE); this.msgBuilder = new EC02MSGBuilder(eqxRaw); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke()); return this.msgBuilder.getDiameterMessage(); } public ArrayList getSMPPRequest(ArrayList eqxRawList){ ArrayList eqxRawDataList = new ArrayList(); for (int i = 0; i < eqxRawList.size(); i++) { eqxRawList.get(i).setType(EQXMsg.REQUEST); this.msgBuilder = new EC02MSGBuilder(eqxRawList.get(i)); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke() + i); eqxRawDataList.add(this.msgBuilder.getSMPPMessage()); } String timeoutConf = this.abstractAF.getUtils().getHmWarmConfig().get("SMPP-timeout").get(0); String timeout = (timeoutConf == null) ? this.ec02Ins.getAbstractAF().getUtils().getHmWarmConfig().get("Default-timeout").get(0) : timeoutConf; this.ec02Ins.setTimeout(timeout); return eqxRawDataList; } public EquinoxRawData getSMPPResponse(EQXRawInstance eqxRaw){ eqxRaw.setType(EQXMsg.RESPONSE); this.msgBuilder = new EC02MSGBuilder(eqxRaw); this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke()); return this.msgBuilder.getSMPPMessage(); } public void getE01Request(){ KeyObject keyobj = new KeyObject(); keyobj.setObjectType(this.ec02Ins.getE01Ins().getObjType()); ArrayList keyList = this.ec02Ins.getE01Ins().getKey(); for (int i = 0; i < keyList.size(); i++) { keyobj.setKey(String.valueOf(i), keyList.get(i)); } if(this.ec02Ins.getE01Ins().getCmd().equals("search")){ this.abstractAF.getUtils().getGlobalData().search(keyobj); } else if(this.ec02Ins.getE01Ins().getCmd().equals("delete")){ this.abstractAF.getUtils().getGlobalData().delete(keyobj); } else if(this.ec02Ins.getE01Ins().getCmd().equals("add")){ this.abstractAF.getUtils().getGlobalData().add(keyobj, this.ec02Ins.getE01Ins().getData()); } else if(this.ec02Ins.getE01Ins().getCmd().equals("replace")){ this.abstractAF.getUtils().getGlobalData().replace(keyobj, this.ec02Ins.getE01Ins().getData()); } this.abstractAF.getUtils().getGlobalData().setMessageId(this.eqxRawData.getInvoke()); } public EquinoxRawData getUpdateIns(){ this.msgBuilder = new EC02MSGBuilder(); this.ec02Ins.setTimeout(this.abstractAF.getUtils().getHmWarmConfig().get("Update-Instance-timeout").get(0)); return this.msgBuilder.getUpdateIns(); } }