package com.simoncat.actions;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.simoncat.vo.Server;
import com.simoncat.beans.ScheduleServerOutput;
import com.simoncat.beans.FinalScreenOutput;
import com.simoncat.Constants;
import java.util.Collection;
import java.util.ArrayList;
import com.simoncat.beans.XMLServers;
import com.simoncat.vo.HTMLFormField;
public final class ScheduleServerAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
System.out.println("1");
//HttpSession session = request.getSession();
System.out.println("2");
Server ss[];
XMLServers xmlserver = new XMLServers();
ss=xmlserver.readXmls("", this.getServlet().getServletContext());
System.out.println("3");
if(ss==null){
FinalScreenOutput fso = new FinalScreenOutput();
fso.setPageTitle ("Schedule Server [Finished]");
fso.setMessage ("No existen servidores para programar reinicios!");
if (Constants.xmlOutputOnly) {
request.setAttribute ("content", Constants.xmlContentType);
} else {
request.setAttribute ("content", Constants.htmlContentType);
request.setAttribute ("style", "confirm.xsl");
}
request.setAttribute ("form", fso);
return (mapping.findForward(Constants.XMLHandler));
}
// Now, let's prepare output
ScheduleServerOutput iwao = new ScheduleServerOutput();
iwao.setPageTitle ("Schedule Server");
iwao.setFormAction ("Schedule.do");
//iwao.setEnctype("multipart/form-data");
iwao.setFormMethod ("POST");
// HTML form's fields
Collection fco = new ArrayList();
HTMLFormField hff1 = new HTMLFormField();
hff1.setTitle ("c1");
hff1.setName ("c1");
hff1.setType ("hidden");
hff1.setSize ("25");
hff1.setValue ( null );
fco.add (hff1);
HTMLFormField hff2 = new HTMLFormField();
hff2.setTitle ("c2");
hff2.setName ("c2");
hff2.setType ("hidden");
hff2.setSize ("25");
hff2.setValue ( null );
fco.add (hff2);
iwao.setFields(fco);
System.out.println("4");
Collection coo = new ArrayList();
for(int j=0;j<ss.length;j++)
coo.add (ss[j]);
System.out.println("5");
iwao.setServers(coo);
System.out.println("6");
if (Constants.xmlOutputOnly) {
request.setAttribute ("content", Constants.xmlContentType);
} else {
request.setAttribute ("content", Constants.htmlContentType);
request.setAttribute ("style", "scheduleServer.xsl");
}
System.out.println("7");
request.setAttribute ("form", iwao);
System.out.println("8");
return (mapping.findForward(Constants.XMLHandler));
}
}