package com.simoncat.actions;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.simoncat.beans.FinalScreenOutput;
import com.simoncat.vo.Server;
import com.simoncat.Constants;
import com.simoncat.beans.XMLServers;
public final class ServerAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
HttpSession session = request.getSession();
FinalScreenOutput fso = new FinalScreenOutput();
fso.setPageTitle ("Add Server [Finished]");
if ( form != null ) {
DynaActionForm df = (DynaActionForm) form;
String username = (String) df.get("name");
String useri_p = (String) df.get("address");
String user = (String) df.get("user");
String password = (String) df.get("password");
String portSSH = (String) df.get("portssh");
String tomcatPath = (String) df.get("tomcatPath");
String userTomcat = (String) df.get("userTomcat");
String passwordTomcat = (String) df.get("passwordTomcat");
String port = (String) df.get("port");
String testURL = (String) df.get("testURL");
String observation = (String) df.get("observation");
Server c = new Server();
c.setName(username);
c.setAddress(useri_p);
c.setUser(user);
c.setPassword(password);
c.setPortSSH(portSSH);
c.setTomcatPath(tomcatPath);
c.setUserTomcat(userTomcat);
c.setPasswordTomcat(passwordTomcat);
c.setPort(port);
c.setTestURL(testURL);
c.setObservation(observation);
session.setAttribute ("server_data", c);
XMLServers xmlserver = new XMLServers();
boolean r = xmlserver.writeToXml(c,"", this.getServlet().getServletContext());
fso.setMessage ("Server's information added sucessfully! xml:"+r);
} else {
fso.setMessage ("Sorry, problem with submitted form!");
}
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));
}
}