package com.eactive.eai.agent.schedule;

import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommandException;
import com.eactive.eai.batch.scheduler.SchedulerMessageManager;
import com.eactive.eai.common.util.Logger;

public class RequestRecieveCommand extends Command{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);

    public RequestRecieveCommand(String name) {
        super(name);
    }

    public Object execute() throws CommandException
    {
    	logger.info(this.name +" 이 호출되었습니다.");
    	if ( args == null || !(args instanceof String[]) ) {
            String msg = makeException("BECEAICAG001", null);
            logger.error(msg);
            throw new CommandException(msg);
        }

        try {
			String[] logKeys         = (String[])args;
			String scheduleCode      = logKeys[0];
			String reqYYYYMMDD       = logKeys[1];
			logger.debug("scheduleCode---->"  + scheduleCode);
			logger.debug("reqYYYYMMDD----->"  + reqYYYYMMDD);
			SchedulerMessageManager manager = SchedulerMessageManager.getInstance();
			manager.requestRecieveJob(scheduleCode.trim(), reqYYYYMMDD);
			

			return "작업큐에 데이터가 추가되었습니다.";
        } catch (Exception ex) {
            String msg = makeException("BECEAICAG002", ex);
            logger.error(msg, ex);
            throw new CommandException(msg);
        }
    }

}
