package se.bth.wpl.server;
import java.io.IOException;
import java.util.logging.Logger;
import javax.servlet.http.*;
import se.bth.wpl.global.Global;
import se.bth.wpl.model.CommonParams;
import se.bth.wpl.model.CompanyParams;
import se.bth.wpl.model.Params;
import se.bth.wpl.model.ParamsContainer;
import se.bth.wpl.model.PersonalParams;
@SuppressWarnings("serial")
public class RequestHandler extends HttpServlet {
private static final Logger log = Logger.getLogger(RequestHandler.class.getName());
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
log.warning("Request received");
// Read Common parameters
String site_type = req.getParameter("site_type");
String sitename = req.getParameter("sitename");
String footernote = req.getParameter("footernote");
String font = req.getParameter("font");
String home_title = req.getParameter("home_title");
String contact_title = req.getParameter("contact_title");
String about_title = req.getParameter("about_title");
String fbLikeButton = req.getParameter("fbLikeButton");
String rtwBtnCheck = req.getParameter("rtwBtnCheck");
String retwButtonURL = req.getParameter("retwButtonURL");
String twIcon = req.getParameter("twIcon");
String twButtonURL = req.getParameter("twButtonURL");
String ldIcon = req.getParameter("ldIcon");
String ldButtonURL = req.getParameter("ldButtonURL");
String gplusIcon = req.getParameter("gplusIcon");
String digIcon = req.getParameter("digIcon");
String cname = req.getParameter("cname");
String cmail = req.getParameter("cmail");
String cphoneCheck = req.getParameter("cphoneCheck");
String cphoneValue = req.getParameter("cphoneValue");
String jqueryCheck = req.getParameter("jqueryCheck");
String ganalytics = req.getParameter("ganalytics");
String ganID = req.getParameter("ganID");
//Fill cp
Params cp = new CommonParams(site_type,sitename,footernote,font,home_title,contact_title,about_title,
fbLikeButton,rtwBtnCheck,retwButtonURL,twIcon,twButtonURL,ldIcon,ldButtonURL,gplusIcon,digIcon,
cname,cmail,cphoneCheck,cphoneValue,jqueryCheck,ganalytics,ganID);
log.warning("Common Param created");
Params ncp = null;
if(site_type.equals(Global.getCompany()))
{
//Read parameters for COMPANY website
String colorCO = req.getParameter("colorCO");
String jobOfferTitle = req.getParameter("jobOfferTitle");
String jobCheck = req.getParameter("jobCheck");
String jobMail = req.getParameter("jobMail");
String productCheck = req.getParameter("productCheck");
String productNameID = req.getParameter("productNameID");
String productRadio = req.getParameter("productRadio");
String fbSocial = req.getParameter("fbSocial");
String fbSocialUrl = req.getParameter("fbSocialUrl");
String caddressCheck = req.getParameter("caddressCheck");
String caddressValue = req.getParameter("caddressValue");
String mapCheckBox = req.getParameter("mapCheckBox");
String newsCheck = req.getParameter("newsCheck");
String newsButtonURL = req.getParameter("newsButtonURL");
//Fill ncp
ncp = new CompanyParams(colorCO,jobOfferTitle,jobCheck,jobMail,productCheck,productNameID,
productRadio,fbSocial,fbSocialUrl,caddressCheck,caddressValue,mapCheckBox,
newsCheck,newsButtonURL);
}
else
{
//Read parameters for PERSONAL website
String portfolioCheck = req.getParameter("portfolioCheck");
String portNameID = req.getParameter("portNameID");
String portRadio = req.getParameter("portRadio");
String colorPE = req.getParameter("colorPE");
String paddressCheck = req.getParameter("paddressCheck");
String paddressValue = req.getParameter("paddressValue");
//Fill ncp
ncp = new PersonalParams(portfolioCheck,portNameID,portRadio,colorPE,paddressCheck,paddressValue);
}
log.warning("non-Common Param created");
ParamsContainer pc = new ParamsContainer(cp, ncp);
log.warning("ParamsContainer Created");
pc.CheckData();
log.warning("Data checked");
log.warning(pc.toString());
//log.warning("Redirecting");
//resp.sendRedirect("/jsp/finish.jsp");
}
}