WaitSubState.java 22 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 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<EquinoxRawData> equinoxRawDataList = new ArrayList<EquinoxRawData>();
	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<ResIns> _listResult = new ArrayList<ResIns>();
	protected boolean isStat = true;
	protected HashMap<String, Boolean> disRespone = new HashMap<String, Boolean>();
	protected String _invokeTimeout = null;
	protected boolean isRetry = false;
	private boolean isIdle = true;
	
	
	@Override
	public List<EquinoxRawData> 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<String> 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<String> listTimeout = mt.getState();
			List<EquinoxRawData> eqxTmpList = new ArrayList<EquinoxRawData>();
			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<EquinoxRawData>();
				// 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<String> 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();
		}
	}
}