package th.co.ais.ssbsrfc.substate; import javax.xml.bind.JAXBException; import javax.xml.stream.XMLStreamException; import ec02.af.abstracts.AbstractAF; import ec02.af.data.EquinoxRawData; import ec02.utils.AppLog; import th.co.ais.ssbsrfc.config.Constant; import th.co.ais.ssbsrfc.config.StateConfig; import th.co.ais.ssbsrfc.instance.AdjustmentRequestRes; import th.co.ais.ssbsrfc.instance.AdjustmentResponseIns; import th.co.ais.ssbsrfc.instance.ChargeReportIns; import th.co.ais.ssbsrfc.instance.EC02Instance; import th.co.ais.ssbsrfc.instance.EQXRawInstance; import th.co.ais.ssbsrfc.instance.ResultHeader; import th.co.ais.ssbsrfc.instance.Stat; import th.co.ais.ssbsrfc.message.MessageParser; import th.co.ais.ssbsrfc.utils.EqxStringUtils; import th.co.ais.ssbsrfc.utils.Global; public class SubWaitAdjustmentChargeReportResponse extends WaitSubState { private ResultHeader res = new ResultHeader(); private AdjustmentRequestRes adj = new AdjustmentRequestRes(); private AdjustmentResponseIns adjustresponse = new AdjustmentResponseIns(); private ChargeReportIns chargeReportIns = new ChargeReportIns(); public void configSubstate(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) { this._state = StateConfig.SSTATE_W_ADJUSTMENT_CHARGEREPORT; this._eventType = StateConfig.Incoming_Adjustment_ChargeReport_Response; this._stateType = Constant.SUBSTATE_TYPE_W_RESPONSE; } public Object getMessage(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) { String value = EqxStringUtils.getMessage(equinoxRawData, ec02Instance); AppLog.d("## PARAMETERS : " + value); try { res = (ResultHeader) MessageParser.formsoapResultHeader(value); adj = (AdjustmentRequestRes) MessageParser.formsoapAdjust(value); } catch (XMLStreamException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } adjustresponse.setResultHeader(res); adjustresponse.setAdjustmentResult(adj); ec02Instance.getAFInstance().setAdjustmentResponseIns(adjustresponse); this._resultCode = "0"; chargeReportIns.setResult(this._resultCode); chargeReportIns.setPrepaidsubscriberflag("1"); return chargeReportIns; } public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) { this.type = Constant.TYPE_SUCCESS; this._resultDescription = "SUCCESS"; if(null==res.getVersion()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(res.getVersion())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } if(null==res.getResultCode()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(res.getResultCode())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } if(null==res.getResultDesc()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(res.getResultDesc())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } if(null==adj.getAcctKey()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(adj.getAcctKey())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } if(null==adj.getAdjustmentInfo().get(0).getBalanceType()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(adj.getAdjustmentInfo().get(0).getBalanceType())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } if(null==adj.getAdjustmentInfo().get(0).getOldBalanceAmt()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(adj.getAdjustmentInfo().get(0).getOldBalanceAmt())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } if(null==adj.getAdjustmentInfo().get(0).getNewBalanceAmt()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(adj.getAdjustmentInfo().get(0).getNewBalanceAmt())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } if(null==adj.getAdjustmentInfo().get(0).getCurrencyID()){ this.type = Constant.TYPE_INVALID; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); this._resultDescription = "INCOMPLETE_DATA"; this._resultCode="322"; } if("".equals(adj.getAdjustmentInfo().get(0).getCurrencyID())){ this.type = Constant.TYPE_INVALID; this._resultCode="322"; this._resultDescription = "INCOMPLETE_DATA"; AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); AppLog.d("ssid:"+"null"); } } public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) { switch (this.type) { case Constant.TYPE_INVALID: { chargeReportIns.setResult(this._resultCode); ec02Instance.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + "Adjustment STAT")); String message = th.co.ais.ssbsrfc.message.MessageParser.toXml(chargeReportIns); EQXRawInstance eqxRaw = SubMessages.getRawChargeReportResponse(abstractAF, ec02Instance, ec02Instance.getAFInstance().getOrig(), ec02Instance.getAFInstance().getInvoke(),message); ec02Instance.getAFInstance().setResultCode(this._resultCode); ec02Instance.getAFInstance().setResultDescription(this._resultDescription); ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_END); this.equinoxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); break; } case Constant.TYPE_SUCCESS: default: { chargeReportIns.setResult(this._resultCode); ec02Instance.getAFInstance().setResultCode(this._resultCode); ec02Instance.getAFInstance().setResultDescription(this._resultDescription); // this.isStat = false; ec02Instance.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + "Adjustment STAT")); String message = th.co.ais.ssbsrfc.message.MessageParser.toXml(chargeReportIns); ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_END); EQXRawInstance eqxRaw = SubMessages.getRawChargeReportResponse(abstractAF, ec02Instance, ec02Instance.getAFInstance().getOrig(), ec02Instance.getAFInstance().getInvoke(),message); this.equinoxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); } } } }