From 1048b1560018139c69f92a47275532dbb8fa81d8 Mon Sep 17 00:00:00 2001 From: Suraputt Suntimitr Date: Mon, 23 May 2016 16:30:29 +0700 Subject: [PATCH] Template --- .classpath | 13 +++++++++++++ .gitignore | 1 + .project | 17 +++++++++++++++++ CustomLog/PreReleasedTest.log_1 | 275 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ CustomLog/PreReleasedTest.log_2 | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 0 conf/WS1.EC02.SERV.0 | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ example.msg/debug.diameter.xml | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ example.msg/debug.html-text-plain.xml | 7 +++++++ example.msg/debug.html-text-xml-header.xml | 20 ++++++++++++++++++++ example.msg/debug.html-text-xml.xml | 15 +++++++++++++++ example.msg/debug.ldap.xml | 29 +++++++++++++++++++++++++++++ example.msg/debug.xml | 31 +++++++++++++++++++++++++++++++ lib/commons-lang-2.6.jar | Bin 0 -> 284220 bytes lib/commons-log-pack-1.1.2.jar | Bin 0 -> 577746 bytes lib/ec02_library.jar | Bin 0 -> 792620 bytes lib/eqxmsg_3_3_2.jar | Bin 0 -> 821825 bytes lib/gson-2.2.2.jar | Bin 0 -> 189285 bytes lib/org.json-20120521.jar | Bin 0 -> 40375 bytes lib/simple-xml-2.7.1.jar | Bin 0 -> 427590 bytes src/th/co/ais/ssbsrfc/config/Constant.java | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/config/EventFilter.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/config/Invoke.java | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/config/State.java | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/config/StateConfig.java | 592 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/control/FlowManager.java | 470 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/control/StateManager.java | 20 ++++++++++++++++++++ src/th/co/ais/ssbsrfc/control/SubStateManager.java | 31 +++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/control/TestDebugMsg.java | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/control/TestMain.java | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/control/mainAF.java | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AFInstance.java | 424 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AccessSecurity.java | 26 ++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AdjustmentInfo.java | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AdjustmentObj.java | 18 ++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AdjustmentRequest.java | 40 ++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AdjustmentRequestIns.java | 30 ++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AdjustmentResponseIns.java | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/AdjustmentResult.java | 29 +++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/BackupSummary.java | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/ChargeReportIns.java | 29 +++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/ChargeRequestIns.java | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/ChargeResponseIns.java | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/CheckRequest.java | 14 ++++++++++++++ src/th/co/ais/ssbsrfc/instance/DetailLog.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/DetailLogDetail.java | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/E01Atomic.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/E01Ins.java | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/E01Instance.java | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/E01Message.java | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/EC02Instance.java | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/EQXRawInstance.java | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/Element.java | 26 ++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/Encryption.java | 37 +++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/FMInstance.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/ListE01Data.java | 30 ++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/LogError.java | 24 ++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/ManageTime.java | 274 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/MenuTemplateIns.java | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/OTPResIns.java | 27 +++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/OwnershipInfo.java | 25 +++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/PromptTemplateIns.java | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/RRRIns.java | 41 +++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/RequestHeader.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/ResIns.java | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/Response.java | 30 ++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/ResultHeader.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/RetryIns.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/SOAPNamespaceMapper.java | 36 ++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/Stat.java | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/SubAccessCode.java | 18 ++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/Summary.java | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/Timeout.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/instance/TimeoutIns.java | 25 +++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/interfaces/AFEvent.java | 8 ++++++++ src/th/co/ais/ssbsrfc/interfaces/AFState.java | 7 +++++++ src/th/co/ais/ssbsrfc/interfaces/AFSubState.java | 17 +++++++++++++++++ src/th/co/ais/ssbsrfc/interfaces/AbstractAFSubStateManager.java | 18 ++++++++++++++++++ src/th/co/ais/ssbsrfc/interfaces/Atomic.java | 7 +++++++ src/th/co/ais/ssbsrfc/interfaces/EQXMsg.java | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/interfaces/IAFSubState.java | 11 +++++++++++ src/th/co/ais/ssbsrfc/message/EC02Builder.java | 317 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/message/EC02MSGBuilder.java | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/message/MSGParser.java | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/message/MessageParser.java | 330 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/state/StateIdle.java | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/state/StateWaitActive.java | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/state/StateWaitE11Timeout.java | 34 ++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/substate/SubMessages.java | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/substate/SubMessagesE01.java | 7 +++++++ src/th/co/ais/ssbsrfc/substate/SubWaitA.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeReportResponse.java | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeRequestResponse.java | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/substate/SubWaitChargeReport.java | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/substate/SubWaitChargeRequest.java | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/substate/WaitSubState.java | 541 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/DateUtil.java | 2342 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/ERDData.java | 32 ++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/ERDHeader.java | 23 +++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/EqxStringUtils.java | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/EqxValidateUtil.java | 376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/Global.java | 308 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/Header.java | 36 ++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/HttpData.java | 31 +++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/HttpStateData.java | 18 ++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/ListStateData.java | 23 +++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/Log.java | 341 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/Zip.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/info.java | 25 +++++++++++++++++++++++++ src/th/co/ais/ssbsrfc/utils/state.java | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 110 files changed, 12079 insertions(+), 0 deletions(-) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 CustomLog/PreReleasedTest.log_1 create mode 100644 CustomLog/PreReleasedTest.log_2 delete mode 100644 README.md create mode 100644 conf/WS1.EC02.SERV.0 create mode 100644 example.msg/debug.diameter.xml create mode 100644 example.msg/debug.html-text-plain.xml create mode 100644 example.msg/debug.html-text-xml-header.xml create mode 100644 example.msg/debug.html-text-xml.xml create mode 100644 example.msg/debug.ldap.xml create mode 100644 example.msg/debug.xml create mode 100644 lib/commons-lang-2.6.jar create mode 100644 lib/commons-log-pack-1.1.2.jar create mode 100644 lib/ec02_library.jar create mode 100644 lib/eqxmsg_3_3_2.jar create mode 100644 lib/gson-2.2.2.jar create mode 100644 lib/org.json-20120521.jar create mode 100644 lib/simple-xml-2.7.1.jar create mode 100644 src/th/co/ais/ssbsrfc/config/Constant.java create mode 100644 src/th/co/ais/ssbsrfc/config/EventFilter.java create mode 100644 src/th/co/ais/ssbsrfc/config/Invoke.java create mode 100644 src/th/co/ais/ssbsrfc/config/State.java create mode 100644 src/th/co/ais/ssbsrfc/config/StateConfig.java create mode 100644 src/th/co/ais/ssbsrfc/control/FlowManager.java create mode 100644 src/th/co/ais/ssbsrfc/control/StateManager.java create mode 100644 src/th/co/ais/ssbsrfc/control/SubStateManager.java create mode 100644 src/th/co/ais/ssbsrfc/control/TestDebugMsg.java create mode 100644 src/th/co/ais/ssbsrfc/control/TestMain.java create mode 100644 src/th/co/ais/ssbsrfc/control/mainAF.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AFInstance.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AccessSecurity.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AdjustmentInfo.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AdjustmentObj.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AdjustmentRequest.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AdjustmentRequestIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AdjustmentResponseIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/AdjustmentResult.java create mode 100644 src/th/co/ais/ssbsrfc/instance/BackupSummary.java create mode 100644 src/th/co/ais/ssbsrfc/instance/ChargeReportIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/ChargeRequestIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/ChargeResponseIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/CheckRequest.java create mode 100644 src/th/co/ais/ssbsrfc/instance/DetailLog.java create mode 100644 src/th/co/ais/ssbsrfc/instance/DetailLogDetail.java create mode 100644 src/th/co/ais/ssbsrfc/instance/E01Atomic.java create mode 100644 src/th/co/ais/ssbsrfc/instance/E01Ins.java create mode 100644 src/th/co/ais/ssbsrfc/instance/E01Instance.java create mode 100644 src/th/co/ais/ssbsrfc/instance/E01Message.java create mode 100644 src/th/co/ais/ssbsrfc/instance/EC02Instance.java create mode 100644 src/th/co/ais/ssbsrfc/instance/EQXRawInstance.java create mode 100644 src/th/co/ais/ssbsrfc/instance/Element.java create mode 100644 src/th/co/ais/ssbsrfc/instance/Encryption.java create mode 100644 src/th/co/ais/ssbsrfc/instance/FMInstance.java create mode 100644 src/th/co/ais/ssbsrfc/instance/ListE01Data.java create mode 100644 src/th/co/ais/ssbsrfc/instance/LogError.java create mode 100644 src/th/co/ais/ssbsrfc/instance/ManageTime.java create mode 100644 src/th/co/ais/ssbsrfc/instance/MenuTemplateIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/OTPResIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/OwnershipInfo.java create mode 100644 src/th/co/ais/ssbsrfc/instance/PromptTemplateIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/RRRIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/RequestHeader.java create mode 100644 src/th/co/ais/ssbsrfc/instance/ResIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/Response.java create mode 100644 src/th/co/ais/ssbsrfc/instance/ResultHeader.java create mode 100644 src/th/co/ais/ssbsrfc/instance/RetryIns.java create mode 100644 src/th/co/ais/ssbsrfc/instance/SOAPNamespaceMapper.java create mode 100644 src/th/co/ais/ssbsrfc/instance/Stat.java create mode 100644 src/th/co/ais/ssbsrfc/instance/SubAccessCode.java create mode 100644 src/th/co/ais/ssbsrfc/instance/Summary.java create mode 100644 src/th/co/ais/ssbsrfc/instance/Timeout.java create mode 100644 src/th/co/ais/ssbsrfc/instance/TimeoutIns.java create mode 100644 src/th/co/ais/ssbsrfc/interfaces/AFEvent.java create mode 100644 src/th/co/ais/ssbsrfc/interfaces/AFState.java create mode 100644 src/th/co/ais/ssbsrfc/interfaces/AFSubState.java create mode 100644 src/th/co/ais/ssbsrfc/interfaces/AbstractAFSubStateManager.java create mode 100644 src/th/co/ais/ssbsrfc/interfaces/Atomic.java create mode 100644 src/th/co/ais/ssbsrfc/interfaces/EQXMsg.java create mode 100644 src/th/co/ais/ssbsrfc/interfaces/IAFSubState.java create mode 100644 src/th/co/ais/ssbsrfc/message/EC02Builder.java create mode 100644 src/th/co/ais/ssbsrfc/message/EC02MSGBuilder.java create mode 100644 src/th/co/ais/ssbsrfc/message/MSGParser.java create mode 100644 src/th/co/ais/ssbsrfc/message/MessageParser.java create mode 100644 src/th/co/ais/ssbsrfc/state/StateIdle.java create mode 100644 src/th/co/ais/ssbsrfc/state/StateWaitActive.java create mode 100644 src/th/co/ais/ssbsrfc/state/StateWaitE11Timeout.java create mode 100644 src/th/co/ais/ssbsrfc/substate/SubMessages.java create mode 100644 src/th/co/ais/ssbsrfc/substate/SubMessagesE01.java create mode 100644 src/th/co/ais/ssbsrfc/substate/SubWaitA.java create mode 100644 src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeReportResponse.java create mode 100644 src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeRequestResponse.java create mode 100644 src/th/co/ais/ssbsrfc/substate/SubWaitChargeReport.java create mode 100644 src/th/co/ais/ssbsrfc/substate/SubWaitChargeRequest.java create mode 100644 src/th/co/ais/ssbsrfc/substate/WaitSubState.java create mode 100644 src/th/co/ais/ssbsrfc/utils/DateUtil.java create mode 100644 src/th/co/ais/ssbsrfc/utils/ERDData.java create mode 100644 src/th/co/ais/ssbsrfc/utils/ERDHeader.java create mode 100644 src/th/co/ais/ssbsrfc/utils/EqxStringUtils.java create mode 100644 src/th/co/ais/ssbsrfc/utils/EqxValidateUtil.java create mode 100644 src/th/co/ais/ssbsrfc/utils/Global.java create mode 100644 src/th/co/ais/ssbsrfc/utils/Header.java create mode 100644 src/th/co/ais/ssbsrfc/utils/HttpData.java create mode 100644 src/th/co/ais/ssbsrfc/utils/HttpStateData.java create mode 100644 src/th/co/ais/ssbsrfc/utils/ListStateData.java create mode 100644 src/th/co/ais/ssbsrfc/utils/Log.java create mode 100644 src/th/co/ais/ssbsrfc/utils/Zip.java create mode 100644 src/th/co/ais/ssbsrfc/utils/info.java create mode 100644 src/th/co/ais/ssbsrfc/utils/state.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..449f8f5 --- /dev/null +++ b/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..89cd453 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + EQXTemplate + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/CustomLog/PreReleasedTest.log_1 b/CustomLog/PreReleasedTest.log_1 new file mode 100644 index 0000000..824b93c --- /dev/null +++ b/CustomLog/PreReleasedTest.log_1 @@ -0,0 +1,275 @@ +TRACE|09:28:16|Thread-0|testCustomLog| +TRACE|09:29:16|Thread-0|testCustomLog| +TRACE|09:29:17|Thread-0|testCustomLog| +TRACE|09:30:16|Thread-0|testCustomLog| +TRACE|09:30:17|Thread-0|testCustomLog| +TRACE|09:31:16|Thread-0|testCustomLog| +TRACE|09:32:16|Thread-0|testCustomLog| +TRACE|09:33:16|Thread-0|testCustomLog| +TRACE|09:34:16|Thread-0|testCustomLog| +TRACE|09:34:22|Thread-0|testCustomLog| +TRACE|09:35:16|Thread-0|testCustomLog| +TRACE|09:35:22|Thread-0|testCustomLog| +TRACE|09:35:26|Thread-0|testCustomLog| +TRACE|09:35:58|Thread-0|testCustomLog| +TRACE|09:36:16|Thread-0|testCustomLog| +TRACE|09:36:22|Thread-0|testCustomLog| +TRACE|09:36:26|Thread-0|testCustomLog| +TRACE|09:36:58|Thread-0|testCustomLog| +TRACE|09:37:16|Thread-0|testCustomLog| +TRACE|09:37:26|Thread-0|testCustomLog| +TRACE|09:37:58|Thread-0|testCustomLog| +TRACE|09:38:16|Thread-0|testCustomLog| +TRACE|09:38:26|Thread-0|testCustomLog| +TRACE|09:38:58|Thread-0|testCustomLog| +TRACE|09:39:16|Thread-0|testCustomLog| +TRACE|09:39:26|Thread-0|testCustomLog| +TRACE|09:39:58|Thread-0|testCustomLog| +TRACE|09:40:16|Thread-0|testCustomLog| +TRACE|09:40:26|Thread-0|testCustomLog| +TRACE|09:40:58|Thread-0|testCustomLog| +TRACE|09:41:16|Thread-0|testCustomLog| +TRACE|09:41:26|Thread-0|testCustomLog| +TRACE|09:41:56|Thread-0|testCustomLog| +TRACE|09:41:58|Thread-0|testCustomLog| +TRACE|09:42:16|Thread-0|testCustomLog| +TRACE|09:42:26|Thread-0|testCustomLog| +TRACE|09:42:58|Thread-0|testCustomLog| +TRACE|09:43:16|Thread-0|testCustomLog| +TRACE|09:43:26|Thread-0|testCustomLog| +TRACE|09:43:58|Thread-0|testCustomLog| +TRACE|09:44:16|Thread-0|testCustomLog| +TRACE|09:44:26|Thread-0|testCustomLog| +TRACE|09:44:37|Thread-0|testCustomLog| +TRACE|09:44:58|Thread-0|testCustomLog| +TRACE|09:45:16|Thread-0|testCustomLog| +TRACE|09:45:26|Thread-0|testCustomLog| +TRACE|09:45:37|Thread-0|testCustomLog| +TRACE|09:45:58|Thread-0|testCustomLog| +TRACE|09:46:16|Thread-0|testCustomLog| +TRACE|09:46:26|Thread-0|testCustomLog| +TRACE|09:46:37|Thread-0|testCustomLog| +TRACE|09:46:58|Thread-0|testCustomLog| +TRACE|09:47:16|Thread-0|testCustomLog| +TRACE|09:47:26|Thread-0|testCustomLog| +TRACE|09:47:37|Thread-0|testCustomLog| +TRACE|09:47:58|Thread-0|testCustomLog| +TRACE|09:48:16|Thread-0|testCustomLog| +TRACE|09:48:26|Thread-0|testCustomLog| +TRACE|09:48:58|Thread-0|testCustomLog| +TRACE|09:49:16|Thread-0|testCustomLog| +TRACE|09:49:26|Thread-0|testCustomLog| +TRACE|09:49:58|Thread-0|testCustomLog| +TRACE|09:50:16|Thread-0|testCustomLog| +TRACE|09:50:26|Thread-0|testCustomLog| +TRACE|09:50:58|Thread-0|testCustomLog| +TRACE|09:51:16|Thread-0|testCustomLog| +TRACE|09:51:26|Thread-0|testCustomLog| +TRACE|09:51:58|Thread-0|testCustomLog| +TRACE|09:52:16|Thread-0|testCustomLog| +TRACE|09:52:26|Thread-0|testCustomLog| +TRACE|09:52:58|Thread-0|testCustomLog| +TRACE|09:53:16|Thread-0|testCustomLog| +TRACE|09:53:26|Thread-0|testCustomLog| +TRACE|09:53:58|Thread-0|testCustomLog| +TRACE|09:54:16|Thread-0|testCustomLog| +TRACE|09:54:26|Thread-0|testCustomLog| +TRACE|09:54:58|Thread-0|testCustomLog| +TRACE|09:55:16|Thread-0|testCustomLog| +TRACE|09:55:26|Thread-0|testCustomLog| +TRACE|09:55:58|Thread-0|testCustomLog| +TRACE|09:56:16|Thread-0|testCustomLog| +TRACE|09:56:26|Thread-0|testCustomLog| +TRACE|09:56:58|Thread-0|testCustomLog| +TRACE|09:57:16|Thread-0|testCustomLog| +TRACE|09:57:26|Thread-0|testCustomLog| +TRACE|09:57:33|Thread-0|testCustomLog| +TRACE|09:57:58|Thread-0|testCustomLog| +TRACE|09:58:16|Thread-0|testCustomLog| +TRACE|09:58:25|Thread-0|testCustomLog| +TRACE|09:58:26|Thread-0|testCustomLog| +TRACE|09:58:29|Thread-0|testCustomLog| +TRACE|09:58:33|Thread-0|testCustomLog| +TRACE|09:58:58|Thread-0|testCustomLog| +TRACE|09:59:16|Thread-0|testCustomLog| +TRACE|09:59:25|Thread-0|testCustomLog| +TRACE|09:59:26|Thread-0|testCustomLog| +TRACE|09:59:29|Thread-0|testCustomLog| +TRACE|09:59:33|Thread-0|testCustomLog| +TRACE|09:59:58|Thread-0|testCustomLog| +TRACE|10:00:16|Thread-0|testCustomLog| +TRACE|10:00:25|Thread-0|testCustomLog| +TRACE|10:00:26|Thread-0|testCustomLog| +TRACE|10:00:29|Thread-0|testCustomLog| +TRACE|10:00:33|Thread-0|testCustomLog| +TRACE|10:00:58|Thread-0|testCustomLog| +TRACE|10:01:16|Thread-0|testCustomLog| +TRACE|10:01:25|Thread-0|testCustomLog| +TRACE|10:01:26|Thread-0|testCustomLog| +TRACE|10:01:29|Thread-0|testCustomLog| +TRACE|10:01:33|Thread-0|testCustomLog| +TRACE|10:01:58|Thread-0|testCustomLog| +TRACE|10:02:16|Thread-0|testCustomLog| +TRACE|10:02:25|Thread-0|testCustomLog| +TRACE|10:02:26|Thread-0|testCustomLog| +TRACE|10:02:29|Thread-0|testCustomLog| +TRACE|10:02:33|Thread-0|testCustomLog| +TRACE|10:02:58|Thread-0|testCustomLog| +TRACE|10:03:16|Thread-0|testCustomLog| +TRACE|10:03:25|Thread-0|testCustomLog| +TRACE|10:03:26|Thread-0|testCustomLog| +TRACE|10:03:29|Thread-0|testCustomLog| +TRACE|10:03:33|Thread-0|testCustomLog| +TRACE|10:03:58|Thread-0|testCustomLog| +TRACE|10:04:08|Thread-0|testCustomLog| +TRACE|10:04:16|Thread-0|testCustomLog| +TRACE|10:04:25|Thread-0|testCustomLog| +TRACE|10:04:26|Thread-0|testCustomLog| +TRACE|10:04:29|Thread-0|testCustomLog| +TRACE|10:04:33|Thread-0|testCustomLog| +TRACE|10:04:58|Thread-0|testCustomLog| +TRACE|10:05:08|Thread-0|testCustomLog| +TRACE|10:05:16|Thread-0|testCustomLog| +TRACE|10:05:25|Thread-0|testCustomLog| +TRACE|10:05:26|Thread-0|testCustomLog| +TRACE|10:05:29|Thread-0|testCustomLog| +TRACE|10:05:33|Thread-0|testCustomLog| +TRACE|10:05:58|Thread-0|testCustomLog| +TRACE|10:06:08|Thread-0|testCustomLog| +TRACE|10:06:16|Thread-0|testCustomLog| +TRACE|10:06:25|Thread-0|testCustomLog| +TRACE|10:06:26|Thread-0|testCustomLog| +TRACE|10:06:29|Thread-0|testCustomLog| +TRACE|10:06:33|Thread-0|testCustomLog| +TRACE|10:06:58|Thread-0|testCustomLog| +TRACE|10:07:08|Thread-0|testCustomLog| +TRACE|10:07:16|Thread-0|testCustomLog| +TRACE|10:07:25|Thread-0|testCustomLog| +TRACE|10:07:26|Thread-0|testCustomLog| +TRACE|10:07:29|Thread-0|testCustomLog| +TRACE|10:07:33|Thread-0|testCustomLog| +TRACE|10:07:58|Thread-0|testCustomLog| +TRACE|10:08:08|Thread-0|testCustomLog| +TRACE|10:08:16|Thread-0|testCustomLog| +TRACE|10:08:25|Thread-0|testCustomLog| +TRACE|10:08:26|Thread-0|testCustomLog| +TRACE|10:08:29|Thread-0|testCustomLog| +TRACE|10:08:33|Thread-0|testCustomLog| +TRACE|10:08:58|Thread-0|testCustomLog| +TRACE|10:09:08|Thread-0|testCustomLog| +TRACE|10:09:16|Thread-0|testCustomLog| +TRACE|10:09:25|Thread-0|testCustomLog| +TRACE|10:09:26|Thread-0|testCustomLog| +TRACE|10:09:29|Thread-0|testCustomLog| +TRACE|10:09:33|Thread-0|testCustomLog| +TRACE|10:09:58|Thread-0|testCustomLog| +TRACE|10:10:16|Thread-0|testCustomLog| +TRACE|10:10:25|Thread-0|testCustomLog| +TRACE|10:10:26|Thread-0|testCustomLog| +TRACE|10:10:29|Thread-0|testCustomLog| +TRACE|10:10:33|Thread-0|testCustomLog| +TRACE|10:10:58|Thread-0|testCustomLog| +TRACE|10:11:16|Thread-0|testCustomLog| +TRACE|10:11:24|Thread-0|testCustomLog| +TRACE|10:11:25|Thread-0|testCustomLog| +TRACE|10:11:26|Thread-0|testCustomLog| +TRACE|10:11:29|Thread-0|testCustomLog| +TRACE|10:11:33|Thread-0|testCustomLog| +TRACE|10:11:58|Thread-0|testCustomLog| +TRACE|10:12:16|Thread-0|testCustomLog| +TRACE|10:12:24|Thread-0|testCustomLog| +TRACE|10:12:25|Thread-0|testCustomLog| +TRACE|10:12:26|Thread-0|testCustomLog| +TRACE|10:12:29|Thread-0|testCustomLog| +TRACE|10:12:34|Thread-0|testCustomLog| +TRACE|10:12:58|Thread-0|testCustomLog| +TRACE|10:13:16|Thread-0|testCustomLog| +TRACE|10:13:24|Thread-0|testCustomLog| +TRACE|10:13:25|Thread-0|testCustomLog| +TRACE|10:13:26|Thread-0|testCustomLog| +TRACE|10:13:29|Thread-0|testCustomLog| +TRACE|10:13:34|Thread-0|testCustomLog| +TRACE|10:13:58|Thread-0|testCustomLog| +TRACE|10:14:16|Thread-0|testCustomLog| +TRACE|10:14:24|Thread-0|testCustomLog| +TRACE|10:14:25|Thread-0|testCustomLog| +TRACE|10:14:26|Thread-0|testCustomLog| +TRACE|10:14:29|Thread-0|testCustomLog| +TRACE|10:14:34|Thread-0|testCustomLog| +TRACE|10:14:58|Thread-0|testCustomLog| +TRACE|10:15:04|Thread-0|testCustomLog| +TRACE|10:15:16|Thread-0|testCustomLog| +TRACE|10:15:24|Thread-0|testCustomLog| +TRACE|10:15:25|Thread-0|testCustomLog| +TRACE|10:15:26|Thread-0|testCustomLog| +TRACE|10:15:29|Thread-0|testCustomLog| +TRACE|10:15:34|Thread-0|testCustomLog| +TRACE|10:15:37|Thread-0|testCustomLog| +TRACE|10:15:58|Thread-0|testCustomLog| +TRACE|10:16:04|Thread-0|testCustomLog| +TRACE|10:16:16|Thread-0|testCustomLog| +TRACE|10:16:24|Thread-0|testCustomLog| +TRACE|10:16:25|Thread-0|testCustomLog| +TRACE|10:16:26|Thread-0|testCustomLog| +TRACE|10:16:29|Thread-0|testCustomLog| +TRACE|10:16:34|Thread-0|testCustomLog| +TRACE|10:16:37|Thread-0|testCustomLog| +TRACE|10:16:58|Thread-0|testCustomLog| +TRACE|10:17:04|Thread-0|testCustomLog| +TRACE|10:17:16|Thread-0|testCustomLog| +TRACE|10:17:24|Thread-0|testCustomLog| +TRACE|10:17:25|Thread-0|testCustomLog| +TRACE|10:17:26|Thread-0|testCustomLog| +TRACE|10:17:29|Thread-0|testCustomLog| +TRACE|10:17:34|Thread-0|testCustomLog| +TRACE|10:17:58|Thread-0|testCustomLog| +TRACE|10:18:04|Thread-0|testCustomLog| +TRACE|10:18:16|Thread-0|testCustomLog| +TRACE|10:18:24|Thread-0|testCustomLog| +TRACE|10:18:25|Thread-0|testCustomLog| +TRACE|10:18:26|Thread-0|testCustomLog| +TRACE|10:18:29|Thread-0|testCustomLog| +TRACE|10:18:29|Thread-0|testCustomLog| +TRACE|10:18:34|Thread-0|testCustomLog| +TRACE|10:18:58|Thread-0|testCustomLog| +TRACE|10:19:04|Thread-0|testCustomLog| +TRACE|10:19:16|Thread-0|testCustomLog| +TRACE|10:19:24|Thread-0|testCustomLog| +TRACE|10:19:25|Thread-0|testCustomLog| +TRACE|10:19:26|Thread-0|testCustomLog| +TRACE|10:19:29|Thread-0|testCustomLog| +TRACE|10:19:34|Thread-0|testCustomLog| +TRACE|10:19:58|Thread-0|testCustomLog| +TRACE|10:20:04|Thread-0|testCustomLog| +TRACE|10:20:16|Thread-0|testCustomLog| +TRACE|10:20:24|Thread-0|testCustomLog| +TRACE|10:20:25|Thread-0|testCustomLog| +TRACE|10:20:26|Thread-0|testCustomLog| +TRACE|10:20:28|Thread-0|testCustomLog| +TRACE|10:20:29|Thread-0|testCustomLog| +TRACE|10:20:34|Thread-0|testCustomLog| +TRACE|10:20:59|Thread-0|testCustomLog| +TRACE|10:21:04|Thread-0|testCustomLog| +TRACE|10:21:16|Thread-0|testCustomLog| +TRACE|10:21:24|Thread-0|testCustomLog| +TRACE|10:21:25|Thread-0|testCustomLog| +TRACE|10:21:26|Thread-0|testCustomLog| +TRACE|10:21:29|Thread-0|testCustomLog| +TRACE|10:21:34|Thread-0|testCustomLog| +TRACE|10:21:59|Thread-0|testCustomLog| +TRACE|10:22:04|Thread-0|testCustomLog| +TRACE|10:22:16|Thread-0|testCustomLog| +TRACE|10:22:24|Thread-0|testCustomLog| +TRACE|10:22:25|Thread-0|testCustomLog| +TRACE|10:22:26|Thread-0|testCustomLog| +TRACE|10:22:29|Thread-0|testCustomLog| +TRACE|10:22:34|Thread-0|testCustomLog| +TRACE|10:22:59|Thread-0|testCustomLog| +TRACE|10:23:04|Thread-0|testCustomLog| +TRACE|10:23:16|Thread-0|testCustomLog| +TRACE|10:23:20|Thread-0|testCustomLog| +TRACE|10:23:24|Thread-0|testCustomLog| +TRACE|10:23:25|Thread-0|testCustomLog| +TRACE|10:23:26|Thread-0|testCustomLog| +TRACE|10:23:29|Thread-0|testCustomLog| +TRACE|10:23:34|Thread-0|testCustomLog| diff --git a/CustomLog/PreReleasedTest.log_2 b/CustomLog/PreReleasedTest.log_2 new file mode 100644 index 0000000..7a672f0 --- /dev/null +++ b/CustomLog/PreReleasedTest.log_2 @@ -0,0 +1,54 @@ +TRACE|10:53:57|Thread-0|testCustomLog| +TRACE|10:54:57|Thread-0|testCustomLog| +TRACE|10:55:18|Thread-0|testCustomLog| +TRACE|10:55:57|Thread-0|testCustomLog| +TRACE|10:56:18|Thread-0|testCustomLog| +TRACE|10:56:57|Thread-0|testCustomLog| +TRACE|10:57:09|Thread-0|testCustomLog| +TRACE|10:57:18|Thread-0|testCustomLog| +TRACE|10:57:57|Thread-0|testCustomLog| +TRACE|10:58:03|Thread-0|testCustomLog| +TRACE|10:58:09|Thread-0|testCustomLog| +TRACE|10:58:17|Thread-0|testCustomLog| +TRACE|10:58:18|Thread-0|testCustomLog| +TRACE|10:58:57|Thread-0|testCustomLog| +TRACE|10:59:03|Thread-0|testCustomLog| +TRACE|10:59:09|Thread-0|testCustomLog| +TRACE|10:59:17|Thread-0|testCustomLog| +TRACE|10:59:18|Thread-0|testCustomLog| +TRACE|10:59:57|Thread-0|testCustomLog| +TRACE|11:00:03|Thread-0|testCustomLog| +TRACE|11:00:09|Thread-0|testCustomLog| +TRACE|11:00:18|Thread-0|testCustomLog| +TRACE|11:00:57|Thread-0|testCustomLog| +TRACE|11:01:03|Thread-0|testCustomLog| +TRACE|11:01:09|Thread-0|testCustomLog| +TRACE|11:01:18|Thread-0|testCustomLog| +TRACE|11:01:57|Thread-0|testCustomLog| +TRACE|11:02:03|Thread-0|testCustomLog| +TRACE|11:02:09|Thread-0|testCustomLog| +TRACE|11:02:18|Thread-0|testCustomLog| +TRACE|11:02:57|Thread-0|testCustomLog| +TRACE|11:03:03|Thread-0|testCustomLog| +TRACE|11:03:09|Thread-0|testCustomLog| +TRACE|11:03:18|Thread-0|testCustomLog| +TRACE|11:03:57|Thread-0|testCustomLog| +TRACE|11:04:03|Thread-0|testCustomLog| +TRACE|11:04:09|Thread-0|testCustomLog| +TRACE|11:04:18|Thread-0|testCustomLog| +TRACE|11:04:57|Thread-0|testCustomLog| +TRACE|11:05:03|Thread-0|testCustomLog| +TRACE|11:05:09|Thread-0|testCustomLog| +TRACE|11:05:18|Thread-0|testCustomLog| +TRACE|11:05:57|Thread-0|testCustomLog| +TRACE|11:06:03|Thread-0|testCustomLog| +TRACE|11:06:09|Thread-0|testCustomLog| +TRACE|11:06:18|Thread-0|testCustomLog| +TRACE|11:06:57|Thread-0|testCustomLog| +TRACE|11:07:03|Thread-0|testCustomLog| +TRACE|11:07:09|Thread-0|testCustomLog| +TRACE|11:07:18|Thread-0|testCustomLog| +TRACE|11:07:57|Thread-0|testCustomLog| +TRACE|11:08:03|Thread-0|testCustomLog| +TRACE|11:08:09|Thread-0|testCustomLog| +TRACE|11:08:18|Thread-0|testCustomLog| diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 --- a/README.md +++ /dev/null diff --git a/conf/WS1.EC02.SERV.0 b/conf/WS1.EC02.SERV.0 new file mode 100644 index 0000000..376230b --- /dev/null +++ b/conf/WS1.EC02.SERV.0 @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example.msg/debug.diameter.xml b/example.msg/debug.diameter.xml new file mode 100644 index 0000000..99e670e --- /dev/null +++ b/example.msg/debug.diameter.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example.msg/debug.html-text-plain.xml b/example.msg/debug.html-text-plain.xml new file mode 100644 index 0000000..e2d0da5 --- /dev/null +++ b/example.msg/debug.html-text-plain.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/example.msg/debug.html-text-xml-header.xml b/example.msg/debug.html-text-xml-header.xml new file mode 100644 index 0000000..544ae43 --- /dev/null +++ b/example.msg/debug.html-text-xml-header.xml @@ -0,0 +1,20 @@ + + + + +
+
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/example.msg/debug.html-text-xml.xml b/example.msg/debug.html-text-xml.xml new file mode 100644 index 0000000..63dd5dd --- /dev/null +++ b/example.msg/debug.html-text-xml.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example.msg/debug.ldap.xml b/example.msg/debug.ldap.xml new file mode 100644 index 0000000..b91ecfb --- /dev/null +++ b/example.msg/debug.ldap.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example.msg/debug.xml b/example.msg/debug.xml new file mode 100644 index 0000000..4ee34e5 --- /dev/null +++ b/example.msg/debug.xml @@ -0,0 +1,31 @@ + + + + + + + + 1 + 0 + 2002 + Operation successfully. + + + 7805693 + + C_MAIN_ACCOUNT + 2550007807518 + MainAccount + 31183 + 32183 + 1049 + + + + + + + + + + \ No newline at end of file diff --git a/lib/commons-lang-2.6.jar b/lib/commons-lang-2.6.jar new file mode 100644 index 0000000..98467d3 Binary files /dev/null and b/lib/commons-lang-2.6.jar differ diff --git a/lib/commons-log-pack-1.1.2.jar b/lib/commons-log-pack-1.1.2.jar new file mode 100644 index 0000000..dcc4633 Binary files /dev/null and b/lib/commons-log-pack-1.1.2.jar differ diff --git a/lib/ec02_library.jar b/lib/ec02_library.jar new file mode 100644 index 0000000..162cf89 Binary files /dev/null and b/lib/ec02_library.jar differ diff --git a/lib/eqxmsg_3_3_2.jar b/lib/eqxmsg_3_3_2.jar new file mode 100644 index 0000000..3611dff Binary files /dev/null and b/lib/eqxmsg_3_3_2.jar differ diff --git a/lib/gson-2.2.2.jar b/lib/gson-2.2.2.jar new file mode 100644 index 0000000..f2108e0 Binary files /dev/null and b/lib/gson-2.2.2.jar differ diff --git a/lib/org.json-20120521.jar b/lib/org.json-20120521.jar new file mode 100644 index 0000000..f11fcd0 Binary files /dev/null and b/lib/org.json-20120521.jar differ diff --git a/lib/simple-xml-2.7.1.jar b/lib/simple-xml-2.7.1.jar new file mode 100644 index 0000000..913725d Binary files /dev/null and b/lib/simple-xml-2.7.1.jar differ diff --git a/src/th/co/ais/ssbsrfc/config/Constant.java b/src/th/co/ais/ssbsrfc/config/Constant.java new file mode 100644 index 0000000..87183aa --- /dev/null +++ b/src/th/co/ais/ssbsrfc/config/Constant.java @@ -0,0 +1,144 @@ +package th.co.ais.ssbsrfc.config; + + + +public class Constant { + + /* + * [mSSB-SRFC] [Send|Received] [Bad] [Response|Request] [Timeout|Abort|Reject|Error] + */ + + public static final int TYPE_SEND = 0; + public static final int TYPE_RECEIVE = 1; + + public static final int TYPE_RESPONSE = 2; + public static final int TYPE_REQUEST = 3; + public static final int TYPE_NOREPLY = 88; + + public static final int TYPE_MISSING = 4; + public static final int TYPE_INVALID = 5; + + public static final int TYPE_TIMEOUT = 6; + public static final int TYPE_ABORT = 7; + public static final int TYPE_REJECT = 8; + public static final int TYPE_ERROR = 9; + + + public static final int TYPE_SUCCESS = 10; + public static final int TYPE_UNKNOWN_ERROR = 12; + public static final int TYPE_MENU_UNIQUELDENTIFIER_DUPLICATE = 100; + public static final int TYPE_CHANNEL = 101; + + + public static final int TYPE_DATA_NOT_FOUND = 11; + public static final int TYPE_SUCCESS_WITH_CONDITION = 13; + public static final int TYPE_SUCCESS_WITH_CONDITION_STATUS_CHANGE = 14; + public static final int TYPE_REJECT_APPLICATION = 15; + public static final int TYPE_SUCCESS_WITH_CONDITION_STATUS_TERMINATED = 16; + public static final int TYPE_SUCCESS_WITH_CONDITION_STATUS_BORROWED = 17; + public static final int TYPE_SUCCESS_WITH_CONDITION_OUTSTANDING_NOT_ZERO = 18; + public static final int TYPE_SUCCESS_WITH_CONDITION_NOT_IN_SEVEN_DAYS = 19; + public static final int TYPE_USER_INACTIVE = 20; + public static final int TYPE_INVALID_CONTRACT_ID = 21; + public static final int TYPE_ACCESS_DENIED = 22; + public static final int TYPE_FILE_NOT_FOUND = 23; + public static final int TYPE_ALREADY_SENT_INVITATION = 24; + public static final int TYPE_ALREADY_SENT_ADD_BALANCE = 25; + public static final int TYPE_DATA_EXISTED = 26; + public static final int TYPE_DUPLICATE = 99; + + public static final String SEND = "Send"; + public static final String RECEIVE = "Receive"; + + public static final String BAD = "Bad"; + public static final String DUPLICATE = "Duplicate"; + + public static final String RESPONSE = "Response"; + public static final String REQUEST = "Request"; + + public static final String TIMEOUT = "Timeout"; + public static final String ABORT = "Abort"; + public static final String REJECT = "Reject"; + public static final String ERROR = "Error"; + + public static final String ENCRYPTKEY = "82BDZsTKxvTJb9Bm"; + + public static final int FLOW_TEST_A = 1; + public static final int FLOW_Unexpected_Event_Handling = 19; + + public static final int SUBSTATE_TYPE_W_REQUEST = 1; + public static final int SUBSTATE_TYPE_W_RESPONSE = 2; + public static final int SUBSTATE_TYPE_W_E01 = 3; + public static final int SUBSTATE_TYPE_UNKNOWN = -1; + + public static String nodeLBSRFP = "LBSRFP"; + public static String nodeE01 = "E01"; + public static String nodeES12 = "ES12"; + + public static final int[] arrSingleFlow = {/*Constant.FLOW_Loan_Potential_Jobs_Tracking, Constant.FLOW_TEST_A, Constant.FLOW_Loan_Potential_Request_Handling, Constant.FLOW_Loan_UI, Constant.FLOW_Loan_Activation, Constant.FLOW_Loan_Customer_Registration*/}; + + public static enum DETAILLOG { + CLOSE(0), + OPENERROR(1), + OPEN(2), + ; + + int num = 0; + DETAILLOG(int message){ + this.num = message; + } + public int get(){ + return this.num; + } + + } + + public static enum ValidateType { + STRING, + NUMBER, + CURRENCY, + MOBILE, + DATETIME, + BOOLEAN, + BOOLEANUPPERCASE, + FIX, +// LANG, + YESNO, + DECIMAL, + OBJECT, + ARRAY, +// SUBSCRIPTIONSTATE, +// AEMFCHARACTERISTIC, +// AEMFVALUETYPE, +// AEMFALERTPOINT, +// AMFLOANSTATE, + URL, + EMAIL, +// DS3CUSTOMERCATEGORY, +// DS3CUSTOMERSUBCATEGORY, +// DS3CUSTOMERSEGMENT, +// AEMFACHIEVE, +// AEMFSTATUS, +// AEMFSTATUS2, +// ARMEDPARAM, +// SDFGUPDATASERVLIFESTYLE, +// SDFGUPAUTHENLEVEL, +// MOBILESTATUS, +// LANGUPPER, +// DAAERRORCODE, + NOTCHECKINVALID, + TOROSUBSCRIPTIONIDTYPE, + BEARERTYPE, + OutbandChannel, + REESULTCODE, + WAITRESULTINDICATOR, + OUTBANDCHANNELOTP, + TOROLANGUAGEPREFERENCE, + INBANDINDICATOR + } + + public static enum Parameter { + MANDATORY, + OPTIONAL + } +} diff --git a/src/th/co/ais/ssbsrfc/config/EventFilter.java b/src/th/co/ais/ssbsrfc/config/EventFilter.java new file mode 100644 index 0000000..71ea2d9 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/config/EventFilter.java @@ -0,0 +1,58 @@ +package th.co.ais.ssbsrfc.config; + +public class EventFilter { + public String eventType; + public String type; + public String ctype; + public String method; + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCtype() { + return ctype; + } + + public void setCtype(String ctype) { + this.ctype = ctype; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getCmd() { + return cmd; + } + + public void setCmd(String cmd) { + this.cmd = cmd; + } + + public String cmd; + + public EventFilter(String _eventType, String _type, String _ctype, String _method, String _cmd) + { + this.eventType = _eventType; + this.type = _type; + this.ctype = _ctype; + this.method = _method; + this.cmd = _cmd; + } +} diff --git a/src/th/co/ais/ssbsrfc/config/Invoke.java b/src/th/co/ais/ssbsrfc/config/Invoke.java new file mode 100644 index 0000000..8d7729e --- /dev/null +++ b/src/th/co/ais/ssbsrfc/config/Invoke.java @@ -0,0 +1,136 @@ +package th.co.ais.ssbsrfc.config; + +import java.util.UUID; + +import th.co.ais.ssbsrfc.utils.Global; + +public class Invoke { + public String nodeName; // UDC, SRFC, SDF + public String key; // 6681234567 + public String cmd = null; // callBackUrl, getFile + public String eventType = null; // Incoming_UDC_Response + public String unique; + public Object dev = null; // for developer + + private static final String DELIMITER = "."; + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getCmd() { + return cmd; + } + + public void setCmd(String cmd) { + this.cmd = cmd; + } + + public String getUnique() { + return unique; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public void setUnique(String unique) { + this.unique = unique; + } + + public static String genUniqueId() + { + UUID uuid = UUID.randomUUID(); + return uuid.toString(); + } + + public Object getDev() { + return dev; + } + + public void setDev(Object dev) { + this.dev = dev; + } + + public Invoke() {} + + public Invoke(String invokeString) + { + String[] strSplit = null; + if(invokeString != null) + { + strSplit = invokeString.split("[\\"+DELIMITER+"]"); + if(strSplit.length == 5) + { + this.nodeName = strSplit[0]; + this.key = strSplit[1]; + this.cmd = strSplit[2]; + this.eventType = strSplit[3]; + this.unique = strSplit[4]; + } else if (strSplit.length == 6) { + this.nodeName = strSplit[0]; + this.key = strSplit[1]; + this.cmd = strSplit[2]; + this.eventType = strSplit[3]; + this.unique = strSplit[4]; + this.dev = strSplit[5]; + } + } + } + + public Invoke(String _key, String _eventType) { + super(); + String _cmd = StateConfig.getCommandFromEventType(eventType); + String _node = Global.getNodeFromEventType(eventType); + this.nodeName = _node; + this.key = _key; + this.cmd = _cmd; + this.eventType = _eventType; + UUID uuid = UUID.randomUUID(); + this.unique = uuid.toString(); + } + + public Invoke(String _nodeName, String _key, String _cmd, String _eventType, String _unique) + { + // TODO check . in all variable (if have) + this.nodeName = _nodeName; + this.key = _key; + this.cmd = _cmd; + this.eventType = _eventType; + if(_unique == null) + { + UUID uuid = UUID.randomUUID(); + this.unique = uuid.toString(); + } + else + { + this.unique = _unique; + } + } + + public String toString() + { + String strInvoke =""; + strInvoke = this.nodeName + DELIMITER + this.key + DELIMITER + this.cmd + DELIMITER + this.eventType + DELIMITER + this.unique; + if(this.dev != null) { + strInvoke += DELIMITER + this.dev.toString(); + } + return strInvoke; + } +} diff --git a/src/th/co/ais/ssbsrfc/config/State.java b/src/th/co/ais/ssbsrfc/config/State.java new file mode 100644 index 0000000..8c3d9b2 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/config/State.java @@ -0,0 +1,68 @@ +package th.co.ais.ssbsrfc.config; + +public class State { + public String name; + public String eventType; + public String nameReq; //Log, Alarm, Stat, Error + public String nameRes; //Log, Alarm, Stat, Error + public int msgType; + public int flow = -1; + + public State(String _stateName, String _stateEventType, String _stateLASEName) + { + this.name = _stateName; + this.eventType = _stateEventType; + this.nameReq = _stateLASEName; + } + + public State(String _stateName, String _stateEventType, String _nameReq, String _nameRes, int _msgType) + { + this.name = _stateName; + this.eventType = _stateEventType; + this.nameReq = _nameReq; + this.nameRes = _nameRes; + this.msgType = _msgType; + } + + public State(String _stateName, String _stateEventType, String _nameReq, String _nameRes, int _msgType, int flow) + { + this.name = _stateName; + this.eventType = _stateEventType; + this.nameReq = _nameReq; + this.nameRes = _nameRes; + this.msgType = _msgType; + this.flow = flow; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getLASEName() { + return nameReq; + } + + public void setLASEName(String lASEName) { + nameReq = lASEName; + } + + public int getMsgType() { + return msgType; + } + + public void setMsgType(int msgType) { + this.msgType = msgType; + } +} diff --git a/src/th/co/ais/ssbsrfc/config/StateConfig.java b/src/th/co/ais/ssbsrfc/config/StateConfig.java new file mode 100644 index 0000000..d3fc409 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/config/StateConfig.java @@ -0,0 +1,592 @@ +package th.co.ais.ssbsrfc.config; + +import th.co.ais.ssbsrfc.instance.CheckRequest; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.utils.Log; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.utils.AppLog; + +public class StateConfig { + + //define project name + public static final String PROJECT_NAME = "LBCF"; + public static String PROJECT_STAT_NAME = PROJECT_NAME; + public static final boolean isMultiFlow = false; + + //define main state + public static final String STATE_IDLE = "IDLE"; + public static final String STATE_ACTIVE = "ACTIVE"; + public static final String STATE_E11_TIMEOUT = "E11_TIMEOUT"; + + //define sub state + public static final String SSTATE_UNKNOWN = "UNKNOWN"; + public static final String SSTATE_REJECT = "REJECT"; + public static final String SSTATE_ABORT = "ABORT"; + public static final String SSTATE_BEGIN = "BEGIN"; + public static final String SSTATE_END = "END"; + public static final String SSTATE_W_A = "W_A"; + public static final String SSTATE_W_CHARGEREQUEST = "W_CHARGEREQUEST"; + public static final String SSTATE_W_CHARGEREPORT = "W_CHARGEREPORT"; + public static final String SSTATE_W_ADJUSTMENT_CHARGEREQUEST = "W_ADJUSTMENTRESPONSE_CHARGEREQUEST"; + public static final String SSTATE_W_ADJUSTMENT_CHARGEREPORT = "W_ADJUSTMENTRESPONSE_CHARGEREPORT"; + //define event + public static final String Incoming_Unknown ="Incoming_Unknown"; + public static final String Incoming_REJECT ="Incoming_REJECT"; + public static final String Incoming_ABORT ="Incoming_ABORT"; + public static final String Incoming_A_Request = "Incoming_A_Request"; + public static final String Incoming_ChargeRequest_Request = "Incoming_ChargeRequest_Request"; + public static final String Incoming_ChargeReport_Request = "Incoming_ChargeReport_Request"; + public static final String Incoming_Adjustment_ChargeRequest_Response = "Incoming_Adjustment_ChargeRequest_Response"; + public static final String Incoming_Adjustment_ChargeReport_Response = "Incoming_Adjustment_ChargeReport_Response"; + + //define LASE (Log, Alarm, Stat, Error) + public static final String LASE_Unknown = "Unknown Command"; + public static final String LASE_Reject = "Unknown Reject"; + public static final String LASE_Abort = "Unknown Abort"; + + // define frist state of each flow + public static final String[] arrFirstStateFlow = { + SSTATE_W_CHARGEREQUEST,SSTATE_W_CHARGEREPORT, + + }; // SSTATE_UNKNOWN + + //define sub state list and messages that relate to + + public static State subStateList[] = { + new State(SSTATE_REJECT, Incoming_REJECT, LASE_Reject), + new State(SSTATE_ABORT, Incoming_ABORT, LASE_Abort), + new State(SSTATE_END, Incoming_Unknown, LASE_Unknown), + + new State(SSTATE_W_CHARGEREQUEST, Incoming_ChargeRequest_Request, "Test A", "Test A", Constant.TYPE_REQUEST, Constant.FLOW_TEST_A), + new State(SSTATE_W_CHARGEREPORT, Incoming_ChargeReport_Request, "Test A", "Test A", Constant.TYPE_REQUEST, Constant.FLOW_TEST_A), + new State(SSTATE_W_ADJUSTMENT_CHARGEREQUEST, Incoming_Adjustment_ChargeRequest_Response, "Test A", "Test A", Constant.TYPE_REQUEST, Constant.FLOW_TEST_A), + new State(SSTATE_W_ADJUSTMENT_CHARGEREPORT, Incoming_Adjustment_ChargeReport_Response, "Test A", "Test A", Constant.TYPE_REQUEST, Constant.FLOW_TEST_A), +// new State(SSTATE_W_A, Incoming_A_Request, "Test A", "Test A", Constant.TYPE_RESPONSE), + new State(SSTATE_END, Incoming_Unknown,"Unknown_Command"), + }; + + //define event type message filter + public static final EventFilter[] eventFilter = { + // Flow 0 + new EventFilter(Incoming_ChargeRequest_Request, "request", "text/plain", null, null), + new EventFilter(Incoming_ChargeReport_Request, "request", "text/plain", null, null), + new EventFilter(Incoming_Adjustment_ChargeRequest_Response, "request", "text/plain", null, null), + new EventFilter(Incoming_Adjustment_ChargeReport_Response, "request", "text/plain", null, null), + }; + + public static String getSubStateFromEventType(String eventType) + { + String subState=""; + try { + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssName = state.name; + String ssEventType = state.eventType; + + // if we found matching relation + if(eventType.equals(ssEventType)) + { + subState = ssName; + break; + } + } + } + catch (Exception e) { + AppLog.e("ERROR: getSubStateFromEventType!! eventType:" + eventType + "desc: " + e); + } + return subState; + } + + public static String getEventTypeFromSubState(String subState) + { + String eventType = ""; + try { + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String sstate = state.name; + String ssEventType = state.eventType; + + // if we found matching relation + if(sstate.equals(subState)) + { + eventType = ssEventType; + break; + } + } + } + catch (Exception e) { + AppLog.e("ERROR: getEventTypeFromSubState!! subState:" + subState + "desc: " + e); + } + return eventType; + } + + public static String getCommandFromEventType(String eventType) + { + String command=""; + try { + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssCommand = state.nameReq; + String ssEventType = state.eventType; + + // if we found matching relation + if(eventType.equals(ssEventType)) + { + command = ssCommand; + break; + } + } + } + catch (Exception e) { + AppLog.e("ERROR: getSubStateFromEventType!! eventType:" + eventType + "desc: " + e); + } + return command; + } + + public static void changeCommandFromEventType(String eventType, String command) + { + try { + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssEventType = state.eventType; + + // if we found matching relation + if(eventType.equals(ssEventType)) + { + subStateList[i].setLASEName(command); + break; + } + } + } + catch (Exception e) { + AppLog.e("ERROR: changeCommangFromEventType!! eventType:" + eventType + " new command:" + command + " desc: " + e); + } + } + + public static int getFlowFromEventType(String eventType) + { + int flow = -1; + try { + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssEventType = state.eventType; + int ssFlow = state.flow; + + // if we found matching relation + if(eventType.equals(ssEventType)) + { + flow = ssFlow; + break; + } + } + } + catch (Exception e) { + AppLog.e("ERROR: getFlowFromEventType!! eventType:" + eventType + "desc: " + e); + } + return flow; + } + + public static String getCommandFromState(String subState) + { + String command=""; + try { + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssCommand = state.nameReq; + String ssState = state.name; + + // if we found matching relation + if(subState.equals(ssState)) + { + command = ssCommand; + break; + } + } + } + catch (Exception e) { + AppLog.e("ERROR: getSubStateFromEventType!! eventType:" + subState + "desc: " + e); + } + return command; + } + + public static String getCommandFromStateAndType(String subState, int type) + { + String command=""; + try { + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssCmdReq= state.nameReq; + String ssCmdRes= state.nameRes; + String ssState = state.name; + + // if we found matching relation + if(subState.equals(ssState)) + { + if (type == Constant.TYPE_REQUEST) { + command = ssCmdReq; + } else if (type == Constant.TYPE_RESPONSE) { + command = ssCmdRes; + } + break; + } + } + } + catch (Exception e) { + AppLog.e("ERROR: getSubStateFromEventType!! eventType:" + subState + "desc: " + e); + } + return command; + } + + public static int getSubStateIndex(String currentState) + { + int idx=-1; + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssName = state.name; + + // if we found matching relation + if(currentState.equals(ssName)) + { + idx = i; + } + } + return idx; + } + + public static boolean isFirstState(String state) + { + boolean first = false; + for (String _state : arrFirstStateFlow) { + if (_state.contains(state)) { + first = true; + break; + } + } + return first; + } + + public static void setNextSubState(EC02Instance ec02Instance) + { + // get current state + String currentState = ec02Instance.getAFInstance().getCurrentState(); + String nextState = StateConfig.getNextSubState(currentState); + ec02Instance.getAFInstance().setCurrentState(nextState); + // end + } + + public static String getNextSubState(String currentState) + { + if(currentState.equals(SSTATE_END)) + { + return SSTATE_END; + } + + int idx = getSubStateIndex(currentState); + if(idx != -1) + { + idx++; + State state = subStateList[idx]; + String ssName = state.name; + return ssName; + } + else //if not found + { + return SSTATE_UNKNOWN; + } + } + + public static String getEventTypeFromInvoke(String invokeMsg) + { + String eventType = null; + Invoke invoke = new Invoke(invokeMsg); + eventType = invoke.getEventType(); + return eventType; + } + + public static boolean isValidateEventType(String eventType) + { + boolean isValidate = false; + + // find sub state to handler event type + for(int i=0; i < subStateList.length; i++) + { + State state = subStateList[i]; + String ssEventType = state.eventType; + + // if we found matching relation + if(ssEventType.equals(eventType)) + { + isValidate = true; + } + } + return isValidate; + } + + public static String getEventTypeFromEquinoxRawData(EC02Instance ec02Instance, EquinoxRawData rawData) + { + String eventType = null; + // 1.1.1. Extract type, ctype, method, invoke, ret attributes. + String type = rawData.getRawDataAttribute("type"); + String ctype = rawData.getRawDataAttribute("ctype"); + String method = rawData.getRawDataAttribute("method"); + String invoke = rawData.getInvoke(); + String cmd = ""; + /*String ret = rawData.getRawDataAttribute("ret"); + // 1.1.2. If ret in (1, 2, 3, 4) Then + if (ret.equals("2")) { + return StateConfig.Incoming_REJECT; + } else if (ret.equals("3")) { + return StateConfig.Incoming_ABORT; + }*/ +// if (type.equals("response")) { +// ArrayList listTimeout = ec02Instance.getAFInstance().getListTimeout(); +// boolean isBool = false; +// for (Timeout timeout : listTimeout) { +// if (timeout.getName().equals(invoke)) { +// isBool = true; +// } +// } +// if (!isBool) { +// return StateConfig.Incoming_Unknown; +// } +// } + + // 1.1.3. Try to get event type from invoke + if(invoke != null && invoke.length() >0) + { + // 1.1.4. If valid event type Then + String event = getEventTypeFromInvoke(invoke); + if(event != null && isValidateEventType(event)) + { + // 1.1.4.1. Set event type = + return event; + } + } + + // 1.1.6. Get event type from type, ctype, method, cmd + int maxCount = 0; + for(int i=0; i < eventFilter.length; i++) + { + EventFilter ef = eventFilter[i]; + boolean bMatch = false; + int count = 0; //use for count matched in each parameter + + // try matching 1 by 1 + // check type + if(ef.type != null) + { + if(type.equals(ef.type)) + { + bMatch = true; + count++; + } + else + bMatch = false; + } + + // check ctype + if(ef.ctype != null) + { + if(ctype.equals(ef.ctype)) + { + bMatch = true; + count++; + } + else + bMatch = false; + } + + // check method + if(ef.method != null) + { + if(method.equals(ef.method)) + { + bMatch = true; + count++; + } + else + bMatch = false; + } + + // check cmd + if(ef.cmd != null) + { + if(cmd.equals(ef.cmd)) + { + bMatch = true; + count++; + } + else + bMatch = false; + } + //check and set maxCount for use to select event type + if(bMatch && count > maxCount) + { + maxCount = count; + + //set return event type to this matched + eventType = ef.eventType; + } + AppLog.d("EVENT TYPE:"+eventType+"In If"+eventType.equals(StateConfig.Incoming_A_Request)); + if (eventType.equals(StateConfig.Incoming_ChargeRequest_Request)) { + //String page = rawData.getRawDataMessage(); + String page = rawData.getRawDataAttribute("val"); + CheckRequest checkRequest = new CheckRequest(); + checkRequest.setDn(page); + String [] dnList = checkRequest.getDn().split("&", -1); + page = dnList[0].substring("page=".length()); + if (page.equals("chargeRequest")) { + eventType = StateConfig.Incoming_ChargeRequest_Request; + } else if (page.equals("chargeReport")) { + eventType = StateConfig.Incoming_ChargeReport_Request; + } + } + } + return eventType; + } + + public static String getLASEName(String currentSubState, int sendOrReceive, int responseOrRequest, int missingOrInvalidOrTARE, String errMsg) + { + String name = StateConfig.getLASEName(currentSubState, sendOrReceive, responseOrRequest, missingOrInvalidOrTARE, errMsg, null); + return name; + } + + public static String getLASEName(String currentSubState, int sendOrReceive, int responseOrRequest, int missingOrInvalidOrTARE, String errMsg, String command, int flow) + { + switch (flow) { + default: + StateConfig.PROJECT_STAT_NAME = StateConfig.PROJECT_NAME; + break; + } + + String name = StateConfig.getLASEName(currentSubState, sendOrReceive, responseOrRequest, missingOrInvalidOrTARE, errMsg, command); + return name; + } + + public static String getLASEName(String currentSubState, int sendOrReceive, int responseOrRequest, int missingOrInvalidOrTARE, String errMsg, String command) + { +// AppLog.d("## [mSSB-SRFC] [Send|Received] [Bad] [Response|Request] [Timeout|Abort|Reject|Error] [errMsg]"); +// AppLog.d("## getLASEName :" + currentSubState + "/" + sendOrReceive + "/" + responseOrRequest + "/" + missingOrInvalidOrTARE + "/" + errMsg); + String stateName = null; +// int idx = StateConfig.getSubStateIndex(currentSubState); +// State state = StateConfig.subStateList[idx]; + String LASEName = StateConfig.getCommandFromStateAndType(currentSubState, responseOrRequest); + + /* + * [mSSB-SRFC] [Send|Received] [Bad] [Response|Request] [Timeout|Abort|Reject|Error] + */ + + String sr = ""; + + switch (sendOrReceive) + { + case Constant.TYPE_SEND: + sr = Constant.SEND; + break; + case Constant.TYPE_RECEIVE: + sr = Constant.RECEIVE; + break; + } + + String rr = ""; + switch (responseOrRequest) + { + case Constant.TYPE_RESPONSE: + rr = Constant.RESPONSE + " "; + break; + case Constant.TYPE_REQUEST: + rr = Constant.REQUEST + " "; + break; + } + + //Timeout, Abort, Reject, Error + String tare = ""; + String bad = ""; + String cmd = ""; + switch (missingOrInvalidOrTARE) + { + case Constant.TYPE_MISSING: + bad = Constant.BAD + " "; + break; + case Constant.TYPE_INVALID: + bad = Constant.BAD + " "; + break; + case Constant.TYPE_DUPLICATE: + bad = Constant.DUPLICATE + " "; + break; + case Constant.TYPE_TIMEOUT: + tare = Constant.TIMEOUT; + break; + case Constant.TYPE_ABORT: + tare = Constant.ABORT; + break; + case Constant.TYPE_REJECT: + tare = Constant.REJECT; + break; + case Constant.TYPE_ERROR: + case Constant.TYPE_UNKNOWN_ERROR: + tare = Constant.ERROR; + break; + } + + if (command != null) { + cmd = command; + } else { + if (missingOrInvalidOrTARE == Constant.TYPE_REJECT_APPLICATION) { + cmd = "Unknown"; + rr = Constant.REQUEST + " "; + } else { + cmd = LASEName; + } + } + + stateName = StateConfig.PROJECT_STAT_NAME + " " + sr + " " + bad + cmd + " " + rr + tare; + stateName = stateName.trim(); + + return stateName; + } + + public static String getTimeout(AbstractAF abstractAF, String event) { + String timeout = StateConfig.getTimeout(abstractAF, event, null); + return timeout; + } + + public static String getTimeout(AbstractAF abstractAF, String event, String command) { + String time = "10"; + String configName = "Default-timeout"; + try { + if (event.equals(StateConfig.Incoming_Unknown)) { + configName = "Wait-Get-File-Timeout"; + } else { + configName = "Default-timeout"; + } + + time = abstractAF.getUtils().getHmWarmConfig().get(configName).get(0); + AppLog.d("## SET TIMEOUT: " + configName + " " + time + " sec"); + } catch (Exception e) { + if (Log.debug) { + AppLog.d("## CHECKCONFIG EC02 READDING..."); + AppLog.d("## EXCEPTION : " + e.getMessage()); + AppLog.d("## DATA EVENTTYPE OR INVOKE:" + event + " COMMAND:" + command); + } + } + return time; + } +} diff --git a/src/th/co/ais/ssbsrfc/control/FlowManager.java b/src/th/co/ais/ssbsrfc/control/FlowManager.java new file mode 100644 index 0000000..62bae00 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/control/FlowManager.java @@ -0,0 +1,470 @@ +package th.co.ais.ssbsrfc.control; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.ArrayUtils; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.AFInstance; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.FMInstance; +import th.co.ais.ssbsrfc.instance.ManageTime; +import th.co.ais.ssbsrfc.instance.Timeout; +import th.co.ais.ssbsrfc.interfaces.EQXMsg; +import th.co.ais.ssbsrfc.message.MessageParser; +import th.co.ais.ssbsrfc.utils.Global; +import th.co.ais.ssbsrfc.utils.Log; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.utils.AppLog; + +public class FlowManager { + private AbstractAF abstractAF = null; + private EC02Instance ec02Instance = null; + private AFInstance afInstance = null; + private EquinoxRawData equinoxRawData = null; + private int flow = 0; + private String type = EQXMsg.EMPTY; +// private int[] arrSingleFlow = {Constant.FLOW_Loan_Potential_Jobs_Tracking, Constant.FLOW_Loan_Potential_Registration, Constant.FLOW_Loan_Potential_Request_Handling, Constant.FLOW_Loan_UI, Constant.FLOW_Loan_Activation, Constant.FLOW_Loan_Customer_Registration}; + private FMInstance ins = null; + private ArrayList listFlow = new ArrayList(); + private Map dicInvoke = new LinkedHashMap(); + private ArrayList listTimeout = new ArrayList(); + private ArrayList globalListTimeout = new ArrayList(); + private int globalDialogueId = -1; + private boolean debug = false; + + public FlowManager(AbstractAF abstractAF, EC02Instance ec02Instance) { + super(); + this.abstractAF = abstractAF; + this.ec02Instance = ec02Instance; + this.afInstance = ec02Instance.getAFInstance(); + } + public void start(EquinoxRawData equinoxRawData) + { + this.equinoxRawData = equinoxRawData; + this.listFlow = this.afInstance.getListFlow(); + this.dicInvoke = this.afInstance.getDicInvoke(); + this.globalDialogueId = this.afInstance.getGlobalDialogueId(); + this.listTimeout = this.afInstance.getListTimeout(); + this.globalListTimeout = this.afInstance.getGlobalListTimeout(); + + if (this.debug) { + AppLog.d("####### TABLE LISTFLOW #######"); + AppLog.d("## SIZE:" + this.ec02Instance.getAFInstance().getListFlow().size()); + AppLog.d("## INPUT TIMESTAMP:" + this.ec02Instance.getAFInstance().getStartFlowTimeStamp()); + AppLog.d("------------------------------"); + for (FMInstance i : this.ec02Instance.getAFInstance().getListFlow()) { + AppLog.d(i.toString()); + } + AppLog.d("############# END ############"); + } + if (this.listFlow.size() != 0) { +// try { + // case e01 + if (this.abstractAF.getUtils().getGlobalData().isRecieve()) { + String invoke = equinoxRawData.getInvoke(); + this.setInstanceForInvoke(invoke); + if (this.debug) { + AppLog.d("## CASE EO1 GET INVOKE:" + invoke); + } + } + else { + String ret = equinoxRawData.getRet(); + if (ret.equals("4")) { // Timeout + String unique = equinoxRawData.getRawDataAttribute("unique"); + this.setInstanceForUnique(unique); + if (this.debug) { + AppLog.d("## CASE TIMEOUT GET UNIQUE:" + unique); + } + } else { + String type = equinoxRawData.getType(); + if ((type.toLowerCase().equals("request") || type.toLowerCase().equals("noreply")) && !ret.equals("1") && !ret.equals("2") && !ret.equals("3")) { + String eventType = equinoxRawData.getRawEventType(); + String ssName = StateConfig.getSubStateFromEventType(eventType); + int flow = StateConfig.getFlowFromEventType(eventType); +// if (flow == -1 && type.toLowerCase().equals("noreply")) { +// String invoke = equinoxRawData.getInvoke(); +// if (invoke != null && invoke.contains(".")) { +// Object code = new Invoke(invoke).dev; +// String strCode = (String)code; +// if (strCode != null && strCode.equals("16")) { +// flow = Constant.FLOW_Loan_Potential_Request_Handling; +// } +// } +// } + if (this.debug) { + AppLog.d("## CASE REQUEST MESSAGE GET FLOW:" + flow); + AppLog.d("## EVENTTYPE:" + eventType); + AppLog.d("## SUBSTATE FOR EVENTTYPE:" + ssName); + } + if (flow != -1) { + this.flow = flow; + String firstState = StateConfig.arrFirstStateFlow[flow-1]; + if (this.debug) { + AppLog.d("## FLOW:" + this.flow); + AppLog.d("## FIRST STATE:" + firstState); + } + if (ssName.equals(firstState) && !ArrayUtils.contains(Constant.arrSingleFlow, this.flow)) { + this.setInstance(new AFInstance()); + if (this.debug) { + AppLog.d("## CASE START STATE FOR MULTI FLOW::NEW INSTANCE"); + } + } else if (/*ssName.equals(firstState) && */ArrayUtils.contains(Constant.arrSingleFlow, this.flow)) { + this.setInstanceForFlow(flow); + if (this.debug) { + AppLog.d("## CASE SINGLE FLOW::GET INSTANCE FOR FLOW:" + this.flow); + } + } else { // not first state + this.setInstanceForFlow(flow); + if (this.debug) { + AppLog.d("## CASE NOT FIRST STATE::GET INSTANCE FOR FLOW:" + this.flow); + } + } + } else { // +// if (eventType.equals(StateConfig.Incoming_DRR_Request) || eventType.equals(StateConfig.Incoming_DUR_Request)) { +// String key = "Dialogue-Id"; +// String dialogueId = this.equinoxRawData.getRawDataAttribute(key); +// this.equinoxRawData.getRawDataAttributes().remove(key); +// // SET FLOW from Dialogue-Id +// this.setInstanceForDialogueId(dialogueId); +// if (this.debug) { +// AppLog.d("## CASE DRR/DUR REQUEST::GET INSTANCE FOR DIALOGUE_ID:" + dialogueId); +// } +// } else { // impossible. + int index = this.listFlow.size() - 1; + FMInstance ins = this.listFlow.get(index); + this.listFlow.remove(index); + AFInstance data = (AFInstance) MessageParser.fromJson(ins.getData(), AFInstance.class); + this.setInstance(data); + if (this.debug) { + AppLog.d("## CASE IMPOSSIBLE::GET INSTANCE FOR INDEX:" + index); + } +// } + } +// } else if (type.toLowerCase().equals("response") && (ret.equals("1") || ret.equals("2") || ret.equals("3"))) { +// int index = this.listFlow.size() - 1; +// FMInstance ins = this.listFlow.get(index); +// this.listFlow.remove(index); +// AFInstance data = (AFInstance) MessageParser.fromJson(ins.getData(), AFInstance.class); +// this.setInstance(data); +// if (this.debug) { +// AppLog.d("## CASE IMPOSSIBLE::GET INSTANCE FOR INDEX:" + index); +// } + } else { + String invoke = equinoxRawData.getInvoke(); + this.setInstanceForInvoke(invoke); + if (this.debug) { + AppLog.d("## CASE RESPONE MESSAGE::GET INSTANCE FOR INVOKE:" + invoke); + } + } + } + } +// } catch (Exception e) { +// if (this.debug) { +// AppLog.d("## EXCEPTION(GET START MULTI FLOW):" + e); +// } +// int index = this.listFlow.size() - 1; +// FMInstance ins = this.listFlow.get(index); +// this.listFlow.remove(index); +// AFInstance data = (AFInstance) MessageParser.fromJson(ins.getData(), AFInstance.class); +// this.setInstance(data); +// } + } else { + if (this.debug) { + AppLog.d("## FLOWMANAGER START"); + AppLog.d("## 1.START FLOW TIMESTAMP:" + this.ec02Instance.getAFInstance().getStartFlowTimeStamp()); + AppLog.d("## 2.INPUT TIMESTAMP:" + Global.inputTimeStamp); + AppLog.d("## 3.CURRENT START:" + this.ec02Instance.getAFInstance().getCurrentState()); + } + } + if (this.debug) { + AppLog.d("## GET INSTANCE START FLOW TIMESTAMP:" + this.ec02Instance.getAFInstance().getStartFlowTimeStamp()); + } + } + public void end(String curState, String nxtState, List eqxRawDataListInput, List eqxRawDataListOutput) + { + Log.detailLog(this.ec02Instance, this.abstractAF, curState, nxtState, eqxRawDataListInput, eqxRawDataListOutput); + Log.summaryLog(this.ec02Instance, this.abstractAF); + this.listFlow = this.ec02Instance.getAFInstance().getListFlow(); + this.dicInvoke = this.ec02Instance.getAFInstance().getDicInvoke(); + this.globalDialogueId = this.ec02Instance.getAFInstance().getGlobalDialogueId(); + this.globalListTimeout = this.ec02Instance.getAFInstance().getGlobalListTimeout(); + // clear + this.ec02Instance.getAFInstance().setListFlow(null); + this.ec02Instance.getAFInstance().setDicInvoke(null); + this.ec02Instance.getAFInstance().setGlobalListTimeout(null); + if (!nxtState.equals(StateConfig.STATE_IDLE)) { +// Gson gsonBuilder = new GsonBuilder().create(); + AFInstance af = this.ec02Instance.getAFInstance(); + String data = Global.encodeInstance(af); + int flow = af.getFlow(); + String date = af.getStartFlowTimeStamp(); + String dialogueId = af.getDialogueIdForMultiFlow(); + String unique = Global.getUnique(); + FMInstance newIns = new FMInstance(flow, date, data, dialogueId); + newIns.setUnique(unique); + if (this.debug) { + AppLog.d("## FLOWMANAGER END"); + AppLog.d("## FLOW:" + flow); + AppLog.d("## DATE:" + date); + AppLog.d("## DIALOGUE_ID:" + dialogueId); + AppLog.d("## UNIQUE:" + unique); + } + ManageTime mTimeout = new ManageTime(this.ec02Instance); + Timeout ins = mTimeout.getInsTime(); + if (ins != null) { + ManageTime mt = new ManageTime(); + mt.setListTimeout(this.ec02Instance.getAFInstance().getGlobalListTimeout()); + mt.setTimeout(newIns.getUnique(), "" + ins.getTimeout(), ins.getDate()); + this.ec02Instance.getAFInstance().setGlobalListTimeout(mt.getListTimeout()); + } +// this.ec02Instance.getAFInstance().putListFlow(newIns); + this.listFlow = this.listFlow == null ? new ArrayList() : this.listFlow; + this.listFlow.add(newIns); + if (this.debug) { + AppLog.d("## LIST FLOW COUNT:" + this.listFlow.size()); + } + } +// this.ec02Instance.getAFInstance().setStartFlowTimeStamp(""); + if (this.debug) { + AppLog.d("####### TABLE LISTFLOW #######"); + AppLog.d("## SIZE:" + this.listFlow.size()); + AppLog.d("------------------------------"); + for (FMInstance i : this.listFlow) { + AppLog.d(i.toString()); + } + AppLog.d("############# END ############"); + AppLog.d("####### TABLE DIC INVOKE #######"); + AppLog.d("## SIZE:" + this.dicInvoke.size()); + AppLog.d("------------------------------"); + if (this.dicInvoke != null) { + Iterator it = this.ec02Instance.getAFInstance().getDicInvoke().entrySet().iterator(); + while (it.hasNext()) { + @SuppressWarnings("rawtypes") + Map.Entry pair = (Map.Entry)it.next(); + AppLog.d(pair.getKey()+ ":" + pair.getValue().toString()); + } + } + AppLog.d("############# END ############"); + } + + this.setInstance(new AFInstance()); + } + + public FMInstance find(FMInstance ins) + { + if (this.debug) { + AppLog.d("####### TABLE LISTFLOW #######"); + AppLog.d("## SIZE:" + this.listFlow.size()); + AppLog.d("------------------------------"); + for (FMInstance i : this.listFlow) { + AppLog.d(i.toString()); + } + AppLog.d("############# END ############"); + AppLog.d("FMInstance find:" + ins.toString()); + } + + FMInstance newIns = null; + for (FMInstance i : this.listFlow) { + if (ins.getUnique() != null && i.getUnique().equals(ins.getUnique())) { +// AppLog.d("## unique"); +// AppLog.d("unique:" + ins.getUnique()); + newIns = i; + break; + } else if (ins.getDialogueId() != null) { +// AppLog.d("## dialogueId"); + if (i.getDialogueId().equals(ins.getDialogueId())) { +// AppLog.d("getDialogueId:" + ins.getDialogueId()); + newIns = i; + break; + } + } else if (ins.getDate() != null) { +// AppLog.d("## date"); + if (i.getFlow() == ins.getFlow() && i.getDate().equals(ins.getDate())) { +// AppLog.d("flow:" + i.getFlow() + " date:" + i.getDate()); + newIns = i; + break; + } + } else { +// AppLog.d("## flow"); + if (i.getFlow() == ins.getFlow()) { +// AppLog.d("flow:" + i.getFlow() ); + newIns = i; + break; + } + } + } + // remove + if (newIns != null) { + this.listFlow.remove(newIns); + if (this.debug) { + AppLog.d("## REMOVE:" +newIns.getFlow() + " " + newIns.getDate() + " " + newIns.getUnique()); + AppLog.d("## globalListTimeout:" + this.globalListTimeout.size()); + } + // remove globalListTimeout + try { + Timeout mIns = null; + for (Timeout mt : this.globalListTimeout) { + if (newIns.getUnique() != null && mt.getName() != null && mt.getName().equals(newIns.getUnique())){ + mIns = mt; + break; + } + } + // check remove + if (mIns != null) { + this.globalListTimeout.remove(mIns); + } + if (this.debug) { + AppLog.d("## REMOVE GLOBAL_LIST_TIMEOUT COUNT:" + this.globalListTimeout.size()); + } + } catch (Exception e) { + if (this.debug) { + AppLog.e("## Exception(remove globalListTimeout:" + this.globalListTimeout.size() + "):" + e.getMessage()); + } + } + } + return newIns; + } + public void setInstance(AFInstance ins) + { + ins.setListFlow(this.listFlow); + ins.setDicInvoke(this.dicInvoke); + ins.setGlobalDialogueId(this.globalDialogueId); + ins.setGlobalListTimeout(this.globalListTimeout); + if (ins.getStartFlowTimeStamp() == null && this.ec02Instance.getAFInstance().getStartFlowTimeStamp() != null) { + ins.setStartFlowTimeStamp(this.ec02Instance.getAFInstance().getStartFlowTimeStamp()); + } + // set instance + this.ec02Instance.setAFInstance(ins); + if (this.debug) { + AppLog.d("## FUNCTION SET INSTANCE"); + AppLog.d("## 1.START FLOW TIMESTAMP:" + ins.getStartFlowTimeStamp()); + AppLog.d("## 2.INPUT TIMESTAMP:" + this.ec02Instance.getAFInstance().getStartFlowTimeStamp()); + } + } + public void setInstanceForInvoke(String invoke) + { +// AppLog.d("#d# invoke :" + invoke); + FMInstance ins = this.dicInvoke.get(invoke); +// AppLog.d("setInstanceForInvoke:" + ins.getFlow() + " " + ins.getDate()); + this.dicInvoke.remove(invoke); + this.setInstance(ins); + } + public void setInstanceForFlow(int flow) + { + FMInstance ins = new FMInstance(flow); +// AppLog.d(ins.toString()); + this.setInstance(ins); + } + public void setInstanceForDialogueId(String dialogueId) + { + FMInstance ins = new FMInstance(flow, null, null, dialogueId); + this.setInstance(ins); + + } + public void setInstanceForUnique(String unique) + { + FMInstance ins = new FMInstance(); + ins.setUnique(unique); + ArrayList listTimeout = this.ec02Instance.getAFInstance().getListTimeout(); + for (Timeout timeout : listTimeout) { + this.dicInvoke.remove(timeout.getName()); + } + this.setInstance(ins); + } + public void setInstance(FMInstance ins) + { + if (this.debug) { + AppLog.d("## FIND AF_INSTANCE"); + AppLog.d(ins.toString()); + } + try { + ins = this.find(ins); + if (ins == null) { + this.setInstance(new AFInstance()); + if (this.debug) { + AppLog.d("## NOSUCH OBJECT::NEW AF_INSTANCE"); + } + } else { +// AFInstance data = (AFInstance) MessageParser.fromJson(ins.getData(), AFInstance.class); + AFInstance data = Global.decodeInstance(ins.getData()); + this.setInstance(data); + if (this.debug) { + AppLog.d("## OBJECT DATA"); + AppLog.d("## 1.FLOW:" + data.getFlow()); + AppLog.d("## 2.START FLOW TIMESTAMP:" + data.getStartFlowTimeStamp()); + } + } + } catch (Exception e) { + if (this.debug) { + AppLog.e("## EXCEPTION:" + e.getMessage()); + } + } + } + public AbstractAF getAbstractAF() { + return abstractAF; + } + public void setAbstractAF(AbstractAF abstractAF) { + this.abstractAF = abstractAF; + } + public EC02Instance getEc02Instance() { + return ec02Instance; + } + public void setEc02Instance(EC02Instance ec02Instance) { + this.ec02Instance = ec02Instance; + } + public int getFlow() { + return flow; + } + public void setFlow(int flow) { + this.flow = flow; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public FMInstance getIns() { + return ins; + } + public void setIns(FMInstance ins) { + this.ins = ins; + } + public ArrayList getListFlow() { + return listFlow; + } + public void setListFlow(ArrayList listFlow) { + this.listFlow = listFlow; + } + public Map getDicInvoke() { + return dicInvoke; + } + public void setDicInvoke(Map dicInvoke) { + this.dicInvoke = dicInvoke; + } + public AFInstance getAfInstance() { + return afInstance; + } + public void setAfInstance(AFInstance afInstance) { + this.afInstance = afInstance; + } + public ArrayList getListTimeout() { + return listTimeout; + } + public void setListTimeout(ArrayList listTimeout) { + this.listTimeout = listTimeout; + } + public EquinoxRawData getEquinoxRawData() { + return equinoxRawData; + } + public void setEquinoxRawData(EquinoxRawData equinoxRawData) { + this.equinoxRawData = equinoxRawData; + } +} diff --git a/src/th/co/ais/ssbsrfc/control/StateManager.java b/src/th/co/ais/ssbsrfc/control/StateManager.java new file mode 100644 index 0000000..de10c45 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/control/StateManager.java @@ -0,0 +1,20 @@ +package th.co.ais.ssbsrfc.control; + +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.state.StateIdle; +import th.co.ais.ssbsrfc.state.StateWaitActive; +import th.co.ais.ssbsrfc.state.StateWaitE11Timeout; +import ec02.af.abstracts.AbstractAFStateManager; + +public class StateManager extends AbstractAFStateManager { + public StateManager(String state) { + this.afState = null; + if (state.equals(StateConfig.STATE_IDLE)) { + this.afState = new StateIdle(); + } else if (state.equals(StateConfig.STATE_ACTIVE)) { + this.afState = new StateWaitActive(); + } else if (state.equals(StateConfig.STATE_E11_TIMEOUT)) { + this.afState = new StateWaitE11Timeout(); + } + } +} diff --git a/src/th/co/ais/ssbsrfc/control/SubStateManager.java b/src/th/co/ais/ssbsrfc/control/SubStateManager.java new file mode 100644 index 0000000..fd47420 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/control/SubStateManager.java @@ -0,0 +1,31 @@ +package th.co.ais.ssbsrfc.control; + +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.interfaces.AbstractAFSubStateManager; +import th.co.ais.ssbsrfc.substate.SubWaitA; +import th.co.ais.ssbsrfc.substate.SubWaitAdjustmentChargeReportResponse; +import th.co.ais.ssbsrfc.substate.SubWaitAdjustmentChargeRequestResponse; +import th.co.ais.ssbsrfc.substate.SubWaitChargeReport; +import th.co.ais.ssbsrfc.substate.SubWaitChargeRequest; +import ec02.utils.Log; + +public class SubStateManager extends AbstractAFSubStateManager { + + public SubStateManager(String subState) { + Log.i("[Sub State ] : " + subState); + this.subStateManager = null; + + if (subState.equals(StateConfig.SSTATE_W_CHARGEREQUEST)) { + this.subStateManager = new SubWaitChargeRequest(); + } + else if (subState.equals(StateConfig.SSTATE_W_CHARGEREPORT)) { + this.subStateManager = new SubWaitChargeReport(); + } + else if (subState.equals(StateConfig.SSTATE_W_ADJUSTMENT_CHARGEREPORT)) { + this.subStateManager = new SubWaitAdjustmentChargeReportResponse(); + } + else if (subState.equals(StateConfig.SSTATE_W_ADJUSTMENT_CHARGEREQUEST)) { + this.subStateManager = new SubWaitAdjustmentChargeRequestResponse(); + } + } +} diff --git a/src/th/co/ais/ssbsrfc/control/TestDebugMsg.java b/src/th/co/ais/ssbsrfc/control/TestDebugMsg.java new file mode 100644 index 0000000..4af93c2 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/control/TestDebugMsg.java @@ -0,0 +1,106 @@ +package th.co.ais.ssbsrfc.control; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileReader; +import java.io.IOException; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.xpath.XPathExpressionException; + +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import ec02.exception.MessageParserException; +import ec02.server.EC02Handler; +import ec02.server.EC02Server; + +public class TestDebugMsg { + public static void main(String[] args) throws IOException, + TransformerException, XPathExpressionException, + ParserConfigurationException, SAXException, MessageParserException { + + BufferedReader in = new BufferedReader(new FileReader( + "./example.msg/" + +// "debug.html-text-plain.xml" +// "debug.html-text-xml.xml" +// "debug.html-text-xml-header.xml" +// "debug.ldap.xml" +// "debug.diameter.xml" + "debug.xml" + )); + + String str, reqMessage = ""; + String conf = ""; + String temp = ""; + while ((str = in.readLine()) != null) { + reqMessage += str; + } + in.close(); + in = new BufferedReader(new FileReader("./conf/WS1.EC02.SERV.0")); + while ((temp = in.readLine()) != null) { + conf += temp; + } + in.close(); + String[] a = { "WS1", "SERV", "0", conf }; + + EC02Server.main(a); + EC02Handler handler = new EC02Handler(); + System.out.println(handler.verifyAFConfig(conf)); + System.out.println(TestDebugMsg.formatXml(handler.handle(reqMessage, + 100000))); + + // int max=100; + // for(int i=0; i<=max; i++) + // { + // ProcessingThread pt = new ProcessingThread(conf, reqMessage); + // Thread t = new Thread(pt, "t"+String.valueOf(i)); + // t.start(); + // } + } + + public static String formatXml(String xml) { + try { + Transformer serializer = TransformerFactory.newInstance() + .newTransformer(); + serializer.setOutputProperty(OutputKeys.INDENT, "yes"); + serializer.setOutputProperty( + "{http://xml.apache.org/xslt}indent-amount", "4"); + Source xmlSource = new SAXSource(new InputSource( + new ByteArrayInputStream(xml.getBytes()))); + StreamResult res = new StreamResult(new ByteArrayOutputStream()); + serializer.transform(xmlSource, res); + return new String( + ((ByteArrayOutputStream) res.getOutputStream()) + .toByteArray()); + } catch (Exception e) { + return xml; + } + } +} + +class ProcessingThread1 implements Runnable { + private String conf; + private String reqMessage; + + public ProcessingThread1(String _conf, String _msg) { + this.conf = _conf; + this.reqMessage = _msg; + } + + @Override + public void run() { + EC02Handler handler = new EC02Handler(); + System.out.println(handler.verifyAFConfig(conf)); + System.out.println(TestDebugMsg.formatXml(handler.handle(reqMessage, + 100000))); + } +} diff --git a/src/th/co/ais/ssbsrfc/control/TestMain.java b/src/th/co/ais/ssbsrfc/control/TestMain.java new file mode 100644 index 0000000..312144a --- /dev/null +++ b/src/th/co/ais/ssbsrfc/control/TestMain.java @@ -0,0 +1,142 @@ +package th.co.ais.ssbsrfc.control; + +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.stream.StreamSource; + + +@XmlAccessorType(XmlAccessType.FIELD) +class Customer { + + @XmlElement(name="Version",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String Version; + @XmlElement(name="ResultCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String ResultCode; + @XmlElement(name="MsgLanguageCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String MsgLanguageCode; + @XmlElement(name="ResultDesc",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String ResultDesc; + @XmlElement(name="AcctKey",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + String AcctKey; + + @XmlElement(name="AdjustmentInfo",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + List AdjustmentInfo; +} +class AdjustmentInfo{ + + String BalanceType; + String BalanceID; + String BalanceTypeName; + String OldBalanceAmt; + String NewBalanceAmt; + String CurrencyID; + + @XmlElement(name="BalanceID",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getBalanceID() { + return BalanceID; + } + + public void setBalanceID(String balanceID) { + BalanceID = balanceID; + } + + @XmlElement(name="BalanceTypeName",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getBalanceTypeName() { + return BalanceTypeName; + } + + public void setBalanceTypeName(String balanceTypeName) { + BalanceTypeName = balanceTypeName; + } + + @XmlElement(name="OldBalanceAmt",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getOldBalanceAmt() { + return OldBalanceAmt; + } + + public void setOldBalanceAmt(String oldBalanceAmt) { + OldBalanceAmt = oldBalanceAmt; + } + + @XmlElement(name="NewBalanceAmt",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getNewBalanceAmt() { + return NewBalanceAmt; + } + + public void setNewBalanceAmt(String newBalanceAmt) { + NewBalanceAmt = newBalanceAmt; + } + + @XmlElement(name="CurrencyID",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getCurrencyID() { + return CurrencyID; + } + + public void setCurrencyID(String currencyID) { + CurrencyID = currencyID; + } + + @XmlElement(name="BalanceType",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getBalanceType() { + return BalanceType; + } + + public void setBalanceType(String BalanceType) { + this.BalanceType = BalanceType; + } + + +} + + +public class TestMain { + + public static void main(String[] args) throws Exception { + + XMLInputFactory xif = XMLInputFactory.newFactory(); + StreamSource xml = new StreamSource("D:\\car.xml"); + XMLStreamReader xsr = xif.createXMLStreamReader(xml); + xsr.nextTag(); + while(!xsr.getLocalName().equals("ResultHeader")) { + xsr.nextTag(); + System.out.println(xsr.getLocalName()); + System.out.println(xsr.hasNext()); + } + System.out.println(xsr.hasNext()); + xsr.next(); + /*while(!xsr.getLocalName().equals("AdjustmentResult")) { + xsr.nextTag(); + }*/ + + JAXBContext jc = JAXBContext.newInstance(Customer.class); + Unmarshaller unmarshaller = jc.createUnmarshaller(); + JAXBElement jb = unmarshaller.unmarshal(xsr, Customer.class); + xsr.close(); + + Customer customer = jb.getValue(); + System.out.println("Version:"+customer.Version); + System.out.println("ResultCode:"+customer.ResultCode); + System.out.println("MsgLanguageCode:"+customer.MsgLanguageCode); + System.out.println("ResultDesc:"+customer.ResultDesc); + /*System.out.println("AcctKey:"+customer.AcctKey); + System.out.println("BalanceID:"+customer.AdjustmentInfo.get(0).getBalanceID()); + System.out.println("BalanceType:"+customer.AdjustmentInfo.get(0).getBalanceType()); + System.out.println("BalanceTypeName:"+customer.AdjustmentInfo.get(0).getBalanceTypeName()); + System.out.println("CurrencyID:"+customer.AdjustmentInfo.get(0).CurrencyID); + System.out.println("NewBalanceAmt:"+customer.AdjustmentInfo.get(0).NewBalanceAmt); + System.out.println("OldBalanceAmt:"+customer.AdjustmentInfo.get(0).OldBalanceAmt);*/ + + + } +} + diff --git a/src/th/co/ais/ssbsrfc/control/mainAF.java b/src/th/co/ais/ssbsrfc/control/mainAF.java new file mode 100644 index 0000000..e4ccc51 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/control/mainAF.java @@ -0,0 +1,129 @@ +package th.co.ais.ssbsrfc.control; + +import java.util.ArrayList; + +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.AFInstance; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.utils.Global; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.ECDialogue; +import ec02.af.data.EquinoxProperties; +import ec02.af.data.EquinoxRawData; +import ec02.af.exception.ActionProcessException; +import ec02.af.exception.ComposeInstanceException; +import ec02.af.exception.ConstructRawDataException; +import ec02.af.exception.ExtractInstanceException; +import ec02.af.exception.ExtractRawDataException; +import ec02.interfaces.IEC02; +import ec02.utils.AppLog; + +public class mainAF extends AbstractAF implements IEC02 { + + @Override + public ECDialogue actionProcess(EquinoxProperties eqxProp, + ArrayList eqxRawDataList, Object instance) + throws ActionProcessException { + AppLog.d("[CURRENT STATE] : " + eqxProp.getState()); + EC02Instance ec02Ins = (EC02Instance) instance; + ec02Ins.setEquinoxProperties(eqxProp); + ec02Ins.setAbstractAF((AbstractAF) this); + ec02Ins.getAFInstance().setStartFlowTimeStampForEmpty(); + + String currentState = eqxProp.getState(); + + StateManager sm = new StateManager(currentState); + String eqxState = sm.doAction((AbstractAF) this, ec02Ins, eqxRawDataList); + EquinoxProperties newEqxProp = new EquinoxProperties(); + newEqxProp.setState(eqxState); + // TODO must be have function to calculate timeout + newEqxProp.setTimeout(ec02Ins.getTimeout()); + ECDialogue ecDialogue = new ECDialogue(newEqxProp, ec02Ins); + return ecDialogue; + } + + @Override + public boolean verifyAFConfiguration(String arg0) { + // TODO Auto-generated method stub + return true; + } + + /* + * 5.4 ComposeInstance Module + */ + @Override + public String composeInstance(Object instance) throws ComposeInstanceException { + // 1. Read instance into variable + EC02Instance ec02Instance = (EC02Instance) instance; + AFInstance afInstance = ec02Instance.getAFInstance(); + String encodeString = ""; + // 2. try to encode instanceData bean object into string format + try { + encodeString = Global.encodeInstance(afInstance); + } + catch (Exception e) { + e.printStackTrace(); + } + // 3. return instanceData in string format + return encodeString; + } + + /* + * 5.3 ConstructRawData Module + */ + @Override + public ArrayList constructRawData(Object instance) + throws ConstructRawDataException { + // 1. Read instance into variable + EC02Instance ins = (EC02Instance) instance; + ArrayList list = ins.getEqxRawDataList(); + // 2. Return equinox raw data + return list; + } + + /* + * 5.1 ExtractInstance Module + */ + @Override + public Object extractInstance(String instance) throws ExtractInstanceException { + + EC02Instance ec02Instance = new EC02Instance(); + AFInstance afInstance = null; + + // 1. Check instance data from equinox is null or not + if ((instance == null) || instance.isEmpty()) { + // 1.1. If instance data is null, create new instanceData bean object + afInstance = new AFInstance(); + } + else { + // 1.2. If instance data is not null, try to decode instance to instanceData bean object + try { + afInstance = Global.decodeInstance(instance); + } + catch (Exception e) { + e.printStackTrace(); + } + } + ec02Instance.setAFInstance(afInstance); + // 2. return instanceData bean object + return (Object) ec02Instance; + } + + /* + * 5.2 ExtractRawData Module + */ + @Override + public void extractRawData(Object instanceData, ArrayList rawDatas) + throws ExtractRawDataException { + EC02Instance ec02Instance = (EC02Instance) instanceData; + // 1. Loop RawData + for (EquinoxRawData r : rawDatas) { + // 1.1. Get event type from equinox raw data + String eventType = StateConfig.getEventTypeFromEquinoxRawData(ec02Instance, r); + // 1.1.7. Set raw event type = event type + r.setRawEventType(eventType); + ec02Instance.getAFInstance().listTimeoutRemove(r.getInvoke()); + AppLog.d("[eventType] : " + eventType); + } + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/AFInstance.java b/src/th/co/ais/ssbsrfc/instance/AFInstance.java new file mode 100644 index 0000000..e0f1ff6 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AFInstance.java @@ -0,0 +1,424 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import th.co.ais.ssbsrfc.config.Invoke; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.interfaces.EQXMsg; +import th.co.ais.ssbsrfc.utils.Global; +import th.co.ais.ssbsrfc.utils.Log; +import ais.mmt.sand.comlog.DetailsLogPrototype; +import ais.mmt.sand.comlog.SummaryLogPrototype; +import ec02.utils.AppLog; + +public class AFInstance { + + private int gDialogueId = -1; + private ArrayList listFlow; + private Map dicInvoke; + private ArrayList globalListTimeout; + // managetimeout + private ArrayList listTimeout; + private int flow = 0; + private ArrayList input = null; /** Detail Log Input **/ + private ArrayList output = null; /** Detail Log Output **/ + private ArrayList listStat; + private ArrayList listConditionStat; + private SummaryLogPrototype sumlog = null; /** Summary Log **/ + private DetailsLogPrototype detaillog = null; /** Detail Log **/ + private BackupSummary backupSummary = null; + private Map mapHttpData = null; + private HashMap listOrig; + private String orig = null; + private String invoke = null; + private String currentState = StateConfig.SSTATE_END; + private String previousState = StateConfig.SSTATE_BEGIN; + private String outgoingStateTimeStamp = null; + private String startFlowTimeStamp = null; + private String initialInvoke = null; + private String resultCode = null; + private String resultDescription = null; + private String responseTime = null; + private String processingTime = null; + private String acknowledgeTime = null; + private String dialogueId = null; + private Map dicRetry = null; + + private AdjustmentRequestIns adjustmentRequestIns = null; + + public AdjustmentRequestIns getAdjustmentRequestIns() { + return adjustmentRequestIns; + } + public void setAdjustmentRequestIns(AdjustmentRequestIns adjustmentRequestIns) { + this.adjustmentRequestIns = adjustmentRequestIns; + } + public String getOrig() { + return orig; + } + public void setOrig(String orig) { + this.orig = orig; + } + public String getInvoke() { + return invoke; + } + public void setInvoke(String invoke) { + this.invoke = invoke; + } + public String getCurrentState() { + return currentState; + } + public void setCurrentState(String currentState) { + if (this.currentState.equals(StateConfig.SSTATE_END)) { + this.setPreviousState(StateConfig.SSTATE_BEGIN); + } else if (!this.currentState.equals(currentState)) { + this.setPreviousState(this.currentState); + } + this.currentState = currentState; + } + public String getPreviousState() { + return previousState; + } + public void setPreviousState(String previousState) { + this.previousState = previousState; + } + public Map getMapHttpData() { + if (mapHttpData == null) { + mapHttpData = new HashMap(); + } + return mapHttpData; + } + + public void setMapHttpData(Map mapHttpData) { + this.mapHttpData = mapHttpData; + } + public HashMap getListOrig() { + if (listOrig == null) { + listOrig = new HashMap(); + } + return listOrig; + } + + public void setListOrig(HashMap listOrig) { + this.listOrig = listOrig; + } + + public void setListOrigKey(String key, Response value) { + this.listOrig.put(key, value); + } + + public Response getListOrigForKey(String key) { + return listOrig.get(key); + } + + public void setListOrigKeyRemove(String key) { + this.listOrig.remove(key); + } + + public int getFlow() { + return flow; + } + public void setFlow(int flow) { + if (this.flow == 0) { + this.flow = flow; + Global.flow = flow; + } + } + public void setForceFlow(int flow) { + this.flow = flow; + } + public void clearFlow() + { + this.flow = 0; + } + public ArrayList getListTimeout() { + if (listTimeout == null) { + listTimeout = new ArrayList(); + } + return listTimeout; + } + public void setListTimeout(ArrayList listTimeout) { + this.listTimeout = listTimeout; + } + public void listTimeoutRemove(String name) { + ArrayList lTimeout = this.getListTimeout(); + for (Timeout timeout : lTimeout) { + if (timeout.getName() != null && timeout.getName().equals(name)) { + this.getListTimeout().remove(timeout); + break; + } + } + // check remove all for eventType + listTimeoutRemoveForEventType(new Invoke(name).eventType); + } + public void listTimeoutRemoveForEventType(String _eventType) { + ArrayList lTimeout = new ArrayList(); + for (Timeout timeout : this.getListTimeout()) { + if (timeout.getName() != null & timeout.getName().contains(".")) { + String eventType = new Invoke(timeout.getName()).eventType; + if (eventType.equals(_eventType)) { + lTimeout.add(timeout); + } + } + } + for (Timeout timeout : lTimeout) { + this.getListTimeout().remove(timeout); + if (Log.debug) { + AppLog.d("## RM TIMEOUT :" + timeout.getName()); + } + } + } + + public boolean isTimeoutFotEventType(String _eventType) { + boolean isTrue = false; + for (Timeout timeout : this.getListTimeout()) { + if (timeout.getName() != null & timeout.getName().contains(".")) { + String eventType = new Invoke(timeout.getName()).eventType; + if (eventType.equals(_eventType)) { + isTrue = true; + } + } + } + return isTrue; + } + + public ArrayList getGlobalListTimeout() { + return globalListTimeout; + } + public void setGlobalListTimeout(ArrayList globalListTimeout) { + this.globalListTimeout = globalListTimeout; + } + public String getOutgoingStateTimeStamp() { + return outgoingStateTimeStamp; + } + public void setOutgoingStateTimeStamp(String outgoingStateTimeStamp) { + this.outgoingStateTimeStamp = outgoingStateTimeStamp; + } + public String getInitialInvoke() { + return initialInvoke; + } + public void setInitialInvoke(String initialInvoke) { + if (this.initialInvoke == null) { + this.initialInvoke = initialInvoke; + } + } + public void setForceInitialInvoke(String initialInvoke) { + this.initialInvoke = initialInvoke; + } + public void clearInitialInvoke() { + this.initialInvoke = null; + } + public String getStartFlowTimeStamp() { + return startFlowTimeStamp; + } + public void setStartFlowTimeStamp(String startFlowTimeStamp) { + this.startFlowTimeStamp = startFlowTimeStamp; + } + public String getResultCode() { + String tmp = resultCode; + if (resultCode == null || resultCode.equals(EQXMsg.EMPTY)) { + tmp = "null"; + } + return tmp; + } + public void setResultCode(String resultCode) { + if (resultCode != null && !resultCode.equals("null")) { + this.resultCode = resultCode; + } + } + public String getResultDescription() { + String tmp = resultDescription; + if (resultDescription == null || resultDescription.equals(EQXMsg.EMPTY)) { + tmp = "null"; + } + return tmp; + } + public void setResultDescription(String resultDescription) { + if (resultDescription != null && !resultDescription.equals("null")) { + this.resultDescription = resultDescription; + } + } + public void setStartFlowTimeStampForEmpty() { + long currentDateTime = System.currentTimeMillis(); + String timeStamp = Global.getTimeStampLog(currentDateTime); + if (this.startFlowTimeStamp == null) { + this.startFlowTimeStamp = timeStamp; + Global.currentInputDateTime = currentDateTime; + } + this.setInputTimeStamp(timeStamp); + } + public void setInputTimeStamp(String inputTimeStamp) { + boolean bool = this.isOutgoingStateTimeStamp(); + if (bool) { + long responseTime = 0; + try { + String input = this.getOutgoingStateTimeStamp(); + String output = inputTimeStamp; + responseTime = Global.diffTimeStampLog(input, output); + } catch (Exception e) { + responseTime = 0; + } + this.setResponseTime("" + responseTime); + } + Global.inputTimeStamp = inputTimeStamp; + } + public boolean isOutgoingStateTimeStamp() { + boolean bool = false; + if (this.outgoingStateTimeStamp != null) { + bool = true; + } + return bool; + } + public String getResponseTime() { + return responseTime; + } + public void setResponseTime(String responseTime) { + this.responseTime = responseTime; + } + public String getProcessingTime() { + return processingTime; + } + public void setProcessingTime(String processingTime) { + this.processingTime = processingTime; + } + public String getAcknowledgeTime() { + return acknowledgeTime; + } + public void setAcknowledgeTime(String acknowledgeTime) { + this.acknowledgeTime = acknowledgeTime; + } + public void putInput(Object input) { + if (this.input == null) { + this.input = new ArrayList(); + } + this.input.add(input); + } + public void putOutput(Object output) { + if (this.output == null) { + this.output = new ArrayList(); + } + this.output.add(output); + } + + public ArrayList getInput() { + return input; + } + public void setInput(ArrayList input) { + this.input = input; + } + public ArrayList getOutput() { + return output; + } + public void setOutput(ArrayList output) { + this.output = output; + } + public ArrayList getListStat() { + if (this.listStat == null) { + this.listStat = new ArrayList(); + } + return listStat; + } + public void setListStat(ArrayList listStat) { + this.listStat = listStat; + } + public ArrayList getListFlow() { + if (listFlow == null) { + listFlow = new ArrayList(); + } + return listFlow; + } + public void setListFlow(ArrayList listFlow) { + this.listFlow = listFlow; + } + public void putListFlow(FMInstance ins) + { + this.listFlow.add(ins); + } + public void removeListFlow(FMInstance ins) + { + this.listFlow.remove(ins); + } + public Map getDicInvoke() { + if (dicInvoke == null) { + dicInvoke = new LinkedHashMap(); + } + return dicInvoke; + } + public void setDicInvoke(Map dicInvoke) { + this.dicInvoke = dicInvoke; + } + public void putDicInvoke(String key, FMInstance value) + { + this.getDicInvoke().put(key, value); + } + public SummaryLogPrototype getSumlog() { + if (sumlog == null) { + sumlog = SummaryLogPrototype.getInstance(StateConfig.PROJECT_NAME); + } + return sumlog; + } + public void setSumlog(SummaryLogPrototype sumlog) { + this.sumlog = sumlog; + } + public DetailsLogPrototype getDetaillog() { + if (detaillog == null) { + detaillog = DetailsLogPrototype.getInstance(StateConfig.PROJECT_NAME); + } + return detaillog; + } + public void setDetaillog(DetailsLogPrototype detaillog) { + this.detaillog = detaillog; + } + public BackupSummary getBackupSummary() { + if (this.backupSummary == null) { + this.backupSummary = new BackupSummary(); + } + return backupSummary; + } + public void setBackupSummary(BackupSummary backupSummary) { + this.backupSummary = backupSummary; + } + public String getDialogueId() { + if(this.gDialogueId == -1) { + this.gDialogueId = Global.minDialogueId; + } + this.dialogueId = String.format("%02d", this.gDialogueId); + this.gDialogueId++; + if(this.gDialogueId == Global.maxDialogueId + 1) { + this.gDialogueId = Global.minDialogueId; + } + return dialogueId; + } + public String getDialogueIdForMultiFlow() { + return dialogueId; + } + public void setDialogueId(String dialogueId) { + this.dialogueId = dialogueId; + } + public int getGlobalDialogueId() { + return this.gDialogueId; + } + public void setGlobalDialogueId(int globalDialogueId) { + this.gDialogueId = globalDialogueId; + } + public ArrayList getListConditionStat() { + if (this.listConditionStat == null) { + this.listConditionStat = new ArrayList(); + } + return this.listConditionStat; + } + public void setListConditionStat(ArrayList listConditionStat) { + this.listConditionStat = listConditionStat; + } + public Map getDicRetry() { + if (this.dicRetry == null) { + this.dicRetry = new LinkedHashMap(); + } + return this.dicRetry; + } + public void setDicRetry(Map dicRetry) { + this.dicRetry = dicRetry; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/AccessSecurity.java b/src/th/co/ais/ssbsrfc/instance/AccessSecurity.java new file mode 100644 index 0000000..e3014fa --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AccessSecurity.java @@ -0,0 +1,26 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; + +public class AccessSecurity { + + private String LoginSystemCode; + private String Password; + + @XmlElement(name="LoginSystemCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getLoginSystemCode() { + return LoginSystemCode; + } + public void setLoginSystemCode(String loginSystemCode) { + LoginSystemCode = loginSystemCode; + } + + @XmlElement(name="Password",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getPassword() { + return Password; + } + public void setPassword(String password) { + Password = password; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/AdjustmentInfo.java b/src/th/co/ais/ssbsrfc/instance/AdjustmentInfo.java new file mode 100644 index 0000000..d72875a --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AdjustmentInfo.java @@ -0,0 +1,80 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; + +public class AdjustmentInfo { + + String BalanceType; + String AdjustmentType; + String AdjustmentAmt; + String CurrencyID; + String BalanceID; + String BalanceTypeName; + String OldBalanceAmt; + String NewBalanceAmt; + + @XmlElement(name="BalanceType",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getBalanceType() { + return BalanceType; + } + public void setBalanceType(String balanceType) { + BalanceType = balanceType; + } + + @XmlElement(name="AdjustmentType",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getAdjustmentType() { + return AdjustmentType; + } + public void setAdjustmentType(String adjustmentType) { + AdjustmentType = adjustmentType; + } + + @XmlElement(name="BalanceID",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getBalanceID() { + return BalanceID; + } + public void setBalanceID(String balanceID) { + BalanceID = balanceID; + } + + @XmlElement(name="BalanceTypeName",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getBalanceTypeName() { + return BalanceTypeName; + } + public void setBalanceTypeName(String balanceTypeName) { + BalanceTypeName = balanceTypeName; + } + + @XmlElement(name="OldBalanceAmt",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getOldBalanceAmt() { + return OldBalanceAmt; + } + public void setOldBalanceAmt(String oldBalanceAmt) { + OldBalanceAmt = oldBalanceAmt; + } + + @XmlElement(name="NewBalanceAmt",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getNewBalanceAmt() { + return NewBalanceAmt; + } + public void setNewBalanceAmt(String newBalanceAmt) { + NewBalanceAmt = newBalanceAmt; + } + + @XmlElement(name="AdjustmentAmt",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getAdjustmentAmt() { + return AdjustmentAmt; + } + public void setAdjustmentAmt(String adjustmentAmt) { + AdjustmentAmt = adjustmentAmt; + } + + @XmlElement(name="CurrencyID",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getCurrencyID() { + return CurrencyID; + } + public void setCurrencyID(String currencyID) { + CurrencyID = currencyID; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/AdjustmentObj.java b/src/th/co/ais/ssbsrfc/instance/AdjustmentObj.java new file mode 100644 index 0000000..d27e458 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AdjustmentObj.java @@ -0,0 +1,18 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; + +public class AdjustmentObj { + + private SubAccessCode subAccessCode; + + @XmlElement(name="SubAccessCode",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + public SubAccessCode getSubAccessCode() { + return subAccessCode; + } + + public void setSubAccessCode(SubAccessCode subAccessCode) { + this.subAccessCode = subAccessCode; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/AdjustmentRequest.java b/src/th/co/ais/ssbsrfc/instance/AdjustmentRequest.java new file mode 100644 index 0000000..0c3d965 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AdjustmentRequest.java @@ -0,0 +1,40 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; + +public class AdjustmentRequest { + + private String AdjustmentSerialNo; + private AdjustmentObj adjustmentObj; + private String OpType; + private AdjustmentInfo adjustmentInfo; + + @XmlElement(name="AdjustmentSerialNo",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + public String getAdjustmentSerialNo() { + return AdjustmentSerialNo; + } + public void setAdjustmentSerialNo(String adjustmentSerialNo) { + AdjustmentSerialNo = adjustmentSerialNo; + } + @XmlElement(name="AdjustmentObj",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + public AdjustmentObj getAdjustmentObj() { + return adjustmentObj; + } + public void setAdjustmentObj(AdjustmentObj adjustmentObj) { + this.adjustmentObj = adjustmentObj; + } + @XmlElement(name="OpType",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + public String getOpType() { + return OpType; + } + public void setOpType(String opType) { + OpType = opType; + } + @XmlElement(name="AdjustmentInfo",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + public AdjustmentInfo getAdjustmentInfo() { + return adjustmentInfo; + } + public void setAdjustmentInfo(AdjustmentInfo adjustmentInfo) { + this.adjustmentInfo = adjustmentInfo; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/AdjustmentRequestIns.java b/src/th/co/ais/ssbsrfc/instance/AdjustmentRequestIns.java new file mode 100644 index 0000000..2b7229f --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AdjustmentRequestIns.java @@ -0,0 +1,30 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement(name = "AdjustmentRequestMsg", namespace="http://www.huawei.com/bme/cbsinterface/arservices") +@XmlType (propOrder={"requestHeader", "adjustmentRequest"}) +public class AdjustmentRequestIns { + + + private RequestHeader RequestHeader; + private AdjustmentRequest AdjustmentRequest; + + @XmlElement(name="RequestHeader") + public RequestHeader getRequestHeader() { + return RequestHeader; + } + public void setRequestHeader(RequestHeader RequestHeader) { + this.RequestHeader = RequestHeader; + } + @XmlElement(name="AdjustmentRequest") + public AdjustmentRequest getAdjustmentRequest() { + return AdjustmentRequest; + } + public void setAdjustmentRequest(AdjustmentRequest AdjustmentRequest) { + this.AdjustmentRequest = AdjustmentRequest; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/AdjustmentResponseIns.java b/src/th/co/ais/ssbsrfc/instance/AdjustmentResponseIns.java new file mode 100644 index 0000000..8c9d2a2 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AdjustmentResponseIns.java @@ -0,0 +1,95 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement(name="AdjustmentRequestMsg",namespace ="http://www.huawei.com/bme/cbsinterface/arservices") +public class AdjustmentResponseIns { + + @XmlElement(name="Version",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String Version; + @XmlElement(name="ResultCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String ResultCode; + @XmlElement(name="MsgLanguageCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String MsgLanguageCode; + public String getVersion() { + return Version; + } + + public void setVersion(String version) { + Version = version; + } + + public String getResultCode() { + return ResultCode; + } + + public void setResultCode(String resultCode) { + ResultCode = resultCode; + } + + public String getMsgLanguageCode() { + return MsgLanguageCode; + } + + public void setMsgLanguageCode(String msgLanguageCode) { + MsgLanguageCode = msgLanguageCode; + } + + public String getResultDesc() { + return ResultDesc; + } + + public void setResultDesc(String resultDesc) { + ResultDesc = resultDesc; + } + + public String getAcctKey() { + return AcctKey; + } + + public void setAcctKey(String acctKey) { + AcctKey = acctKey; + } + + public List getAdjustmentInfo() { + return AdjustmentInfo; + } + + public void setAdjustmentInfo(List adjustmentInfo) { + AdjustmentInfo = adjustmentInfo; + } + + @XmlElement(name="ResultDesc",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + String ResultDesc; + @XmlElement(name="AcctKey",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + String AcctKey; + + @XmlElement(name="AdjustmentInfo",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + List AdjustmentInfo; + + /*@XmlElement(name = "ResultHeader") + List resultHeader; + @XmlElement(name = "AdjustmentResult") + List adjustmentResult; + + @XmlElement(name = "ResultHeader") + public List getResultHeader() { + return resultHeader; + } + @XmlElement(name = "AdjustmentResult") + public List getAdjustmentResult() { + return adjustmentResult; + } + public void setResultHeader(List resultHeader) { + this.resultHeader = resultHeader; + } + public void setAdjustmentResult(List adjustmentResult) { + this.adjustmentResult = adjustmentResult; + }*/ + + +} \ No newline at end of file diff --git a/src/th/co/ais/ssbsrfc/instance/AdjustmentResult.java b/src/th/co/ais/ssbsrfc/instance/AdjustmentResult.java new file mode 100644 index 0000000..a9f2e73 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/AdjustmentResult.java @@ -0,0 +1,29 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; + +public class AdjustmentResult { + + private String AcctKey; + @XmlElement(name = "AdjustmentInfo",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + private List adjustmentInfo; + + @XmlElement(name="AcctKey",namespace="http://www.huawei.com/bme/cbsinterface/arservices") + public String getAcctKey() { + return AcctKey; + } + public void setAcctKey(String acctKey) { + AcctKey = acctKey; + } + public List getAdjustmentInfo() { + return adjustmentInfo; + } + public void setAdjustmentInfo(List adjustmentInfo) { + this.adjustmentInfo = adjustmentInfo; + } + + + +} diff --git a/src/th/co/ais/ssbsrfc/instance/BackupSummary.java b/src/th/co/ais/ssbsrfc/instance/BackupSummary.java new file mode 100644 index 0000000..c892447 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/BackupSummary.java @@ -0,0 +1,84 @@ +package th.co.ais.ssbsrfc.instance; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.utils.Global; +import ais.mmt.sand.comlog.SummaryLogPrototype; +import ec02.af.data.EquinoxRawData; + + +public class BackupSummary { + private int flow = -1; + private long requestTimestamp = -1; + private String initialInvoke = null; + private String resultCode = null; + private String resultDescription = null; + private SummaryLogPrototype sumLog = null; + + public BackupSummary() { + super(); + } + public void backup(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) { + AFInstance ins = ec02Instance.getAFInstance(); + this.flow = ins.getFlow(); + this.requestTimestamp = Global.currentInputDateTime; + this.initialInvoke = ins.getInitialInvoke(); + this.resultCode = ins.getResultCode(); + this.resultDescription = ins.getResultDescription(); + this.sumLog = ins.getSumlog(); + + String input = Global.inputTimeStamp; + long reqTimestamp = Global.convertTocurrentTimeMillis(input); + String invoke = (equinoxRawData != null) ? equinoxRawData.getInvoke() : ""; + + ec02Instance.getAFInstance().setForceFlow(Constant.FLOW_Unexpected_Event_Handling); + Global.currentInputDateTime = reqTimestamp; + ec02Instance.getAFInstance().setForceInitialInvoke(invoke); + ec02Instance.getAFInstance().setResultCode(null); + ec02Instance.getAFInstance().setResultDescription(null); + ec02Instance.getAFInstance().setSumlog(null); + } + public void restore(EC02Instance ec02Instance) { + ec02Instance.getAFInstance().setForceFlow(this.flow); + Global.currentInputDateTime = this.requestTimestamp; + ec02Instance.getAFInstance().setForceInitialInvoke(this.initialInvoke); + ec02Instance.getAFInstance().setResultCode(this.resultCode); + ec02Instance.getAFInstance().setResultDescription(this.resultDescription); + ec02Instance.getAFInstance().setSumlog(this.sumLog); + } + public int getFlow() { + return flow; + } + public void setFlow(int flow) { + this.flow = flow; + } + public long getRequestTimestamp() { + return requestTimestamp; + } + public void setRequestTimestamp(long requestTimestamp) { + this.requestTimestamp = requestTimestamp; + } + public String getInitialInvoke() { + return initialInvoke; + } + public void setInitialInvoke(String initialInvoke) { + this.initialInvoke = initialInvoke; + } + public String getResultCode() { + return resultCode; + } + public void setResultCode(String resultCode) { + this.resultCode = resultCode; + } + public String getResultDescription() { + return resultDescription; + } + public void setResultDescription(String resultDescription) { + this.resultDescription = resultDescription; + } + public SummaryLogPrototype getSumLog() { + return sumLog; + } + public void setSumLog(SummaryLogPrototype sumLog) { + this.sumLog = sumLog; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/ChargeReportIns.java b/src/th/co/ais/ssbsrfc/instance/ChargeReportIns.java new file mode 100644 index 0000000..32f4ee5 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/ChargeReportIns.java @@ -0,0 +1,29 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "vcrr") +@XmlAccessorType(XmlAccessType.FIELD) +public class ChargeReportIns { + + private String Result; + private String Prepaidsubscriberflag; + + public String getResult() { + return Result; + } + public void setResult(String result) { + Result = result; + } + public String getPrepaidsubscriberflag() { + return Prepaidsubscriberflag; + } + public void setPrepaidsubscriberflag(String prepaidsubscriberflag) { + Prepaidsubscriberflag = prepaidsubscriberflag; + } + + +} diff --git a/src/th/co/ais/ssbsrfc/instance/ChargeRequestIns.java b/src/th/co/ais/ssbsrfc/instance/ChargeRequestIns.java new file mode 100644 index 0000000..05ece4c --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/ChargeRequestIns.java @@ -0,0 +1,84 @@ +package th.co.ais.ssbsrfc.instance; + +public class ChargeRequestIns { + + private String page; + private String ms; + private String id; + private String mod; + private String cat; + private String dat; + private String fee; + private String pwd; + private String ssid; + private String nid; + private String scpid; + + public String getPage() { + return page; + } + public void setPage(String page) { + this.page = page; + } + public String getMs() { + return ms; + } + public void setMs(String ms) { + this.ms = ms; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getMod() { + return mod; + } + public void setMod(String mod) { + this.mod = mod; + } + public String getCat() { + return cat; + } + public void setCat(String cat) { + this.cat = cat; + } + public String getDat() { + return dat; + } + public void setDat(String dat) { + this.dat = dat; + } + public String getFee() { + return fee; + } + public void setFee(String fee) { + this.fee = fee; + } + public String getPwd() { + return pwd; + } + public void setPwd(String pwd) { + this.pwd = pwd; + } + public String getSsid() { + return ssid; + } + public void setSsid(String ssid) { + this.ssid = ssid; + } + public String getNid() { + return nid; + } + public void setNid(String nid) { + this.nid = nid; + } + public String getScpid() { + return scpid; + } + public void setScpid(String scpid) { + this.scpid = scpid; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/ChargeResponseIns.java b/src/th/co/ais/ssbsrfc/instance/ChargeResponseIns.java new file mode 100644 index 0000000..2cf57b4 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/ChargeResponseIns.java @@ -0,0 +1,73 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "vcrr") +@XmlAccessorType(XmlAccessType.FIELD) +public class ChargeResponseIns { + + @XmlElement(name = "res") + private Element Result; + @XmlElement(name = "desc") + private Element desc; + @XmlElement(name = "id") + private Element ChargingID; + @XmlElement(name = "ppf") + private Element Prepaidsubscriberflag; + + public String getResult() { + return getElementValue(this.Result); + } + + public void setResult(String Result) { + this.Result = setElementValue(this.Result, Result); + } + + public String getdesc() { + return getElementValue(this.desc); + } + + public void setdesc(String desc) { + this.desc = setElementValue(this.desc, desc); + } + + public String getChargingID() { + return getElementValue(this.ChargingID); + } + + public void setChargingID(String ChargingID) { + this.ChargingID = setElementValue(this.ChargingID, ChargingID); + } + + public String getPrepaidsubscriberflag() { + return getElementValue(this.Prepaidsubscriberflag); + } + + public void setPrepaidsubscriberflag(String Prepaidsubscriberflag) { + this.Prepaidsubscriberflag = setElementValue(this.Prepaidsubscriberflag, Prepaidsubscriberflag); + } + + public static String getElementValue(Element element) { + if(element == null) { + return null; + } else { + return element.getValue(); + } + } + + public static Element setElementValue(Element element, String value) { + if(value != null) { + if(element == null) { + element = new Element(); + } + element.setValue(value); + } else { + return null; + } + return element; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/CheckRequest.java b/src/th/co/ais/ssbsrfc/instance/CheckRequest.java new file mode 100644 index 0000000..7d0e5e8 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/CheckRequest.java @@ -0,0 +1,14 @@ +package th.co.ais.ssbsrfc.instance; + +public class CheckRequest { + private String dn; + + public String getDn() { + return dn; + } + + public void setDn(String dn) { + this.dn = dn; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/DetailLog.java b/src/th/co/ais/ssbsrfc/instance/DetailLog.java new file mode 100644 index 0000000..cb88735 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/DetailLog.java @@ -0,0 +1,54 @@ +package th.co.ais.ssbsrfc.instance; + + +public class DetailLog { + + private DetailLogDetail _projectName_ = null; + private String CurrentState = ""; + private String NextState = ""; + private long ProcessingTime = -1; + + public DetailLog () + { } + + public DetailLog(DetailLogDetail details, String currentState, + String nextState, long processingTime) { + super(); + this._projectName_ = details; + CurrentState = currentState; + NextState = nextState; + ProcessingTime = processingTime; + } + + public DetailLogDetail getDetail() { + return _projectName_; + } + + public void setDetail(DetailLogDetail details) { + this._projectName_ = details; + } + + public String getCurrentState() { + return CurrentState; + } + + public void setCurrentState(String currentState) { + CurrentState = currentState; + } + + public String getNextState() { + return NextState; + } + + public void setNextState(String nextState) { + NextState = nextState; + } + + public long getProcessingTime() { + return ProcessingTime; + } + + public void setProcessingTime(long processingTime) { + ProcessingTime = processingTime; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/DetailLogDetail.java b/src/th/co/ais/ssbsrfc/instance/DetailLogDetail.java new file mode 100644 index 0000000..387d080 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/DetailLogDetail.java @@ -0,0 +1,98 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; + +public class DetailLogDetail { + + private String Session = ""; + private String InitialInvoke = ""; + private String Scenario = ""; + private String MSISDN = ""; + private ArrayList Input = null; + private String InputTimeStamp = ""; + private ArrayList Output = null; + private String OutputTimeStamp = ""; + + public DetailLogDetail () + { } + + public DetailLogDetail(String session, String initialInvoke, String scenario, + String mSISDN, ArrayList input, String inputTimeStamp, + ArrayList output, String outputTimeStamp) { + super(); + Session = session; + InitialInvoke = initialInvoke; + Scenario = scenario; + MSISDN = mSISDN; + Input = input; + InputTimeStamp = inputTimeStamp; + Output = output; + OutputTimeStamp = outputTimeStamp; + } + + public String getSession() { + return Session; + } + + public void setSession(String session) { + Session = session; + } + + public String getInitialInvoke() { + return InitialInvoke; + } + + public void setInitialInvoke(String initialInvoke) { + InitialInvoke = initialInvoke; + } + + public String getScenario() { + return Scenario; + } + + public void setScenario(String scenario) { + Scenario = scenario; + } + + public String getMSISDN() { + return MSISDN; + } + + public void setMSISDN(String mSISDN) { + MSISDN = mSISDN; + } + + public ArrayList getInput() { + return Input; + } + + public void setInput(ArrayList input) { + Input = input; + } + + public ArrayList getOutput() { + return Output; + } + + public void setOutput(ArrayList output) { + Output = output; + } + + public String getInputTimeStamp() { + return InputTimeStamp; + } + + public void setInputTimeStamp(String inputTimeStamp) { + InputTimeStamp = inputTimeStamp; + } + + public String getOutputTimeStamp() { + return OutputTimeStamp; + } + + public void setOutputTimeStamp(String outputTimeStamp) { + OutputTimeStamp = outputTimeStamp; + } + + +} diff --git a/src/th/co/ais/ssbsrfc/instance/E01Atomic.java b/src/th/co/ais/ssbsrfc/instance/E01Atomic.java new file mode 100644 index 0000000..1d0cc11 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/E01Atomic.java @@ -0,0 +1,49 @@ +package th.co.ais.ssbsrfc.instance; + +public class E01Atomic { + private String command; + private String name; + private long value; + private long min; + private long max; + + public E01Atomic() { + super(); + } + public E01Atomic(String command, String name, long value) { + super(); + this.command = command; + this.name = name; + this.value = value; + } + public String getCommand() { + return command; + } + public void setCommand(String command) { + this.command = command; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public long getValue() { + return value; + } + public void setValue(long value) { + this.value = value; + } + public long getMin() { + return min; + } + public void setMin(long min) { + this.min = min; + } + public long getMax() { + return max; + } + public void setMax(long max) { + this.max = max; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/E01Ins.java b/src/th/co/ais/ssbsrfc/instance/E01Ins.java new file mode 100644 index 0000000..8def204 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/E01Ins.java @@ -0,0 +1,85 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; + +import th.co.ais.ssbsrfc.message.MessageParser; +import th.co.ais.ssbsrfc.utils.Global; +import ec02.data.E01Data; +import ec02.utils.AppLog; + +public class E01Ins { + private ArrayList message; + private ArrayList atomic; + + public E01Ins() { } + + public E01Ins(String strJson) { + try { + ListE01Data listIns = (ListE01Data) MessageParser.fromJson(strJson, ListE01Data.class); + + for(E01Data ins : listIns.getListE01Data()) { + String command = ins.getCmdName(); + String resultcode = ins.getResultCode(); + String description = ins.getDescription(); + + boolean isAtomic = ins.isAtomic(); + E01Message e01Msg = null; + if(isAtomic) { + String name = ins.getAtomicName(); + long value = ins.getAtomicValue(); + + if(this.message == null) { + this.atomic = new ArrayList(); + } + + e01Msg = new E01Message(command, resultcode, description, name, value); + this.atomic.add(e01Msg); + } else { + String id = ins.getId(); + String objecttype = ins.getKeyObject() == null ? null : ins.getKeyObject().getObjectType(); + String key0 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey0(); + String key1 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey1(); + String key2 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey2(); + String key3 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey3(); + String key4 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey4(); + E01MessageData data = new E01MessageData(ins.getData()); + + if(this.message == null) { + this.message = new ArrayList(); + } + + e01Msg = new E01Message(command, resultcode, description, id, objecttype, key0, key1, key2, key3, key4, data); + this.message.add(e01Msg); + } + + + } + +// this.description = ins.getDescription(); + } catch (Exception e) { + AppLog.e("## EXCEPTION :" + e.getMessage()); + } + } + + @Override + public String toString() { + return Global.unescapePrintString(MessageParser.toJson(this)); + } + + public ArrayList getMessage() { + return message; + } + + public void setMessage(ArrayList message) { + this.message = message; + } + + public ArrayList getAtomic() { + return atomic; + } + + public void setAtomic(ArrayList atomic) { + this.atomic = atomic; + } +} + diff --git a/src/th/co/ais/ssbsrfc/instance/E01Instance.java b/src/th/co/ais/ssbsrfc/instance/E01Instance.java new file mode 100644 index 0000000..d16ce9c --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/E01Instance.java @@ -0,0 +1,65 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; + +public class E01Instance { + private String cmd = ""; + private String objType = ""; + private String data = ""; + private String id = "1"; + private String Invoke = ""; + private String serviceName = null; + private String timeout = null; + private ArrayList key = null; + + public E01Instance() { } + + public String getCmd() { + return cmd; + } + public void setCmd(String cmd) { + this.cmd = cmd; + } + public String getObjType() { + return objType; + } + public void setObjType(String objType) { + this.objType = objType; + } + public String getData() { + return data; + } + public void setData(String data) { + this.data = data; + } + public ArrayList getKey() { + return key; + } + public void setKey(ArrayList key) { + this.key = key; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getInvoke() { + return Invoke; + } + public void setInvoke(String invoke) { + Invoke = invoke; + } + public String getServiceName() { + return serviceName; + } + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + public String getTimeout() { + return timeout; + } + public void setTimeout(String timeout) { + this.timeout = timeout; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/E01Message.java b/src/th/co/ais/ssbsrfc/instance/E01Message.java new file mode 100644 index 0000000..ed08708 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/E01Message.java @@ -0,0 +1,188 @@ +package th.co.ais.ssbsrfc.instance; + + +public class E01Message { + private String command; + private String resultcode; + private String description; + private String name; + private String id; + private String objecttype; + private String key0; + private String key1; + private String key2; + private String key3; + private String key4; + private E01MessageData data; + private String value; + + public E01Message(String command, String resultcode, String description, + String id, String objecttype, String key0, String key1, + String key2, String key3, String key4, E01MessageData data) { + super(); + this.command = command; + this.resultcode = resultcode; + this.id = id; + this.objecttype = objecttype; + this.key0 = key0; + this.key1 = key1; + this.key2 = key2; + this.key3 = key3; + this.key4 = key4; + this.data = data; + this.description = description; + } + + public E01Message(String command, String resultcode, String description, String name, long value) { + this.command = command; + this.resultcode = resultcode; + this.description = description; + this.name = name; + this.value = "" + value; + } + + public void setMode(String mode) { + if (mode.equals("res_replace")) { + this.objecttype = null; + this.key0 = null; + this.key1 = null; + this.key2 = null; + this.key3 = null; + this.key4 = null; + this.data = null; + } + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + + public String getResultcode() { + return resultcode; + } + + public void setResultcode(String resultcode) { + this.resultcode = resultcode; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getObjecttype() { + return objecttype; + } + + public void setObjecttype(String objecttype) { + this.objecttype = objecttype; + } + + public String getKey0() { + return key0; + } + + public void setKey0(String key0) { + this.key0 = key0; + } + + public String getKey1() { + return key1; + } + + public void setKey1(String key1) { + this.key1 = key1; + } + + public String getKey2() { + return key2; + } + + public void setKey2(String key2) { + this.key2 = key2; + } + + public String getKey3() { + return key3; + } + + public void setKey3(String key3) { + this.key3 = key3; + } + + public String getKey4() { + return key4; + } + + public void setKey4(String key4) { + this.key4 = key4; + } + + public E01MessageData getData() { + return data; + } + + public void setData(E01MessageData data) { + this.data = data; + } + + public String getDataValue() { + return this.data.getValue(); + } + + public void setDataValue(String value) { + this.data.setValue(value); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(long value) { + this.value = "" + value; + } + + public void setValue(String value) { + this.value = value; + } +} + +class E01MessageData { + private String value; + + public E01MessageData(String value) { + super(); + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/EC02Instance.java b/src/th/co/ais/ssbsrfc/instance/EC02Instance.java new file mode 100644 index 0000000..78c3dd7 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/EC02Instance.java @@ -0,0 +1,81 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; + +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxProperties; +import ec02.af.data.EquinoxRawData; + +public class EC02Instance { + private String orig = ""; + private String timeout = ""; + private String e01data = ""; + + private EquinoxProperties eqxProp = null; + private AbstractAF abstractAF = null; + private E01Instance e01Ins = null; + private E01Atomic atomic = null; + private AFInstance afIns = null; + private ArrayList eqxRawDataList = null; + + public String getOrig() { + return orig; + } + public void setOrig(String orig) { + this.orig = orig; + } + public String getTimeout() { + return timeout; + } + public void setTimeout(String timeout) { + this.timeout = timeout; + } + public ArrayList getEqxRawDataList() { + return eqxRawDataList; + } + public void setEqxRawDataList(ArrayList eqxRawDataList) { + this.eqxRawDataList = eqxRawDataList; + } + public AFInstance getAFInstance() { + return afIns; + } + public void setAFInstance(AFInstance afIns) { + this.afIns = afIns; + } + public EquinoxProperties getEquinoxProperties() { + return eqxProp; + } + public void setEquinoxProperties(EquinoxProperties eqxProp) { + this.eqxProp = eqxProp; + } + public AbstractAF getAbstractAF() { + return abstractAF; + } + public void setAbstractAF(AbstractAF abstractAF) { + this.abstractAF = abstractAF; + } + public String getE01data() { + return e01data; + } + public void setE01data(String e01data) { + this.e01data = e01data; + } + public E01Instance getE01Ins() { + if(this.e01Ins == null) { + this.e01Ins = new E01Instance(); + } + return e01Ins; + } + public void setE01Ins(E01Instance e01Ins) { + this.e01Ins = e01Ins; + } + public E01Atomic getAtomic() { + if (this.atomic == null) { + this.atomic = new E01Atomic(); + } + return atomic; + } + public void setAtomic(E01Atomic atomic) { + this.atomic = atomic; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/EQXRawInstance.java b/src/th/co/ais/ssbsrfc/instance/EQXRawInstance.java new file mode 100644 index 0000000..920f70f --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/EQXRawInstance.java @@ -0,0 +1,150 @@ +package th.co.ais.ssbsrfc.instance; + + +public class EQXRawInstance { + private String to = null; + private String type = null; + private String ctype = null; + private String oid = null; + private String uri = null; + private String ecode = null; + private String message = ""; + private String url = null; + private String method = null; + private String invoke = null; + private String name = null; + private String timeout = null; + private String subState = null; + private Object dataOutput = null; + private String nodeTo = ""; + private String command = null; + + public String getInvoke() { + return invoke; + } + + public void setInvoke(String invoke) { + this.invoke = invoke; + } + + public String getTo() { + return to; + } + + public void setTo(String to) { + this.to = to; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCtype() { + return ctype; + } + + public void setCtype(String ctype) { + this.ctype = ctype; + } + + public String getOid() { + return oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public String getEcode() { + return ecode; + } + + public void setEcode(String ecode) { + this.ecode = ecode; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getUrl() { + return this.url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getMethod() { + return this.method; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTimeout() { + return timeout; + } + + public void setTimeout(String timeout) { + this.timeout = timeout; + } + + public String getSubState() { + return subState; + } + + public void setSubState(String subState) { + this.subState = subState; + } + + public Object getDataOutput() { + return dataOutput; + } + + public void setDataOutput(Object dataOutput) { + this.dataOutput = dataOutput; + } + + public String getNodeTo() { + return nodeTo; + } + + public void setNodeTo(String nodeTo) { + this.nodeTo = nodeTo; + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/Element.java b/src/th/co/ais/ssbsrfc/instance/Element.java new file mode 100644 index 0000000..7ffedd4 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/Element.java @@ -0,0 +1,26 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; + +@XmlAccessorType(XmlAccessType.FIELD) +public class Element { + @XmlAttribute(name="value") + private String value; + + public Element() { } + + public Element(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/Encryption.java b/src/th/co/ais/ssbsrfc/instance/Encryption.java new file mode 100644 index 0000000..1f0b429 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/Encryption.java @@ -0,0 +1,37 @@ +package th.co.ais.ssbsrfc.instance; + +import th.co.ais.ssbsrfc.utils.DateUtil; + +public class Encryption { + private String uid = ""; + private String msisdn = ""; + private String datetime = ""; + + public Encryption () {} + + public Encryption (String _uid, String _msisdn) + { + this.setUid(_uid); + this.setMsisdn(_msisdn); + this.setDatetime(DateUtil.getDateTimeNow()); + } + + public String getUid() { + return uid; + } + public void setUid(String uid) { + this.uid = uid; + } + public String getMsisdn() { + return msisdn; + } + public void setMsisdn(String msisdn) { + this.msisdn = msisdn; + } + public String getDatetime() { + return datetime; + } + public void setDatetime(String datetime) { + this.datetime = datetime; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/FMInstance.java b/src/th/co/ais/ssbsrfc/instance/FMInstance.java new file mode 100644 index 0000000..f94f238 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/FMInstance.java @@ -0,0 +1,72 @@ +package th.co.ais.ssbsrfc.instance; + + +public class FMInstance { + private int flow = 0; + private String date = null; + private String data = null; + private String dialogueId = null; + private String unique = null; + + @Override + public String toString() { + return "## PARAMETERS: {\tflow=" + flow + ", \tdate=" + date + + ", \tdata=" + data + ", \tdialogueId=" + dialogueId + + ", \tunique=" + unique + "}"; + } + public FMInstance() { + super(); + } + public FMInstance(int flow) { + super(); + this.flow = flow; + } + public FMInstance(int flow, String date) { + super(); + this.flow = flow; + this.date = date; + } + public FMInstance(int flow, String date, String data) { + super(); + this.flow = flow; + this.date = date; + this.data = data; + } + public FMInstance(int flow, String date, String data, String dialogueId) { + super(); + this.flow = flow; + this.date = date; + this.data = data; + this.dialogueId = dialogueId; + } + public int getFlow() { + return flow; + } + public void setFlow(int flow) { + this.flow = flow; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + public String getData() { + return data; + } + public void setData(String data) { + this.data = data; + } + public String getDialogueId() { + return dialogueId; + } + public void setDialogueId(String dialogueId) { + this.dialogueId = dialogueId; + } + public String getUnique() { + return unique; + } + public void setUnique(String unique) { + this.unique = unique; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/ListE01Data.java b/src/th/co/ais/ssbsrfc/instance/ListE01Data.java new file mode 100644 index 0000000..39d1170 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/ListE01Data.java @@ -0,0 +1,30 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; + +import th.co.ais.ssbsrfc.message.MessageParser; +import ec02.data.E01Data; + +public class ListE01Data { + private ArrayList listE01Data; + + public ListE01Data() { } + + public ListE01Data(ArrayList listE01Data) { + this.listE01Data = listE01Data; + } + + public ListE01Data(String strJson) { + ListE01Data ins = (ListE01Data) MessageParser.fromJson(strJson, ListE01Data.class); + + this.listE01Data = ins.listE01Data; + } + + public ArrayList getListE01Data() { + return listE01Data; + } + + public void setListE01Data(ArrayList listE01Data) { + this.listE01Data = listE01Data; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/LogError.java b/src/th/co/ais/ssbsrfc/instance/LogError.java new file mode 100644 index 0000000..8d60da5 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/LogError.java @@ -0,0 +1,24 @@ +package th.co.ais.ssbsrfc.instance; + +public class LogError { + private String ret = null; + private String description = null; + + public LogError(String ret, String description) { + super(); + this.ret = ret; + this.description = description; + } + public String getRet() { + return ret; + } + public void setRet(String ret) { + this.ret = ret; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/ManageTime.java b/src/th/co/ais/ssbsrfc/instance/ManageTime.java new file mode 100644 index 0000000..dfca0ac --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/ManageTime.java @@ -0,0 +1,274 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import th.co.ais.ssbsrfc.utils.DateUtil; +import th.co.ais.ssbsrfc.utils.Global; +import th.co.ais.ssbsrfc.utils.Log; +import ec02.utils.AppLog; + +public class ManageTime { + + private ArrayList listTimeout = new ArrayList(); + private EC02Instance ec02Instance = null; + + public ManageTime() { } + + public ManageTime(EC02Instance ec02Instance) { + this.setStart(ec02Instance, true); + } + + public ManageTime(EC02Instance ec02Instance, boolean isSet) { + this.setStart(ec02Instance, isSet); + } + + public void setStart(EC02Instance ec02Instance, boolean isSet) + { + this.setEc02Instance(ec02Instance); + if (isSet) { + this.setListTimeout(ec02Instance.getAFInstance().getListTimeout()); + } + } + + public Date getNow() + { + Date date = Calendar.getInstance().getTime(); + return date; + } + + public int diffDate(Date date1, Date date2) + { + Calendar strF_Cal = Calendar.getInstance(); + Calendar strL_Cal = Calendar.getInstance(); + strF_Cal.setTime(date1); + strL_Cal.setTime(date2); + Calendar fCal = DateUtil.getCalendar(DateUtil.getDay(strF_Cal), DateUtil + .getMonth(strF_Cal), DateUtil.getYear(strF_Cal), DateUtil + .getHour(strF_Cal), DateUtil.getMinute(strF_Cal), DateUtil.getSecond(strF_Cal)); + Calendar lCal = DateUtil.getCalendar(DateUtil.getDay(strL_Cal), DateUtil + .getMonth(strL_Cal), DateUtil.getYear(strL_Cal), + DateUtil.getHour(strL_Cal), DateUtil.getMinute(strL_Cal), DateUtil.getSecond(strL_Cal)); + + long lastLong = lCal.getTime().getTime(); + long firstLong = fCal.getTime().getTime(); + + long diff = lastLong - firstLong; + + return (new Long(diff / 1000)).intValue(); + } + + public String getTimeout(String name, String timeout) + { + Date now = this.getNow(); +// System.out.println(name + ":" + timeout + ":" + now); + String time = this.getTimeout(name, timeout, now); + return time; + } + + public String getTimeout(String name, String timeout, Date now) + { + String inputTimeStamp = Global.inputTimeStamp; + for (Timeout item : this.getListTimeout()) { + if (inputTimeStamp == null) { + int second = item.getTimeout() - this.diffDate(item.getDate(), now); + item.setNet(second); + } else { + if (!item.getInputTimeStamp().equals(inputTimeStamp)) { + int second = item.getTimeout() - this.diffDate(item.getDate(), now); + item.setNet(second); + } else { + item.setDate(now); + } + } + } + Timeout state = new Timeout(); + state.setName(name); + state.setInputTimeStamp(inputTimeStamp); + state.setDate(now); + state.setTimeout(Integer.parseInt(timeout)); + state.setNet(Integer.parseInt(timeout)); + this.getListTimeout().add(state); + Collections.sort(this.getListTimeout(), new Comparator(){ + public int compare(Timeout p1, Timeout p2) { + return Integer.valueOf(p1.getNet()) .compareTo(Integer.valueOf(p2.getNet())); + } + }); + this.getEc02Instance().getAFInstance().setListTimeout(this.getListTimeout()); + String time = ""; + if (this.getListTimeout().size() > 0) { + time = String.valueOf(this.getListTimeout().get(0).getNet()); + if (!time.matches("^\\d+$")) { + time = "0"; + } + } + ///////////////////////////////////////////////////// + AppLog.d("####### TABLE TIMEOUT #######"); + for (Timeout item : this.getListTimeout()) { + AppLog.d("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); +// System.out.println("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); + } + AppLog.d("############# END #############"); + ///////////////////////////////////////////////////// + return time; + } + + public void setTimeout(String name, String timeout, Date now) + { + String inputTimeStamp = Global.inputTimeStamp; + for (Timeout item : this.getListTimeout()) { + if (inputTimeStamp == null) { + int second = item.getTimeout() - this.diffDate(item.getDate(), now); + item.setNet(second); + } else { + if (!item.getInputTimeStamp().equals(inputTimeStamp)) { + int second = item.getTimeout() - this.diffDate(item.getDate(), now); + item.setNet(second); + } else { + item.setDate(now); + } + } + } + Timeout state = new Timeout(); + state.setName(name); + state.setInputTimeStamp(inputTimeStamp); + state.setDate(now); + state.setTimeout(Integer.parseInt(timeout)); + state.setNet(Integer.parseInt(timeout)); + this.getListTimeout().add(state); + Collections.sort(this.getListTimeout(), new Comparator(){ + public int compare(Timeout p1, Timeout p2) { + return Integer.valueOf(p1.getNet()) .compareTo(Integer.valueOf(p2.getNet())); + } + }); + ///////////////////////////////////////////////////// + AppLog.d("####### TABLE TIMEOUT #######"); + for (Timeout item : this.getListTimeout()) { + AppLog.d("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); + //System.out.println("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); + } + AppLog.d("############# END #############"); + ///////////////////////////////////////////////////// + } + + public String getCalTime() + { + Date now = this.getNow(); + for (Timeout item : this.getListTimeout()) { + int second = item.getTimeout() - this.diffDate(item.getDate(), now); + item.setNet(second); + } + Collections.sort(this.getListTimeout(), new Comparator(){ + public int compare(Timeout p1, Timeout p2) { + return Integer.valueOf(p1.getNet()).compareTo(Integer.valueOf(p2.getNet())); + } + }); + String time = null; + int second = 0; + if (this.getListTimeout().size() > 0) { + second = this.getListTimeout().get(0).getNet(); + } + if (second > 0) { + time = "" + second; + } + return time; + } + + public String getTime() + { + String time = null; + int second = 0; + if (this.getListTimeout().size() > 0) { + second = this.getListTimeout().get(0).getNet(); + } + if (second > 0) { + time = "" + second; + } + return time; + } + + public Timeout getInsTime() + { + Date now = this.getNow(); + for (Timeout item : this.getListTimeout()) { + int second = item.getTimeout() - this.diffDate(item.getDate(), now); + item.setNet(second); + } + Collections.sort(this.getListTimeout(), new Comparator(){ + public int compare(Timeout p1, Timeout p2) { + return Integer.valueOf(p1.getNet()).compareTo(Integer.valueOf(p2.getNet())); + } + }); + Timeout ins = null; + if (this.getListTimeout().size() > 0) { + ins = this.getListTimeout().get(0); + } + return ins; + } + + public List getState() + { + List list = this.getState(true); + return list; + } + + public List getState(boolean isSet) + { + Log.dev("####### TABLE TIMEOUT(OLD) #######"); + for (Timeout item : this.getListTimeout()) { + Log.dev("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); +// System.out.println("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); + } + Log.dev("############# END #############"); + Collections.sort(this.getListTimeout(), new Comparator(){ + public int compare(Timeout p1, Timeout p2) { + return Integer.valueOf(p1.getNet()).compareTo(Integer.valueOf(p2.getNet())); + } + }); + int second = 0; + List list = new ArrayList(); + if (this.getListTimeout().size() > 0) { + second = this.getListTimeout().get(0).getNet(); + } + List tmp = new ArrayList(); + for (Timeout item : this.getListTimeout()) { + if (item.getNet() == second) { + tmp.add(item); + list.add(item.getName()); + } + } + for (Timeout timeout : tmp) { + this.getListTimeout().remove(timeout); + } + if (isSet) { + this.getEc02Instance().getAFInstance().setListTimeout(this.getListTimeout()); + } + Log.dev("####### TABLE TIMEOUT(NEW) #######"); + for (Timeout item : this.getListTimeout()) { + Log.dev("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); +// System.out.println("NAME :" + item.getName() + " DATE :" + item.getDate() + " TIME :" + item.getTimeout() + " NET :" + item.getNet()); + } + Log.dev("############# END #############"); + return list; + } + + public ArrayList getListTimeout() { + return listTimeout; + } + + public void setListTimeout(ArrayList listTimeout) { + this.listTimeout = listTimeout; + } + + public EC02Instance getEc02Instance() { + return ec02Instance; + } + + public void setEc02Instance(EC02Instance ec02Instance) { + this.ec02Instance = ec02Instance; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/MenuTemplateIns.java b/src/th/co/ais/ssbsrfc/instance/MenuTemplateIns.java new file mode 100644 index 0000000..0fd0f3a --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/MenuTemplateIns.java @@ -0,0 +1,148 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.HashMap; +import java.util.LinkedList; + +public class MenuTemplateIns { + private String currentPath; + private String xml; + private String currentPromptId; + private String currentOrderId; + private String currentAPIId; + private int type; + private String redirectAddress = ""; + private String senderName; + private boolean isSendResponse = false; + + public String getCurrentPath() { + return currentPath; + } + public void setCurrentPath(String currentPath) { + this.currentPath = currentPath; + } + public String getXml() { + return xml; + } + public void setXml(String xml) { + this.xml = xml; + } + public int getType() { + return type; + } + public void setType(int type) { + this.type = type; + } + public String getCurrentPromptId() { + return currentPromptId; + } + public void setCurrentPromptId(String currentPromptId) { + this.currentPromptId = currentPromptId; + } + public String getCurrentOrderId() { + return currentOrderId; + } + public void setCurrentOrderId(String currentOrderId) { + this.currentOrderId = currentOrderId; + } + public String getCurrentAPIId() { + return currentAPIId; + } + public void setCurrentAPIId(String currentAPIId) { + this.currentAPIId = currentAPIId; + } + public String getRedirectAddress() { + return redirectAddress; + } + public void setRedirectAddress(String redirectAddress) { + this.redirectAddress = redirectAddress; + } + public String getSenderName() { + return senderName; + } + public void setSenderName(String senderName) { + this.senderName = senderName; + } + + // data + private HashMap mapXML = null; + private LinkedList linkedlistXPath = null; + public HashMap getMapXML() { + if (mapXML == null) { + mapXML = new HashMap(); + } + return mapXML; + } + public void setMapXML(HashMap mapXML) { + this.mapXML = mapXML; + } + public LinkedList getLinkedlistXPath() { + return linkedlistXPath; + } + public void setLinkedlistXPath(LinkedList linkedlistXPath) { + this.linkedlistXPath = linkedlistXPath; + } + public void pushXPath(String xpath) + { + if (this.linkedlistXPath == null) { + this.linkedlistXPath = new LinkedList(); + } + this.linkedlistXPath.add(xpath); + } + public String popXPath() + { + String xpath = null; + if (this.linkedlistXPath != null && this.linkedlistXPath.size() != 0) { + xpath = this.linkedlistXPath.getLast(); + this.linkedlistXPath.removeLast(); + } + + return xpath; + } + public boolean isSendResponse() { + return isSendResponse; + } + public void setSendResponse(boolean isSendResponse) { + if (!this.isSendResponse) { + this.isSendResponse = isSendResponse; + } + } + + // Prompt + private PromptTemplateIns promptIns; + + public PromptTemplateIns getPromptIns() { + if(promptIns == null) { + this.promptIns = new PromptTemplateIns(); + } + return promptIns; + } + public void setPromptIns(PromptTemplateIns promptIns) { + this.promptIns = promptIns; + } + + // RRR + private RRRIns rrrIns; + + public RRRIns getRrrIns() { + if(rrrIns == null) { + this.rrrIns = new RRRIns(); + } + return rrrIns; + } + public void setRrrIns(RRRIns rrrIns) { + this.rrrIns = rrrIns; + } + + // OTP Response + private OTPResIns otpIns; + + public OTPResIns getOtpIns() { + if(otpIns == null) { + this.otpIns = new OTPResIns(); + } + return otpIns; + } + public void setOtpIns(OTPResIns otpIns) { + this.otpIns = otpIns; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/OTPResIns.java b/src/th/co/ais/ssbsrfc/instance/OTPResIns.java new file mode 100644 index 0000000..c32e5d1 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/OTPResIns.java @@ -0,0 +1,27 @@ +package th.co.ais.ssbsrfc.instance; + +public class OTPResIns { + + private String xml; + private String resultCode; + private String errorMessage; + + public String getXml() { + return xml; + } + public void setXml(String xml) { + this.xml = xml; + } + public String getResultCode() { + return resultCode; + } + public void setResultCode(String resultCode) { + this.resultCode = resultCode; + } + public String getErrorMessage() { + return errorMessage; + } + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/OwnershipInfo.java b/src/th/co/ais/ssbsrfc/instance/OwnershipInfo.java new file mode 100644 index 0000000..81d7f73 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/OwnershipInfo.java @@ -0,0 +1,25 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; + +public class OwnershipInfo { + + private String BEID; + private String BRID; + + @XmlElement(name="BEID",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getBEID() { + return BEID; + } + public void setBEID(String bEID) { + BEID = bEID; + } + @XmlElement(name="BRID",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getBRID() { + return BRID; + } + public void setBRID(String bRID) { + BRID = bRID; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/PromptTemplateIns.java b/src/th/co/ais/ssbsrfc/instance/PromptTemplateIns.java new file mode 100644 index 0000000..9df453c --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/PromptTemplateIns.java @@ -0,0 +1,81 @@ +package th.co.ais.ssbsrfc.instance; + +public class PromptTemplateIns { + private String id; + private String retrySubmitSM; + private String timeoutSubmitSM; + private String requireDeliveryReport; + private String timeoutDeliveryReport; + private String requireDeliverSM; + private String timeoutDeliverSM; + private String retry; + private String rrrResult = "1"; + private String rrrDiagnostic = "SRFC Send Prompt Fail"; + + public void setPromptSuccess() { + this.rrrResult = "0"; + this.rrrDiagnostic = "SRFC Send Prompt " + this.id + " Success"; + } + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + this.rrrDiagnostic = this.rrrDiagnostic.replace("", id); + } + public String getRetrySubmitSM() { + return retrySubmitSM; + } + public void setRetrySubmitSM(String retrySubmitSM) { + this.retrySubmitSM = retrySubmitSM; + } + public String getTimeoutSubmitSM() { + return timeoutSubmitSM; + } + public void setTimeoutSubmitSM(String timeoutSubmitSM) { + this.timeoutSubmitSM = timeoutSubmitSM; + } + public String getRequireDeliveryReport() { + return requireDeliveryReport; + } + public void setRequireDeliveryReport(String requireDeliveryReport) { + this.requireDeliveryReport = requireDeliveryReport; + } + public String getTimeoutDeliveryReport() { + return timeoutDeliveryReport; + } + public void setTimeoutDeliveryReport(String timeoutDeliveryReport) { + this.timeoutDeliveryReport = timeoutDeliveryReport; + } + public String getRequireDeliverSM() { + return requireDeliverSM; + } + public void setRequireDeliverSM(String requireDeliverSM) { + this.requireDeliverSM = requireDeliverSM; + } + public String getTimeoutDeliverSM() { + return timeoutDeliverSM; + } + public void setTimeoutDeliverSM(String timeoutDeliverSM) { + this.timeoutDeliverSM = timeoutDeliverSM; + } + public String getRetry() { + return retry; + } + public void setRetry(String retry) { + this.retry = retry; + } + public String getRrrResult() { + return rrrResult; + } + public void setRrrResult(String rrrResult) { + this.rrrResult = rrrResult; + } + public String getRrrDiagnostic() { + return rrrDiagnostic; + } + public void setRrrDiagnostic(String rrrDiagnostic) { + this.rrrDiagnostic = rrrDiagnostic; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/RRRIns.java b/src/th/co/ais/ssbsrfc/instance/RRRIns.java new file mode 100644 index 0000000..0859afe --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/RRRIns.java @@ -0,0 +1,41 @@ +package th.co.ais.ssbsrfc.instance; + +public class RRRIns { + + private String xml; + private String result; + private String diagnostic; + private int retryMax = 0; + private int retryCount = 0; + + public String getXml() { + return xml; + } + public void setXml(String xml) { + this.xml = xml; + } + public String getResult() { + return result; + } + public void setResult(String result) { + this.result = result; + } + public String getDiagnostic() { + return diagnostic; + } + public void setDiagnostic(String diagnostic) { + this.diagnostic = diagnostic; + } + public int getRetryMax() { + return retryMax; + } + public void setRetryMax(int retryMax) { + this.retryMax = retryMax; + } + public int getRetryCount() { + return retryCount; + } + public void setRetryCount(int retryCount) { + this.retryCount = retryCount; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/RequestHeader.java b/src/th/co/ais/ssbsrfc/instance/RequestHeader.java new file mode 100644 index 0000000..bd45b1b --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/RequestHeader.java @@ -0,0 +1,60 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +@XmlType (propOrder={"version","businessCode","messageSeq","ownershipInfo","accessSecurity","accessMode"}) +public class RequestHeader { + + private String Version; + private String BusinessCode; + private String MessageSeq; + private OwnershipInfo ownershipInfo; + private AccessSecurity accessSecurity; + private String AccessMode; + + @XmlElement(name="Version",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getVersion() { + return Version; + } + public void setVersion(String version) { + Version = version; + } + @XmlElement(name="AccessSecurity",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public AccessSecurity getAccessSecurity() { + return accessSecurity; + } + public void setAccessSecurity(AccessSecurity accessSecurity) { + this.accessSecurity = accessSecurity; + } + @XmlElement(name="AccessMode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getAccessMode() { + return AccessMode; + } + public void setAccessMode(String accessMode) { + AccessMode = accessMode; + } + @XmlElement(name="BusinessCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getBusinessCode() { + return BusinessCode; + } + public void setBusinessCode(String businessCode) { + BusinessCode = businessCode; + } + @XmlElement(name="MessageSeq",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getMessageSeq() { + return MessageSeq; + } + public void setMessageSeq(String messageSeq) { + MessageSeq = messageSeq; + } + @XmlElement(name="OwnershipInfo",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public OwnershipInfo getOwnershipInfo() { + return ownershipInfo; + } + public void setOwnershipInfo(OwnershipInfo ownershipInfo) { + this.ownershipInfo = ownershipInfo; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/ResIns.java b/src/th/co/ais/ssbsrfc/instance/ResIns.java new file mode 100644 index 0000000..7dcaeb8 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/ResIns.java @@ -0,0 +1,79 @@ +package th.co.ais.ssbsrfc.instance; + +import th.co.ais.ssbsrfc.message.MessageParser; +import th.co.ais.ssbsrfc.utils.Global; + +import com.google.gson.Gson; + +import ec02.utils.AppLog; + +public class ResIns +{ + private String method = null; + private String resultCode = ""; + private String resultDescription = ""; + private String command = null; + + public ResIns () {} + + public ResIns(String resultCode, String resultDescription) { + super(); + this.resultCode = resultCode; + this.resultDescription = resultDescription; + } + + public ResIns (String code, String desc, String cmd) { + this.resultCode = code; + this.resultDescription = desc; + this.command = cmd; + } + + public ResIns(String strJson) { + try { + Gson gson = new Gson(); + ResIns ins = gson.fromJson(strJson, ResIns.class); + this.resultCode = ins.getResultCode(); + this.resultDescription = ins.getResultDescription(); + if (ins.getCommand() != null) { + this.command = ins.getCommand(); + } + } catch (Exception e) { + AppLog.e("## EXCEPTION :" + e.getMessage()); + } + } + + @Override + public String toString() { + return Global.unescapePrintString(MessageParser.toJson(this)); + } + + public String getResultCode() { + return resultCode; + } + public void setResultCode(String resultCode) { + this.resultCode = resultCode; + } + public String getResultDescription() { + return resultDescription; + } + public void setResultDescription(String resultDescription) { + this.resultDescription = resultDescription; + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/Response.java b/src/th/co/ais/ssbsrfc/instance/Response.java new file mode 100644 index 0000000..2e543d5 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/Response.java @@ -0,0 +1,30 @@ +package th.co.ais.ssbsrfc.instance; + +public class Response { + + private String orig = ""; + private String invoke = ""; + + public Response () {} + + public Response (String orig, String invoke) { + this.orig = orig; + this.invoke = invoke; + } + + public String getOrig() { + return orig; + } + + public void setOrig(String orig) { + this.orig = orig; + } + + public String getInvoke() { + return invoke; + } + + public void setInvoke(String invoke) { + this.invoke = invoke; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/ResultHeader.java b/src/th/co/ais/ssbsrfc/instance/ResultHeader.java new file mode 100644 index 0000000..f06d2b2 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/ResultHeader.java @@ -0,0 +1,48 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; + +public class ResultHeader { + + private String Version; + private String ResultCode; + private String MsgLanguageCode; + private String ResultDesc; + + @XmlElement(name="Version",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getVersion() { + return Version; + } + + public void setVersion(String version) { + Version = version; + } + + @XmlElement(name="ResultCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getResultCode() { + return ResultCode; + } + + public void setResultCode(String resultCode) { + ResultCode = resultCode; + } + + @XmlElement(name="MsgLanguageCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getMsgLanguageCode() { + return MsgLanguageCode; + } + + public void setMsgLanguageCode(String msgLanguageCode) { + MsgLanguageCode = msgLanguageCode; + } + + @XmlElement(name="ResultDesc",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon") + public String getResultDesc() { + return ResultDesc; + } + + public void setResultDesc(String resultDesc) { + ResultDesc = resultDesc; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/RetryIns.java b/src/th/co/ais/ssbsrfc/instance/RetryIns.java new file mode 100644 index 0000000..4fc2a5e --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/RetryIns.java @@ -0,0 +1,54 @@ +package th.co.ais.ssbsrfc.instance; + +import ec02.utils.AppLog; + +public class RetryIns { + private int countRetry = 0; + private int max = 0; +// private EquinoxRawData eqx = null; + private String url = null; + + public RetryIns(int max, /*EquinoxRawData eqx,*/ String url) { + super(); + this.max = max; + this.countRetry = 0; +// this.eqx = eqx; + this.url = url; + } + public boolean isRetry(EC02Instance ec02Instance, String key) + { + boolean isBool = false; + if (this.max > this.countRetry) { + this.countRetry++; + AppLog.d("## RETRY MESSAGE MAX:" + this.getMax() + " COUNT RETRY:" + this.getCountRetry()); + isBool = true; + } else { + ec02Instance.getAFInstance().getDicRetry().remove(key); + } + return isBool; + } + public int getCountRetry() { + return countRetry; + } + public void setCountRetry(int countRetry) { + this.countRetry = countRetry; + } + public int getMax() { + return max; + } + public void setMax(int max) { + this.max = max; + } +// public EquinoxRawData getEqx() { +// return eqx; +// } +// public void setEqx(EquinoxRawData eqx) { +// this.eqx = eqx; +// } + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/SOAPNamespaceMapper.java b/src/th/co/ais/ssbsrfc/instance/SOAPNamespaceMapper.java new file mode 100644 index 0000000..bf53ca2 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/SOAPNamespaceMapper.java @@ -0,0 +1,36 @@ +package th.co.ais.ssbsrfc.instance; + +import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper; + + +public class SOAPNamespaceMapper extends NamespacePrefixMapper { + + private static final String SOAPENV_PREFIX = "soapenv"; // DEFAULT NAMESPACE + private static final String SOAPENV_URI = "http://schemas.xmlsoap.org/soap/envelope/"; + + private static final String CBS_PREFIX = "cbs"; + private static final String CBS_URI = "http://www.huawei.com/bme/cbsinterface/cbscommon"; + + private static final String ARS_PREFIX = "ars"; + private static final String ARS_URI = "http://www.huawei.com/bme/cbsinterface/arservices"; + + private static final String ARC_PREFIX = "arc"; + private static final String ARC_URI = "http://cbs.huawei.com/ar/wsservice/arcommon"; + + + @Override + public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { + if(SOAPENV_URI.equals(namespaceUri)) { + return SOAPENV_PREFIX; + } else if(ARC_URI.equals(namespaceUri)) { + return ARC_PREFIX; + } else if(ARS_URI.equals(namespaceUri)) { + return ARS_PREFIX; + } else if(CBS_URI.equals(namespaceUri)) { + return CBS_PREFIX; + } + return suggestion; + } + + +} diff --git a/src/th/co/ais/ssbsrfc/instance/Stat.java b/src/th/co/ais/ssbsrfc/instance/Stat.java new file mode 100644 index 0000000..7ffff96 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/Stat.java @@ -0,0 +1,98 @@ +package th.co.ais.ssbsrfc.instance; + +import th.co.ais.ssbsrfc.config.Constant; + +public class Stat { + + private String currentSubState = null; + private int sendOrReceive; + private int responseOrRequest; + private int type; + private String message; + private String command = null; + private String name = null; + + public Stat(String currentSubState, int sendOrReceive, int responseOrRequest) { + super(); + this.currentSubState = currentSubState; + this.sendOrReceive = sendOrReceive; + this.responseOrRequest = responseOrRequest; + this.type = Constant.TYPE_SUCCESS; + this.message = ""; + } + + public Stat(String currentSubState, int sendOrReceive, + int responseOrRequest, int type, String message) { + super(); + this.currentSubState = currentSubState; + this.sendOrReceive = sendOrReceive; + this.responseOrRequest = responseOrRequest; + this.type = type; + this.message = message; + } + + public Stat(String currentSubState, int sendOrReceive, + int responseOrRequest, int type, String message, String command) { + super(); + this.currentSubState = currentSubState; + this.sendOrReceive = sendOrReceive; + this.responseOrRequest = responseOrRequest; + this.type = type; + this.message = message; + this.command = command; + } + + public Stat(String name) { + super(); + this.name = name; + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getCurrentSubState() { + return currentSubState; + } + public void setCurrentSubState(String currentSubState) { + this.currentSubState = currentSubState; + } + public int getSendOrReceive() { + return sendOrReceive; + } + public void setSendOrReceive(int sendOrReceive) { + this.sendOrReceive = sendOrReceive; + } + public int getResponseOrRequest() { + return responseOrRequest; + } + public void setResponseOrRequest(int responseOrRequest) { + this.responseOrRequest = responseOrRequest; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/SubAccessCode.java b/src/th/co/ais/ssbsrfc/instance/SubAccessCode.java new file mode 100644 index 0000000..c9269da --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/SubAccessCode.java @@ -0,0 +1,18 @@ +package th.co.ais.ssbsrfc.instance; + +import javax.xml.bind.annotation.XmlElement; + +public class SubAccessCode { + + private String PrimaryIdentity; + + @XmlElement(name="SubAccessCode",namespace="http://cbs.huawei.com/ar/wsservice/arcommon") + public String getPrimaryIdentity() { + return PrimaryIdentity; + } + + public void setPrimaryIdentity(String primaryIdentity) { + PrimaryIdentity = primaryIdentity; + } + +} diff --git a/src/th/co/ais/ssbsrfc/instance/Summary.java b/src/th/co/ais/ssbsrfc/instance/Summary.java new file mode 100644 index 0000000..d5bab60 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/Summary.java @@ -0,0 +1,77 @@ +package th.co.ais.ssbsrfc.instance; + +public class Summary { + private String destinationNodeName = "null"; + private String destinationNodeIP = "null"; + private String destinationNodeCommand = "null"; + private String destinationNodeResultCode = "null"; + private String destinationNodeResultDescription = "null"; + + public Summary() { + super(); + } + public Summary(String destinationNodeResultCode, + String destinationNodeResultDescription) { + super(); + this.destinationNodeResultCode = destinationNodeResultCode; + this.destinationNodeResultDescription = destinationNodeResultDescription; + } + public Summary(String destinationNodeName, String destinationNodeCommand, + String destinationNodeResultCode, + String destinationNodeResultDescription) { + super(); + this.destinationNodeName = destinationNodeName; + this.destinationNodeCommand = destinationNodeCommand; + this.destinationNodeResultCode = destinationNodeResultCode; + this.destinationNodeResultDescription = destinationNodeResultDescription; + } + public Summary(String destinationNodeName, String destinationNodeIP, + String destinationNodeCommand, String destinationNodeResultCode, + String destinationNodeResultDescription) { + super(); + this.destinationNodeName = destinationNodeName; + this.destinationNodeIP = destinationNodeIP; + this.destinationNodeCommand = destinationNodeCommand; + this.destinationNodeResultCode = destinationNodeResultCode; + this.destinationNodeResultDescription = destinationNodeResultDescription; + } + public String getDestinationNodeName() { + return destinationNodeName; + } + public void setDestinationNodeName(String destinationNodeName) { + this.destinationNodeName = destinationNodeName; + } + public String getDestinationNodeIP() { + return destinationNodeIP; + } + public void setDestinationNodeIP(String destinationNodeIP) { + this.destinationNodeIP = destinationNodeIP; + } + public String getDestinationNodeCommand() { + return destinationNodeCommand; + } + public void setDestinationNodeCommand(String destinationNodeCommand) { + this.destinationNodeCommand = destinationNodeCommand; + } + public String getDestinationNodeResultCode() { + return destinationNodeResultCode; + } + public void setDestinationNodeResultCode(String destinationNodeResultCode) { + if (this.destinationNodeResultCode == null) { + this.destinationNodeResultCode = destinationNodeResultCode; + } else { + this.destinationNodeResultCode += "," + destinationNodeResultCode; + } + } + public String getDestinationNodeResultDescription() { + return destinationNodeResultDescription; + } + public void setDestinationNodeResultDescription( + String destinationNodeResultDescription) { + if (this.destinationNodeResultDescription == null) { + this.destinationNodeResultDescription = destinationNodeResultDescription; + } else { + this.destinationNodeResultDescription += "," + destinationNodeResultDescription; + } + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/Timeout.java b/src/th/co/ais/ssbsrfc/instance/Timeout.java new file mode 100644 index 0000000..e33496e --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/Timeout.java @@ -0,0 +1,56 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.Date; + +public class Timeout { + + private String name = ""; + private String inputTimeStamp = null; + private Date date = null; + private int timeout = 0; + private int net = 0; + private int flow = 0; + + @Override + public String toString() { + return "## PARAMETERS: {\tname=" + name + ", \tdate=" + date + + ", \ttimeout=" + timeout + ", \tnet=" + net + + ", \tflow=" + flow + "}"; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public Date getDate() { + return date; + } + public void setDate(Date date) { + this.date = date; + } + public int getTimeout() { + return timeout; + } + public void setTimeout(int timeout) { + this.timeout = timeout; + } + public int getNet() { + return net; + } + public void setNet(int net) { + this.net = net; + } + public int getFlow() { + return flow; + } + public void setFlow(int flow) { + this.flow = flow; + } + public String getInputTimeStamp() { + return inputTimeStamp; + } + public void setInputTimeStamp(String inputTimeStamp) { + this.inputTimeStamp = inputTimeStamp; + } +} diff --git a/src/th/co/ais/ssbsrfc/instance/TimeoutIns.java b/src/th/co/ais/ssbsrfc/instance/TimeoutIns.java new file mode 100644 index 0000000..248785c --- /dev/null +++ b/src/th/co/ais/ssbsrfc/instance/TimeoutIns.java @@ -0,0 +1,25 @@ +package th.co.ais.ssbsrfc.instance; + +import java.util.ArrayList; +import java.util.List; + +import ec02.af.data.EquinoxRawData; + +public class TimeoutIns { + + private List equinoxRawDataList = new ArrayList(); + private String eqxState = ""; + + public List getEquinoxRawDataList() { + return equinoxRawDataList; + } + public void setEquinoxRawDataList(List equinoxRawDataList) { + this.equinoxRawDataList = equinoxRawDataList; + } + public String getEqxState() { + return eqxState; + } + public void setEqxState(String eqxState) { + this.eqxState = eqxState; + } +} diff --git a/src/th/co/ais/ssbsrfc/interfaces/AFEvent.java b/src/th/co/ais/ssbsrfc/interfaces/AFEvent.java new file mode 100644 index 0000000..c66969d --- /dev/null +++ b/src/th/co/ais/ssbsrfc/interfaces/AFEvent.java @@ -0,0 +1,8 @@ +package th.co.ais.ssbsrfc.interfaces; + +public interface AFEvent { + public String Unknown ="Unknown"; + public String ERROR = "EQUINOX_EVENT_ERROR"; + public String REJECT = "EQUINOX_EVENT_REJECT"; + public String ABORT = "EQUINOX_EVENT_ABORT"; +} diff --git a/src/th/co/ais/ssbsrfc/interfaces/AFState.java b/src/th/co/ais/ssbsrfc/interfaces/AFState.java new file mode 100644 index 0000000..13439fa --- /dev/null +++ b/src/th/co/ais/ssbsrfc/interfaces/AFState.java @@ -0,0 +1,7 @@ +package th.co.ais.ssbsrfc.interfaces; + +public interface AFState { + public String IDLE = "IDLE"; + public String W_ACTIVE = "W_ACTIVE"; + public String W_E11_TIMEOUT = "W_E11_TIMEOUT"; +} diff --git a/src/th/co/ais/ssbsrfc/interfaces/AFSubState.java b/src/th/co/ais/ssbsrfc/interfaces/AFSubState.java new file mode 100644 index 0000000..b8de940 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/interfaces/AFSubState.java @@ -0,0 +1,17 @@ +package th.co.ais.ssbsrfc.interfaces; + +import java.util.ArrayList; + +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.af.interfaces.IAFState; + +public class AFSubState implements IAFState { + + @Override + public String doAction(AbstractAF arg0, Object arg1, + ArrayList arg2) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/th/co/ais/ssbsrfc/interfaces/AbstractAFSubStateManager.java b/src/th/co/ais/ssbsrfc/interfaces/AbstractAFSubStateManager.java new file mode 100644 index 0000000..bbe333f --- /dev/null +++ b/src/th/co/ais/ssbsrfc/interfaces/AbstractAFSubStateManager.java @@ -0,0 +1,18 @@ +package th.co.ais.ssbsrfc.interfaces; + +import java.util.List; + +import th.co.ais.ssbsrfc.instance.EC02Instance; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; + +public class AbstractAFSubStateManager implements IAFSubState { + + public IAFSubState subStateManager; + + @Override + public List doActionSubState(AbstractAF abstractAF, + EC02Instance ec02Instance, EquinoxRawData equinoxRawData) { + return this.subStateManager.doActionSubState(abstractAF, ec02Instance, equinoxRawData); + } +} diff --git a/src/th/co/ais/ssbsrfc/interfaces/Atomic.java b/src/th/co/ais/ssbsrfc/interfaces/Atomic.java new file mode 100644 index 0000000..8fa0b24 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/interfaces/Atomic.java @@ -0,0 +1,7 @@ +package th.co.ais.ssbsrfc.interfaces; + +public interface Atomic { + public String command_get = "get"; + public String command_increase = "increase"; + public String command_clear = "clear"; +} diff --git a/src/th/co/ais/ssbsrfc/interfaces/EQXMsg.java b/src/th/co/ais/ssbsrfc/interfaces/EQXMsg.java new file mode 100644 index 0000000..de9ef24 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/interfaces/EQXMsg.java @@ -0,0 +1,70 @@ +package th.co.ais.ssbsrfc.interfaces; + +public interface EQXMsg { + public String ORIG = "orig"; + + public String INVOKE = "invoke"; + public String TYPE = "type"; + public String CTYPE = "ctype"; + public String NAME = "name"; + public String OID = "oid"; + public String VAL = "val"; + public String ECODE = "ecode"; + public String URL = "url"; + public String METHOD = "method"; + + public String OID_CODE = ""; + + //message + public String EMPTY = ""; + + //type + public String REQUEST = "request"; + public String RESPONSE = "response"; + public String NOREPLY = "noreply"; + + //ctype + public String UNKNOWN = "unknown"; + + //method + public String POST = "POST"; + public String GET = "GET"; + public String PUT = "PUT"; + public String DELETE = "DELETE"; + + //http + public String HTTP = "HTTP"; + public String TEXTPLAIN = "text/plain"; + public String TEXTXML = "text/xml"; + public String TEXTHTML = "text/html"; + public String FILECONTROL = "FILECONTROL"; + public String APPSOAPXML = "application/soap-xml"; + public String SPECIALIZEDRESOURCE = "Specialized-Resource"; + public String RESOURCEREPORT = "Resource-Report"; + public String ONETIMEPASSWORD = "One-Time-Password"; + public String CONFIRMONETIMEPASSWORD = "Confirm-One-Time-Password"; + + //ldap + public String LDAP = "LDAP"; + public String SEARCH = "search"; + public String MODIFY = "modify"; +// public String DELETE = "delete"; + public String EXTENDED = "extended"; + public String EXECUTE = "execute"; + + //smpp + public String SMPP = "SMPP"; + + //diameter + public String DIAMETER = "DIAMETER"; + + // type ES00 + public int TYPE_START = 1; + public int TYPE_FINISH = 2; + public int TYPE_ERROR = 3; + + // state ES00 + public int STATE_START = 1; + public int STATE_FINISH = 2; + +} diff --git a/src/th/co/ais/ssbsrfc/interfaces/IAFSubState.java b/src/th/co/ais/ssbsrfc/interfaces/IAFSubState.java new file mode 100644 index 0000000..68da943 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/interfaces/IAFSubState.java @@ -0,0 +1,11 @@ +package th.co.ais.ssbsrfc.interfaces; + +import java.util.List; + +import th.co.ais.ssbsrfc.instance.EC02Instance; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; + +public interface IAFSubState{ + public List doActionSubState(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData); +} diff --git a/src/th/co/ais/ssbsrfc/message/EC02Builder.java b/src/th/co/ais/ssbsrfc/message/EC02Builder.java new file mode 100644 index 0000000..417c341 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/message/EC02Builder.java @@ -0,0 +1,317 @@ +package th.co.ais.ssbsrfc.message; + +import java.util.ArrayList; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.Invoke; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.EQXRawInstance; +import th.co.ais.ssbsrfc.instance.Response; +import th.co.ais.ssbsrfc.instance.Stat; +import th.co.ais.ssbsrfc.interfaces.Atomic; +import th.co.ais.ssbsrfc.interfaces.EQXMsg; +import th.co.ais.ssbsrfc.utils.EqxStringUtils; +import th.co.ais.ssbsrfc.utils.Global; +import th.co.ais.ssbsrfc.utils.Log; +import ais.mmt.sand.comlog.DetailsLogPrototype; +import ais.mmt.sand.comlog.bean.DataBean; +import ais.mmt.sand.comlog.bean.DataBean.TYPE; +import ais.mmt.sand.comlog.exception.CommonLogException; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.af.data.KeyObject; +import ec02.utils.AppLog; + +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(); + String timeout = null; + for (int i = 0; i < eqxRawList.size(); i++) { + String type = eqxRawList.get(i).getType(); + if (type == null) { + eqxRawList.get(i).setType(EQXMsg.REQUEST); + } + this.msgBuilder = new EC02MSGBuilder(eqxRawList.get(i)); + this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke() + i); + + timeout = eqxRawList.get(i).getTimeout(); + + EquinoxRawData rowData = this.msgBuilder.getHttpMessage(); + this.logDetailOutput(rowData, eqxRawList.get(i).getDataOutput(), eqxRawList.get(i).getNodeTo(), eqxRawList.get(i).getCommand()); + eqxRawDataList.add(rowData); + } + if (timeout != null) { + this.ec02Ins.setTimeout(timeout); + } + this.ec02Ins.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + " Send Total Armed Event")); + return eqxRawDataList; + } + + public EquinoxRawData getRequest(EQXRawInstance eqxRaw) { + String type = eqxRaw.getType(); + if (type == null) { + eqxRaw.setType(EQXMsg.REQUEST); + } + this.msgBuilder = new EC02MSGBuilder(eqxRaw); + this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke()); + String timeout = eqxRaw.getTimeout(); + if (timeout != null) { + this.ec02Ins.setTimeout(timeout); + } + EquinoxRawData rowData = this.msgBuilder.getHttpMessage(); + this.logDetailOutput(rowData, eqxRaw.getDataOutput(), eqxRaw.getNodeTo(), eqxRaw.getCommand()); + return rowData; + } + + public EquinoxRawData getRequestJobTracking(EQXRawInstance eqxRaw) { + String type = eqxRaw.getType(); + if (type == null) { + eqxRaw.setType(EQXMsg.REQUEST); + } + this.msgBuilder = new EC02MSGBuilder(eqxRaw); + this.msgBuilder.setInvoke(this.ec02Ins.getAFInstance().getInvoke()); + String timeout = eqxRaw.getTimeout(); + if (timeout != null) { + this.ec02Ins.setTimeout(timeout); + } + + // set orig/invoke + String key = eqxRaw.getInvoke(); + String orig = ""; + String invoke = ""; + if (this.eqxRawData != null) { + orig = this.eqxRawData.getRawDataAttribute(EQXMsg.ORIG); + invoke = this.eqxRawData.getInvoke(); + } else { + orig = this.ec02Ins.getAFInstance().getOrig(); + invoke = this.ec02Ins.getAFInstance().getInvoke(); + } + if (!(new Invoke(key).eventType).equals(EQXMsg.UNKNOWN)) { + Response res = new Response (orig, invoke) ; + this.ec02Ins.getAFInstance().setListOrigKey(key, res); +// AppLog.d("## RESPONSE[MG]: " + orig + "/" + invoke); + } + EquinoxRawData rowData = this.msgBuilder.getHttpMessage(); + this.logDetailOutput(rowData, eqxRaw.getDataOutput(), eqxRaw.getNodeTo(), eqxRaw.getCommand()); + return rowData; + } + + public EquinoxRawData getHTTPResponse(EQXRawInstance eqxRaw){ + eqxRaw.setType(EQXMsg.RESPONSE); + this.msgBuilder = new EC02MSGBuilder(eqxRaw); + String invoke = (eqxRaw.getInvoke() == null) ? this.ec02Ins.getAFInstance().getInvoke() : eqxRaw.getInvoke(); + if (invoke != null && !invoke.equals("")) { + this.msgBuilder.setInvoke(invoke); + } + EquinoxRawData rowData = this.msgBuilder.getHttpMessage(); + this.logDetailOutput(rowData, eqxRaw.getDataOutput(), eqxRaw.getNodeTo(), eqxRaw.getCommand()); + String subState = (eqxRaw.getSubState() == null) ? "" : eqxRaw.getSubState(); + if (!subState.equals("")) { + rowData.getRawDataAttributes().put("subState", subState); + } + String timeout = eqxRaw.getTimeout(); + if (timeout != null) { + this.ec02Ins.setTimeout(timeout); + } + 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 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 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 void getE01Request() { + this.getE01Request(false); + } + + public void getE01Request(boolean bool) { + String serviceName = this.ec02Ins.getE01Ins().getServiceName(); + if (serviceName == null) { + serviceName = this.abstractAF.getUtils().getHmWarmConfig().get("Resource-Name-E01").get(0).trim(); + } + this.abstractAF.getUtils().getGlobalData().configService(serviceName); + KeyObject keyobj = new KeyObject(); + keyobj.setObjectType(this.ec02Ins.getE01Ins().getObjType()); + ArrayList keyList = this.ec02Ins.getE01Ins().getKey(); +// for (int i = 0; i < keyList.size(); i++) { +// AppLog.d("## key " + i + " " + keyList.get(i)); +// keyobj.setKey(String.valueOf(i), keyList.get(i)); +// } + String[] stringArray = keyList.toArray(new String[keyList.size()]); + for (int i = 0; i < stringArray.length; i++) { + AppLog.d("## key " + i + " " + stringArray[i]); + } + AppLog.d("## keyObj :" + stringArray.length); + if(this.ec02Ins.getE01Ins().getCmd().equals("search")){ +// this.abstractAF.getUtils().getGlobalData().search(keyobj, this.ec02Ins.getE01Ins().getId()); + this.abstractAF.getUtils().getGlobalData().search(this.ec02Ins.getE01Ins().getObjType(), stringArray, this.ec02Ins.getE01Ins().getId()); + } + else if(this.ec02Ins.getE01Ins().getCmd().equals("delete")){ + this.abstractAF.getUtils().getGlobalData().delete(keyobj, this.ec02Ins.getE01Ins().getId()); + } + else if(this.ec02Ins.getE01Ins().getCmd().equals("add")){ + this.abstractAF.getUtils().getGlobalData().add(keyobj, this.ec02Ins.getE01Ins().getData(), this.ec02Ins.getE01Ins().getId()); + } + else if(this.ec02Ins.getE01Ins().getCmd().equals("replace")){ + this.abstractAF.getUtils().getGlobalData().replace(keyobj, this.ec02Ins.getE01Ins().getData(), this.ec02Ins.getE01Ins().getId()); + } + this.abstractAF.getUtils().getGlobalData().setTransactionId(this.ec02Ins.getE01Ins().getInvoke()); + // timeout + String timeout = this.ec02Ins.getE01Ins().getTimeout(); + if (timeout != null) { + this.ec02Ins.setTimeout(timeout); + } + if (bool) { + String objType = this.ec02Ins.getE01Ins().getObjType(); + this.ec02Ins.getAFInstance().getListStat().add(new Stat(this.ec02Ins.getAFInstance().getCurrentState(), Constant.TYPE_SEND, Constant.TYPE_REQUEST, Constant.TYPE_SUCCESS, objType)); + } else { + this.ec02Ins.getAFInstance().getListStat().add(new Stat(this.ec02Ins.getAFInstance().getCurrentState(), Constant.TYPE_SEND, Constant.TYPE_REQUEST)); + } + } + + public void getE01AtomicRequest() + { + String command = this.ec02Ins.getAtomic().getCommand(); + String atomicName = this.ec02Ins.getAtomic().getName(); + if (command.equals(Atomic.command_get)) { + this.abstractAF.getUtils().getGlobalData().get(atomicName); + } else if(command.equals(Atomic.command_increase)) { + long atomicValue = this.ec02Ins.getAtomic().getValue(); + this.abstractAF.getUtils().getGlobalData().increase(atomicName, atomicValue, this.ec02Ins.getAtomic().getMin(), this.ec02Ins.getAtomic().getMax()); + } else if(command.equals(Atomic.command_clear)) { + this.abstractAF.getUtils().getGlobalData().clear(atomicName); + } + this.abstractAF.getUtils().getGlobalData().setTransactionId(this.ec02Ins.getE01Ins().getInvoke()); + this.ec02Ins.getAFInstance().getListStat().add(new Stat(this.ec02Ins.getAFInstance().getCurrentState(), Constant.TYPE_SEND, Constant.TYPE_REQUEST)); + // timeout + String timeout = this.ec02Ins.getE01Ins().getTimeout(); + if (timeout != null) { + this.ec02Ins.setTimeout(timeout); + } + } + + public EquinoxRawData getUpdateIns(){ + this.msgBuilder = new EC02MSGBuilder(); + this.ec02Ins.setTimeout(this.abstractAF.getUtils().getHmWarmConfig().get("Update-Instance-timeout").get(0)); + return this.msgBuilder.getUpdateIns(); + } + + private void logDetailOutput(EquinoxRawData equinoxRawData, Object data, String nodeTo, String command) + { + if (Log.debug) { + AppLog.d("## LOGDETAIL_OUTPUT NODETO:" + nodeTo + " command:" + command); + } + // Log Detail Output + if (data != null) { + String currentState = ""; + String cmd = (command == null ) ? StateConfig.getCommandFromState(currentState) : command; + if (nodeTo == null && currentState != null) { + String eventType = StateConfig.getEventTypeFromSubState(currentState); + nodeTo = Global.getNodeFromEventType(eventType); + } + String invoke = equinoxRawData.getInvoke(); + String type = equinoxRawData.getRawDataAttribute("type"); + String rawData = EqxStringUtils.getMessage(equinoxRawData, null, false); + + DetailsLogPrototype detLog = this.ec02Ins.getAFInstance().getDetaillog(); + DataBean output = new DataBean(); + output.setInvoke(invoke); + output.setDirector(nodeTo); + output.setCommandName(cmd); + + if(type.equals("response")) { + output.setType(TYPE.RES); + } else { + output.setType(TYPE.REQ); + } + + output.setJsonData(MessageParser.toJsonObject(data)); + output.setRawData(Global.getDetailLogRawData(rawData)); + try { + detLog.addOutput(output); + } catch (CommonLogException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +} diff --git a/src/th/co/ais/ssbsrfc/message/EC02MSGBuilder.java b/src/th/co/ais/ssbsrfc/message/EC02MSGBuilder.java new file mode 100644 index 0000000..3875bec --- /dev/null +++ b/src/th/co/ais/ssbsrfc/message/EC02MSGBuilder.java @@ -0,0 +1,143 @@ +package th.co.ais.ssbsrfc.message; + +import java.util.HashMap; +import java.util.Map; + +import th.co.ais.ssbsrfc.instance.EQXRawInstance; +import th.co.ais.ssbsrfc.interfaces.EQXMsg; +import ec02.af.data.EquinoxRawData; + +public class EC02MSGBuilder { + private String message = null; + private EQXRawInstance eqxRawIns = null; + private EquinoxRawData eqxRawDatas = null; + private Map map = new HashMap(); + private String invoke = null; + + public EC02MSGBuilder(){ + this.eqxRawDatas = new EquinoxRawData(); + } + + public EC02MSGBuilder(EQXRawInstance eqxRawIns){ + this.setEqxRawIns(eqxRawIns); + this.eqxRawDatas = new EquinoxRawData(); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + public String getInvoke() { + return invoke; + } + + public void setInvoke(String invoke) { + this.invoke = invoke; + } + + public EquinoxRawData getDiameterMessage() { + String invoke = this.eqxRawIns.getInvoke(); + if (this.invoke != null || invoke != null) { + if (invoke != null) { + this.map.put(EQXMsg.INVOKE, invoke); + } else { + this.map.put(EQXMsg.INVOKE, this.invoke); + } + } + this.map.put(EQXMsg.NAME, EQXMsg.DIAMETER); + this.map.put(EQXMsg.TYPE, this.eqxRawIns.getType()); + this.map.put(EQXMsg.CTYPE, this.eqxRawIns.getCtype()); + this.eqxRawDatas.setRawDataAttributes(this.map); + this.eqxRawDatas.setTo(this.eqxRawIns.getTo()); + this.eqxRawDatas.setRawMessage(this.eqxRawIns.getMessage()); + + return this.eqxRawDatas; + } + + public EquinoxRawData getHttpMessage() { + String invoke = this.eqxRawIns.getInvoke(); + if (this.invoke != null || invoke != null) { + if (invoke != null) { + this.map.put(EQXMsg.INVOKE, invoke); + } else { + this.map.put(EQXMsg.INVOKE, this.invoke); + } + } + if (this.eqxRawIns.getName() != null) { + this.map.put(EQXMsg.NAME, this.eqxRawIns.getName()); + } else { + this.map.put(EQXMsg.NAME, EQXMsg.HTTP); + } + this.map.put(EQXMsg.TYPE, this.eqxRawIns.getType()); + this.map.put(EQXMsg.CTYPE, this.eqxRawIns.getCtype()); + // #TOM + if (this.eqxRawIns.getUrl() != null) { + this.map.put(EQXMsg.URL, this.eqxRawIns.getUrl()); + } + if (this.eqxRawIns.getMethod() != null) { + this.map.put(EQXMsg.METHOD, this.eqxRawIns.getMethod()); + } + // END + if(this.eqxRawIns.getCtype().equals(EQXMsg.TEXTPLAIN) || this.eqxRawIns.getCtype().equals(EQXMsg.TEXTHTML)) { + this.map.put(EQXMsg.VAL, this.eqxRawIns.getMessage()); + } + else { + this.eqxRawDatas.setRawMessage(this.eqxRawIns.getMessage()); + } + this.eqxRawDatas.setRawDataAttributes(this.map); + this.eqxRawDatas.setTo(this.eqxRawIns.getTo()); + + return this.eqxRawDatas; + } + + public EquinoxRawData getLdapMessage() { + if (this.invoke != null) + this.map.put(EQXMsg.INVOKE, this.invoke); + this.map.put(EQXMsg.NAME, EQXMsg.LDAP); + this.map.put(EQXMsg.TYPE, this.eqxRawIns.getType()); + this.map.put(EQXMsg.CTYPE, this.eqxRawIns.getCtype()); + this.map.put(EQXMsg.OID, this.eqxRawIns.getOid()); + this.eqxRawDatas.setRawDataAttributes(this.map); + this.eqxRawDatas.setTo(this.eqxRawIns.getTo()); + this.eqxRawDatas.setRawMessage(this.eqxRawIns.getMessage()); + + return this.eqxRawDatas; + } + + public EquinoxRawData getSMPPMessage() { + if (this.invoke != null) + this.map.put(EQXMsg.INVOKE, this.invoke); + this.map.put(EQXMsg.NAME, EQXMsg.SMPP); + this.map.put(EQXMsg.TYPE, this.eqxRawIns.getType()); + this.map.put(EQXMsg.CTYPE, this.eqxRawIns.getCtype()); + this.eqxRawDatas.setRawDataAttributes(this.map); + this.eqxRawDatas.setTo(this.eqxRawIns.getTo()); + this.eqxRawDatas.setRawMessage(this.eqxRawIns.getMessage()); + + return this.eqxRawDatas; + } + + public EquinoxRawData getUpdateIns() { + return this.eqxRawDatas; + } + + public EQXRawInstance getEqxRawIns() { + return eqxRawIns; + } + + public void setEqxRawIns(EQXRawInstance eqxRawIns) { + this.eqxRawIns = eqxRawIns; + } +} diff --git a/src/th/co/ais/ssbsrfc/message/MSGParser.java b/src/th/co/ais/ssbsrfc/message/MSGParser.java new file mode 100644 index 0000000..413bb65 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/message/MSGParser.java @@ -0,0 +1,68 @@ +package th.co.ais.ssbsrfc.message; + +import java.util.ArrayList; + +import th.co.ais.ssbsrfc.instance.AFInstance; +import th.co.ais.ssbsrfc.instance.E01Instance; + +public class MSGParser { + private String msg = ""; + private E01Instance e01Ins = null; + private AFInstance afInstance = null; + + + + public MSGParser(String msg){ + this.msg = msg; + } + + public void extractHTTPMessage(AFInstance afIns){ + this.afInstance = afIns; + + } + + public void extractE01Message(E01Instance e01Ins){ + this.e01Ins = e01Ins; + ArrayList key = null; + String [] e01msg = this.msg.split(":"); + String [] cmd = e01msg[0].split("="); + this.e01Ins.setCmd(cmd[1].trim()); + String [] e01objAndkey = e01msg[1].split(","); + for(int i = 0; i < e01objAndkey.length; i++){ + String [] e01val = e01objAndkey[i].split("="); + if(e01val[0].trim().equalsIgnoreCase("objecttype")){ + this.e01Ins.setObjType(e01val[1].trim()); + } + else if(e01val[0].contains("key")){ + if(key == null){ + key = new ArrayList(); + } + key.add(e01val[1].trim()); + } + else if(e01val[0].trim().equalsIgnoreCase("data")){ + this.e01Ins.setData(e01val[1].trim()); + } + else if(e01val[0].trim().equalsIgnoreCase("id")){ + this.e01Ins.setId(e01val[1].trim()); + } + } + + this.e01Ins.setKey(key); + } + + public E01Instance getE01Ins() { + return e01Ins; + } + + public void setE01Ins(E01Instance e01Ins) { + this.e01Ins = e01Ins; + } + + public AFInstance getAFInstance() { + return afInstance; + } + + public void setMsgIns(AFInstance afInstance) { + this.afInstance = afInstance; + } +} diff --git a/src/th/co/ais/ssbsrfc/message/MessageParser.java b/src/th/co/ais/ssbsrfc/message/MessageParser.java new file mode 100644 index 0000000..eecbd99 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/message/MessageParser.java @@ -0,0 +1,330 @@ +package th.co.ais.ssbsrfc.message; + +import java.io.ByteArrayInputStream; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.soap.MessageFactory; +import javax.xml.soap.SOAPBody; +import javax.xml.soap.SOAPEnvelope; +import javax.xml.soap.SOAPMessage; +import javax.xml.soap.SOAPPart; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import ec02.utils.AppLog; +import th.co.ais.ssbsrfc.instance.AdjustmentResponseIns; +import th.co.ais.ssbsrfc.instance.SOAPNamespaceMapper; + +public class MessageParser +{ + public static String toXml(Object obj) { + String strXml = ""; + StringWriter sw = new StringWriter(); + + try { + JAXBContext jc = JAXBContext.newInstance(obj.getClass()); + + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); + marshaller.marshal(obj, sw); + strXml = sw.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + + return strXml; + } + + public static String toXmlWithoutRoot(Object obj) { + String strXml = ""; + StringWriter sw = new StringWriter(); + + try { + JAXBContext jc = JAXBContext.newInstance(obj.getClass()); + + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); + marshaller.marshal(obj, sw); + strXml = sw.toString().replace("", "").replace("", ""); + } catch (Exception e) { + e.printStackTrace(); + } + + return strXml; + } + + public static String toXml(Object obj, String rootElement) { + String strXml = ""; + StringWriter sw = new StringWriter(); + + try { + JAXBContext jc = JAXBContext.newInstance(obj.getClass()); + + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); + marshaller.marshal(obj, sw); + strXml = sw.toString().replace("root", rootElement); + } catch (Exception e) { + e.printStackTrace(); + } + + return strXml; + } + + @SuppressWarnings("rawtypes") + public static String toXmlWithNamespace(Object obj, Class objClass, Object namespaceMapper) { + String strXml = ""; + StringWriter sw = new StringWriter(); + + try { + JAXBContext jc = JAXBContext.newInstance(objClass); + + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); + marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", namespaceMapper); + marshaller.marshal(obj, sw); + strXml = sw.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + + return strXml; + } + + @SuppressWarnings("rawtypes") + public static Object fromXml(String strXml, Class objClass) { + Object obj = null; + + try { + strXml = removeXmlVersion(strXml); + JAXBContext jc = JAXBContext.newInstance(objClass); + Unmarshaller unmarshaller = jc.createUnmarshaller(); + StringReader reader = new StringReader(strXml); + + obj = unmarshaller.unmarshal(reader); + } catch (Exception e) { + e.printStackTrace(); + } + + return obj; + } + + @SuppressWarnings("rawtypes") + public static Object fromXmlWithoutRoot(String strXml, Class objClass) { + Object obj = null; + + try { + strXml = "" + removeXmlVersion(strXml) + ""; + JAXBContext jc = JAXBContext.newInstance(objClass); + Unmarshaller unmarshaller = jc.createUnmarshaller(); + StringReader reader = new StringReader(strXml); + + obj = unmarshaller.unmarshal(reader); + } catch (Exception e) { + e.printStackTrace(); + } + + return obj; + } + + public static String toSoap(Object obj) { + String message = ""; + + try { + JAXBContext jc = JAXBContext.newInstance(obj.getClass()); + + MessageFactory messageFactory = MessageFactory.newInstance(); + SOAPMessage outgoingMessage = messageFactory.createMessage(); + SOAPPart soappart = outgoingMessage.getSOAPPart(); + SOAPEnvelope envelope = soappart.getEnvelope(); + envelope.addNamespaceDeclaration("def", "http://definition.webservices.daa.ema.com/"); + + envelope.removeNamespaceDeclaration("SOAP-ENV"); + envelope.removeNamespaceDeclaration("cbs"); + envelope.removeNamespaceDeclaration("arc"); + envelope.removeNamespaceDeclaration("ars"); + envelope.addNamespaceDeclaration("soapenv", "http://schemas.xmlsoap.org/soap/envelope/"); + envelope.addNamespaceDeclaration("cbs", "http://www.huawei.com/bme/cbsinterface/cbscommon"); + envelope.addNamespaceDeclaration("arc", "http://cbs.huawei.com/ar/wsservice/arcommon"); + envelope.addNamespaceDeclaration("ars", "http://www.huawei.com/bme/cbsinterface/arservices"); + envelope.setPrefix("soapenv"); + outgoingMessage.getSOAPHeader().setPrefix("soapenv"); + outgoingMessage.getSOAPBody().setPrefix("soapenv"); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + org.w3c.dom.Document doc = dbf.newDocumentBuilder().newDocument(); + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ); + marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new SOAPNamespaceMapper()); + marshaller.marshal( obj, doc ); + + SOAPBody body = envelope.getBody(); + body.addDocument(doc); + + outgoingMessage.saveChanges(); + + StringWriter sw = new StringWriter(); + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.transform(new DOMSource(outgoingMessage.getSOAPPart()), new StreamResult(sw)); + + message = sw.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + + return message; + } + + public static String toSoap(Object obj, String namespacePrefix, String namespaceUrl) { + String message = ""; + + try { + JAXBContext jc = JAXBContext.newInstance(obj.getClass()); + + MessageFactory messageFactory = MessageFactory.newInstance(); + SOAPMessage outgoingMessage = messageFactory.createMessage(); + SOAPPart soappart = outgoingMessage.getSOAPPart(); + SOAPEnvelope envelope = soappart.getEnvelope(); + envelope.addNamespaceDeclaration(namespacePrefix, namespaceUrl); + + envelope.removeNamespaceDeclaration("SOAP-ENV"); + envelope.addNamespaceDeclaration("soapenv", "http://schemas.xmlsoap.org/soap/envelope/"); + envelope.setPrefix("soapenv"); + outgoingMessage.getSOAPHeader().setPrefix("soapenv"); + outgoingMessage.getSOAPBody().setPrefix("soapenv"); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + org.w3c.dom.Document doc = dbf.newDocumentBuilder().newDocument(); + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ); + marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new SOAPNamespaceMapper() ); + marshaller.marshal( obj, doc ); + + SOAPBody body = envelope.getBody(); + body.addDocument(doc); + + outgoingMessage.saveChanges(); + + StringWriter sw = new StringWriter(); + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.transform(new DOMSource(outgoingMessage.getSOAPPart()), new StreamResult(sw)); + + message = sw.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + + return message; + } + + @SuppressWarnings("rawtypes") + public static Object fromSoap(String strSoap, Class objClass) { + Object obj = null; + + try { + SOAPMessage message = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(strSoap.getBytes())); + Unmarshaller unmarshaller = JAXBContext.newInstance(objClass).createUnmarshaller(); + SOAPBody body = message.getSOAPBody(); + if(body != null && !body.getTextContent().trim().equals("")) { + obj = unmarshaller.unmarshal(body.extractContentAsDocument()); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return obj; + } + + public static AdjustmentResponseIns formsoap(String ss) throws XMLStreamException, JAXBException{ + + Reader reader = new StringReader(ss); + XMLInputFactory factory = XMLInputFactory.newInstance(); // Or newFactory() + XMLStreamReader xsr = factory.createXMLStreamReader(reader); + + AppLog.d("IN:"+xsr); + xsr.nextTag(); + int i =0; + while(!xsr.getLocalName().equals("ResultHeader")) { + xsr.nextTag(); + AppLog.d("I HERE:"+i++); + } + + JAXBContext jc = JAXBContext.newInstance(AdjustmentResponseIns.class); + Unmarshaller unmarshaller = jc.createUnmarshaller(); + JAXBElement jb = unmarshaller.unmarshal(xsr, AdjustmentResponseIns.class); + xsr.close(); + + AdjustmentResponseIns customer = jb.getValue(); + return customer; + } + + public static String toJson(Object obj) { + String strJson = ""; + + try { + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + strJson = gson.toJson(obj, obj.getClass()); + } catch (Exception e) { + e.printStackTrace(); + } + + return strJson; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static Object fromJson(String strJson, Class objClass) { + Object obj = null; + try { + Gson gson = new Gson(); + obj = gson.fromJson(strJson, objClass); + } catch (Exception e) { + e.printStackTrace(); + } + + return obj; + } + + public static JsonObject toJsonObject(Object obj) { + JsonObject jsonObj = null; + + try { + Gson gson = new Gson(); + JsonElement element = gson.fromJson (MessageParser.toJson(obj), JsonElement.class); + jsonObj = element.getAsJsonObject(); + } catch (Exception e) { + e.printStackTrace(); + } + + return jsonObj; + } + + private static String removeXmlVersion(String value) + { + return value.replaceAll("\\<\\?xml(.+?)\\?\\>", ""); + } +} diff --git a/src/th/co/ais/ssbsrfc/state/StateIdle.java b/src/th/co/ais/ssbsrfc/state/StateIdle.java new file mode 100644 index 0000000..9363a43 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/state/StateIdle.java @@ -0,0 +1,115 @@ +package th.co.ais.ssbsrfc.state; + +import java.util.ArrayList; +import java.util.List; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.control.FlowManager; +import th.co.ais.ssbsrfc.control.SubStateManager; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.ManageTime; +import th.co.ais.ssbsrfc.utils.Global; +import th.co.ais.ssbsrfc.utils.Log; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.af.interfaces.IAFState; +import ec02.utils.AppLog; + +public class StateIdle implements IAFState { + + private String eqxState = null; + private ArrayList eqxRawDataList = new ArrayList(); + + @Override + public String doAction(AbstractAF abstractAF, Object instance, ArrayList eqxRawDataList) { + AppLog.d("[### StateIdle ###]"); + EC02Instance ec02Instance = (EC02Instance) instance; + Global.getConfigEC02(abstractAF, ec02Instance); + // MultiFlow new + if (StateConfig.isMultiFlow) { + // E01 Recieve + if (abstractAF.getUtils().getGlobalData().isRecieve()) { + EquinoxRawData eqxRaw = new EquinoxRawData(); + eqxRaw.setInvoke(abstractAF.getUtils().getGlobalData().getTransactionId()); + eqxRaw.setType(Constant.RESPONSE.toLowerCase()); + eqxRaw.setRawEventType(StateConfig.Incoming_Unknown); + + this.subStateManager(abstractAF, ec02Instance, eqxRaw); + Log.detailLog(ec02Instance, abstractAF, StateConfig.STATE_IDLE, this.eqxState, eqxRawDataList, this.eqxRawDataList); + Log.summaryLog(ec02Instance, abstractAF); + } + // rowdatalist + if (eqxRawDataList != null) { + FlowManager flowManager = new FlowManager(abstractAF, ec02Instance); + for(EquinoxRawData equinoxRawData : eqxRawDataList) { + // manage flow start + flowManager.start(equinoxRawData); + this.subStateManager(abstractAF, ec02Instance, equinoxRawData); + flowManager.end(StateConfig.STATE_IDLE, this.eqxState, eqxRawDataList, this.eqxRawDataList); + } + } + ec02Instance.setEqxRawDataList(this.eqxRawDataList); + } else { + for(EquinoxRawData equinoxRawData : eqxRawDataList) { + ec02Instance.getAFInstance().setInitialInvoke(equinoxRawData.getInvoke()); + String eventType = equinoxRawData.getRawEventType(); + String ssName = StateConfig.getSubStateFromEventType(eventType); + SubStateManager subStateManager = new SubStateManager(ssName); + List eqxList = subStateManager.doActionSubState(abstractAF, ec02Instance, equinoxRawData); + String currentState = ec02Instance.getAFInstance().getCurrentState(); + for(EquinoxRawData eqx : eqxList) { + String type = eqx.getType(); + String invoke = eqx.getInvoke(); + if (type.equals("request") && (invoke.length() > 0 || invoke != null)) { + ec02Instance.getAFInstance().putDicInvoke(invoke, Global.getInvokeForManageFlow(ec02Instance)); + } + this.eqxRawDataList.add(eqx); + } + + if (currentState.equals("END") || currentState.equals("")) { + this.eqxState = StateConfig.STATE_IDLE; + } else { + this.eqxState = StateConfig.STATE_ACTIVE; + } + } + + int count = ec02Instance.getAFInstance().getListTimeout().size(); + if (count > 0 && ec02Instance.getTimeout() == null) { + ManageTime mt = new ManageTime(ec02Instance); + mt.setListTimeout(ec02Instance.getAFInstance().getListTimeout()); + String timeout = mt.getCalTime(); + ec02Instance.setTimeout(timeout); + } + Log.detailLog(ec02Instance, abstractAF, StateConfig.STATE_IDLE, this.eqxState, eqxRawDataList, this.eqxRawDataList); + Log.summaryLog(ec02Instance, abstractAF); + ec02Instance.setEqxRawDataList(this.eqxRawDataList); + } + AppLog.d("[### END StateIdle ###]"); + return this.eqxState; + } + + public void subStateManager(AbstractAF abstractAF,EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + String eventType = equinoxRawData.getRawEventType(); + String ssName = StateConfig.getSubStateFromEventType(eventType); + + SubStateManager subStateManager = new SubStateManager(ssName); + List eqxList = subStateManager.doActionSubState(abstractAF, ec02Instance, equinoxRawData); + for(EquinoxRawData eqx : eqxList) { + String type = eqx.getType(); + String invoke = eqx.getInvoke(); + if (type.equals("request") && (invoke.length() > 0 || invoke != null)) { + ec02Instance.getAFInstance().putDicInvoke(invoke, Global.getInvokeForManageFlow(ec02Instance)); + } + this.eqxRawDataList.add(eqx); + } + // END + String currentState = ec02Instance.getAFInstance().getCurrentState(); + if (currentState.equals("END")) { + this.eqxState = StateConfig.STATE_IDLE; + } else { + this.eqxState = StateConfig.STATE_ACTIVE; + } + } +} diff --git a/src/th/co/ais/ssbsrfc/state/StateWaitActive.java b/src/th/co/ais/ssbsrfc/state/StateWaitActive.java new file mode 100644 index 0000000..b0585f7 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/state/StateWaitActive.java @@ -0,0 +1,135 @@ +package th.co.ais.ssbsrfc.state; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang.ArrayUtils; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.control.FlowManager; +import th.co.ais.ssbsrfc.control.SubStateManager; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.ManageTime; +import th.co.ais.ssbsrfc.utils.Global; +import th.co.ais.ssbsrfc.utils.Log; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.af.data.GlobalData; +import ec02.af.interfaces.IAFState; +import ec02.utils.AppLog; + +public class StateWaitActive implements IAFState { + + private String eqxState = null; + private ArrayList eqxRawDataList = new ArrayList(); + + @Override + public String doAction(AbstractAF abstractAF, Object instance, ArrayList eqxRawDataList) { + AppLog.d("[### StateWaitActive ###]"); + EC02Instance ec02Instance = (EC02Instance) instance; + Global.getConfigEC02(abstractAF, ec02Instance); + // MultiFlow new + if (StateConfig.isMultiFlow) { + FlowManager flowManager = new FlowManager(abstractAF, ec02Instance); + // E01 + if (abstractAF.getUtils().getGlobalData().isRecieve() ) { + GlobalData e01 = abstractAF.getUtils().getGlobalData(); + String invoke = e01.getTransactionId(); + ec02Instance.getAFInstance().listTimeoutRemove(invoke); + EquinoxRawData equinoxRawData = new EquinoxRawData(); + equinoxRawData.setInvoke(invoke); + flowManager.start(equinoxRawData); + this.subStateManager(abstractAF, ec02Instance, null); + flowManager.end(StateConfig.STATE_ACTIVE, this.eqxState, eqxRawDataList, this.eqxRawDataList); + } else if (eqxRawDataList.isEmpty()) { // TIMEOUT + ManageTime mt = new ManageTime(); + mt.setListTimeout(ec02Instance.getAFInstance().getGlobalListTimeout()); + List listTimeout = mt.getState(false); + ec02Instance.getAFInstance().setGlobalListTimeout(mt.getListTimeout()); + for (String unique : listTimeout) { + EquinoxRawData equinoxRawData = new EquinoxRawData(); + equinoxRawData.getRawDataAttributes().put("unique", unique); + equinoxRawData.setRet("4"); + flowManager.start(equinoxRawData); + this.subStateManager(abstractAF, ec02Instance, null); + flowManager.end(StateConfig.STATE_ACTIVE, this.eqxState, eqxRawDataList, this.eqxRawDataList); + } + } + // CASE SUCCESS, ERROR, REJECT, ABORT + else { + for(EquinoxRawData equinoxRawData : eqxRawDataList) { + flowManager.start(equinoxRawData); + this.subStateManager(abstractAF, ec02Instance, equinoxRawData); + flowManager.end(StateConfig.STATE_ACTIVE, this.eqxState, eqxRawDataList, this.eqxRawDataList); + } + } + ec02Instance.setEqxRawDataList(this.eqxRawDataList); + this.checkEqxState(ec02Instance); + } else { + // E01, TIMEOUT + if (abstractAF.getUtils().getGlobalData().isRecieve() || eqxRawDataList.isEmpty()) { + this.subStateManager(abstractAF, ec02Instance, null); + } else { // CASE SUCCESS, ERROR, REJECT, ABORT + for(EquinoxRawData equinoxRawData : eqxRawDataList) { + this.subStateManager(abstractAF, ec02Instance, equinoxRawData); + } + } + + int count = ec02Instance.getAFInstance().getListTimeout().size(); + if (count > 0 && ec02Instance.getTimeout() == null) { + ManageTime mt = new ManageTime(ec02Instance); + mt.setListTimeout(ec02Instance.getAFInstance().getListTimeout()); + String timeout = mt.getCalTime(); + if (timeout == null) { + timeout = "0"; + } + ec02Instance.setTimeout(timeout); + } + Log.detailLog(ec02Instance, abstractAF, StateConfig.STATE_ACTIVE, this.eqxState, eqxRawDataList, this.eqxRawDataList); + Log.summaryLog(ec02Instance, abstractAF); + ec02Instance.setEqxRawDataList(this.eqxRawDataList); + this.checkEqxState(ec02Instance); + } + AppLog.d("[### END StateWaitActive ###]"); + return this.eqxState; + } + + public void subStateManager(AbstractAF abstractAF,EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + String currentState = ec02Instance.getAFInstance().getCurrentState(); + if (currentState.equals(StateConfig.SSTATE_END)) { + String eventType = equinoxRawData.getRawEventType(); + currentState = StateConfig.getSubStateFromEventType(eventType); + } + + SubStateManager subStateManager = new SubStateManager(currentState); + List eqxList = subStateManager.doActionSubState(abstractAF, ec02Instance, equinoxRawData); + for(EquinoxRawData eqx : eqxList) { + String type = eqx.getType(); + String invoke = eqx.getInvoke(); + if (type.equals("request") && (invoke.length() > 0 || invoke != null)) { + ec02Instance.getAFInstance().putDicInvoke(invoke, Global.getInvokeForManageFlow(ec02Instance)); + } + this.eqxRawDataList.add(eqx); + } + + // END + currentState = ec02Instance.getAFInstance().getCurrentState(); + if (currentState.equals("END")) { + this.eqxState = StateConfig.STATE_IDLE; + } else { + this.eqxState = StateConfig.STATE_ACTIVE; + } + } + + public void checkEqxState(EC02Instance ec02Instance) + { + if (!ArrayUtils.contains(Constant.arrSingleFlow, ec02Instance.getAFInstance().getFlow())) { + int count = ec02Instance.getAFInstance().getListFlow().size(); + if (count > 0 && this.eqxState.equals(StateConfig.STATE_IDLE)) { + this.eqxState = StateConfig.STATE_ACTIVE; + } + } + } +} diff --git a/src/th/co/ais/ssbsrfc/state/StateWaitE11Timeout.java b/src/th/co/ais/ssbsrfc/state/StateWaitE11Timeout.java new file mode 100644 index 0000000..9dba596 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/state/StateWaitE11Timeout.java @@ -0,0 +1,34 @@ +package th.co.ais.ssbsrfc.state; + +import java.util.ArrayList; + +import th.co.ais.ssbsrfc.instance.EC02Instance; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxProperties; +import ec02.af.data.EquinoxRawData; +import ec02.af.interfaces.IAFState; +import ec02.utils.AppLog; + +public class StateWaitE11Timeout implements IAFState { + + private String eqxState = null; + private ArrayList eqxRawDataList = new ArrayList(); + + @Override + public String doAction(AbstractAF abstractAF, Object instance, ArrayList eqxRawDataList) { + EC02Instance ec02Instance = (EC02Instance) instance; + for(EquinoxRawData equinoxRawData : eqxRawDataList) { + String eventType = equinoxRawData.getRawEventType(); + AppLog.d("## EVENTTYPE :" + eventType); + } + // TIMEOUT + EquinoxProperties eqxProp = ec02Instance.getEquinoxProperties(); + String diag = eqxProp.getDiag(); + if (diag.equals("Timeout")) { + AppLog.d("## RET:4 DIAG:TIMEOUT"); + } + ec02Instance.setEqxRawDataList(this.eqxRawDataList); + return this.eqxState; + } + +} diff --git a/src/th/co/ais/ssbsrfc/substate/SubMessages.java b/src/th/co/ais/ssbsrfc/substate/SubMessages.java new file mode 100644 index 0000000..5254c07 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/SubMessages.java @@ -0,0 +1,84 @@ +package th.co.ais.ssbsrfc.substate; + +import ec02.af.abstracts.AbstractAF; +import ec02.utils.AppLog; +import th.co.ais.ssbsrfc.config.Invoke; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.AdjustmentRequestIns; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.EQXRawInstance; +import th.co.ais.ssbsrfc.interfaces.EQXMsg; +import th.co.ais.ssbsrfc.message.MessageParser; +import th.co.ais.ssbsrfc.utils.Global; + + + +public class SubMessages { + + public static EQXRawInstance getRawAdjustmentRequest(AbstractAF abstractAF, EC02Instance ec02Instancee, String eventType,AdjustmentRequestIns ajr) + { + + AdjustmentRequestIns ins = ajr; + String message = MessageParser.toSoap(ins); + EQXRawInstance eqxRaw = new EQXRawInstance(); + String command = "Test B"; + String to = Global.getEC02WarmConfig("Resource-Name-SDF"); + String session = "SESSION"; + Invoke iv = new Invoke("B",session,command,eventType,null); + String invoke = iv.toString(); + eqxRaw.setMessage(message); + eqxRaw.setTo(to); + eqxRaw.setInvoke(invoke); + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); + + return eqxRaw; + } + + public static EQXRawInstance getRawAResponse(AbstractAF abstractAF, EC02Instance ec02Instancee, String to, String invoke,String mag) + { + String message = "Hello"; + String command = "A"; + + EQXRawInstance eqxRaw = new EQXRawInstance(); + eqxRaw.setMessage(message); + eqxRaw.setTo(to); + eqxRaw.setInvoke(invoke); + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); + eqxRaw.setCommand(command); + + return eqxRaw; + } + + public static EQXRawInstance getRawChargeRequestResponse(AbstractAF abstractAF, EC02Instance ec02Instancee, String to, String invoke,String mag) + { + String message = mag; + String command = "A"; + + EQXRawInstance eqxRaw = new EQXRawInstance(); + eqxRaw.setMessage(message); + eqxRaw.setTo(to); + eqxRaw.setInvoke(invoke); + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); + eqxRaw.setCommand(command); + + return eqxRaw; + } + + + public static EQXRawInstance getRawChargeReportResponse(AbstractAF abstractAF, EC02Instance ec02Instancee, String to, String invoke,String mag) + { + String message = mag; + String command = "A"; + + EQXRawInstance eqxRaw = new EQXRawInstance(); + eqxRaw.setMessage(message); + eqxRaw.setTo(to); + eqxRaw.setInvoke(invoke); + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); + eqxRaw.setCommand(command); + + return eqxRaw; + } + + +} diff --git a/src/th/co/ais/ssbsrfc/substate/SubMessagesE01.java b/src/th/co/ais/ssbsrfc/substate/SubMessagesE01.java new file mode 100644 index 0000000..4ea998b --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/SubMessagesE01.java @@ -0,0 +1,7 @@ +package th.co.ais.ssbsrfc.substate; + + + +public class SubMessagesE01 { + +} diff --git a/src/th/co/ais/ssbsrfc/substate/SubWaitA.java b/src/th/co/ais/ssbsrfc/substate/SubWaitA.java new file mode 100644 index 0000000..996def7 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/SubWaitA.java @@ -0,0 +1,54 @@ +package th.co.ais.ssbsrfc.substate; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.EQXRawInstance; +import th.co.ais.ssbsrfc.utils.EqxStringUtils; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.utils.AppLog; + + +public class SubWaitA extends WaitSubState { + public void configSubstate(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + this._state = StateConfig.SSTATE_W_A; + this._eventType = StateConfig.Incoming_A_Request; + this._stateType = Constant.SUBSTATE_TYPE_W_REQUEST; + if (equinoxRawData != null) { + ec02Instance.getAFInstance().setOrig(equinoxRawData.getOrig()); + ec02Instance.getAFInstance().setInvoke(equinoxRawData.getInvoke()); + ec02Instance.getAFInstance().setInitialInvoke(equinoxRawData.getInvoke()); + } + ec02Instance.getAFInstance().setFlow(Constant.FLOW_TEST_A); + } + + public Object getMessage(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + String value = EqxStringUtils.getMessage(equinoxRawData, ec02Instance); + AppLog.d("## PARAMETERS : " + value); + return value; + } + + public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + AppLog.d("## TEST MSG SUBSTATE A"); + this.type = Constant.TYPE_SUCCESS; + } + public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + switch (this.type) { + case Constant.TYPE_SUCCESS: + default: + { +// this.isStat = false; +// ec02Instance.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + " ABCDEFG STAT")); + + ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_END); + EQXRawInstance eqxRaw = SubMessages.getRawAResponse(abstractAF, ec02Instance, ec02Instance.getAFInstance().getOrig(), ec02Instance.getAFInstance().getInvoke(),"xx"); + this.equinoxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); + } + } + } +} diff --git a/src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeReportResponse.java b/src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeReportResponse.java new file mode 100644 index 0000000..beea99b --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeReportResponse.java @@ -0,0 +1,75 @@ +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.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.message.MessageParser; +import th.co.ais.ssbsrfc.utils.EqxStringUtils; + + +public class SubWaitAdjustmentChargeReportResponse extends WaitSubState { + + 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; + ec02Instance.getAFInstance().setFlow(Constant.FLOW_TEST_A); + } + + public Object getMessage(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + String value = EqxStringUtils.getMessage(equinoxRawData, ec02Instance); + AppLog.d("## PARAMETERS : " + value); + + + AdjustmentResponseIns ins = null; + try { + ins = (AdjustmentResponseIns) MessageParser.formsoap(value); + } catch (XMLStreamException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + AppLog.d(ins.getVersion()); + chargeReportIns.setResult("000"); + chargeReportIns.setPrepaidsubscriberflag("1"); + + return chargeReportIns; + } + + public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + + this.type = Constant.TYPE_SUCCESS; + } + + public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + switch (this.type) { + case Constant.TYPE_SUCCESS: + default: + { +// this.isStat = false; +// ec02Instance.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + " ABCDEFG 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)); + } + } + } +} diff --git a/src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeRequestResponse.java b/src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeRequestResponse.java new file mode 100644 index 0000000..9a502e0 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeRequestResponse.java @@ -0,0 +1,83 @@ +package th.co.ais.ssbsrfc.substate; + +import java.io.Reader; +import java.io.StringReader; + +import javax.xml.bind.JAXBException; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +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.AdjustmentResponseIns; +import th.co.ais.ssbsrfc.instance.ChargeResponseIns; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.EQXRawInstance; +import th.co.ais.ssbsrfc.message.MessageParser; +import th.co.ais.ssbsrfc.utils.EqxStringUtils; + + +public class SubWaitAdjustmentChargeRequestResponse extends WaitSubState { + + private ChargeResponseIns chargeResponseIns = new ChargeResponseIns(); + + public void configSubstate(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + this._state = StateConfig.SSTATE_W_ADJUSTMENT_CHARGEREQUEST; + this._eventType = StateConfig.Incoming_Adjustment_ChargeRequest_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); + + AdjustmentResponseIns ins=null; + + try { + ins = (AdjustmentResponseIns) MessageParser.formsoap(value); + } catch (XMLStreamException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + AppLog.d("MsgLanguageCode:"+ins.getMsgLanguageCode()); + chargeResponseIns.setResult("000"); + chargeResponseIns.setdesc("SUCCESS"); + chargeResponseIns.setChargingID("50928192340800649741"); + chargeResponseIns.setPrepaidsubscriberflag("1"); + + return chargeResponseIns; + } + + public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + + this.type = Constant.TYPE_SUCCESS; + } + + public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + + switch (this.type) { + + case Constant.TYPE_SUCCESS: + default: + { +// this.isStat = false; +// ec02Instance.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + " ABCDEFG STAT")); + String message = th.co.ais.ssbsrfc.message.MessageParser.toXml(chargeResponseIns); + ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_END); + EQXRawInstance eqxRaw = SubMessages.getRawChargeRequestResponse(abstractAF, ec02Instance, ec02Instance.getAFInstance().getOrig(), ec02Instance.getAFInstance().getInvoke(),message); + this.equinoxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); + } + } + } +} diff --git a/src/th/co/ais/ssbsrfc/substate/SubWaitChargeReport.java b/src/th/co/ais/ssbsrfc/substate/SubWaitChargeReport.java new file mode 100644 index 0000000..7627b63 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/SubWaitChargeReport.java @@ -0,0 +1,97 @@ +package th.co.ais.ssbsrfc.substate; + +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.AccessSecurity; +import th.co.ais.ssbsrfc.instance.AdjustmentInfo; +import th.co.ais.ssbsrfc.instance.AdjustmentObj; +import th.co.ais.ssbsrfc.instance.AdjustmentRequest; +import th.co.ais.ssbsrfc.instance.AdjustmentRequestIns; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.EQXRawInstance; +import th.co.ais.ssbsrfc.instance.OwnershipInfo; +import th.co.ais.ssbsrfc.instance.RequestHeader; +import th.co.ais.ssbsrfc.instance.SubAccessCode; + + +public class SubWaitChargeReport extends WaitSubState { + + AdjustmentRequestIns adjustmentRequest = new AdjustmentRequestIns(); + + public void configSubstate(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + this._state = StateConfig.SSTATE_W_CHARGEREPORT; + this._eventType = StateConfig.Incoming_ChargeReport_Request; + this._stateType = Constant.SUBSTATE_TYPE_W_REQUEST; + if (equinoxRawData != null) { + ec02Instance.getAFInstance().setOrig(equinoxRawData.getOrig()); + ec02Instance.getAFInstance().setInvoke(equinoxRawData.getInvoke()); + ec02Instance.getAFInstance().setInitialInvoke(equinoxRawData.getInvoke()); + } + ec02Instance.getAFInstance().setFlow(Constant.FLOW_TEST_A); + } + + public Object getMessage(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + RequestHeader requestHeader = new RequestHeader(); + requestHeader.setVersion("1"); + requestHeader.setBusinessCode("1"); + requestHeader.setMessageSeq("20160429104931209"); + OwnershipInfo ownershipInfo = new OwnershipInfo(); + ownershipInfo.setBEID("101"); + ownershipInfo.setBRID("101"); + requestHeader.setOwnershipInfo(ownershipInfo); + AccessSecurity accessSecurity = new AccessSecurity(); + accessSecurity.setLoginSystemCode("Xaysombath"); + accessSecurity.setPassword("ATBoomuNQidKc8iYhPgx5A=="); + requestHeader.setAccessSecurity(accessSecurity); + requestHeader.setAccessMode("3"); + + AdjustmentRequest adjustmentrequest = new AdjustmentRequest(); + adjustmentrequest.setAdjustmentSerialNo("20160429104632990"); + AdjustmentObj adjustmentObj = new AdjustmentObj(); + SubAccessCode subAccessCode = new SubAccessCode(); + subAccessCode.setPrimaryIdentity("2055579910"); + adjustmentObj.setSubAccessCode(subAccessCode); + adjustmentrequest.setAdjustmentObj(adjustmentObj); + adjustmentrequest.setOpType("1"); + AdjustmentInfo adjustmentInfo = new AdjustmentInfo(); + adjustmentInfo.setBalanceType("C_MAIN_ACCOUNT"); + adjustmentInfo.setAdjustmentType("1"); + adjustmentInfo.setAdjustmentAmt("1000"); + adjustmentInfo.setCurrencyID("1049"); + adjustmentrequest.setAdjustmentInfo(adjustmentInfo); + + adjustmentRequest.setRequestHeader(requestHeader); + adjustmentRequest.setAdjustmentRequest(adjustmentrequest); + + ec02Instance.getAFInstance().setAdjustmentRequestIns(adjustmentRequest); + + return adjustmentRequest; + } + + public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + AppLog.d("## TEST MSG SUBSTATE A"); + this.type = Constant.TYPE_SUCCESS; + } + + public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + switch (this.type) { + case Constant.TYPE_SUCCESS: + default: + { +// this.isStat = false; +// ec02Instance.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + " ABCDEFG STAT")); + ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_W_ADJUSTMENT_CHARGEREPORT); + EQXRawInstance eqxRaw = SubMessages.getRawAdjustmentRequest(abstractAF, ec02Instance,StateConfig.Incoming_Adjustment_ChargeReport_Response,adjustmentRequest); + + this.equinoxRawDataList.add(this.ec02Builder.getRequest(eqxRaw)); + } + } + } +} diff --git a/src/th/co/ais/ssbsrfc/substate/SubWaitChargeRequest.java b/src/th/co/ais/ssbsrfc/substate/SubWaitChargeRequest.java new file mode 100644 index 0000000..5136ac8 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/SubWaitChargeRequest.java @@ -0,0 +1,109 @@ +package th.co.ais.ssbsrfc.substate; + +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.AccessSecurity; +import th.co.ais.ssbsrfc.instance.AdjustmentInfo; +import th.co.ais.ssbsrfc.instance.AdjustmentObj; +import th.co.ais.ssbsrfc.instance.AdjustmentRequest; +import th.co.ais.ssbsrfc.instance.AdjustmentRequestIns; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.EQXRawInstance; +import th.co.ais.ssbsrfc.instance.OwnershipInfo; +import th.co.ais.ssbsrfc.instance.RequestHeader; +import th.co.ais.ssbsrfc.instance.SubAccessCode; +import th.co.ais.ssbsrfc.utils.EqxStringUtils; + + +public class SubWaitChargeRequest extends WaitSubState { + + AdjustmentRequestIns adjustmentRequest = new AdjustmentRequestIns(); + + public void configSubstate(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + this._state = StateConfig.SSTATE_W_CHARGEREQUEST; + this._eventType = StateConfig.Incoming_ChargeRequest_Request; + this._stateType = Constant.SUBSTATE_TYPE_W_REQUEST; + if (equinoxRawData != null) { + ec02Instance.getAFInstance().setOrig(equinoxRawData.getOrig()); + ec02Instance.getAFInstance().setInvoke(equinoxRawData.getInvoke()); + ec02Instance.getAFInstance().setInitialInvoke(equinoxRawData.getInvoke()); + } + ec02Instance.getAFInstance().setFlow(Constant.FLOW_TEST_A); + } + + public Object getMessage(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + String value = EqxStringUtils.getMessage(equinoxRawData, ec02Instance); + AppLog.d("## PARAMETERS : " + value); + + this.type = Constant.TYPE_SUCCESS; + + RequestHeader requestHeader = new RequestHeader(); + requestHeader.setVersion("1"); + requestHeader.setBusinessCode("1"); + requestHeader.setMessageSeq("20160429104931209"); + OwnershipInfo ownershipInfo = new OwnershipInfo(); + ownershipInfo.setBEID("101"); + ownershipInfo.setBRID("101"); + requestHeader.setOwnershipInfo(ownershipInfo); + AccessSecurity accessSecurity = new AccessSecurity(); + accessSecurity.setLoginSystemCode("Xaysombath"); + accessSecurity.setPassword("ATBoomuNQidKc8iYhPgx5A=="); + requestHeader.setAccessSecurity(accessSecurity); + requestHeader.setAccessMode("3"); + + AdjustmentRequest adjustmentrequest = new AdjustmentRequest(); + adjustmentrequest.setAdjustmentSerialNo("20160429104632990"); + AdjustmentObj adjustmentObj = new AdjustmentObj(); + SubAccessCode subAccessCode = new SubAccessCode(); + subAccessCode.setPrimaryIdentity("2055579910"); + adjustmentObj.setSubAccessCode(subAccessCode); + adjustmentrequest.setAdjustmentObj(adjustmentObj); + adjustmentrequest.setOpType("1"); + AdjustmentInfo adjustmentInfo = new AdjustmentInfo(); + adjustmentInfo.setBalanceType("C_MAIN_ACCOUNT"); + adjustmentInfo.setAdjustmentType("1"); + adjustmentInfo.setAdjustmentAmt("1000"); + adjustmentInfo.setCurrencyID("1049"); + adjustmentrequest.setAdjustmentInfo(adjustmentInfo); + + adjustmentRequest.setRequestHeader(requestHeader); + adjustmentRequest.setAdjustmentRequest(adjustmentrequest); + + ec02Instance.getAFInstance().setAdjustmentRequestIns(adjustmentRequest); + + return value; + + + + } + + public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + + + + + } + + public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + switch (this.type) { + case Constant.TYPE_SUCCESS: + default: + { +// this.isStat = false; +// ec02Instance.getAFInstance().getListStat().add(new Stat(StateConfig.PROJECT_STAT_NAME + " ABCDEFG STAT")); + String message = th.co.ais.ssbsrfc.message.MessageParser.toSoap(adjustmentRequest); + ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_W_ADJUSTMENT_CHARGEREQUEST); + EQXRawInstance eqxRaw = SubMessages.getRawAdjustmentRequest(abstractAF, ec02Instance,StateConfig.Incoming_Adjustment_ChargeRequest_Response,adjustmentRequest); + + this.equinoxRawDataList.add(this.ec02Builder.getRequest(eqxRaw)); + } + } + } +} diff --git a/src/th/co/ais/ssbsrfc/substate/WaitSubState.java b/src/th/co/ais/ssbsrfc/substate/WaitSubState.java new file mode 100644 index 0000000..8682153 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/substate/WaitSubState.java @@ -0,0 +1,541 @@ +package th.co.ais.ssbsrfc.substate; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.Invoke; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.ListE01Data; +import th.co.ais.ssbsrfc.instance.LogError; +import th.co.ais.ssbsrfc.instance.ManageTime; +import th.co.ais.ssbsrfc.instance.ResIns; +import th.co.ais.ssbsrfc.interfaces.EQXMsg; +import th.co.ais.ssbsrfc.interfaces.IAFSubState; +import th.co.ais.ssbsrfc.message.EC02Builder; +import th.co.ais.ssbsrfc.message.MessageParser; +import th.co.ais.ssbsrfc.utils.EqxStringUtils; +import th.co.ais.ssbsrfc.utils.Global; +import th.co.ais.ssbsrfc.utils.Log; +import ais.mmt.sand.comlog.DetailsLogPrototype; +import ais.mmt.sand.comlog.bean.DataBean; +import ais.mmt.sand.comlog.bean.DataBean.TYPE; +import ais.mmt.sand.comlog.exception.CommonLogException; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.af.data.GlobalData; +import ec02.utils.AppLog; + +public class WaitSubState implements IAFSubState { + + protected int type = -1; + protected EC02Builder ec02Builder = new EC02Builder(); + protected List equinoxRawDataList = new ArrayList(); + protected int _stateType = Constant.SUBSTATE_TYPE_UNKNOWN; + protected String _state = ""; + protected String _eventType = ""; + protected Object _objIns = null; + protected String _resultCode = "null"; + protected String _resultDescription = "null"; + protected List _listResult = new ArrayList(); + protected boolean isStat = true; + protected HashMap disRespone = new HashMap(); + protected String _invokeTimeout = null; + protected boolean isRetry = false; + private boolean isIdle = true; + + + @Override + public List doActionSubState(AbstractAF abstractAF, + EC02Instance ec02Instance, EquinoxRawData equinoxRawData) { + this.isIdle = (ec02Instance.getAFInstance().getFlow() != 0) ? false : true; + configSubstate(ec02Instance, equinoxRawData); + + AppLog.d("#### FLOWMANAGER CURRENTFLOW: " + Global.getFlowName(ec02Instance.getAFInstance().getFlow())); +// try { + switch (this._stateType) { + case Constant.SUBSTATE_TYPE_W_REQUEST: + initRequest(abstractAF, ec02Instance, equinoxRawData); + break; + case Constant.SUBSTATE_TYPE_W_RESPONSE: + initResponse(abstractAF, ec02Instance, equinoxRawData); + break; + case Constant.SUBSTATE_TYPE_W_E01: + initE01(abstractAF, ec02Instance, equinoxRawData); + break; + case Constant.SUBSTATE_TYPE_UNKNOWN: + default: + break; + } + + if (this._invokeTimeout == null) { + this.summaryLog(ec02Instance, equinoxRawData); + } +// } catch (Exception e) { +// AppLog.d("## EXCEPTION(MESSAGE): " + e.getMessage()); +// AppLog.d("## EXCEPTION(STACKTRACE): " + e.getStackTrace()); +// AppLog.d("## EXCEPTION(E): " + e); +// ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_END); +// } + return this.equinoxRawDataList; + } + + protected void configSubstate(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { } + + protected boolean checkRejectApplication(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + String currentState = ec02Instance.getAFInstance().getCurrentState(); + boolean bool = false; + if (!currentState.equals(_state) && !currentState.equals(StateConfig.SSTATE_END)) { + bool = true; + } else { // case is IDLE + if (currentState.equals(StateConfig.SSTATE_END)) + { + boolean first = StateConfig.isFirstState(_state); + AppLog.d("State"+first); + if (!first) { + bool = true; + } + } else { + ec02Instance.getAFInstance().setCurrentState(_state); + } + } + return bool; + } + + protected void initRequest(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + AppLog.d("[#### CURRENTSUBSTATE: " + _state + "(START) ####]"); + this.ec02Builder.setEquinoxRawData(equinoxRawData, abstractAF, ec02Instance); + Global.setEc02Builder(this.ec02Builder); + + if (equinoxRawData == null) { // TIMEOUT + ManageTime mt = new ManageTime(ec02Instance); + List listTimeout = mt.getState(); + for (String invoke : listTimeout) { + Invoke _iv = new Invoke(invoke); + String eventType = _iv.eventType; + String cmd = _iv.cmd; + this.timeout(abstractAF, ec02Instance, invoke, eventType, Constant.REQUEST.toLowerCase(), null); + String subState = StateConfig.getSubStateFromEventType(eventType); + // SET LOG + Log.results(ec02Instance, subState, this.equinoxRawDataList, this.type, cmd, this.isStat); + // summary for timeout + this._invokeTimeout = invoke; + this.summaryLog(ec02Instance, equinoxRawData); + } + } else { + // CHECK EVENT TYPE/ CURRENTSTATE + String eventType = equinoxRawData.getRawEventType(); + ec02Instance.getAFInstance().listTimeoutRemoveForEventType(eventType); + if (eventType.equals(_eventType)) { + String ret = equinoxRawData.getRet(); + Log.dev(" initRequest RET: " + ret); + AppLog.d("ret Value:"+ret); + if (ret.equals("4")) { + String invoke = equinoxRawData.getInvoke(); + String messageType = equinoxRawData.getType(); + String cmd = new Invoke(invoke).cmd; + Log.dev(" initRequest TIMEOUT: " + invoke + ":" + messageType + ":" + cmd); + this.timeout(abstractAF, ec02Instance, invoke, eventType, messageType, null); + // SET LOG + Log.results(ec02Instance, _state, this.equinoxRawDataList, this.type, cmd, this.isStat); + // summary for timeout + this._invokeTimeout = invoke; + this.summaryLog(ec02Instance, equinoxRawData); + } else { + // MAIN + this.action(abstractAF, ec02Instance, equinoxRawData); + // SET LOG + Log.results(ec02Instance, _state, this.equinoxRawDataList, this.type, this.isStat); + } + } else { + this.rejectApplication(abstractAF, ec02Instance, equinoxRawData, this._objIns); + // SET LOG + Log.results(ec02Instance, _state, this.equinoxRawDataList, this.type, this.isStat); + } + } + AppLog.d("[#### CURRENTSUBSTATE: " + _state + "(END) ####]"); + AppLog.d("#### NEXTSUBSTATE: " + ec02Instance.getAFInstance().getCurrentState()); + } + + protected void initResponse(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + AppLog.d("[#### CURRENTSUBSTATE: " + _state + "(START) ####]"); + this.ec02Builder.setEquinoxRawData(equinoxRawData, abstractAF, ec02Instance); + Global.setEc02Builder(this.ec02Builder); + + if (equinoxRawData == null) { // TIMEOUT + ManageTime mt = new ManageTime(ec02Instance); + List listTimeout = mt.getState(); + List eqxTmpList = new ArrayList(); + for (String invoke : listTimeout) { + String eventType = new Invoke(invoke).eventType; + String cmd = new Invoke(invoke).cmd; + this.timeout(abstractAF, ec02Instance, invoke, eventType, Constant.RESPONSE.toLowerCase(), null); + String subState = StateConfig.getSubStateFromEventType(eventType); + // SET LOG + for (EquinoxRawData eqxxRawlist : this.equinoxRawDataList) { + eqxTmpList.add(eqxxRawlist); + } + Log.results(ec02Instance, subState, this.equinoxRawDataList, this.type, cmd, this.isStat); + this.equinoxRawDataList = new ArrayList(); + // summary for timeout + this._invokeTimeout = invoke; + this.summaryLog(ec02Instance, equinoxRawData); + } + this.equinoxRawDataList = eqxTmpList; + } else { + String eventType = equinoxRawData.getRawEventType(); + if (eventType.equals(_eventType)) { + // CASE SUCCESS, ERROR, REJECT, ABORT, TIMEOUT + String invoke = equinoxRawData.getInvoke(); + String messageType = equinoxRawData.getType(); + String cmd = new Invoke(invoke).cmd; + // CHECK EVENT TYPE/ CURRENTSTATE + String ret = equinoxRawData.getRet(); + if (ret.equals("1")) { // ERROR + this.error(abstractAF, ec02Instance, invoke, eventType, messageType, null); + } else if (ret.equals("2")) { // REJECT + this.reject(abstractAF, ec02Instance, invoke, eventType, messageType, null); + } else if (ret.equals("3")) { // ABORT + this.abort(abstractAF, ec02Instance, invoke, eventType, messageType, null); + } else if (ret.equals("4")) { // TIMEOUT + this.timeout(abstractAF, ec02Instance, invoke, eventType, messageType, null); + } else { // SUCCESS + this.action(abstractAF, ec02Instance, equinoxRawData); + } + // SET LOG + Log.results(ec02Instance, _state, this.equinoxRawDataList, this.type, cmd, this.isStat); + } else { + this.rejectApplication(abstractAF, ec02Instance, equinoxRawData, this._objIns); + // SET LOG + Log.results(ec02Instance, _state, this.equinoxRawDataList, this.type, this.isStat); + } + } + AppLog.d("[#### CURRENTSUBSTATE: " + _state + "(END) ####]"); + AppLog.d("#### NEXTSUBSTATE: " + ec02Instance.getAFInstance().getCurrentState()); + } + + protected void initE01(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + AppLog.d("[#### CURRENTSUBSTATE: " + _state + "(START) ####]"); + this.ec02Builder.setEquinoxRawData(equinoxRawData, abstractAF, ec02Instance); + Global.setEc02Builder(this.ec02Builder); + + GlobalData e01 = abstractAF.getUtils().getGlobalData(); + if (e01.isRecieve()) { + String messageType = Constant.RESPONSE.toLowerCase(); + String invoke = null; +// try { + int ret = e01.getGlobaldataMessageType().getCode(); + if (ret == 1) { // ERROR + this.error(abstractAF, ec02Instance, invoke, this._eventType, messageType, e01); + } else if (ret == 2) { // REJECT + this.reject(abstractAF, ec02Instance, invoke, this._eventType, messageType, e01); + } else if (ret == 3) { // ABORT + this.abort(abstractAF, ec02Instance, invoke, this._eventType, messageType, e01); + } else if (ret == 4) { // TIMEOUT + this.timeout(abstractAF, ec02Instance, invoke, this._eventType, messageType, e01); + } else { // SUCCESS // REJECT APPICATION + if (e01.isRecieve()) { + invoke = e01.getTransactionId(); + ec02Instance.getAFInstance().listTimeoutRemove(invoke); + EquinoxRawData eqxRawData = new EquinoxRawData(); + ListE01Data ins = new ListE01Data(e01.getDataResultSet()); + String rawData = MessageParser.toJson(ins); +// AppLog.d("E01 RAWDATA: " + rawData); + eqxRawData.getRawDataAttributes().put("val", rawData); + eqxRawData.setRawEventType(this._eventType); + eqxRawData.setRet("0"); + eqxRawData.setInvoke(invoke); + eqxRawData.setCType(EQXMsg.TEXTPLAIN); + eqxRawData.setType(Constant.RESPONSE.toLowerCase()); + + this.action(abstractAF, ec02Instance, eqxRawData); + } + } + // SET LOG + Log.results(ec02Instance, _state, this.equinoxRawDataList, this.type, this.isStat); +// } catch (Exception e) { +// AppLog.e("## E01(GET RET):" + e.getMessage()); +// } + } + else { // TIMEOUT + if (equinoxRawData == null) { + ManageTime mt = new ManageTime(ec02Instance); + List listTimeout = mt.getState(); + for (String invoke : listTimeout) { + String cmd = new Invoke(invoke).cmd; + String eventType = new Invoke(invoke).eventType; + this.timeout(abstractAF, ec02Instance, invoke, eventType, Constant.RESPONSE.toLowerCase(), null); + String subState = StateConfig.getSubStateFromEventType(eventType); + // SET LOG + Log.results(ec02Instance, subState, this.equinoxRawDataList, this.type, cmd, this.isStat); + // summary for timeout + this._invokeTimeout = invoke; + this.summaryLog(ec02Instance, equinoxRawData); + } + } else { + String ret = equinoxRawData.getRet(); + String invoke = equinoxRawData.getInvoke(); + String messageType = equinoxRawData.getType(); + if (ret.equals("4")) { // TIMEOUT + String eventType = new Invoke(invoke).eventType; + this.timeout(abstractAF, ec02Instance, invoke, eventType, messageType, e01); + // SET LOG + Log.results(ec02Instance, _state, this.equinoxRawDataList, Constant.TYPE_TIMEOUT, this.isStat); + } else { // REJECT APPICATION + this.action(abstractAF, ec02Instance, equinoxRawData); + } + } + } + + AppLog.d("[#### CURRENTSUBSTATE: " + _state + "(END) ####]"); + AppLog.d("#### NEXTSUBSTATE: " + ec02Instance.getAFInstance().getCurrentState()); + } + + protected void action(AbstractAF abstractAF,EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { +// try { + this._objIns = this.getMessage(ec02Instance, equinoxRawData); + ec02Instance.getAFInstance().setResultCode(this._resultCode); + ec02Instance.getAFInstance().setResultDescription(this._resultDescription); + + boolean isReject = this.checkRejectApplication(ec02Instance, equinoxRawData); + if(isReject) { + this.rejectApplication(abstractAF, ec02Instance, equinoxRawData, this._objIns); + } else { + // set type + this.verifyMessage(abstractAF, ec02Instance, equinoxRawData); + if (this.type == Constant.TYPE_REJECT_APPLICATION) { + this.rejectApplication(abstractAF, ec02Instance, equinoxRawData, this._objIns); + } else { + //Detail Log Input + String value = EqxStringUtils.getMessage(equinoxRawData, null, false); + String invoke = equinoxRawData.getInvoke(); + String eventType = equinoxRawData.getRawEventType(); + String messageType = equinoxRawData.getType(); + this.detailLogInput(ec02Instance, invoke, eventType, messageType, this._objIns, value); + + this.buildMessage(abstractAF, ec02Instance, equinoxRawData); + } + } +// } catch (Exception e) { +// AppLog.e("## EXCEPTION(MESSAGE): " + e.getMessage()); +// AppLog.e("## EXCEPTION(STACKTRACE): " + e.getStackTrace().toString()); +// AppLog.e("## EXCEPTION(E): " + e.toString()); +// AppLog.e("## GETMESSAGE EQUINOX: ERROR"); +// AppLog.d("## VERIFY(PARAMETER) :INVALID PARAMETER"); +// this.type = Constant.TYPE_INVALID; +// +// //Detail Log Input +// String value = EqxStringUtils.getMessage(equinoxRawData, null, false); +// String invoke = equinoxRawData.getInvoke(); +// String eventType = equinoxRawData.getRawEventType(); +// String messageType = equinoxRawData.getType(); +// this.detailLogInput(ec02Instance, invoke, eventType, messageType, this._objIns, value); +// +// this.buildMessage(abstractAF, ec02Instance, equinoxRawData); +// } + } + + protected void rejectApplication(AbstractAF abstractAF,EC02Instance ec02Instance, EquinoxRawData equinoxRawData, Object ins) + { + AppLog.d("REJECTED BY APPLICATION"); + this.type = Constant.TYPE_REJECT_APPLICATION; + String eventType = equinoxRawData.getRawEventType(); + String currentState = ec02Instance.getAFInstance().getCurrentState(); + String invoke = equinoxRawData.getInvoke(); + String messageType = equinoxRawData.getType(); + String value = EqxStringUtils.getMessage(equinoxRawData, null, false); + AppLog.d("REJECT [" + eventType + "]: IN [" + currentState + "]"); + Global.setRejectByApplication(true); + ec02Instance.getAFInstance().getBackupSummary().backup(ec02Instance, equinoxRawData); + this.detailLogInput(ec02Instance, invoke, eventType, messageType, ins, value); + + if (messageType.toLowerCase().equals(Constant.REQUEST.toLowerCase()) && equinoxRawData != null && !equinoxRawData.getRet().equals("1") && !equinoxRawData.getRet().equals("2") && !equinoxRawData.getRet().equals("3") && !equinoxRawData.getRet().equals("4")) { +// String to = equinoxRawData.getOrig(); +// EQXRawInstance eqxRaw = SubMessages.getRawUnknownResponse(abstractAF, ec02Instance, to, invoke, eventType); +// this.equinoxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); + } + + } + + public Object getMessage(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + return null; + } + + public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { } + + public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { } + + protected void error(AbstractAF abstractAF,EC02Instance ec02Instance, String invoke, String eventType, String messageType, GlobalData e01) + { + AppLog.d("SPECIFIC ERROR BY APPLICATION"); + this.type = Constant.TYPE_ERROR; + LogError ins = new LogError("1", "Error"); + this._resultCode = "null"; + this._resultDescription = "Error"; + this.buildResponeMsg(abstractAF, ec02Instance, invoke, eventType, messageType, ins, e01); + } + + protected void reject(AbstractAF abstractAF,EC02Instance ec02Instance, String invoke, String eventType, String messageType, GlobalData e01) + { + AppLog.d("REJECTED BY PLATFORM"); + this.type = Constant.TYPE_REJECT; + LogError ins = new LogError("2", "Reject"); + this._resultCode = "null"; + this._resultDescription = "Reject"; + this.buildResponeMsg(abstractAF, ec02Instance, invoke, eventType, messageType, ins, e01); + } + + protected void abort(AbstractAF abstractAF,EC02Instance ec02Instance, String invoke, String eventType, String messageType, GlobalData e01) + { + AppLog.d("RETURN ABORTED BY PLATFORM"); + this.type = Constant.TYPE_ABORT; + this._resultCode = "null"; + LogError ins = new LogError("3", "Abort"); + this._resultDescription = "Abort"; + this.buildResponeMsg(abstractAF, ec02Instance, invoke, eventType, messageType, ins, e01); + } + + protected void timeout(AbstractAF abstractAF, EC02Instance ec02Instance, String invoke, String eventType, String messageType, GlobalData e01) + { + AppLog.d("RETURN TIMEOUT BY PLATFORM"); + this.type = Constant.TYPE_TIMEOUT; + this._resultCode = "null"; + LogError ins = new LogError("4", "Timeout"); + this._resultDescription = "Timeout"; + this.buildResponeMsg(abstractAF, ec02Instance, invoke, eventType, messageType, ins, e01); + } + + private void detailLogInput(EC02Instance ec02Instance,String invoke, String eventType, String messageType, Object ins) + { + this.detailLogInput(ec02Instance, invoke, eventType, messageType, ins, null); + } + + protected void detailLogInput(EC02Instance ec02Instance,String invoke, String eventType, String messageType, Object ins, String rawData) + { + //Detail Log Input + if(invoke == null) { + invoke = ""; + } + + String command = StateConfig.getCommandFromEventType(eventType); + String node = Global.getNodeFromEventType(eventType); + if (command != null && command.contains("|") && invoke.contains(".")) { + Invoke _iv = new Invoke(invoke); + command = _iv.cmd; + node = _iv.nodeName; + } + + //String event = node + "." + command; + String responseTime = ec02Instance.getAFInstance().getResponseTime(); + if(this._stateType == Constant.SUBSTATE_TYPE_W_REQUEST) { + responseTime = null; + } + + DetailsLogPrototype detLog = ec02Instance.getAFInstance().getDetaillog(); + DataBean input = new DataBean(); + input.setInvoke(invoke); + input.setDirector(node); + input.setCommandName(command); + + if (!this.isIdle) { + try { + if (messageType != null && messageType.toLowerCase().equals(EQXMsg.REQUEST.toLowerCase())) { + input.setType(TYPE.REQ); + responseTime = null; + } else if (messageType != null && messageType.toLowerCase().equals(EQXMsg.RESPONSE.toLowerCase())) { + input.setType(TYPE.RES); + } else { + if (Log.debug) { + AppLog.d("## MessageType :" + messageType); + } + if(this._stateType == Constant.SUBSTATE_TYPE_W_REQUEST) { + input.setType(TYPE.REQ); + responseTime = null; + } else { + input.setType(TYPE.RES); + } + } + } catch (Exception e) { + if(this._stateType == Constant.SUBSTATE_TYPE_W_REQUEST) { + input.setType(TYPE.REQ); + } else { + input.setType(TYPE.RES); + } + } + } else { + if(this._stateType == Constant.SUBSTATE_TYPE_W_REQUEST) { + input.setType(TYPE.REQ); + responseTime = null; + } else { + input.setType(TYPE.RES); + } + } + input.setJsonData(MessageParser.toJsonObject(ins)); + input.setRawData(Global.getDetailLogRawData(rawData)); + + if(responseTime != null) { + input.setRespTime(Long.parseLong(responseTime)); + } + + try { + detLog.addInput(input); + } catch (CommonLogException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void buildResponeMsg(AbstractAF abstractAF,EC02Instance ec02Instance, String invoke, String eventType, String messageType, Object ins, GlobalData e01) + { + this.detailLogInput(ec02Instance, invoke, eventType, messageType, ins); + // set error code + ec02Instance.getAFInstance().setResultCode(this._resultCode); + ec02Instance.getAFInstance().setResultDescription(this._resultDescription); +// String subState = StateConfig.getSubStateFromEventType(eventType); +// LogError insError = (LogError)ins; + ec02Instance.getAFInstance().setCurrentState(StateConfig.SSTATE_END); + } + + private void summaryLog(EC02Instance ec02Instance, EquinoxRawData equinoxRawData) + { + try { + if ((this.type != Constant.TYPE_SUCCESS && this.type != -1 && this.type != Constant.TYPE_REJECT_APPLICATION && this.type != Constant.TYPE_SUCCESS_WITH_CONDITION && this.type != Constant.TYPE_FILE_NOT_FOUND && this.type != Constant.TYPE_DATA_EXISTED && this.type != Constant.TYPE_DATA_NOT_FOUND && this._resultCode != null && !this._resultCode.equals("20000") && !this.isRetry && !this._resultCode.equals("23")) || (this.type == Constant.TYPE_MISSING || this.type == Constant.TYPE_INVALID)) { + String command = StateConfig.getCommandFromEventType(this._eventType); + if (command.contains("|") && equinoxRawData != null && equinoxRawData.getInvoke() != null && equinoxRawData.getInvoke().contains(".")) { + String invoke = equinoxRawData.getInvoke(); + command = new Invoke(invoke).cmd; + } else if (command.contains("|") && this._invokeTimeout != null && this._invokeTimeout.contains(".")) { + command = new Invoke(this._invokeTimeout).cmd; + } + if (this.type == Constant.TYPE_MISSING || this.type == Constant.TYPE_INVALID) { + this._resultCode = "null"; + this._resultDescription = "Missing or invalid parameter"; + ec02Instance.getAFInstance().setResultCode(this._resultCode); + ec02Instance.getAFInstance().setResultDescription(this._resultDescription); + } + String node = Global.getNodeFromEventType(this._eventType); + if (Log.debug) { + AppLog.d("## SUMMARY:" + this.type + node + command + this._resultCode + this._resultDescription); + } + + if(this._resultDescription.equals(EQXMsg.EMPTY)) { + this._resultDescription = "null"; + } + ec02Instance.getAFInstance().getSumlog().addDestination(node, command, this._resultCode, this._resultDescription); + } + } catch (CommonLogException e) { + e.printStackTrace(); + } + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/DateUtil.java b/src/th/co/ais/ssbsrfc/utils/DateUtil.java new file mode 100644 index 0000000..18a282c --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/DateUtil.java @@ -0,0 +1,2342 @@ +package th.co.ais.ssbsrfc.utils; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Locale; +import java.util.Random; +import java.util.TimeZone; + + + +public class DateUtil { + + protected final static long ONEDAY = 10 * 10 * 10 * 24 * 60 * 60; + static long w_oneDay = (long) 1000.0 * 60 * 60 * 24; + static String vLocale_defined = "TH"; + public static final String yyyyMMdd = "yyyy-MM-dd"; + public static final String ddMMyyyy = "dd/MM/yyyy"; + public static final String ddMMMMyyyy = "dd MMMM yyyy"; + public static final String ddMMyyyyHHmiss = "dd MMMM yyyy HH:mm:ss"; + public static final String yyyyMMddHHmiss = "yyyy-MM-dd HH:mm:ss"; + public static final String ddMMyyyyHHmi = "dd MMMM yyyy HH:mm"; + + public static Calendar getCurrentDateTime() { + Calendar cal = new GregorianCalendar(); + return cal; + } + + public static String getDateExpiryTime(String startTime, int numDay) { + + String newCal = null; + java.util.Date date = null; + Calendar c; + SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd:HHmmss"); + try { + date = (Date)formatter.parse(startTime); + c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.DATE, numDay); + newCal = formatter.format(c.getTime()); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newCal; + } + + public static String getDateExpiryTimeZone(String startTime, int numDay) { + + String newCal = null; + java.util.Date date = null; + Calendar c; + SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssZ"); + try { + date = (Date)formatter.parse(startTime); + c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.DATE, numDay); + newCal = formatter.format(c.getTime()); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newCal; + } + + public static String getExpiryTime(String startTime, int sec) { + String datetime = null; + java.util.Date date = null; + Calendar c; + SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd:HHmmss"); + try { + date = (Date)formatter.parse(startTime); + c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.SECOND, sec); + //System.out.println("calendar"+c.getTime()); + datetime = formatter.format(c.getTime()); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return datetime; + } + + public static String getExpiryTimeZone(String startTime, int sec) { + String datetime = null; + java.util.Date date = null; + Calendar c; + SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssZ"); + try { + date = (Date)formatter.parse(startTime); + c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.SECOND, sec); + //System.out.println("calendar"+c.getTime()); + datetime = formatter.format(c.getTime()); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return datetime; + } + + /*public static String getDateExpiryTime(int numDay, int numMonth, int numYear) { + + String oldCal = null; + String newCal = null; + oldCal = getCurrentDateTime().get(Calendar.YEAR) + "/" + + (getCurrentDateTime().get(Calendar.MONTH)+1) + "/" + + getCurrentDateTime().get(Calendar.DAY_OF_MONTH) + " " + + getCurrentDateTime().get(Calendar.HOUR_OF_DAY) + ":" + + getCurrentDateTime().get(Calendar.MINUTE) + ":" + + getCurrentDateTime().get(Calendar.SECOND); + SimpleDateFormat dfold = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Calendar c = Calendar.getInstance(); + + try { + Date date = dfold.parse(oldCal); + c.setTime(date); + c.add(Calendar.DATE, numDay); + c.add(Calendar.MONTH, numMonth); + c.add(Calendar.YEAR, numYear); + SimpleDateFormat dfnew = new SimpleDateFormat("yyyyMMdd:HHmmss"); + newCal = dfnew.format(c.getTime()); + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return newCal; + }*/ + + public static String getDateTimeNow() { + String oldCal = null; + String newCal = null; + oldCal = getCurrentDateTime().get(Calendar.YEAR) + "/" + + (getCurrentDateTime().get(Calendar.MONTH)+1) + "/" + + getCurrentDateTime().get(Calendar.DAY_OF_MONTH) + " " + + getCurrentDateTime().get(Calendar.HOUR_OF_DAY) + ":" + + getCurrentDateTime().get(Calendar.MINUTE) + ":" + + getCurrentDateTime().get(Calendar.SECOND); + SimpleDateFormat dfold = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + try { + Date date = dfold.parse(oldCal); + SimpleDateFormat dfnew = new SimpleDateFormat("yyyyMMdd:HHmmss"); + newCal = dfnew.format(date); + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newCal; + } + + public static String getDateTimeZoneNow() { + String oldCal = null; + String newCal = null; + oldCal = getCurrentDateTime().get(Calendar.YEAR) + "/" + + (getCurrentDateTime().get(Calendar.MONTH)+1) + "/" + + getCurrentDateTime().get(Calendar.DAY_OF_MONTH) + " " + + getCurrentDateTime().get(Calendar.HOUR_OF_DAY) + ":" + + getCurrentDateTime().get(Calendar.MINUTE) + ":" + + getCurrentDateTime().get(Calendar.SECOND); + SimpleDateFormat dfold = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + try { + Date date = dfold.parse(oldCal); + SimpleDateFormat dfnew = new SimpleDateFormat("yyyyMMddHHmmssZ"); + newCal = dfnew.format(date); + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newCal; + } + + public static String getDateTimeNowForWriteFile() { + String oldCal = null; + String newCal = null; + oldCal = getCurrentDateTime().get(Calendar.YEAR) + "/" + + (getCurrentDateTime().get(Calendar.MONTH)+1) + "/" + + getCurrentDateTime().get(Calendar.DAY_OF_MONTH) + " " + + getCurrentDateTime().get(Calendar.HOUR_OF_DAY) + ":" + + getCurrentDateTime().get(Calendar.MINUTE) + ":" + + getCurrentDateTime().get(Calendar.SECOND); + SimpleDateFormat dfold = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + try { + Date date = dfold.parse(oldCal); + SimpleDateFormat dfnew = new SimpleDateFormat("yyyyMMdd|HHmm"); + newCal = dfnew.format(date); + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newCal; + } + + public static String getDateTimeNowYYYYMMdd() { + String oldCal = null; + String newCal = null; + oldCal = getCurrentDateTime().get(Calendar.YEAR) + "/" + + (getCurrentDateTime().get(Calendar.MONTH)+1) + "/" + + getCurrentDateTime().get(Calendar.DAY_OF_MONTH) + " " + + getCurrentDateTime().get(Calendar.HOUR_OF_DAY) + ":" + + getCurrentDateTime().get(Calendar.MINUTE) + ":" + + getCurrentDateTime().get(Calendar.SECOND); + SimpleDateFormat dfold = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + try { + Date date = dfold.parse(oldCal); + SimpleDateFormat dfnew = new SimpleDateFormat("yyyyMMdd"); + newCal = dfnew.format(date); + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newCal; + } + + public static String getDateTimeNow_ddMMyyyy_HHmmss() { + + String newCal = null; + newCal = getCurrentDateTime().get(Calendar.DAY_OF_MONTH) + "/" + + getMonthStr(getCurrentDateTime().get(Calendar.MONTH)) + "/" + + getCurrentDateTime().get(Calendar.YEAR) + " " + + getCurrentDateTime().get(Calendar.HOUR_OF_DAY) + ":" + + getCurrentDateTime().get(Calendar.MINUTE) + ":" + + getCurrentDateTime().get(Calendar.SECOND); + return newCal; + } + + public static int getCurrentDay() { + return getCurrentDateTime().get(Calendar.DAY_OF_MONTH); + } + + public static int getCurrentDayOfWeek() { + return getCurrentDateTime().get(Calendar.DAY_OF_WEEK); + } + + public static int getCurrentMonth() { + return getCurrentDateTime().get(Calendar.MONTH); + } + + public static int getCurrentYear() { + return getCurrentDateTime().get(Calendar.YEAR); + } + + public static int getCurrentHour() { + return getCurrentDateTime().get(Calendar.HOUR_OF_DAY); + } + + public static int getCurrentMinute() { + return getCurrentDateTime().get(Calendar.MINUTE); + } + + + public static int getCurrentSecond() { + return getCurrentDateTime().get(Calendar.SECOND); + } + + public synchronized static long getCurrentDateTimeinLong() { + Calendar cal = new GregorianCalendar(); + return cal.getTime().getTime(); + } + + /* getCurrentDateTime by pattern format */ + public static String getStringSystemDateTime(String pattern) { + Calendar currentCalendar = DateUtil.getCurrentDateTime(); + String systemDateTime = DateUtil.convertDateTime2String( + currentCalendar, pattern); + return systemDateTime; + } + + /* convert Calendar by pattern format */ + public static String convertDateTime2String(Calendar calendar, + String pattern) { + String data = null; + + if (calendar != null) { + SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US); + data = sdf.format(calendar.getTime()); + } + return data; + } + + public static String convertDateTime2String(Calendar calendar, + String pattern, Locale local) { + String data = null; + + if (calendar != null) { + SimpleDateFormat sdf = new SimpleDateFormat(pattern, local); + data = sdf.format(calendar.getTime()); + } + + return data; + } + + public static String convertDateTime2String(Date calendar, String pattern, + Locale local) { + String data = null; + + if (calendar != null) { + SimpleDateFormat sdf = new SimpleDateFormat(pattern, local); + data = sdf.format(calendar.getTime()); + } + + return data; + } + + public static String convertDateTime2String(Timestamp calendar, String pattern, + Locale local) { + String data = null; + + if (calendar != null) { + SimpleDateFormat sdf = new SimpleDateFormat(pattern, local); + data = sdf.format(calendar.getTime()); + } + + return data; + } + + public static Calendar getCalendar(long time) { + Calendar cal = new GregorianCalendar(); + cal.setTime(new Date(time)); + + return cal; + } + + public static Calendar getCalendar(int day, int month, int year) { + return getCalendar(day, month, year, 0, 0, 0); + } + + public static Calendar getCalendar(int day, int month, int year, int hour, + int minute) { + return getCalendar(day, month, year, hour, minute, 0); + } + + public static Calendar getCalendar(int day, int month, int year, int hour, + int minute, int second) { + Calendar cal = null; + + if (day >= 0 && month >= 0 && year >= 0 && hour >= 0 && minute >= 0) { + cal = new GregorianCalendar(Locale.US); + cal.set(Calendar.DAY_OF_MONTH, day); + cal.set(Calendar.MONTH, month); + cal.set(Calendar.YEAR, year); + cal.set(Calendar.HOUR_OF_DAY, hour); + cal.set(Calendar.MINUTE, minute); + cal.set(Calendar.SECOND, second); + cal.set(Calendar.MILLISECOND, 0); + } + + // cal.add(Calendar.HOUR_OF_DAY, plus); + + return cal; + } + + /** + * Convert from java.lang.Object to java.util.Date Creation date: + * (26/05/2004 11:00:00) + * + * @return java.util.Date + * @param theDateObj + * java.lang.Object + */ + public static java.util.Date getDate(Object theDateObj) { + java.sql.Date w_TempDate; + if (theDateObj == null) { + w_TempDate = null; + } else { + java.util.Date theDateDate = (java.util.Date) theDateObj; + w_TempDate = new java.sql.Date(theDateDate.getTime()); + } + + return w_TempDate; + + } + + /** + * Convert from java.lang.Object to java.util.Date. Creation date: + * (26/05/2004 11:00:00) + * + * @return java.util.Date + * @param theDateObj,theTimeObj + * java.lang.Object + */ + public static java.util.Date getDate(Object theDateObj, Object theTimeObj) { + java.util.Date w_TempDate = null; + java.sql.Date w_ArgDate = null; + if (theDateObj != null) { + w_ArgDate = (java.sql.Date) theDateObj; + java.util.GregorianCalendar w_DateGregorian = new java.util.GregorianCalendar(); + w_DateGregorian.setTime(w_ArgDate); + + if (theTimeObj != null) { + + java.util.GregorianCalendar w_TimeGregorian = new java.util.GregorianCalendar(); + w_TimeGregorian.setTime((DateUtil.getDate(theTimeObj))); + w_DateGregorian.set(GregorianCalendar.HOUR_OF_DAY, + w_TimeGregorian.get(GregorianCalendar.HOUR_OF_DAY)); + w_DateGregorian.set(GregorianCalendar.MINUTE, w_TimeGregorian + .get(GregorianCalendar.MINUTE)); + w_DateGregorian.set(GregorianCalendar.SECOND, w_TimeGregorian + .get(GregorianCalendar.SECOND)); + + w_TimeGregorian = null; + } + + w_TempDate = w_DateGregorian.getTime(); + w_DateGregorian = null; + } + + w_ArgDate = null; + + return w_TempDate; + + } + + /** *************************************************************************** */ + /** + * Convert from java.lang.String to java.util.Date. Creation date: + * (26/05/2004 11:30:03) + * + * @return java.lang.String + * @param theDateStr + * java.util.Date + */ + /*public static java.util.Date getDate(String theDateStr) throws Exception { + Date w_TempDate = null; + Vector w_VecterDate = null; + String vLocale = null; + if (theDateStr != null && !theDateStr.trim().equals("")) { + w_VecterDate = StringUtil.getStringByDelimeter(theDateStr, "/"); + java.util.GregorianCalendar w_TempGregorian = null; + vLocale = vLocale_defined; + if ("TH".equals(vLocale)) { + w_TempGregorian = new java.util.GregorianCalendar( + NumberUtil.getInt((String) w_VecterDate.elementAt(2)) - 543, + NumberUtil.getInt((String) w_VecterDate.elementAt(1)) - 1, + NumberUtil.getInt((String) w_VecterDate.elementAt(0))); + } else { + w_TempGregorian = new java.util.GregorianCalendar(NumberUtil + .getInt((String) w_VecterDate.elementAt(2)), NumberUtil + .getInt((String) w_VecterDate.elementAt(1)) - 1, + NumberUtil.getInt((String) w_VecterDate.elementAt(0))); + } + + w_TempDate = w_TempGregorian.getTime(); + w_TempGregorian = null; + + } + w_VecterDate = null; + + return w_TempDate; + } + + public static java.util.Date getDateDelimerterByDash(String theDateStr) + throws Exception { + Date w_TempDate = null; + // Vector w_VecterDate = null; + String vLocale = null; + if (theDateStr != null && !theDateStr.trim().equals("")) { + // Vector w_Vecter = StringUtil.getStringByDelimeter(theDateStr," + // "); + String[] tempSplit = theDateStr.split(" "); + Vector w_VecterDate = null; + w_VecterDate = StringUtil.getStringByDelimeter(tempSplit[0], "-"); + Vector w_VecterTime = null; + try { + w_VecterTime = StringUtil.getStringByDelimeter(theDateStr + .split(" ")[1], ":"); + } catch (Exception ex) { + + } + java.util.GregorianCalendar w_TempGregorian = null; + vLocale = vLocale_defined; + // if("TH".equals(vLocale)){ + // w_TempGregorian = new + // java.util.GregorianCalendar(NumberUtil.getInt((String)w_VecterDate.elementAt(2))-543,NumberUtil.getInt((String)w_VecterDate.elementAt(1)) + // - 1,NumberUtil.getInt((String)w_VecterDate.elementAt(0))); + // }else{ + w_TempGregorian = new java.util.GregorianCalendar(NumberUtil + .getInt((String) w_VecterDate.elementAt(0)), NumberUtil + .getInt((String) w_VecterDate.elementAt(1)) - 1, NumberUtil + .getInt((String) w_VecterDate.elementAt(2))); + if (w_VecterTime != null) { + w_TempGregorian.set(NumberUtil.getInt((String) w_VecterDate + .elementAt(0)), NumberUtil.getInt((String) w_VecterDate + .elementAt(1)) - 1, NumberUtil + .getInt((String) w_VecterDate.elementAt(2)), NumberUtil + .getInt((String) w_VecterTime.elementAt(0)), NumberUtil + .getInt((String) w_VecterTime.elementAt(1)), NumberUtil + .getInt((String) w_VecterTime.elementAt(2))); + } + // } + + w_TempDate = w_TempGregorian.getTime(); + w_TempGregorian = null; + + w_VecterDate = null; + w_VecterTime = null; + } + + return w_TempDate; + }*/ + + /** + * Convert from java.lang.String to java.util.Date. Creation date: + * (11/05/2004 08:30:03) + * + * @return java.lang.String + * @param theDateStr,theTimeStr + * java.util.Date + */ + /*public static java.util.Date getDate(String theDateStr, String theTimeStr) + throws Exception { + Date w_TempDate = null; + Vector w_DateVector = null; + Vector w_TimeVector = null; + int w_DateInt = 0, w_YearInt = 0, w_MonthInt = 0, w_MinutehInt = 0, w_HourInt = 0; + if (theDateStr != null) { + w_DateVector = StringUtil.getStringByDelimeter(theDateStr, "/"); + w_YearInt = NumberUtil.getInt((String) w_DateVector.elementAt(2)); + w_MonthInt = NumberUtil.getInt((String) w_DateVector.elementAt(1)) - 1; + w_DateInt = NumberUtil.getInt((String) w_DateVector.elementAt(0)); + w_DateVector = null; + if (theTimeStr != null) { + w_TimeVector = StringUtil.getStringByDelimeter(theTimeStr, ":"); + w_HourInt = NumberUtil.getInt((String) w_TimeVector + .elementAt(0)); + w_MinutehInt = NumberUtil.getInt((String) w_TimeVector + .elementAt(1)); + w_TimeVector = null; + } + java.util.GregorianCalendar w_TempGregorian = new java.util.GregorianCalendar( + w_YearInt, w_MonthInt, w_DateInt, w_HourInt, w_MinutehInt); + w_TempDate = w_TempGregorian.getTime(); + w_TempGregorian = null; + + } + w_DateVector = null; + w_TimeVector = null; + + return w_TempDate; + }*/ + + /** + * Convert from java.sql.Date and java.sql.Time to java.util.Date. Creation + * date: (26/05/2004 11:40:03) + * + * @return java.util.Date + * @param theDateDate + * java.sql.Date ,theTimeDate java.sql.Time + */ + public static java.util.Date getDate(java.sql.Date theDateDate, + java.sql.Time theTimeDate) { + java.util.Date w_TempDate = null; + if (theDateDate == null) { + w_TempDate = null; + } else { + java.util.GregorianCalendar w_DateGregorian = new java.util.GregorianCalendar(); + + w_DateGregorian.setTime(theDateDate); + + if (theTimeDate != null) { + java.util.GregorianCalendar w_TimeGregorian = new java.util.GregorianCalendar(); + w_TimeGregorian.setTime((DateUtil.getDate(theTimeDate))); + w_DateGregorian.set(GregorianCalendar.HOUR_OF_DAY, + w_TimeGregorian.get(GregorianCalendar.HOUR_OF_DAY)); + w_DateGregorian.set(GregorianCalendar.MINUTE, w_TimeGregorian + .get(GregorianCalendar.MINUTE)); + w_DateGregorian.set(GregorianCalendar.SECOND, w_TimeGregorian + .get(GregorianCalendar.SECOND)); + } + w_TempDate = w_DateGregorian.getTime(); + w_DateGregorian = null; + } + + return w_TempDate; + } + + public static java.util.Date getTime(Object theDateObj) { + java.sql.Time w_TempDate; + if (theDateObj == null) { + w_TempDate = null; + } else { + java.util.Date theDateDate = (java.util.Date) theDateObj; + w_TempDate = new java.sql.Time(theDateDate.getTime()); + } + + return w_TempDate; + + } + + @SuppressWarnings("unchecked") + public static Collection getWeekend(Calendar beginCal, Calendar endCal) { + Calendar begin = getCalendar(beginCal.get(Calendar.DAY_OF_MONTH), + beginCal.get(Calendar.MONTH), beginCal.get(Calendar.YEAR), 0, + 0, 0); + Calendar end = getCalendar(endCal.get(Calendar.DAY_OF_MONTH), endCal + .get(Calendar.MONTH), endCal.get(Calendar.YEAR), 0, 0, 0); + + int day = begin.get(Calendar.DAY_OF_WEEK); + Collection weekendCol = new ArrayList(); + int nextSat = 6; + + if (day == Calendar.SUNDAY) { + weekendCol.add(getCalendar(begin.get(Calendar.DAY_OF_MONTH), begin + .get(Calendar.MONTH), begin.get(Calendar.YEAR))); + } else if (day == Calendar.SATURDAY) { + weekendCol.add(getCalendar(begin.get(Calendar.DAY_OF_MONTH), begin + .get(Calendar.MONTH), begin.get(Calendar.YEAR))); + + begin.add(Calendar.DAY_OF_MONTH, 1); + + if (begin.before(end) || begin.equals(end)) { + weekendCol.add(getCalendar(begin.get(Calendar.DAY_OF_MONTH), + begin.get(Calendar.MONTH), begin.get(Calendar.YEAR))); + } + } else { + nextSat = 7 - day; + } + + begin.add(Calendar.DAY_OF_MONTH, nextSat); + + for (; begin.before(end) || begin.equals(end); begin.add( + Calendar.DAY_OF_MONTH, 6)) { + weekendCol.add(getCalendar(begin.get(Calendar.DAY_OF_MONTH), begin + .get(Calendar.MONTH), begin.get(Calendar.YEAR))); + + begin.add(Calendar.DAY_OF_MONTH, 1); + + if (begin.before(end) || begin.equals(end)) { + weekendCol.add(getCalendar(begin.get(Calendar.DAY_OF_MONTH), + begin.get(Calendar.MONTH), begin.get(Calendar.YEAR))); + } + } + + return weekendCol; + } + + /** + * Insert the method's description here. Creation date: (11/3/2005 9:59:23) + * + * @return int + * @param d + * java.util.Date + */ + public static Date getLastDateOfMonth(Date firstDateOfMonth) { + + Date newDate = null; + Date newDate2 = null; + + try { + newDate = addMonth(firstDateOfMonth, true, 1); + newDate2 = addDate(newDate, false, 1); + + } catch (Exception e) { + e.printStackTrace(); + } + + return newDate2; + } + + /** + * Convert from java.util.Date to java.sql.Date. Creation date: (26/05/2004 + * 13:00:03) + * + * @return java.sql.Date + * @param theDateDate + * java.util.Date + */ + public static java.sql.Date getDBDate(java.util.Date theDateDate) { + java.sql.Date w_TempDate; + if (theDateDate == null) + w_TempDate = null; + else { + w_TempDate = new java.sql.Date(theDateDate.getTime()); + } + + return w_TempDate; + } + + /** + * Convert from String to java.sql.Date. Creation date: (26/05/2004 + * 13:00:03) + * + * @return java.sql.Date + * @param theDate + * String + */ + public static java.sql.Date getDBDate(String theDate) throws Exception { + return getDBDate(getDate(theDate)); + } + + /** + * Convert from Timestamp to java.sql.Date. Creation date: (26/05/2004 + * 13:00:03) + * + * @return java.sql.Date + * @param theTimestamp + * Timestamp + */ + public static java.sql.Date getDBDate(Timestamp theTimestamp) + throws Exception { + return getDBDate(new java.sql.Date(theTimestamp.getTime())); + } + + /* + * Format is DD/MM/YYYY:HH:MI 10/9/2005:08:00 // public static Calendar + * getCalendar(String calStr){ + * + * StringTokenizer token = new StringTokenizer(calStr,"/"); String dd = + * token.nextToken(); String mm = token.nextToken(); String yy = + * token.nextToken(":").replace('/',' ').trim(); String hh = + * token.nextToken(":"); String mi = token.nextToken(":"); + * + * return getCalendar(Integer.parseInt(dd),Integer.parseInt(mm), + * Integer.parseInt(yy),Integer.parseInt(hh),Integer.parseInt(mi)); } + */ + + /*public static java.sql.Time getDBTime(String theTimeStr) throws Exception { + java.sql.Time w_time = null; + java.util.Vector w_TimeVector = null; + int w_HourInt = 0; + int w_MinuteInt = 0; + if (theTimeStr != null) { + w_TimeVector = StringUtil.getStringByDelimeter(theTimeStr, ":"); + w_HourInt = NumberUtil.getInt((String) w_TimeVector.elementAt(0)); + w_MinuteInt = NumberUtil.getInt((String) w_TimeVector.elementAt(1)); + w_TimeVector = null; + } + java.util.GregorianCalendar w_TempGregorian = new java.util.GregorianCalendar( + 0, 0, 0, w_HourInt, w_MinuteInt); + w_time = new Time(w_TempGregorian.getTime().getTime()); + return w_time; + }*/ + + public static Timestamp getDBTimestamp(java.util.Date theDate) + throws Exception { + Timestamp w_timestamp = null; + if (theDate != null) { + w_timestamp = new Timestamp(theDate.getTime()); + } else { + w_timestamp = new Timestamp(new java.util.Date().getTime()); + } + return w_timestamp; + } + + /*public static Timestamp getDBTimestamp(Object theDate) throws Exception { + Timestamp w_timestamp = null; + if (theDate != null && !theDate.equals("")) { + w_timestamp = new Timestamp( + getDBDate(StringUtil.getString(theDate)).getTime()); + } else { + w_timestamp = null; + } + return w_timestamp; + }*/ + + /* + * public static HashMap getYearMonthDay(java.sql.Date theStartDate , + * java.sql.Date theEndDate){ int w_start_day = theStartDate.getDate(); int + * w_start_month = theStartDate.getMonth()+1; int w_start_year = + * theStartDate.getYear()+1900; int w_end_day = theEndDate.getDate(); int + * w_end_month = theEndDate.getMonth()+1; int w_end_year = + * theEndDate.getYear()+1900; HashMap w_result = null; int w_year = 0 ; int + * w_month =0; int w_day = 0; int w_diff_year = 0; int w_diff_month = 0; + * + * w_diff_year = w_end_year - w_start_year; w_diff_month = w_end_month - + * w_start_month; switch(w_diff_year){ + * + * case 0 : w_year = w_diff_year; w_month = w_diff_month -1; break; case 1 : + * w_year = w_diff_year - 1; w_month = w_end_month + (12 - w_start_month) - + * 1; break; default : w_year = w_diff_year - 1; w_month = w_end_month + (12 - + * w_start_month) - 1; break; + * + * }//switch(YEAR) + * + * switch(w_start_month){ case 1 : case 3 : case 5 : case 7 : case 8 : case + * 10 : case 12 : w_day = w_end_day + (31 - w_start_day)+ 1; if (w_day > + * 31){ w_month = w_month + 1; w_day = w_day - 31; }; break; case 2 : if + * ((w_start_year % 4) == 0) { w_day = w_end_day + (29 - w_start_day)+1; if + * (w_day > 29){ w_month = w_month + 1; w_day = w_day - 29; } }else{ w_day = + * w_end_day + (28-w_start_day)+1; if(w_day > 28){ w_month = w_month +1; + * w_day = w_day - 28; } };//end case 2: break; + * + * case 4 : case 6 : case 9 : case 11 : w_day = w_end_day + (30 - + * w_start_day) +1; if(w_day > 30){ w_month = w_month +1; w_day = w_day - + * 31; }; break; }//switch(START MONTH) switch(w_end_month){ case 1 : case 3 : + * case 5 : case 7 : case 8 : case 10 : case 12 : if(w_day == 31){ w_month = + * w_month + 1; w_day = 0; } break; case 2 : if ((w_start_year % 4) == 0) { + * if(w_day == 29){ w_month = w_month + 1; w_day = 0; } }else{ if((w_day == + * 28) || (w_day == 29)){ w_month = w_month + 1; w_day = 0; } };//end case + * 2: break; + * + * case 4 : case 6 : case 9 : case 11 : if(w_day == 30){ w_month = w_month + + * 1; w_day = 0; } break; }//switch(STOP MONTH) if(w_month >= 24){ w_year = + * w_year + 2; w_month = w_month - 24; }else{ if(w_month >=12){ w_year = + * w_year + 1; w_month = w_month - 12; } } + * + * w_result = new HashMap(); + * w_result.put("YEAR",NumberUtil.getInteger(w_year)); + * w_result.put("MONTH",NumberUtil.getInteger(w_month)); + * w_result.put("DAY",NumberUtil.getInteger(w_day)); return w_result; + * }//getYearMonthDay + */ + + public static int getYear(Calendar cal) { + return cal.get(Calendar.YEAR); + } + + /** + * Insert the method's description here. Creation date: (16/8/2001 15:42:23) + * + * @return int + * @param d + * java.util.Date + */ + public static int getYear(Date d) { + java.util.GregorianCalendar temp = new java.util.GregorianCalendar(); + temp.setTime(d); + return temp.get(GregorianCalendar.YEAR); + } + + public static int getMonth(Calendar cal) { + return cal.get(Calendar.MONTH); + } + + /** + * Insert the method's description here. Creation date: (16/8/2001 15:42:23) + * + * @return int + * @param d + * java.util.Date + */ + /*public static int getMonth(Date d) throws Exception { + String w_date = StringUtil.getLocaleDate(d); + java.util.Date w_d = DateUtil.getDate(w_date); + java.util.GregorianCalendar temp = new java.util.GregorianCalendar(); + temp.setTime(w_d); + return temp.get(GregorianCalendar.MONTH) + 1; + }*/ + + public static int getDay(Calendar cal) { + return cal.get(Calendar.DAY_OF_MONTH); + } + + public static int getDayOfWeek(Calendar cal) { + return cal.get(Calendar.DAY_OF_WEEK); + } + + public static int getDayOfYear(Timestamp theTimestamp) throws Exception { + int w_total_day = 0; + Date w_util_date = DateUtil.getDate(theTimestamp); + // GregorianCalendar w_gre_calendar = new GregorianCalendar(); + w_total_day = getDayOfYear(w_util_date); + return w_total_day; + } + + public static int getDayOfYear(String theDate) throws Exception { + int w_total_day = 0; + Date w_util_date = DateUtil.getDate(theDate); + w_total_day = getDayOfYear(w_util_date); + return w_total_day; + } + + @SuppressWarnings("deprecation") + public static int getDayOfYear(Date theDate) throws Exception { + int w_total_day = 0; + GregorianCalendar w_gre_calendar = new GregorianCalendar(); + if (w_gre_calendar.isLeapYear(theDate.getYear())) { + w_total_day = 366; + } else { + w_total_day = 365; + } + return w_total_day; + } + + public static int getHour(Calendar cal) { + return cal.get(Calendar.HOUR_OF_DAY); + } + + public static int getMinute(Calendar cal) { + return cal.get(Calendar.MINUTE); + } + public static int getSecond(Calendar cal) { + return cal.get(Calendar.SECOND); + } + public static void setDay(Calendar cal, int day) { + cal.set(Calendar.DAY_OF_MONTH, day); + } + + public static void setMonth(Calendar cal, int month) { + cal.set(Calendar.MONTH, month); + } + + public static void setYear(Calendar cal, int year) { + cal.set(Calendar.YEAR, year); + } + + public static void setHour(Calendar cal, int hour) { + cal.set(Calendar.HOUR_OF_DAY, hour); + } + + public static void setMinute(Calendar cal, int minute) { + cal.set(Calendar.MINUTE, minute); + } + + public static void setSecond(Calendar cal, int second) { + cal.set(Calendar.SECOND, second); + } + + public static void setMilli(Calendar cal, int milli) { + cal.set(Calendar.MILLISECOND, milli); + } + + public static boolean equal(Calendar cal1, Calendar cal2) { + Calendar c1 = getCalendar(cal1.get(Calendar.DAY_OF_MONTH), cal1 + .get(Calendar.MONTH), cal1.get(Calendar.YEAR), cal1 + .get(Calendar.HOUR), cal1.get(Calendar.MINUTE), cal1 + .get(Calendar.SECOND)); + Calendar c2 = getCalendar(cal2.get(Calendar.DAY_OF_MONTH), cal2 + .get(Calendar.MONTH), cal2.get(Calendar.YEAR), cal2 + .get(Calendar.HOUR), cal2.get(Calendar.MINUTE), cal2 + .get(Calendar.SECOND)); + + return c1.equals(c2); + } + + public static java.util.Date addDate(java.util.Date theDate, boolean add, + int amount) throws Exception { + if (theDate == null) + throw new Exception("theDate is null"); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(theDate); + if (add) + calendar.add(GregorianCalendar.DATE, amount); + else + calendar.add(GregorianCalendar.DATE, (-1) * amount); + + return calendar.getTime(); + } + public static java.util.Date addSecond(java.util.Date theDate,boolean add, int amount) throws Exception { + if(theDate == null) + throw new Exception ("theDate is null"); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(theDate); + if(add) + calendar.add(GregorianCalendar.SECOND,amount); + else + calendar.add(GregorianCalendar.SECOND,(-1)*amount); + + return calendar.getTime(); + } + public static java.util.Date addMonth(java.util.Date theDate, boolean add, + int amount) throws Exception { + if (theDate == null) + throw new Exception("theDate is null"); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(theDate); + if (add) + calendar.add(GregorianCalendar.MONTH, amount); + else + calendar.add(GregorianCalendar.MONTH, (-1) * amount); + + return calendar.getTime(); + } + + public static java.util.Date addYear(java.util.Date theDate, boolean add, + int amount) throws Exception { + if (theDate == null) + throw new Exception("theDate is null"); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(theDate); + if (add) + calendar.add(GregorianCalendar.YEAR, amount); + else + calendar.add(GregorianCalendar.YEAR, (-1) * amount); + + return calendar.getTime(); + } + + public static void addDay(Calendar cal, int i) { + cal.add(Calendar.DAY_OF_MONTH, i); + } + + public static void addHour(Calendar cal, int i) { + cal.add(Calendar.HOUR_OF_DAY, i); + } + + public static void addMinute(Calendar cal, int i) { + cal.add(Calendar.MINUTE, i); + } + + // public static long diffDate(Calendar d1,Calendar d2) { + // Calendar c1 = getCalendar(d1.get(Calendar.DAY_OF_MONTH), + // d1.get(Calendar.MONTH), d1.get(Calendar.YEAR),0,0,0); + // Calendar c2 = getCalendar(d2.get(Calendar.DAY_OF_MONTH), + // d2.get(Calendar.MONTH), d2.get(Calendar.YEAR),0,0,0); + // long diffInMilliSeconds=c1.getTime().getTime()-c2.getTime().getTime(); + // return diffInMilliSeconds/(1000*60*60*24); + // } + public static int diffDate(Calendar d1, Calendar d2) { + Calendar c1 = getCalendar(d1.get(Calendar.DAY_OF_MONTH), d1 + .get(Calendar.MONTH), d1.get(Calendar.YEAR), 0, 0, 0); + Calendar c2 = getCalendar(d2.get(Calendar.DAY_OF_MONTH), d2 + .get(Calendar.MONTH), d2.get(Calendar.YEAR), 0, 0, 0); + long diffInMilliSeconds = c1.getTime().getTime() + - c2.getTime().getTime(); + int diffDays = (int) (diffInMilliSeconds / (1000 * 60 * 60 * 24)); + return diffDays; + } + + public static int diffDate(Date dateStart, Date dateEnd) throws Exception { + Calendar calDateStart = new GregorianCalendar(); + calDateStart.set(Calendar.MONTH, dateStart.getMonth()); + calDateStart.set(Calendar.DATE, dateStart.getDate()); + calDateStart.set(Calendar.YEAR, dateStart.getYear()); + Calendar calDateEnd = new GregorianCalendar(); + calDateEnd.set(Calendar.MONTH, dateEnd.getMonth()); + calDateEnd.set(Calendar.DATE, dateEnd.getDate()); + calDateEnd.set(Calendar.YEAR, dateEnd.getYear()); + return diffDate(calDateStart, calDateEnd); + } + + public static String diffDateStringThai(Date dateStart, Date dateEnd) + throws Exception { + String strDiffDateThai = ""; + int daysDiff = diffDate(dateStart, dateEnd); + System.out.println("pass 764 - dateStart=" + dateStart.toString() + + " dateEnd=" + dateEnd.toString()); + System.out.println("pass 764 - daysDiff=" + daysDiff); + double dblYearsDiff = daysDiff / 365.25; + int intYearsDiff = (int) (dblYearsDiff); + double dblMonthDiff = (daysDiff % 365.25) / 30.4375; + int intMonthDiff = (int) dblMonthDiff; + double dblDayDiff = (daysDiff % 365.25) % 30.4375; + int intDayDiff = (int) dblDayDiff; + + strDiffDateThai = intYearsDiff + " ปี " + intMonthDiff + + " เดือน " + intDayDiff + " วัน "; + return strDiffDateThai; + } + + public static String diffDateStringEng(Date dateStart, Date dateEnd) + throws Exception { + String strDiffDateEng = ""; + int daysDiff = diffDate(dateStart, dateEnd); + System.out.println("pass 764 - dateStart=" + dateStart.toString() + + " dateEnd=" + dateEnd.toString()); + System.out.println("pass 764 - daysDiff=" + daysDiff); + double dblYearsDiff = daysDiff / 365.25; + int intYearsDiff = (int) (dblYearsDiff); + double dblMonthDiff = (daysDiff % 365.25) / 30.4375; + int intMonthDiff = (int) dblMonthDiff; + double dblDayDiff = (daysDiff % 365.25) % 30.4375; + int intDayDiff = (int) dblDayDiff; + strDiffDateEng = intYearsDiff + " years " + intMonthDiff + " months " + + intDayDiff + " days "; + return strDiffDateEng; + } + + // + // public static int diffDate(Date d1, Date d2) throws Exception{ + // int diffDate = 0; + // long diffLong = 0; + // if(d1 != null && d2 != null){ + // java.util.GregorianCalendar x1= new java.util.GregorianCalendar(); + // x1.setTime(d1); + // java.util.GregorianCalendar x2= new java.util.GregorianCalendar(); + // x2.setTime(d2); + // + // long dLong1 = + // x1.getTime().getTime();//x1.UTC(x1.get(x1.YEAR),x1.get(x1.MONTH),x1.get(x1.DATE),x1.get(x1.HOUR_OF_DAY),x1.get(x1.MINUTE),x1.get(x1.SECOND)); + // long dLong2 = + // x2.getTime().getTime();//x2.UTC(x2.get(x1.YEAR),x2.get(x1.MONTH),x2.get(x1.DATE),x2.get(x1.HOUR_OF_DAY),x2.get(x1.MINUTE),x2.get(x1.SECOND)); + // // if(dLong1>dLong2) + // // diffLong = dLong1 - dLong2; + // // else + // diffLong = dLong2 - dLong1; + // + // diffLong = diffLong / ONEDAY; + // diffDate = (int)diffLong; + // + // }else + // throw new Exception("D1 or D2 is null"); + // + // return diffDate; + // } + + public static int diff(Date date1, Date date2) { + Calendar c1 = Calendar.getInstance(); + Calendar c2 = Calendar.getInstance(); + + c1.setTime(date1); + c2.setTime(date2); + int diffDay = 0; + + if (c1.before(c2)) { + diffDay = countDiffDay(c1, c2); + } else { + diffDay = countDiffDay(c2, c1); + } + + return diffDay; + } + + public static int checkDatediff(Date date1, Date date2) { + Calendar c1 = Calendar.getInstance(); + Calendar c2 = Calendar.getInstance(); + + c1.setTime(date1); + c2.setTime(date2); + int diffDay = 0; + + if (c1.before(c2)) { + diffDay = diffDate(c2, c1); + } else { + diffDay = 0; + } + + return diffDay; + } + + public static void DateDiff(Date date1, Date date2) { + int diffDay = diff(date1, date2); + System.out.println("Different Day : " + diffDay); + } + + public static int countDiffDay(Calendar c1, Calendar c2) { + int returnInt = 0; + while (!c1.after(c2)) { + c1.add(Calendar.DAY_OF_MONTH, 1); + returnInt++; + } + + if (returnInt > 0) { + returnInt = returnInt - 1; + } + + return (returnInt); + } + public static int countDiffDay(Date date1, Date date2) { + Calendar c1 = Calendar.getInstance(); + Calendar c2 = Calendar.getInstance(); + + c1.setTime(date1); + c2.setTime(date2); + int returnInt = 0; + while (!c1.after(c2)) { + c1.add(Calendar.DAY_OF_MONTH, 1); + returnInt++; + } + + if (returnInt > 0) { + returnInt = returnInt - 1; + } + + return (returnInt); + } + + public static Date makeDate(String dateString) throws Exception { + SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); + return formatter.parse(dateString); + } + + public static Date makeDate(String dateString, String pattern) + throws Exception { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(dateString); + } + + public static String convertDateStringFormat(String dateStr, + String formatDateFrom, String formatDateTo) { + return convertDateStringFormat(dateStr, formatDateFrom, null, + formatDateTo, null); + } + + public static String convertDateStringFormat(String dateStr, + String formatDateFrom, Locale localeFrom, String formatDateTo, + Locale localeTO) { + // System.out.println("convertDateStringFormat(dateStr<"+ dateStr + // +">)"); + if (dateStr == null || "".equals(dateStr)) { + return ""; + } + + String result = null; + try { + + SimpleDateFormat dateFormatFrom = null; + SimpleDateFormat dateFormatTO = null; + if (localeFrom != null) { + dateFormatFrom = new SimpleDateFormat(formatDateFrom, + localeFrom); + } else { + dateFormatFrom = new SimpleDateFormat(formatDateFrom); + } + // dateFormat = new SimpleDateFormat(formatDateFrom); + java.util.Date date = dateFormatFrom.parse(dateStr); + if (localeTO != null) { + dateFormatTO = new SimpleDateFormat(formatDateTo, localeTO); + } else { + dateFormatTO = new SimpleDateFormat(formatDateTo); + } + result = dateFormatTO.format(date); + } catch (Exception e) { + e.printStackTrace(); + result = dateStr; + } + return result; + } + + public static String convertDateStringFormat(String dateStr, int diffDay, + String formatDateFrom, Locale localeFrom, String formatDateTo, + Locale localeTO) { + // System.out.println("convertDateStringFormat(dateStr<"+ dateStr + // +">)"); + if (dateStr == null || "".equals(dateStr)) { + return ""; + } + + String result = null; + try { + + SimpleDateFormat dateFormatFrom = null; + SimpleDateFormat dateFormatTO = null; + if (localeFrom != null) { + dateFormatFrom = new SimpleDateFormat(formatDateFrom, + localeFrom); + } else { + dateFormatFrom = new SimpleDateFormat(formatDateFrom); + } + // dateFormat = new SimpleDateFormat(formatDateFrom); + java.util.Date date = dateFormatFrom.parse(dateStr); + date.setDate(date.getDate() + diffDay); + if (localeTO != null) { + dateFormatTO = new SimpleDateFormat(formatDateTo, localeTO); + } else { + dateFormatTO = new SimpleDateFormat(formatDateTo); + } + result = dateFormatTO.format(date); + } catch (Exception e) { + e.printStackTrace(); + result = dateStr; + } + return result; + } + + // public static void main(String argv[]) throws Exception { + // Calendar cc1 = Calendar.getInstance(); + // Calendar cc2 = Calendar.getInstance(); + // cc1.add(Calendar.DAY_OF_MONTH, 10); + // + // DateDiff(cc1.getTime(), cc2.getTime()); + // + // java.util.Date d1 = makeDate("10/10/2000"); + // java.util.Date d2 = makeDate("10/18/2000"); + // DateDiff(d1, d2); + // + // java.util.Date d3 = makeDate("1/1/2000"); + // java.util.Date d4 = makeDate("12/31/2000"); + // int diff34 = diff(d3, d4); + // System.out.println("diff34=" + diff34); + // } + + public static int diffMinute(Calendar first, Calendar last) { + Calendar fCal = DateUtil.getCalendar(DateUtil.getDay(first), DateUtil + .getMonth(first), DateUtil.getYear(first), DateUtil + .getHour(first), DateUtil.getMinute(first), 0); + Calendar lCal = DateUtil.getCalendar(DateUtil.getDay(last), DateUtil + .getMonth(last), DateUtil.getYear(last), + DateUtil.getHour(last), DateUtil.getMinute(last), 0); + + long lastLong = lCal.getTime().getTime(); + long firstLong = fCal.getTime().getTime(); + + long diff = lastLong - firstLong; + + return (new Long(diff / (60 * 1000))).intValue(); + } + + public static long diffTimestamp(String first, String last) { + long firstParsedDate = Long.parseLong(first); + long secondParsedDate = Long.parseLong(last); + long diff = secondParsedDate - firstParsedDate; + return diff; + } + + public static long diffSecond(String first, String last) throws ParseException { + DateFormat formatter = new SimpleDateFormat("yyyyMMdd:HHmmss"); + Date dateFist = formatter.parse(first); + Date dateLast = formatter.parse(last); + Calendar strF_Cal = Calendar.getInstance(); + Calendar strL_Cal = Calendar.getInstance(); + strF_Cal.setTime(dateFist); + strL_Cal.setTime(dateLast); + Calendar fCal = DateUtil.getCalendar(DateUtil.getDay(strF_Cal), DateUtil + .getMonth(strF_Cal), DateUtil.getYear(strF_Cal), DateUtil + .getHour(strF_Cal), DateUtil.getMinute(strF_Cal), DateUtil.getSecond(strF_Cal)); + Calendar lCal = DateUtil.getCalendar(DateUtil.getDay(strL_Cal), DateUtil + .getMonth(strL_Cal), DateUtil.getYear(strL_Cal), + DateUtil.getHour(strL_Cal), DateUtil.getMinute(strL_Cal), DateUtil.getSecond(strL_Cal)); + + long lastLong = lCal.getTime().getTime(); + long firstLong = fCal.getTime().getTime(); + + long diff = lastLong - firstLong; + + return (new Long(diff / 1000)); + } + + public static java.sql.Date getYesterday(java.sql.Date theDate) { + return diffTomorrowYesterday(theDate, true); + } + + public static java.sql.Date getTomorrow(java.sql.Date theDate) { + return diffTomorrowYesterday(theDate, false); + } + + private static java.sql.Date diffTomorrowYesterday(java.sql.Date theDate, + boolean theYesterday) { + java.sql.Date w_tmpDate = null; + + if (theYesterday) { + w_tmpDate = new java.sql.Date(theDate.getTime() - w_oneDay); + } else { + w_tmpDate = new java.sql.Date(theDate.getTime() + w_oneDay); + } + + return w_tmpDate; + } + + public static java.util.Date getPreviousOrNextByDayCount( + java.util.Date oldDate, int dayCount) { + java.util.Date newDate = null; + newDate = new java.util.Date(oldDate.getTime() + (w_oneDay * dayCount)); + return newDate; + } + + public static String convertDateFormatString(java.util.Date oldDate, + String format, Locale locale) { + String newDate = ""; + SimpleDateFormat formatter; + formatter = new SimpleDateFormat(format, locale); + newDate = formatter.format(oldDate); + return newDate; + } + + public static String convertDateFormatString(java.util.Date oldDate, + int diffDay, String format, Locale locale) { + String newDate = ""; + SimpleDateFormat formatter; + formatter = new SimpleDateFormat(format, locale); + oldDate.setDate(oldDate.getDate() + diffDay); + newDate = formatter.format(oldDate); + return newDate; + } + + /*--------------------------------*/ + /* @author surasc45 - 25 Feb 2009 */ + /* Creation for : EBill Project */ + /*--------------------------------*/ + public synchronized static long getCurrentTime() { + return Calendar.getInstance(new Locale("en", "US")).getTime().getTime(); + } + + public static java.sql.Date getCurrentDate() { + return new java.sql.Date(getCurrentTime()); + } + + public static java.sql.Timestamp getCurrentTimestamp() { + return new java.sql.Timestamp(getCurrentTime()); + } + + public static String convertTimestampToThaiDateString( + java.sql.Timestamp inputDate, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, new Locale( + "th", "TH")); + String dateStr = formatter.format(inputDate); + return dateStr; + } + + public static String convertTimestampToDateString( + java.sql.Timestamp inputDate, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, new Locale( + "en", "US")); + String dateStr = ""; + try { + dateStr = formatter.format(inputDate); + // System.out.println("dateStr : "+ dateStr); + } catch (Exception ex) { + ex.printStackTrace(); + } + return dateStr; + } + + public static String convertDateToThaiDateString(java.sql.Date inputDate, + String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, new Locale( + "th", "TH")); + String dateStr = formatter.format(inputDate); + return dateStr; + } + + public static String convertDateToDateString(java.sql.Date inputDate, + String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, new Locale( + "en", "US")); + String dateStr = ""; + try { + dateStr = formatter.format(inputDate); + } catch (Exception ex) { + ex.printStackTrace(); + } + return dateStr; + } + + public static java.sql.Timestamp stringToTimeStamp(String datestr, + String pattern) { + return stringToTimeStamp(datestr, pattern, new Locale("en", "US")); + } + + public static java.sql.Timestamp stringToTimeStamp(String datestr, + String pattern, Locale locale) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); + java.util.Date tmpdate = null; + java.sql.Timestamp outdate = null; + try { + tmpdate = formatter.parse(datestr); + outdate = new Timestamp(tmpdate.getTime()); + } catch (Exception e) { + System.out.println("Cannot parse String \"" + datestr + + "\" to TimeStamp object"); + } + return outdate; + } + + public static java.sql.Date stringToDate(String datestr, String pattern) { + return stringToDate(datestr, pattern, new Locale("en", "US")); + } + + public static java.sql.Date stringToDate(String datestr, String pattern, + Locale locale) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); + java.util.Date tmpdate = null; + java.sql.Date outdate = null; + try { + tmpdate = formatter.parse(datestr); + outdate = new java.sql.Date(tmpdate.getTime()); + } catch (Exception e) { + System.out.println("Cannot parse String \"" + datestr + + "\" to Date object"); + } + return outdate; + } + + public static String formatThaiDate(String dateStr, String patternIn, + String patternOut) { + String result = ""; + try { + SimpleDateFormat defDateF = new SimpleDateFormat(patternIn, + new Locale("th", "TH")); + java.util.Date date = null; + if (dateStr.equals("")) { + date = new java.util.Date(); + } else { + date = defDateF.parse(dateStr); + } + defDateF = new SimpleDateFormat(patternOut, new Locale("th", "TH")); + result = defDateF.format(date); + } catch (Exception e) { + System.out + .println("formatThaiDate with locale : get format date/datetime error."); + e.printStackTrace(); + } + return result; + } + + public static String formatEngDate(String dateStr, String patternIn, + String patternOut) { + String result = ""; + try { + SimpleDateFormat defDateF = new SimpleDateFormat(patternIn, + new Locale("en", "US")); + java.util.Date date = null; + if (dateStr.equals("")) { + date = new java.util.Date(); + } else { + date = defDateF.parse(dateStr); + } + defDateF = new SimpleDateFormat(patternOut, new Locale("en", "US")); + result = defDateF.format(date); + } catch (Exception e) { + System.out + .println("formatEngDate with locale : get format date/datetime error."); + e.printStackTrace(); + } + return result; + } + + public static String formatDate(String dateStr, Locale localeIn, + Locale localeOut) { + String result = ""; + try { + SimpleDateFormat defDateF = new SimpleDateFormat("dd/MM/yyyy", + localeIn); + java.util.Date date = null; + if (dateStr.equals("")) { + date = new java.util.Date(); + } else { + date = defDateF.parse(dateStr); + } + defDateF = new SimpleDateFormat("dd/MM/yyyy", localeOut); + result = defDateF.format(date); + } catch (Exception e) { + System.out + .println("formatDate with locale : get format date/datetime error."); + e.printStackTrace(); + } + return result; + } + + public static String formatDateThai(String dateStr, String formatDate, + Locale localeIn, Locale localeOut) { + String result = ""; + try { + SimpleDateFormat defDateF = new SimpleDateFormat(formatDate, + localeIn); + java.util.Date date = null; + if (dateStr.equals("")) { + date = new java.util.Date(); + } else { + date = defDateF.parse(dateStr); + } + defDateF = new SimpleDateFormat(formatDate, localeOut); + result = defDateF.format(date); + } catch (Exception e) { + System.out + .println("formatDate with locale : get format date/datetime error."); + e.printStackTrace(); + } + return result; + } + + public static String getMonthThai(int monthNumber) { + String monthNameTH = ""; + switch (monthNumber) { + case 1: + monthNameTH = "\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21"; + break; + case 2: + monthNameTH = "\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C"; + break; + case 3: + monthNameTH = "\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21"; + break; + case 4: + monthNameTH = "\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19"; + break; + case 5: + monthNameTH = "\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21"; + break; + case 6: + monthNameTH = "\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19"; + break; + case 7: + monthNameTH = "\u0E01\u0E23\u0E01\u0E0F\u0E32\u0E04\u0E21"; + break; + case 8: + monthNameTH = "\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21"; + break; + case 9: + monthNameTH = "\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19"; + break; + case 10: + monthNameTH = "\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21"; + break; + case 11: + monthNameTH = "\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19"; + break; + case 12: + monthNameTH = "\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"; + break; + } + return monthNameTH; + } + + public static String getMonthEng(int monthNumber) { + String monthNameEN = ""; + switch (monthNumber) { + case 1: + monthNameEN = "January"; + break; + case 2: + monthNameEN = "February"; + break; + case 3: + monthNameEN = "March"; + break; + case 4: + monthNameEN = "April"; + break; + case 5: + monthNameEN = "May"; + break; + case 6: + monthNameEN = "June"; + break; + case 7: + monthNameEN = "July"; + break; + case 8: + monthNameEN = "August"; + break; + case 9: + monthNameEN = "September"; + break; + case 10: + monthNameEN = "October"; + break; + case 11: + monthNameEN = "November"; + break; + case 12: + monthNameEN = "December"; + break; + } + return monthNameEN; + } + + // format "strDate" : mm/dd/yy + public static String dateThai(String strDate) { + String[] date = strDate.split("/"); + if (date[0].charAt(0) == '0') { + date[0] = date[0].replaceFirst("0", ""); + } + if (date[1].charAt(0) == '0') { + date[1] = date[1].replaceFirst("0", ""); + } + return date[1] + " " + getMonthThai(Integer.parseInt(date[0].trim())) + + " " + date[2].trim(); + } + + // format "strDate" : mm/dd/yy + public static String dateThaiWithThaiYear(String strDate) { + String[] date = strDate.split("/"); + if (date[0].charAt(0) == '0') { + date[0] = date[0].replaceFirst("0", ""); + } + if (date[1].charAt(0) == '0') { + date[1] = date[1].replaceFirst("0", ""); + } + return date[1] + " " + getMonthThai(Integer.parseInt(date[0].trim())) + + " " + (Integer.parseInt(date[2].trim()) + 543); + } + + // format "strDate" : mm/dd/yy + public static String dateEng(String strDate) { + String[] date = strDate.split("/"); + if (date[0].charAt(0) == '0') { + date[0] = date[0].replaceFirst("0", ""); + } + if (date[1].charAt(0) == '0') { + date[1] = date[1].replaceFirst("0", ""); + } + return date[1] + " " + getMonthEng(Integer.parseInt(date[0].trim())) + + " " + date[2].trim(); + } + + // format "strDateTime" : 2009-06-04 18:31:22.0 + public static String getDateTimeThai(String strDateTime) { + String strDateTimeThai = ""; + if (strDateTime.trim() != "") { + String[] arrayDateTimeThai = strDateTime.split(" "); + String[] arrayDateThai = arrayDateTimeThai[0].split("-"); + String[] arrayTimeThai = null; + if (arrayDateTimeThai.length > 1) { + arrayTimeThai = arrayDateTimeThai[1].split(":"); + } + strDateTimeThai = arrayDateThai[2].trim() + + " " + + DateUtil.getMonthThai(Integer.parseInt(arrayDateThai[1] + .trim())) + " " + + (Integer.parseInt(arrayDateThai[0].trim()) + 543); + if (arrayTimeThai != null) { + strDateTimeThai += " " + arrayTimeThai[0].trim() + ":" + + arrayTimeThai[1].trim(); + } + } + return strDateTimeThai; + } + + // format "strDateTime" : 31/05/2019 14:27:57 + public static String getDateTimeThai(String strDateTime, String token) { + String strDateTimeThai = ""; + if (strDateTime.trim() != "") { + String[] arrayDateTimeThai = strDateTime.split(" "); + String[] arrayDateThai = arrayDateTimeThai[0].split(token); + strDateTimeThai = arrayDateThai[0].trim() + + " " + + DateUtil.getMonthThai(Integer.parseInt(arrayDateThai[1] + .trim())) + " " + + (Integer.parseInt(arrayDateThai[2].trim()) + 543); + strDateTimeThai += " " + arrayDateTimeThai[1]; + } + return strDateTimeThai; + } + + // format "strDateTime" : 31/05/2019 14:27:57 + public static String getDateTimeEng(String strDateTime, String token) { + String strDateTimeEng = ""; + if (strDateTime.trim() != "") { + String[] arrayDateTimeEng = strDateTime.split(" "); + String[] arrayDateThai = arrayDateTimeEng[0].split(token); + strDateTimeEng = arrayDateThai[0].trim() + + " " + + DateUtil.getMonthEng(Integer.parseInt(arrayDateThai[1] + .trim())) + " " + + (Integer.parseInt(arrayDateThai[2].trim())); + strDateTimeEng += " " + arrayDateTimeEng[1]; + } + return strDateTimeEng; + } + + // format "strDateTime" : 2009-06-04 18:31:22.0 + public static String getDateTimeEng(String strDateTime) { + String strDateTimeEng = ""; + if (strDateTime.trim() != "") { + String[] arrayDateTimeEng = strDateTime.split(" "); + String[] arrayDateEng = arrayDateTimeEng[0].split("-"); + String[] arrayTimeEng = null; + if (arrayDateTimeEng.length > 1) { + arrayTimeEng = arrayDateTimeEng[1].split(":"); + } + strDateTimeEng = arrayDateEng[2].trim() + + " " + + DateUtil.getMonthEng(Integer.parseInt(arrayDateEng[1] + .trim())) + " " + + (Integer.parseInt(arrayDateEng[0].trim())); + if (arrayTimeEng != null) { + strDateTimeEng += " " + arrayTimeEng[0].trim() + ":" + + arrayTimeEng[1].trim(); + } + + } + return strDateTimeEng; + } + + // format "strDateTime" : 2009-06-04 18:31:22.0 + + /** + * @param strDateTime + * 2009-06-04 18:31:22.0 + * @return 04/06/2009 18:31:22 + */ + public static String getDateTimeString(String strDateTime) { + String strDateTimeEng = ""; + if (strDateTime.trim() != "") { + String[] arrayDateTimeEng = strDateTime.split(" "); + String[] arrayDateEng = arrayDateTimeEng[0].split("-"); + String[] arrayTimeEng = null; + if (arrayDateTimeEng.length > 1) { + arrayTimeEng = arrayDateTimeEng[1].split(":"); + } + strDateTimeEng = arrayDateEng[2].trim() + "/" + + arrayDateEng[1].trim() + "/" + + (Integer.parseInt(arrayDateEng[0].trim())); + if (arrayTimeEng != null) { + strDateTimeEng += " " + arrayTimeEng[0].trim() + ":" + + arrayTimeEng[1].trim(); + } + + } + return strDateTimeEng; + } + + + + + + + public static Calendar getCalendar(Locale locale) { + Calendar cal = Calendar.getInstance(locale); + cal.setTimeZone(TimeZone.getTimeZone("GMT+07:00")); + return cal; + } + + public static Calendar getSimpleDate(String strDate,String simpleDateFormat, Locale locale) { + Calendar calendar = null; + if (strDate != null && strDate.trim().length() > 0) { + try { + calendar = getCalendar(Locale.US); + calendar.setTime(new SimpleDateFormat(simpleDateFormat, locale).parse(strDate)); + } catch (Exception e) { + calendar = null; + } + } + return calendar; + } + public static int getCustomerAge(String birthDate,String pattern,String locale) { + return getCustomerAge(birthDate,pattern,new Locale(locale)); + } + + public static int getCustomerAge(String birthDate,String pattern,Locale locale) { + + + Calendar dob = getSimpleDate(birthDate, pattern, locale); + Calendar now = Calendar.getInstance(locale); + + + if (dob.after(now)) { + throw new IllegalArgumentException("Can't be born in the future"); + } + int year1 = now.get(Calendar.YEAR); + int year2 = dob.get(Calendar.YEAR); + int age = year1 - year2; + int month1 = now.get(Calendar.MONTH); + int month2 = dob.get(Calendar.MONTH); + if (month2 > month1) { + age--; + } else if (month1 == month2) { + int day1 = now.get(Calendar.DAY_OF_MONTH); + int day2 = dob.get(Calendar.DAY_OF_MONTH); + if (day2 > day1) { + age--; + } + } + + return age; + } + + + + public static String mappingMonth(HashMap monthMap, String date) { + String result = ""; + try { + if (date != null && !"".equals(date)) { + String month = date.substring(3, 6); + // System.out.println("sub month : "+ month); + result = date.replaceAll(month, String.valueOf(monthMap + .get(month))); + // System.out.println("replace month to : "+ result); + } else { + return ""; + } + } catch (Exception e) { + e.printStackTrace(); + result = date; + } + return result; + } + + public static HashMap getMonthHashMap() { + HashMap monthMap = new HashMap(); + monthMap.put("JAN", "01"); + monthMap.put("FEB", "02"); + monthMap.put("MAR", "03"); + monthMap.put("APR", "04"); + monthMap.put("MAY", "05"); + monthMap.put("JUN", "06"); + monthMap.put("JUL", "07"); + monthMap.put("AUG", "08"); + monthMap.put("SEP", "09"); + monthMap.put("OCT", "10"); + monthMap.put("NOV", "11"); + monthMap.put("DEC", "12"); + + return monthMap; + } + + public static String getMonthStr(int calendarMonth) { + + String rtnMonth = ""; + + switch (calendarMonth) { + case 0: rtnMonth = "01"; + break; + case 1: rtnMonth = "02"; + break; + case 2: rtnMonth = "03"; + break; + case 3: rtnMonth = "04"; + break; + case 4: rtnMonth = "05"; + break; + case 5: rtnMonth = "06"; + break; + case 6: rtnMonth = "07"; + break; + case 7: rtnMonth = "08"; + break; + case 8: rtnMonth = "09"; + break; + case 9: rtnMonth = "10"; + break; + case 10:rtnMonth = "11"; + break; + case 11:rtnMonth = "12"; + break; + default: + rtnMonth = "01"; + break; + } + + return rtnMonth; + } + + public static String getFirstDay(Date d) throws Exception { + Calendar calendar = new GregorianCalendar(Locale.US); + calendar.setTime(d); + calendar.set(Calendar.DAY_OF_MONTH, 1); + Date dddd = calendar.getTime(); + SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy"); + return sdf1.format(dddd); + } + + public static Calendar getLastDay(Date d) throws Exception { + Calendar calendar = new GregorianCalendar(Locale.US); + calendar.setTime(d); + calendar.set(Calendar.DAY_OF_MONTH, calendar + .getActualMaximum(Calendar.DAY_OF_MONTH)); + // Date dddd = calendar.getInstance(); + + return calendar; + } + + public static String getMonthEng_Abbreviations(String month) { + String monthNameEN = ""; + + if (month.equals("JAN")) { + monthNameEN = "01"; + } else if (month.equals("FEB")) { + monthNameEN = "02"; + } else if (month.equals("MAR")) { + monthNameEN = "03"; + } else if (month.equals("APR")) { + monthNameEN = "04"; + } else if (month.equals("MAY")) { + monthNameEN = "05"; + } else if (month.equals("JUN")) { + monthNameEN = "06"; + } else if (month.equals("JUL")) { + monthNameEN = "07"; + } else if (month.equals("AUG")) { + monthNameEN = "08"; + } else if (month.equals("SEP")) { + monthNameEN = "09"; + } else if (month.equals("OCT")) { + monthNameEN = "10"; + } else if (month.equals("NOV")) { + monthNameEN = "11"; + } else if (month.equals("DEC")) { + monthNameEN = "12"; + } + + return monthNameEN; + } + + /* + * #tom + * + * gen TransactionId + */ + public static String getSONbr() + { + DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + //get current date time with Calendar() + Calendar cal = Calendar.getInstance(); + int randomNum1 = new Random().nextInt((1000000 - 100000) + 1) + 100000; + int randomNum2 = new Random().nextInt((1000000 - 100000) + 1) + 100000; + int randomNum3 = new Random().nextInt((10000 - 1000) + 1) + 1000; + String output = dateFormat.format(cal.getTime()) + randomNum1 + randomNum2 + randomNum3; +// System.out.println(output); + return output; + } + + + /** + * + * @param dateStr + * format MM/DD/YYYY HH:MM:SS + * @return + */ + public static Calendar getCalendar(String dateStr) { + // DateFormat format = DateFormat.getInstance("MM/DD/YYYY HH:MM:SS"); + Calendar calendar = null; + try { + SimpleDateFormat format = new SimpleDateFormat( + "MM/dd/yyyy HH:mm:ss", Locale.US); + calendar = Calendar.getInstance(); + + calendar.setTime(format.parse(dateStr)); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return calendar; + } + + + public static String dateTimeThaiddMMNoTime(String strDate){ + Date tempDate = DateUtil.stringToDate(strDate, "dd/MM/yyyy"); + String[] tempSplit = strDate.split(" "); + String tempTime = tempSplit[1]==null?"":tempSplit[1]; + String strFullDate = tempDate.getDate() + " " + getMonthThai(tempDate.getMonth()+1) + " " + (tempDate.getYear() +2443); + return strFullDate; + } + public static String dateTimeEngddMMNoTime(String strDate){ + Date tempDate = DateUtil.stringToDate(strDate, "dd/MM/yyyy"); + String[] tempSplit = strDate.split(" "); + String tempTime = tempSplit[1]==null?"":tempSplit[1]; + String strFullDate = tempDate.getDate() + " " + getMonthEng(tempDate.getMonth()+1) + " " + (tempDate.getYear() +1900); + return strFullDate; + } + public static String dateTimeThaiddMM(String strDate){ + Date tempDate = DateUtil.stringToDate(strDate, "dd/MM/yyyy"); + String[] tempSplit = strDate.split(" "); + String tempTime = tempSplit[1]==null?"":tempSplit[1]; + String strFullDate = tempDate.getDate() + " " + getMonthThai(tempDate.getMonth()+1) + " " + (tempDate.getYear() +2443) + " " + tempTime; + return strFullDate; + } + + public static String dateTimeEngddMM(String strDate){ + Date tempDate = DateUtil.stringToDate(strDate, "dd/MM/yyyy"); + String[] tempSplit = strDate.split(" "); + String tempTime = tempSplit[1]==null?"":tempSplit[1]; + String strFullDate = tempDate.getDate() + " " + getMonthEng(tempDate.getMonth()+1) + " " + (tempDate.getYear() +1900) + " " + tempTime; + return strFullDate; + } + public static String checkWithIn3MonthsAgo(){ + Timestamp startTime = DateUtil.getCurrentTimestamp(); + String curDate = DateUtil.convertTimestampToDateString(startTime, "dd/MM/yyyy"); + String[] arrCurDate = curDate.split("/"); + // String[] arrCurDate = "02/01/2012".split("/"); + String result = ""; + String tempMonth = ""; + for(int i = 0; i < 4; i++){ + if((Integer.parseInt(arrCurDate[1])-i) > 0){ // this year + tempMonth = (Integer.parseInt(arrCurDate[1])-i)+""; + if(tempMonth.length() == 1){ + tempMonth = "0" + tempMonth; + } + result += (tempMonth+"/") + (arrCurDate[2]+"|"); + }else{ // last year + if((Integer.parseInt(arrCurDate[1])-i) == 0){ + result += 12+"/"; + }else if((Integer.parseInt(arrCurDate[1])-i) == -1){ + result += 11+"/"; + }else if((Integer.parseInt(arrCurDate[1])-i) == -2){ + result += 10+"/"; + }else if((Integer.parseInt(arrCurDate[1])-i) == -3){ + result += "0"+9+"/"; + } + result += ((Integer.parseInt(arrCurDate[2])-1)+"|"); + } + } + return result; + } + public static String dateWithThaiYear2(String strDate){ + String[] temp = strDate.split("/"); + if(temp[0].length() == 1){ + temp[0] = "0" + temp[0]; + } + if(temp[1].length() == 1){ + temp[1] = "0" + temp[1]; + } + return temp[0].trim() + "/" + temp[1].trim() + "/" + (Integer.parseInt(temp[2].trim()) +543); + } + public static String getDateTimeThaiContractSFF(String strDateTime){ + String strDateTimeThai = ""; + System.out.println("lerk strDateTime = "+strDateTime); + if (strDateTime.trim() != ""){ + + String[] arrayDateThai = strDateTime.split("/"); + if(arrayDateThai.length == 3){ + + System.out.println("Length of arrayDateThai = 3"); + String Year = arrayDateThai[2].substring(0,4); + System.out.println("lerk Year = "+Year); + strDateTimeThai = arrayDateThai[0].trim() + " " + DateUtil.getMonthThai(Integer.parseInt(arrayDateThai[1].trim())) + " " + (Integer.parseInt(Year.trim())+543) ; + System.out.println("strDateTimeThai = "+strDateTimeThai); + } + else + { + System.out.println("But Length of arrayDateThai = "+arrayDateThai.length); + + } + } + return strDateTimeThai; + } + + + +// dd/MM/yyyy + public static String getDateTimeEngContractSFF(String strDateTime){ + String strDateTimeEng = ""; + if (strDateTime.trim() != ""){ + String[] arrayDateEng = strDateTime.split("/"); + + if(arrayDateEng.length == 3){ + System.out.println("Length of arrayDateEng = 3"); + String Year = arrayDateEng[2].substring(0,4); + strDateTimeEng = arrayDateEng[0].trim() + " " + DateUtil.getMonthEng(Integer.parseInt(arrayDateEng[1].trim())) + " " + (Integer.parseInt(Year.trim())); + } + else + { + System.out.println("But Length of arrayDateEng = "+arrayDateEng.length); + + } + } + return strDateTimeEng; + } + + public static String convertStringDateTimeToStringFormat(String date){ + String dateDt=""; + try{ + DateFormat formatter; + Date dateNew; + formatter=new SimpleDateFormat("ddMMyyyy HH:mm:ss",new Locale("en","US")); + dateNew=(Date)formatter.parse(date); + formatter=new SimpleDateFormat("dd/MM/yyyy HH:mm:ss",new Locale("en","US")); + //dateDt=dateWithThaiYear(formatter.format(dateNew)); + dateDt=formatter.format(dateNew); + String date1[]= dateDt.split(" "); + int str1=0; + if(date1.length>=2){ + String date2[]=date1[0].split("/"); + if(date2.length>=3){ + str1=Integer.parseInt(date2[2])+543; + } + dateDt=date2[0]+"/"+date2[1]+"/"+str1+" "+date1[1]; + } + }catch(ParseException e){ + e.printStackTrace(); + } + return dateDt; + } + + public static String convertStringDateTimeToStringFormatEn(String date){ + String dateDt=""; + try{ + DateFormat formatter; + Date dateNew; + formatter=new SimpleDateFormat("ddMMyyyy HH:mm:ss",new Locale("en","US")); + dateNew=(Date)formatter.parse(date); + formatter=new SimpleDateFormat("dd/MM/yyyy HH:mm:ss",new Locale("en","US")); + //dateDt=dateWithThaiYear(formatter.format(dateNew)); + dateDt=formatter.format(dateNew); + + }catch(ParseException e){ + e.printStackTrace(); + } + return dateDt; + } + public static String convertStringTimeStampToStringFormat(String date){ + String dateDt=""; + try{ + DateFormat formatter; + Date dateNew; + formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",new Locale("en","US")); + dateNew=(Date)formatter.parse(date); + formatter=new SimpleDateFormat("dd/MM/yyyy HH:mm:ss",new Locale("en","US")); + //dateDt=dateWithThaiYear(formatter.format(dateNew)); + dateDt=formatter.format(dateNew); + String date1[]= dateDt.split(" "); + int str1=0; + if(date1.length>=2){ + String date2[]=date1[0].split("/"); + if(date2.length>=3){ + str1=Integer.parseInt(date2[2])+543; + } + dateDt=date2[0]+"/"+date2[1]+"/"+str1+" "+date1[1]; + } + }catch(ParseException e){ + e.printStackTrace(); + } + return dateDt; + } + + public static String convertStringTimeStampToStringFormatEn(String date){ + String dateDt=""; + try{ + DateFormat formatter; + Date dateNew; + formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",new Locale("en","US")); + dateNew=(Date)formatter.parse(date); + formatter=new SimpleDateFormat("dd/MM/yyyy HH:mm:ss",new Locale("en","US")); + //dateDt=dateWithThaiYear(formatter.format(dateNew)); + dateDt=formatter.format(dateNew); + + }catch(ParseException e){ + e.printStackTrace(); + } + return dateDt; + } + + public static String dateTimeThai(String strDate){ + Date tempDate = DateUtil.stringToDate(strDate, "MM/dd/yyyy HH:mm:ss"); + String[] tempSplit = strDate.split(" "); + String tempTime = tempSplit[1]==null?"":tempSplit[1]; + String strFullDate = tempDate.getDate() + " " + getMonthThai(tempDate.getMonth()+1) + " " + (tempDate.getYear() +2443) + " " + tempTime; + return strFullDate; + } + + public static String dateTimeEng(String strDate){ + Date tempDate = DateUtil.stringToDate(strDate, "MM/dd/yyyy HH:mm:ss"); + String[] tempSplit = strDate.split(" "); + String tempTime = tempSplit[1]==null?"":tempSplit[1]; + String strFullDate = tempDate.getDate() + " " + getMonthEng(tempDate.getMonth()+1) + " " + (tempDate.getYear() +1900) + " " + tempTime; + return strFullDate; + } + + public static int countDay(Date startDate, Date endDate) throws NullPointerException { + if(endDate==null) + throw new NullPointerException("DateUtil.countDay().endDate:null"); + if(startDate==null) + throw new NullPointerException("DateUtil.countDay().startDate:null"); + return (int)( (startDate.getTime() - endDate.getTime()) / (86400000) )+1; + } + + + public static boolean betweenCurrentTime(String start,String end,String pattern) throws ParseException{ + Calendar current = DateUtil.getCurrentDateTime(); + SimpleDateFormat sf = new SimpleDateFormat(pattern); + String currentStr = sf.format(current.getTime()); + Date currentTime = sf.parse(currentStr); + Date startTime = sf.parse(start); + Date endTime = sf.parse(end); + current.setTime(currentTime); + Calendar startCalendar = DateUtil.getCurrentDateTime(); + startCalendar.setTime(startTime); + Calendar endCalendar = DateUtil.getCurrentDateTime(); + endCalendar.setTime(endTime); + if(startCalendar.compareTo(endCalendar)<=0) + return current.compareTo(startCalendar)>=0&¤t.compareTo(endCalendar)<=0; + else + return current.compareTo(startCalendar)>=0||current.compareTo(endCalendar)<=0; + } + + /** + * calculates the last date of a month + */ + + public static Integer calculateMonthEndDate(int month, int year) { + int[] daysInAMonth = { 29, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int day = daysInAMonth[month]; + boolean isLeapYear = new GregorianCalendar().isLeapYear(year); + + if (isLeapYear && month == 2) { + day++; + } + + GregorianCalendar gc = new GregorianCalendar(year, month - 1, day); + + java.sql.Date monthEndDate = new java.sql.Date(gc.getTime().getTime()); + + return monthEndDate.getDate(); + } + + + public static boolean checkBillCycle(String lastInvStartDateStr, String lastInvEndDateStr, String billCycle) { + boolean result = false; + try { + + int lastInvStartDate = Integer.parseInt(lastInvStartDateStr.split("/")[0].trim()); + int lastInvEndDate = Integer.parseInt(lastInvEndDateStr.split("/")[0].trim()); + int calculatedDate = calculateMonthEndDate(Integer.parseInt(lastInvEndDateStr.split("/")[1].trim()), Integer.parseInt(lastInvEndDateStr.split("/")[2].trim())); + String billCycleSelect = billCycle!=null?billCycle:""; + String cycleType = billCycleSelect; + cycleType = cycleType.replace("Cycle ", ""); + + String[] temp = cycleType.split("/"); + int cycleStartDay = Integer.parseInt( ((String)temp[0]).split("-")[0].toString() ); + int cycleEndDay = Integer.parseInt( ((String)temp[0]).split("-")[1].toString() ); + + DateFormat df = new SimpleDateFormat ("dd/MM/yyyy"); + Date d1 = df.parse(lastInvStartDateStr); + Date d2 = df.parse(lastInvEndDateStr); + + String checkLastInv = String.valueOf(lastInvStartDate)+"-"+String.valueOf(lastInvEndDate); + String checkCycleBill = String.valueOf(cycleStartDay)+"-"+String.valueOf(cycleEndDay); + + if(!d1.after(d2)){ + + if((!checkLastInv.equals(checkCycleBill)) && (!checkCycleBill.equals("1-30")) ){ + + return result = false; + + }else{ + + if( (lastInvStartDate==cycleStartDay)&&(lastInvEndDate==cycleEndDay) ){ + + if(checkCycleBill.equals("1-30") ){ + + if(calculatedDate == cycleEndDay){ + return result = true; + }else{ + return result = false; + } + + }else{ + return result = true; + } + + } + + if((lastInvStartDate==cycleStartDay)&&(lastInvEndDate==calculatedDate) ){ + + result = true; + }else{ + result = false; + } + + } + + + + }else{ + + result = false; + } + + } catch (ParseException e) { + + e.printStackTrace(); + } + + return result; + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/ERDData.java b/src/th/co/ais/ssbsrfc/utils/ERDData.java new file mode 100644 index 0000000..a311400 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/ERDData.java @@ -0,0 +1,32 @@ +package th.co.ais.ssbsrfc.utils; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.Root; +import org.simpleframework.xml.Text; + +@Root(name="ERDData") +public class ERDData { + @Attribute(required=false) + private String value; + + @Text(required=false) + private String text; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + +} diff --git a/src/th/co/ais/ssbsrfc/utils/ERDHeader.java b/src/th/co/ais/ssbsrfc/utils/ERDHeader.java new file mode 100644 index 0000000..88d1dcd --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/ERDHeader.java @@ -0,0 +1,23 @@ +package th.co.ais.ssbsrfc.utils; + +import java.util.List; + +import org.simpleframework.xml.ElementList; +import org.simpleframework.xml.ElementListUnion; +import org.simpleframework.xml.Root; + +@Root(name="ERDHeader") +public class ERDHeader { + @ElementListUnion({ + @ElementList(entry="Header", inline=true, required=false) + }) + private List
header; + + public void setHeader(List
header) { + this.header = header; + } + + public List
getHeader() { + return header; + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/EqxStringUtils.java b/src/th/co/ais/ssbsrfc/utils/EqxStringUtils.java new file mode 100644 index 0000000..76f5d78 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/EqxStringUtils.java @@ -0,0 +1,159 @@ +package th.co.ais.ssbsrfc.utils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.StringEscapeUtils; +import org.simpleframework.xml.Serializer; +import org.simpleframework.xml.core.Persister; + +import th.co.ais.ssbsrfc.instance.EC02Instance; +import ec02.af.data.EquinoxRawData; +import ec02.utils.AppLog; + +public class EqxStringUtils { + + public static Map convertXMLtoHttpData(String rcvXMLData) throws Exception{ + Map rtnMapHttpData = new HashMap(); + + if(rcvXMLData != null) { + Serializer serializer = new Persister(); + rcvXMLData = "" + rcvXMLData + ""; + HttpData httpData = serializer.read(HttpData.class, rcvXMLData); + if(httpData != null ) { + if(httpData.getErdData() != null + && httpData.getErdData().getValue() != null) { + rtnMapHttpData.put("erddata_value", httpData.getErdData().getValue()); + } else { + rtnMapHttpData.put("erddata_value", rcvXMLData); + } + + ERDHeader eRDHeader = httpData.getErdHeader(); + if(eRDHeader != null) { + List
lsHeader = eRDHeader.getHeader(); + + if(lsHeader != null) { + for(int i = 0; i < lsHeader.size(); i++) { + Header header = lsHeader.get(i); + + if(header.getName() != null) { + rtnMapHttpData.put(header.getName(), header.getValue()); + } + } + } + } + } + } + return rtnMapHttpData; + } + + public static String getMessage(EquinoxRawData equinoxRawData) { + String value = EqxStringUtils.getMessage(equinoxRawData, null); + return value; + } + + public static String getMessage(EquinoxRawData equinoxRawData, EC02Instance ec02Instance) { + String value = EqxStringUtils.getMessage(equinoxRawData, ec02Instance, false); + return value; + } + + public static String getMessage(EquinoxRawData equinoxRawData, EC02Instance ec02Instance, boolean isLog) { + String value = ""; + try { + String ctype = equinoxRawData.getRawDataAttribute("ctype"); + String val = equinoxRawData.getRawDataAttribute("val"); + String message = equinoxRawData.getRawDataMessage(); + if (ctype.equals("Specialized-Resource")) { + value = message; + if (isLog) { + AppLog.d("[GETMESSAGE(MESSAGE)]: " + value); + } + } else if (ctype.equals("text/xml")) { + if ((message == null || message.equals("")) && (val != null && !val.equals(""))) { + value = val; + if (isLog) { + AppLog.d("[GETMESSAGE(VAL)]: " + value); + } + } else if (message != null && !message.equals("")) { + value = EqxStringUtils.getERDData(message, ec02Instance); + if (isLog) { + AppLog.d("[GETMESSAGE(MESSAGE)]: " + value); + } + } + } else if (ctype.equals("filefeed")) { + value = message; + } else if (ctype.equals("unknown")) { + value = message; + } else { + if ((val == null || val.equals("")) && (message != null && !message.equals(""))) { + value = EqxStringUtils.getERDData(message, ec02Instance); + if (isLog) { + AppLog.d("[GETMESSAGE(MESSAGE)]: " + value); + } + } else { + value = val; + if (isLog) { + AppLog.d("[GETMESSAGE(VAL)]: " + value); + } + } + } + } catch (Exception e) { + AppLog.e("[ EXCEPTION GETMESSAGES ] : " + e); + } + return value; + } + + public static String getERDData(String message, EC02Instance ec02Instance) { + String value = ""; + try { + Map mapHttpData = EqxStringUtils.convertXMLtoHttpData(message); + value = mapHttpData.get("erddata_value"); + if (ec02Instance != null) { + ec02Instance.getAFInstance().setMapHttpData(mapHttpData); + } + } catch (Exception e) { +// AppLog.e("[ Exception convertXMLtoHttpData ] : " + e.getMessage()); +// AppLog.d("## convertXMLtoHttpData: NOTMATH"); + value = message; + } + return value; + } + + public static String builMessageERDHeader(EC02Instance ec02Instance, String value) { + String buil = "\n\t\t\n"; + Map map = ec02Instance.getAFInstance().getMapHttpData(); + if (map != null) { + for (Map.Entry entry : map.entrySet()) + { + String name = entry.getKey(); + String data = entry.getValue(); + if (!name.equals("Content-Type") && !name.equals("erddata_value") && !name.equals("Content-Length")) { + buil += "\t\t\t
\n"; + } + } + } +// buil += "
\n"; + buil += "\t\t\n"; + buil += "\t\t"; + return buil; + } + + public static String escapePostdata(String rcvData) { + if(rcvData != null ) { + return StringEscapeUtils.escapeXml(rcvData); + } else { + return null; + } + } + + public static String unescapePostdata(String rcvData) { + if(rcvData != null ) { + //return rcvData; + return StringEscapeUtils.unescapeXml(rcvData); + + } else { + return null; + } + } +} \ No newline at end of file diff --git a/src/th/co/ais/ssbsrfc/utils/EqxValidateUtil.java b/src/th/co/ais/ssbsrfc/utils/EqxValidateUtil.java new file mode 100644 index 0000000..e9ac276 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/EqxValidateUtil.java @@ -0,0 +1,376 @@ +package th.co.ais.ssbsrfc.utils; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.apache.commons.lang.ArrayUtils; + +import th.co.ais.ssbsrfc.config.Constant.Parameter; +import th.co.ais.ssbsrfc.config.Constant.ValidateType; +import ec02.utils.AppLog; + +public class EqxValidateUtil { + private boolean isMissing = false; + private boolean isInvalid = false; + private boolean isBlank = false; + private String name = ""; + + public boolean isMissing() { + return isMissing; + } + + public void setMissing(boolean isMissing) { + this.isMissing = isMissing; + } + + public boolean isInvalid() { + return isInvalid; + } + + public void setInvalid(boolean isInvalid) { + this.isInvalid = isInvalid; + } + + public boolean isBlank() { + return isBlank; + } + + public void setBlank(boolean isBlank) { + this.isBlank = isBlank; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void validate(String paramName, Object paramValue, Parameter paramType, ValidateType type) { + this.name = paramName; + if (paramValue == null) { + this.printMissingLog(); + } + } + + public void validate(String paramName, Object[] paramValue, Parameter paramType, ValidateType type) { + this.name = paramName; + if (paramValue == null || paramValue.length == 0) { + this.printMissingLog(); + } + } + + public void validate(String paramName, String paramValue, Parameter paramType, ValidateType type) { + this.validate(paramName, paramValue, paramType, type, -1, -1, null); + } + + public void validate(String paramName, String paramValue, Parameter paramType, ValidateType type, String format) { + this.validate(paramName, paramValue, paramType, type, -1, -1, format); + } + + public void validate(String paramName, String paramValue, Parameter paramType, ValidateType type, int minLength, int maxLength) { + this.validate(paramName, paramValue, paramType, type, minLength, maxLength, null); + } + + public void validate(String paramName, String paramValue, Parameter paramType, ValidateType type, int minLength, int maxLength, String format) { + this.name = paramName; + if (paramType == Parameter.MANDATORY && paramValue == null) { + this.printMissingLog(); + } else if (paramValue != null) { + switch (type) { + case STRING: + { + if(maxLength > 0) { + this.checkLength(paramValue, minLength, maxLength); + } + + if(format != null) { + this.checkMatch(paramValue, format); + } + break; + } + case NUMBER: + { + String pattern = "[0-9]*"; + this.checkMatch(paramValue, pattern); + if(maxLength > 0) { + this.checkLength(paramValue, minLength, maxLength); + } + break; + } + case CURRENCY: + { + if(!paramValue.equals("0") && !paramValue.equals("0.00")) { + String pattern = "[1-9][0-9]*([.][0-9]{2})?"; + this.checkMatch(paramValue, pattern); + } + + break; + } + case MOBILE: + { + String pattern = "66\\d{9}"; + this.checkMatch(paramValue, pattern); + break; + } + case DATETIME: + { + this.checkDateFormat(paramValue, format); + break; + } + case BOOLEAN: + { + String[] arrValidValue = new String[] {"true", "false"}; + this.checkContain(paramValue.toLowerCase(), arrValidValue); + break; + } + case BOOLEANUPPERCASE: + { + String[] arrValidValue = new String[] {"TRUE", "FALSE"}; + this.checkContain(paramValue, arrValidValue); + break; + } + case FIX: + { + this.checkFix(paramValue, format); + break; + } +// case LANG: +// { +// String[] arrValidValue = new String[] {"eng", "tha"}; +// this.checkContain(paramValue.toLowerCase(), arrValidValue); +// break; +// } +// case LANGUPPER: +// { +// String[] arrValidValue = new String[] {"ENG", "THA"}; +// this.checkContain(paramValue.toUpperCase(), arrValidValue); +// break; +// } + case YESNO: + { + String[] arrValidValue = new String[] {"yes", "no"}; + this.checkContain(paramValue.toLowerCase(), arrValidValue); + break; + } + case DECIMAL: + { + String pattern = "[0-9]+([.][0-9]{2})"; + this.checkMatch(paramValue, pattern); + break; + } +// case SUBSCRIPTIONSTATE: +// { +// String[] arrValidValue = new String[] {"active", "suspendFraud", "suspendDebt", "barredLeasing", "creditLimitted", "barredRequest", "terminated", "barredDisconnect", "barredPending", "prep", "test", "freeze", "barredDebtOut", "suspendDebt1way", "creditLimitted1way", "barredDisconnectOver30", "barredCredit", "barredCreditOut", "terminatedOver30", "prepaidSuspend", "prepaidDisable", "pool"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case AEMFCHARACTERISTIC: +// { +// String[] arrValidValue = new String[] {"dynamic", "static"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case AEMFVALUETYPE: +// { +// String[] arrValidValue = new String[] {"numeric", "latitude_longtitude", "text"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case AEMFALERTPOINT: +// { +// String[] arrValidValue = new String[] {"targetDecisionPoint", "referencePoint", "both"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case AMFLOANSTATE: +// { +// String[] arrValidValue = new String[] {"idle", "active", "terminated", "borrowed"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } + case URL: + { + this.checkMatch(paramValue, format); + break; + } + case EMAIL: + { + String pattern = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$"; + this.checkMatch(paramValue, pattern); + break; + } +// case DS3CUSTOMERCATEGORY: +// { +// String[] arrValidValue = new String[] {"residential", "business", "exclusive", "governmentAndNonProfit", "inHouse"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case DS3CUSTOMERSUBCATEGORY: +// { +// String[] arrValidValue = new String[] {"keyAccount", "sme", "royal", "tot", "government", "stateEnterprise", "embassy", "nonProfit", "ais", "prepaid", "foreigner", "thaiCitizen"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case DS3CUSTOMERSEGMENT: +// { +// String[] arrValidValue = new String[] {"standard", "classic", "gold", "platinum", "platinumPlus", "serenadeCeo", "serenadePrestige"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case AEMFACHIEVE: +// { +// String[] arrValidValue = new String[] {"target", "reference", "expire"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case AEMFSTATUS: +// { +// String[] arrValidValue = new String[] {"terminate", "recall", "prep", "port out", "active"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case AEMFSTATUS2: +// { +// String[] arrValidValue = new String[] {"terminate", "refund", "recall", "prep", "port out"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case ARMEDPARAM: +// { +// String[] arrValidValue = new String[] {"topup", "repay", "lowbalance", "status"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case SDFGUPDATASERVLIFESTYLE: +// { +// String[] arrValidValue = new String[] {"speedy", "business", "decent", "pennyPicker"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case SDFGUPAUTHENLEVEL: +// { +// String[] arrValidValue = new String[] {"no", "password", "token", "bio"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case MOBILESTATUS: +// { +// String[] arrValidValue = new String[] {"SS", "SA", "SD", "T", "SF"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } +// case DAAERRORCODE: +// { +// String[] arrValidValue = new String[] {"0", "1000", "1001", "110", "111", "120", "130", "150", "310"}; +// this.checkContain(paramValue, arrValidValue); +// break; +// } + case OutbandChannel: + { + String[] arrValidValue = new String[] {"0", "1", "2", "3", "4"}; + this.checkContain(paramValue, arrValidValue); + break; + } + case TOROSUBSCRIPTIONIDTYPE: + { + String[] arrValidValue = new String[] {"0", "1", "2", "3", "4"}; + this.checkContain(paramValue, arrValidValue); + break; + } + case BEARERTYPE: + { + String[] arrValidValue = new String[] {"0", "1", "2", "3"}; + this.checkContain(paramValue, arrValidValue); + break; + } + case REESULTCODE: + { + String[] arrValidValue = new String[] {"2001", "3001", "5003", "5004", "5005", "5006", "5012"}; + this.checkContain(paramValue, arrValidValue); + break; + } + + case WAITRESULTINDICATOR: + { + String[] arrValidValue = new String[] {"0", "1"}; + this.checkContain(paramValue, arrValidValue); + break; + } + case OUTBANDCHANNELOTP: + { + String[] arrValidValue = new String[] {"0", "1"}; + this.checkContain(paramValue, arrValidValue); + break; + } + case TOROLANGUAGEPREFERENCE: + { + String[] arrValidValue = new String[] {"1", "2"}; + this.checkContain(paramValue, arrValidValue); + break; + } + + case INBANDINDICATOR: + { + String[] arrValidValue = new String[] {"0", "1", "2"}; + this.checkContain(paramValue, arrValidValue); + break; + } + + case NOTCHECKINVALID: + default: + break; + } + } + } + + private void checkLength(String value, int min, int max) { + int length = value.length(); + if(length < min || length > max) { + this.printInvalidLog("LENGTH", value); + } + } + + private void checkDateFormat(String value, String format) { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + try { + Date date = (Date) dateFormat.parse(value); + String strDate = dateFormat.format(date); + if(!value.equals(strDate)) { + this.printInvalidLog("DATE FORMAT", value); + } + } + catch(Exception e){ + this.printInvalidLog("DATE FORMAT", value); + } + } + + private void checkFix(String value, String fix) { + if(!value.equals(fix)) { + this.printInvalidLog("VALUE", value); + } + } + + private void checkMatch(String value, String pattern) { + if(!value.matches(pattern)) { + this.printInvalidLog("FORMAT", value); + } + } + + private void checkContain(String value, String[] arrValidValue) { + if(!ArrayUtils.contains(arrValidValue, value)) { + this.printInvalidLog("VALUE", value); + } + } + + private void printInvalidLog(String invalidType, String value) { + this.isInvalid = true; + AppLog.d("## INVALID " + invalidType + " : " + this.name + " : " + value); + } + + private void printMissingLog() { + this.isMissing = true; + AppLog.d("## MISSING PARAMETER : " + this.name); + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/Global.java b/src/th/co/ais/ssbsrfc/utils/Global.java new file mode 100644 index 0000000..1106d36 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/Global.java @@ -0,0 +1,308 @@ +package th.co.ais.ssbsrfc.utils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.UUID; + +import org.json.JSONException; +import org.json.JSONObject; +import org.json.XML; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.AFInstance; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.FMInstance; +import th.co.ais.ssbsrfc.message.EC02Builder; +import ais.mmt.sand.comlog.bean.DataBean; +import ais.mmt.sand.comlog.bean.DataBean.TYPE; + +import com.google.gson.Gson; +import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; + +import ec02.af.abstracts.AbstractAF; +import ec02.utils.AppLog; + +public class Global +{ + private static AbstractAF abstractAF = null; + private static EC02Builder ec02Builder = null; + private static boolean isOpenRawData = true; + private static String outputTimeStamp = null; + + public static String inputTimeStamp = null; + public static String detailNameLog = null; + public static String summaryNameLog = null; + public static boolean isUDR = false; + public static boolean isDetail = true; + public static boolean isDetailRawData = true; + public static boolean isDetailData = true; + public static boolean isDetailStat = true; + public static boolean isDetailScenario = true; + public static boolean isDetailCurrentState = true; + public static boolean isDetailNextState = true; + public static boolean isSummary = false; + public static boolean isStat = true; + public static boolean isErrorLog = false; + public static int detailLog = 0; + public static String tmpDialogueId = null; + public static int minDialogueId = 0; + public static int maxDialogueId = 99; + public static int flow = 0; + public static HashMap mapNode = new HashMap(); + public static HashMap mapFlow = new HashMap(); + public static boolean isDebugModeForQA = false; + public static boolean isWriteSummary = false; + public static boolean isOutputTimeStamp = true; + public static boolean isRejectByApplication = false; + public static long currentInputDateTime; + + public static boolean isOpenRawData() { + return isOpenRawData; + } + + public static void getConfigEC02(AbstractAF abstractAF, EC02Instance ec02Instance) + { + Global.setNode(); + Global.setFlow(); + Global.flow = ec02Instance.getAFInstance().getFlow(); + Global.abstractAF = abstractAF; + } + + public static String getNodeFromEventType(String eventType) { + String node = mapNode.get(eventType); +// AppLog.d("## node:" + node + ":eventtype:" + eventType); + return node; + } + + public static void setNode() + { + mapNode.put(StateConfig.Incoming_A_Request, Constant.nodeE01); + } + + public static String getFlowName(int flow) { + String flowName = mapFlow.get(flow); + if(flowName == null) { + flowName = mapFlow.get(Constant.FLOW_Unexpected_Event_Handling); + } + return flowName; + } + + public static void setFlow() { + //flow #1 + mapFlow.put(Constant.FLOW_TEST_A, "TEST A"); + } + + public static void setOpenRawData(boolean isOpenRawData) { + Global.isOpenRawData = isOpenRawData; + } + + public static void checkActiveLog(EC02Instance ec02Instance, String value) + { + String[] tempLog =null; + tempLog = value.split("\\|"); + //"DETAIL|STAT|UDR" + for (int i = 0; i < tempLog.length; i++) { + if (tempLog[i].equalsIgnoreCase("DETAIL")) { + isDetail = true; + } else if (tempLog[i].equalsIgnoreCase("STAT")) { + isStat = true; + } else if (tempLog[i].equalsIgnoreCase("UDR")) { + isUDR = true; + } else if (tempLog[i].equalsIgnoreCase("SUMMARY")) { + isSummary = true; + } else if (tempLog[i].equalsIgnoreCase("ERROR")) { + isErrorLog = true; + } + } + } + + public static FMInstance getInvokeForManageFlow(EC02Instance ec02Instance) + { + int flow = ec02Instance.getAFInstance().getFlow(); + String date = ec02Instance.getAFInstance().getStartFlowTimeStamp(); + return new FMInstance(flow, date); + } + + public static void setRejectByApplication(boolean isRejectByApplication) { + Global.isRejectByApplication = isRejectByApplication; + // write summary + if (isRejectByApplication) { + Global.isWriteSummary = isRejectByApplication; + } + } + + public static String getDetailLogRawData(String rawData) { + if (rawData != null) { +// rawData = StringEscapeUtils.escapeHtml(rawData); +// rawData = StringEscapeUtils.unescapeJava(rawData); + } + return rawData; + } + + public static void setDetailLog(String value) + { + if (value.equals("0")) { + Global.detailLog = Constant.DETAILLOG.CLOSE.get(); + } else if (value.equals("1")) { + Global.detailLog = Constant.DETAILLOG.OPENERROR.get(); + } else if (value.equals("2")) { + Global.detailLog = Constant.DETAILLOG.OPEN.get(); + } + } + + public static String unescapePrintString(String value) + { + return value; + } + + public static String getUnique() + { + return UUID.randomUUID().toString().replace("-", ""); + } + + public static DataBean.TYPE getDetailLogType(String strType) { + TYPE retType = null; + if(strType.toLowerCase().equals("request")) { + retType = TYPE.REQ; + } else { + retType = TYPE.RES; + } + + return retType; + } + + public static String encodeInstance(AFInstance instance) { + String encodeString = ""; + try { + // check remove Timeout + int cout = instance.getListTimeout().size(); + if (cout == 0) { + instance.setListTimeout(null); + } + Gson gson = new Gson(); + String str = gson.toJson(instance); + byte[] bytes = str.getBytes(); + byte[] zipBytes = Zip.compressBytes(bytes); + encodeString = Base64.encode(zipBytes); + } + catch (Exception e) { + AppLog.e("Encode fail!! " + e); + } + return encodeString; + } + + public static AFInstance decodeInstance(String instance) { + AFInstance afInstance = null; + try { + byte[] simpleString = Base64.decode(instance); + byte[] unZipString = Zip.extractBytes(simpleString); + Gson gson = new Gson(); + afInstance = gson.fromJson(new String(unZipString), AFInstance.class); + } catch (Exception e) { + AppLog.e("Decode fail!! " + e); + } + return afInstance; + } + + public static String getOutputTimeStamp() { + return outputTimeStamp; + } + + public static void setOutputTimeStamp(String outputTimeStamp) { + Global.outputTimeStamp = outputTimeStamp; + } + + public static String getEC02WarmConfig(String key) + { + String value = null; + try { + value = Global.abstractAF.getUtils().getHmWarmConfig().get(key).get(0).trim(); + AppLog.d("## GETCONFIG EC02 READDING(" + key + ") VALUE:" + value); + } catch (Exception e) { + AppLog.e("## CHECKCONFIG EC02 EXCEPTION(" + key + ") READ ERROR"); + } + return value; + } + + public static EC02Builder getEc02Builder() { + return ec02Builder; + } + + public static void setEc02Builder(EC02Builder ec02Builder) { + Global.ec02Builder = ec02Builder; + } + + public static String replaceSoapToXml(String value) + { + try { + JSONObject json = new JSONObject(value); + value = XML.toString(json); + AppLog.d("## CONVERT MESSAGE JSON TO XML :" + value); + } catch (JSONException e) { } + return value.replaceAll("(?s)<(\\w+):Envelope[^<>]*>.*?<\\1:Body>\\s*(.*?)\\s*\\s*", "$2").replaceAll(" xmlns(:\\w+)?=\"(.*)\"", "").replaceAll("\\<\\?xml(.+?)\\?\\>", ""); + } + + + // LOG ETC + public static long convertTocurrentTimeMillis(String strDate) + { + DateFormat formatter = new SimpleDateFormat("yyyyMMdd HH:mm:ss.S"); + long value = 0; + try { + Date date = formatter.parse(strDate); + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + value = cal.getTimeInMillis(); + } catch (ParseException e) { + e.printStackTrace(); + } + return value; + } + + public static String getTimeStampLog (long currentDateTime) + { + Date date = new Date(currentDateTime); + SimpleDateFormat ft = new SimpleDateFormat ("yyyyMMdd HH:mm:ss.S"); + // display time and date using toString() + String timestamp = ft.format(date); + + return timestamp; + } + + public static long diffTimeStampLog(String first, String last) throws ParseException + { + DateFormat formatter = new SimpleDateFormat("yyyyMMdd HH:mm:ss.S"); + Date dateFist = formatter.parse(first); + Date dateLast = formatter.parse(last); + Calendar strF_Cal = Calendar.getInstance(); + Calendar strL_Cal = Calendar.getInstance(); + strF_Cal.setTime(dateFist); + strL_Cal.setTime(dateLast); + long lastLong = strL_Cal.getTimeInMillis(); + long firstLong = strF_Cal.getTimeInMillis(); + long diff = lastLong - firstLong; + + return diff; + } + + public static String datePartnerTimestamp(String value) + { + String partner = ""; + try { + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + DateFormat newFttr = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss.S"); + Date date = formatter.parse(value); + partner = newFttr.format(date); + } catch (ParseException e) { } + return partner; + } + + public static String getXmlTemplateKey(String keyType, String id) { + return keyType + "[id='"+id+"']"; + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/Header.java b/src/th/co/ais/ssbsrfc/utils/Header.java new file mode 100644 index 0000000..036ada3 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/Header.java @@ -0,0 +1,36 @@ +package th.co.ais.ssbsrfc.utils; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.Root; +import org.simpleframework.xml.Text; + +@Root(name="Header") +public class Header { + @Attribute(required=false) + private String name; + @Attribute(required=false) + private String value; + @Text(required=false) + private String text; + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getText() { + return text; + } + public void setText(String text) { + this.text = text; + } + + +} diff --git a/src/th/co/ais/ssbsrfc/utils/HttpData.java b/src/th/co/ais/ssbsrfc/utils/HttpData.java new file mode 100644 index 0000000..95ad0ac --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/HttpData.java @@ -0,0 +1,31 @@ +package th.co.ais.ssbsrfc.utils; + +import org.simpleframework.xml.Element; +import org.simpleframework.xml.Root; + +@Root(name="HttpData") +public class HttpData { + @Element(name="ERDHeader", required=false) + private ERDHeader erdHeader; + + @Element(name="ERDData", required=false) + private ERDData erdData; + + public ERDHeader getErdHeader() { + return erdHeader; + } + + public void setErdHeader(ERDHeader erdHeader) { + this.erdHeader = erdHeader; + } + + public ERDData getErdData() { + return erdData; + } + + public void setErdData(ERDData erdData) { + this.erdData = erdData; + } + + +} diff --git a/src/th/co/ais/ssbsrfc/utils/HttpStateData.java b/src/th/co/ais/ssbsrfc/utils/HttpStateData.java new file mode 100644 index 0000000..9a4c9dd --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/HttpStateData.java @@ -0,0 +1,18 @@ +package th.co.ais.ssbsrfc.utils; + +import org.simpleframework.xml.Element; +import org.simpleframework.xml.Root; + +@Root(name="HttpStateData") +public class HttpStateData { + @Element(name="state", required=false) + private state state; + + public state getState() { + return state; + } + + public void setState(state state) { + this.state = state; + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/ListStateData.java b/src/th/co/ais/ssbsrfc/utils/ListStateData.java new file mode 100644 index 0000000..9b65643 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/ListStateData.java @@ -0,0 +1,23 @@ +package th.co.ais.ssbsrfc.utils; + +import java.util.List; + +import org.simpleframework.xml.ElementList; +import org.simpleframework.xml.ElementListUnion; +import org.simpleframework.xml.Root; + +@Root(name="ListStateData") +public class ListStateData { + @ElementListUnion({ + @ElementList(entry="state", inline=true, required=false) + }) + private List listState; + + public List getListState() { + return listState; + } + + public void setListState(List listState) { + this.listState = listState; + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/Log.java b/src/th/co/ais/ssbsrfc/utils/Log.java new file mode 100644 index 0000000..73bcd80 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/Log.java @@ -0,0 +1,341 @@ +package th.co.ais.ssbsrfc.utils; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import th.co.ais.ssbsrfc.config.Constant; +import th.co.ais.ssbsrfc.config.Invoke; +import th.co.ais.ssbsrfc.config.State; +import th.co.ais.ssbsrfc.config.StateConfig; +import th.co.ais.ssbsrfc.instance.EC02Instance; +import th.co.ais.ssbsrfc.instance.Stat; +import th.co.ais.ssbsrfc.interfaces.EQXMsg; +import th.co.ais.ssbsrfc.message.MessageParser; +import ais.mmt.sand.comlog.DetailsLogPrototype; +import ais.mmt.sand.comlog.SummaryLogPrototype; +import ais.mmt.sand.comlog.exception.CommonLogException; +import ec02.af.abstracts.AbstractAF; +import ec02.af.data.EquinoxRawData; +import ec02.utils.AppLog; + +public class Log { + + public static boolean debug = false; + + public static void results(EC02Instance ec02Instance, String currentSubState, List equinoxRawDataList, int type, boolean isStat) { + int idx = StateConfig.getSubStateIndex(currentSubState); + State state = StateConfig.subStateList[idx]; + + int msgType = state.msgType; + results(ec02Instance, currentSubState, equinoxRawDataList, type, Constant.TYPE_RECEIVE, msgType, null, isStat); + } + + public static void results(EC02Instance ec02Instance, String currentSubState, List equinoxRawDataList, int type, String cmd, boolean isStat) { + int idx = StateConfig.getSubStateIndex(currentSubState); + State state = StateConfig.subStateList[idx]; + + int msgType = state.msgType; + results(ec02Instance, currentSubState, equinoxRawDataList, type, Constant.TYPE_RECEIVE, msgType, cmd, isStat); + } + + public static void results(EC02Instance ec02Instance, String currentSubState, List equinoxRawDataList, int type, int direction, int msgType, String _cmd, boolean isStat) + { + String errMsg = ""; + if (Global.isStat) + { + int flow = ec02Instance.getAFInstance().getFlow(); + switch (flow) { + default: + StateConfig.PROJECT_STAT_NAME = StateConfig.PROJECT_NAME; + break; + } + + AbstractAF abstractAF = ec02Instance.getAbstractAF(); + String name = EQXMsg.EMPTY; + if (Log.debug) { + AppLog.d("## RECEIVE WRITE STAT FOR SUBSTATE"); + } + if (isStat) { + // RECEIVE + name = StateConfig.getLASEName(currentSubState, direction, msgType, type, errMsg, _cmd); + abstractAF.getUtils().incrementStats(name); + if (Log.debug) { + AppLog.d("## CST_(" + flow + ":" + currentSubState + "): " + name); + } + } + if (Log.debug) { + AppLog.d("## RECEIVE WRITE STAT FOR SUBSTATE END"); + } + + // SEND + if (Log.debug) { + AppLog.d("## SEND WRITE STAT FOR EQUINOXRAWDATA"); + } + for(EquinoxRawData eqx : equinoxRawDataList) { + if (isStat) { + String _type = eqx.getType(); + if (_type.equals("request")) { + String invoke = eqx.getInvoke(); + currentSubState = ec02Instance.getAFInstance().getCurrentState(); + if (invoke != null && invoke.contains(".")) { + String cmd = new Invoke(invoke).cmd; + name = StateConfig.getLASEName(currentSubState, Constant.TYPE_SEND, Constant.TYPE_REQUEST, Constant.TYPE_SUCCESS, "", cmd); + abstractAF.getUtils().incrementStats(name); + if (Log.debug) { + AppLog.d("## CST_(" + flow + ":" + currentSubState + "): " + name); + } + } else { + name = StateConfig.getLASEName(currentSubState, Constant.TYPE_SEND, Constant.TYPE_REQUEST, Constant.TYPE_SUCCESS, ""); + abstractAF.getUtils().incrementStats(name); + if (Log.debug) { + AppLog.d("## CST_(" + flow + ":" + currentSubState + "): " + name); + } + } + } else if (_type.equals("response")) { + int x = type; + try { + String subState = eqx.getRawDataAttributes().get("subState"); +// AppLog.d("subState :" + subState); + String[] arr = subState.split(","); + currentSubState = arr[0]; + x = Integer.parseInt(arr[1]); + } + catch (Exception e) { + if (Log.debug) { + AppLog.d("## ERROR STAT:" + e.getMessage()); + } + } + +// AppLog.d("## currentSubState : " + currentSubState); + eqx.getRawDataAttributes().remove("subState"); + name = StateConfig.getLASEName(currentSubState, Constant.TYPE_SEND, Constant.TYPE_RESPONSE, x, ""); + abstractAF.getUtils().incrementStats(name); + if (Log.debug) { + AppLog.d("## CST_(" + flow + ":" + currentSubState + "): " + name); + } + } + } + } + if (Log.debug) { + AppLog.d("## SEND WRITE STAT FOR EQUINOXRAWDATA END"); + } + + // etc + if (Log.debug) { + AppLog.d("## STAT WRITE STAT FOR LISTSTAT"); + } + ArrayList listStat = ec02Instance.getAFInstance().getListStat(); + if (listStat.size() > 0) { + for(Stat stat : listStat) { + String nameLog = stat.getName(); + if (nameLog == null) { + name = StateConfig.getLASEName(stat.getCurrentSubState(), stat.getSendOrReceive(), stat.getResponseOrRequest(), stat.getType(), stat.getMessage(), stat.getCommand()); + abstractAF.getUtils().incrementStats(name); + if (Log.debug) { + AppLog.d("## CST_(" + flow + ":LISTSTAT): " + name); + } + } else { + name = nameLog; + abstractAF.getUtils().incrementStats(name); + if (Log.debug) { + AppLog.d("## CST_(" + flow + ":LISTSTAT): " + name); + } + } + } + } + ec02Instance.getAFInstance().setListStat(null); + // etc + if (Log.debug) { + AppLog.d("## STAT WRITE STAT FOR LISTSTAT END"); + } + } + } + + public static void summaryLog(EC02Instance ec02Instance, AbstractAF abstractAF) + { + Log.dev("" + Global.isWriteSummary); + if (Global.isSummary && (ec02Instance.getAFInstance().getCurrentState().equals(StateConfig.SSTATE_END) || Global.isWriteSummary)) + { + int flow = ec02Instance.getAFInstance().getFlow(); + long requestTimestamp = Global.currentInputDateTime; + String session = abstractAF.getEquinoxProperties().getSession(); + String commandName = EQXMsg.EMPTY; + String initialInvoke = ec02Instance.getAFInstance().getInitialInvoke(); + String identity = Log.getIdentity(ec02Instance, abstractAF); + String resultCode = ec02Instance.getAFInstance().getResultCode(); + String resultDescription = ec02Instance.getAFInstance().getResultDescription(); + long responseTimestamp = System.currentTimeMillis(); + try { + String subState = StateConfig.arrFirstStateFlow[flow-1]; + commandName = StateConfig.getCommandFromState(subState); + } catch (Exception e) { } + + SummaryLogPrototype sumLog = ec02Instance.getAFInstance().getSumlog(); + sumLog.setSession(session); + sumLog.setIdentity(identity); + sumLog.setInitInvoke(initialInvoke); + sumLog.setCmdName(commandName); + sumLog.setResultCode(resultCode); + sumLog.setResultDesc(resultDescription); + sumLog.setReqTimeStamp(requestTimestamp); + sumLog.setRespTimeStamp(responseTimestamp); + String message = ""; + try { + message = sumLog.print(); + } catch (CommonLogException e) { + AppLog.e("## COMMONLOG EXCEPTION:" + e); + AppLog.e("## COMMONLOG EXCEPTION:" + e.getStackTrace()); + } + abstractAF.getUtils().writeLog(Global.summaryNameLog, message); + if (Log.debug) { + AppLog.d("## SUMMARY :" + message); + } + + if (Global.isWriteSummary) { + Global.isWriteSummary = false; + ec02Instance.getAFInstance().getBackupSummary().restore(ec02Instance); + } + } + } + + private static String getIdentity(EC02Instance ec02Instance, AbstractAF abstractAF) + { + String identity = ""; + int flow = ec02Instance.getAFInstance().getFlow(); + switch (flow) { + case Constant.FLOW_TEST_A: + break; + } + + return identity; + } + +// public static void errorLog(EC02Instance ec02Instance, AbstractAF abstractAF) +// { +// AppLog.d("## isErrorLog : " + Global.isErrorLog); +// if(Global.isErrorLog) { +// AppLog.d("## WRITE ERROR LOG"); +// +// DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd HH:mm:ss.S"); +// Calendar cal = Calendar.getInstance(); +// String timestamp = dateFormat.format(cal.getTime()); +// String logLevel = "ERROR"; +// String identity = Log.getIdentity(ec02Instance, abstractAF); +// String rawInstance = Global.encodeInstance(ec02Instance.getAFInstance()); +// String errorCode = ec02Instance.getAFInstance().getResultCode(); +// String errorDescription = ec02Instance.getAFInstance().getResultDescription(); +// +// String message = timestamp + "|" + logLevel + "|" + identity + "|" + rawInstance + "|" + errorCode + "|" + errorDescription; +// abstractAF.getUtils().writeLog(Global.errorNameLog, message); +// if (Log.debug) { +// AppLog.d("## ERROR LOG :" + message); +// } +// } +// } + + public static void detailLog(EC02Instance ec02Instance, AbstractAF abstractAF,String currentState, String nextState, List eqxRawDataListInput, List eqxRawDataListOutput) + { + if (Global.isDetail) + { + String session = abstractAF.getEquinoxProperties().getSession(); + String initialInvoke = ec02Instance.getAFInstance().getInitialInvoke(); + String scenario = "Unexpected Event Handling"; +// String msisdn = ec02Instance.getAFInstance().getMsisdn(); + String strInputTimeStamp = Global.inputTimeStamp; + java.sql.Date dateInput = DateUtil.stringToDate(strInputTimeStamp, "yyyyMMdd HH:mm:ss.S"); + Calendar c = Calendar.getInstance(); + c.setTime(dateInput); + long lInputTimeStamp = c.getTimeInMillis(); + long lOutputTimeStamp = System.currentTimeMillis(); + String outputTimeStamp = Global.getTimeStampLog(lOutputTimeStamp); +// Global.setOutputTimeStamp(outputTimeStamp); + if (!Global.isRejectByApplication) { + ec02Instance.getAFInstance().setOutgoingStateTimeStamp(outputTimeStamp); + } else { + Global.setRejectByApplication(false); + } +// long totalProcessingTime = 0; +// try { +// totalProcessingTime = Global.diffTimeStampLog(inputTimeStamp, outputTimeStamp); +// } catch (Exception e) { +// totalProcessingTime = -1; +// } + + for(EquinoxRawData eqx : eqxRawDataListOutput) { + String type = eqx.getType(); + String invoke = eqx.getInvoke(); + if (type.equals("request") && (invoke.length() > 0 || invoke != null)) { +// ec02Instance.getAFInstance().putTimeRequest(invoke, outputTimeStamp); + } + } + + int flow = ec02Instance.getAFInstance().getFlow(); + scenario = Global.getFlowName(flow); + + ArrayList arrInput = ec02Instance.getAFInstance().getInput(); + ArrayList arrOutput = ec02Instance.getAFInstance().getOutput(); + + if (arrInput == null || (arrInput != null && arrInput.size() == 0)) { + arrInput = null; + } + if (arrOutput == null || (arrOutput != null && arrOutput.size() == 0)) { + arrOutput = null; + outputTimeStamp = null; + } else { + Log.dev(" arrOutput count:" + arrOutput.size()); + } + + String identity = session; + switch (flow) { + case Constant.FLOW_TEST_A: + identity = "MIS"; + if(session.matches("66\\d{9}")) { + identity = session; + } + break; + default: + identity = session; + break; + } + + String message = ""; + DetailsLogPrototype detLog = ec02Instance.getAFInstance().getDetaillog(); + try { + detLog.setSession(session); + detLog.setIdentity(identity); + detLog.setInputTimestamp(lInputTimeStamp); + detLog.addScenario(scenario, initialInvoke, currentState + "." + ec02Instance.getAFInstance().getPreviousState(), nextState + "." + ec02Instance.getAFInstance().getCurrentState()); + detLog.setOutputTimestamp(lOutputTimeStamp); + + detLog.setEnableData(Global.isDetailData); + detLog.setEnableRawData(Global.isDetailRawData); + detLog.setEnableScenario(Global.isDetailScenario); + detLog.setEnableCurrentState(Global.isDetailCurrentState); + detLog.setEnableNextState(Global.isDetailNextState); + +// AppLog.d("## PARAMETERS : " + MessageParser.toJson(detLog)); + message = detLog.print(); + } catch (CommonLogException e) { + if (Log.debug) { + AppLog.d("## DETAIL LOG:" + e.getMessage()); + } + } + + ec02Instance.getAFInstance().setDetaillog(null); + abstractAF.getUtils().writeLog(Global.detailNameLog, message); + if (Log.debug) { + message = "## DETAIL LOG:" + message; + AppLog.d(message); + } + ec02Instance.getAFInstance().setInput(null); + ec02Instance.getAFInstance().setOutput(null); + } + } + + public static void dev(String message) { + if (debug) { + AppLog.d("#dev# :" + message); + } + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/Zip.java b/src/th/co/ais/ssbsrfc/utils/Zip.java new file mode 100644 index 0000000..e8bf414 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/Zip.java @@ -0,0 +1,72 @@ +package th.co.ais.ssbsrfc.utils; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.zip.DataFormatException; +import java.util.zip.Deflater; +import java.util.zip.Inflater; + +/** + * Created by IntelliJ IDEA. + * User: Administrator + * Date: 25/8/2555 + * To change this template use File | Settings | File Templates. + */ +public class Zip { + public static byte[] compressBytes(byte[] input) throws UnsupportedEncodingException, IOException { + Deflater df = new Deflater(); //this function mainly generate the byte code + //df.setLevel(Deflater.BEST_COMPRESSION); + df.setInput(input); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(input.length); //we write the generated byte code in this array + df.finish(); + byte[] buff = new byte[1024]; //segment segment pop....segment set 1024 + while (!df.finished()) { + int count = df.deflate(buff); //returns the generated code... index + baos.write(buff, 0, count); //write 4m 0 to count + } + baos.close(); + byte[] output = baos.toByteArray(); + + //System.out.println("Original: " + input.length); + //System.out.println("Compressed: " + output.length); + return output; + } + + public static byte[] extractBytes(byte[] input) throws UnsupportedEncodingException, IOException, DataFormatException { + Inflater ifl = new Inflater(); //mainly generate the extraction + //df.setLevel(Deflater.BEST_COMPRESSION); +// Log.i(input +""); + ifl.setInput(input); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(input.length); + byte[] buff = new byte[1024]; + while (!ifl.finished()) { + int count = ifl.inflate(buff); + baos.write(buff, 0, count); + } + baos.close(); + byte[] output = baos.toByteArray(); + + //System.out.println("Original: " + input.length); + //System.out.println("Extracted: " + output.length); + //System.out.println("Data:"); + //System.out.println(new String(output)); + return output; + } + + public static void compressFile(String src, String dest) throws IOException { + java.util.zip.GZIPOutputStream out = new java.util.zip.GZIPOutputStream(new java.io.FileOutputStream(dest)); + java.io.FileInputStream in = new java.io.FileInputStream(src); + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + // Complete the GZIP file + out.finish(); + out.close(); + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/info.java b/src/th/co/ais/ssbsrfc/utils/info.java new file mode 100644 index 0000000..0e3ae85 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/info.java @@ -0,0 +1,25 @@ +package th.co.ais.ssbsrfc.utils; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.Root; + +@Root(name="info") +public class info { + @Attribute(required=false) + private String index; + @Attribute(required=false) + private String detail; + + public String getIndex() { + return index; + } + public void setIndex(String index) { + this.index = index; + } + public String getDetail() { + return detail; + } + public void setDetail(String detail) { + this.detail = detail; + } +} diff --git a/src/th/co/ais/ssbsrfc/utils/state.java b/src/th/co/ais/ssbsrfc/utils/state.java new file mode 100644 index 0000000..ecb8df7 --- /dev/null +++ b/src/th/co/ais/ssbsrfc/utils/state.java @@ -0,0 +1,77 @@ +package th.co.ais.ssbsrfc.utils; + +import java.util.List; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.ElementList; +import org.simpleframework.xml.ElementListUnion; +import org.simpleframework.xml.Root; + +@Root(name="state") +public class state { + @ElementListUnion({ + @ElementList(entry="info", inline=true, required=false) + }) + private List info; + + @Attribute(required=false) + private String id; + @Attribute(required=false) + private String command; + @Attribute(required=false) + private String state_type; + @Attribute(required=false) + private String resultcode; + @Attribute(required=false) + private String resultdescription; + + public void setInfo(List info) { + this.info = info; + } + + public List getInfo() { + return info; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + + public String getState_type() { + return state_type; + } + + public void setState_type(String state_type) { + this.state_type = state_type; + } + + public String getResultcode() { + return resultcode; + } + + public void setResultcode(String resultcode) { + this.resultcode = resultcode; + } + + public String getResultdescription() { + return resultdescription; + } + + public void setResultdescription(String resultdescription) { + this.resultdescription = resultdescription; + } + + +} -- libgit2 0.21.2