<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.eactive.eai.adapter.socket2.config.MonitoringUtil"%>
<%@ page import="com.eactive.eai.common.util.CharsetDecoderUtil" %>
<%@ page import="java.util.*,com.eactive.eai.common.util.Logger" %>
<%!
	static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
%>	
<%
	//
	//  Socket2 adapter start/stop command
	
    String adapterGroupName = request.getParameter("adapterGroupName");
	String adapterName      = request.getParameter("adapterName");
	String cmd              = request.getParameter("cmd");
	
	if( adapterGroupName == null ) {
		adapterGroupName = "" ;
	}
	
	if( adapterName == null ) {
		adapterName = "" ;
	}
	
	if( cmd == null ) {
		cmd = "" ;
	}
	
    
    String retMsg = null ;
    try {
    	if( cmd.equals("start") ) {
    		MonitoringUtil.adapterStart(adapterGroupName, adapterName);
    		retMsg = "true" ;
    	} else if( cmd.equals("stop") ) {
    		MonitoringUtil.adapterStop(adapterGroupName, adapterName);
    		retMsg = "true" ;
    	} else {
    		retMsg = "Unknown command error :" + cmd ;
    	}
    } catch ( Exception e ) {
    	if (logger.isError()){
    		logger.error("MonitoringUtil.adapterStart|adapterStop(" + adapterGroupName + ", " + adapterName + ")" );
    	}    	
    	//e.printStackTrace(new java.io.PrintWriter(out));
    	retMsg = "false" ;
    }
    
    if( retMsg == null  )
    	retMsg = "" ;
    
    

    out.println( CharsetDecoderUtil.toKor(retMsg) );
%>
