<%@ page import ="com.eg.IniFile" %>
<%@ page import ="com.eg.EgInstallInfo"%>
<%@ page import = "com.eg.UpdateAndTransmitUserInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<jsp:useBean id="managerOutputBean" scope="page" class="egurkha.TransactionBean"/>
<%
String priMgrRestart = request.getParameter("priMgr");
String secMgrRestart = request.getParameter("secMgr");
String stlnMgrRestart = request.getParameter("stlnMgr");

String managerOutput = request.getParameter("mgrOut_Err");
String managerOutputOverWrite = request.getParameter("out_err_mode");
String prevMgrOutput = request.getParameter("$_mgrOutput");
String prevMgrOutputOverWrite = request.getParameter("$_mgrOutputOverWirte");

String updateMsg = "";
String manager_label = EgInstallInfo.isSuperManager ? "SuperManager" : "Manager";

UpdateAndTransmitUserInfo userInfo = new UpdateAndTransmitUserInfo();
boolean isUpdated = false;

if(managerOutput != null && managerOutputOverWrite != null)
{
	if(prevMgrOutput != null && prevMgrOutputOverWrite != null && !managerOutput.equals(prevMgrOutput) || !managerOutputOverWrite.equals(prevMgrOutputOverWrite))
	{
		managerOutputBean.createFile("eg_outputstatus.ini","save");
		managerOutputBean.setValue("MANAGER_OUTPUT_STATUS","output",managerOutput);
		managerOutputBean.setValue("MANAGER_OUTPUT_STATUS","manager_output_overwrite",managerOutputOverWrite);
		managerOutputBean.saveFile();
		userInfo.updateManagerSettings(managerOutput, managerOutputOverWrite, "yes");
		isUpdated = true;
		if(managerOutput.equalsIgnoreCase("Yes"))
			updateMsg = manager_label+" output and error has been enabled.";
		else if(managerOutput.equalsIgnoreCase("No"))
			updateMsg = manager_label+" output and error has been disabled.";
	}
}
if(com.eg.EgInstallInfo.isClusterSupported)
{
	if(priMgrRestart != null && priMgrRestart.equalsIgnoreCase("yes") && secMgrRestart != null && secMgrRestart.equalsIgnoreCase("yes"))
	{
		userInfo.restartManager("no");//starting primary manager
		userInfo.restartManager("yes");//starting secondary manager
	}
	else if(priMgrRestart != null && priMgrRestart.equalsIgnoreCase("yes"))
	{
		userInfo.restartManager("no");//starting primary manager
	}
	else if(secMgrRestart != null && secMgrRestart.equalsIgnoreCase("yes"))
	{
		userInfo.restartManager("yes");//starting secondary manager
	}
}
else if(stlnMgrRestart != null && stlnMgrRestart.equalsIgnoreCase("yes"))
{
	userInfo.restartManager("no");//restart stand-alone manager
}
if(isUpdated)
{
	response.sendRedirect("ManagerRestart.jsp?resultMsg="+updateMsg+"&sessionInUse=true");
}
%>



