package com.eactive.eai.adapter.wca.command; 

import com.eactive.eai.adapter.wca.cfg.SNAAdapterManager;
import com.eactive.eai.adapter.wca.cfg.WcaInfoDataEx;
import com.eactive.eai.adapter.wca.global.WCADefine;
import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommandException;
import com.eactive.eai.common.util.Logger;

/** 
* 1. 기능 : EAI 서버에 실시간 LU 세션 그룹 삭제
* 2. 처리 개요 : 
*       - SNAAdapterManager 클래스에 deleteSessionGroup 함수 실행
*       - softlink에  notify 해준다.
* 3. 주의사항 
*
* @author  : 
* @version : 
* @see : 
* @since   :
*/
public class UpdateWcaInfoEx extends Command
{
	/** 
    * 1. 기능 :  Default Constructor
    * 2. 처리 개요 : 
    * 3. 주의사항 
    **/
    public UpdateWcaInfoEx() {
        super("UpdateWcaInfo");   
    }
    
   /** 
    * 1. 기능 :  LU 세션 그룹 삭제
    * 2. 처리 개요 : 
    * 3. 주의사항
    * 
    * @exception CommandException	command  실행 시 발생하는 예외 상황
    **/
    public Object execute() throws CommandException
    {
        Logger adapter_logger = Logger.getLogger(WCADefine.ADAPTER_LOGGER_NAME);

       	adapter_logger.warn("UpdateWcaInfoEx:execute> Start Execute Command, Command = " + this.name);
       	
        if(!(args instanceof WcaInfoDataEx) ) {
            String rspErrorCode = "RECEAIMCM001";
            String msg = makeException(rspErrorCode, null);
            adapter_logger.error("UpdateWcaInfoEx:execute> Invalid Data Type, Msg = " + msg);            
            throw new CommandException(msg);
        }
        
        try {          
        	WcaInfoDataEx data = (WcaInfoDataEx)args;
        	SNAAdapterManager.getInstance().updateWcaInfo(data);
        }
        catch (Exception e) {
            String rspErrorCode = "RECEAIMCM002";
            String msg = makeException(rspErrorCode, e);
            adapter_logger.error("UpdateWcaInfoEx:execute> Exception Occur, Msg = " + msg, e);           
            
            throw new CommandException(msg);
        }
        return "success";
    }
}
