{
WebResourcesFacet web = this.project.getFacet(WebResourcesFacet.class);
ServletFacet servlet = this.project.getFacet(ServletFacet.class);
if (servlet instanceof ServletFacet_3_0)
{
WebAppDescriptor servletConfig = (WebAppDescriptor) servlet.getConfig();
Node root = ((NodeDescriptor) servletConfig).getRootNode();
removeConflictingErrorPages(root);
// (prefer /faces/error.xhtml)
String errorLocation = getAccessStrategy().getWebPaths(web.getWebResource(ERROR_XHTML)).get(1);
servletConfig.createErrorPage().errorCode("404").location(errorLocation);
servletConfig.createErrorPage().errorCode("500").location(errorLocation);
// Use the server timezone since we accept dates in that timezone, and it makes sense to display them in the
// same
boolean found = false;
for (ParamValueType<WebAppDescriptor> contextParam : servletConfig.getAllContextParam())
{
if (contextParam.getParamName().equals("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE"))
{
found = true;
}
}
if (!found)
{
servletConfig.createContextParam()
.paramName("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE").paramValue("true");
}
servlet.saveConfig(servletConfig);
}
else if (servlet instanceof ServletFacet_3_1)
{
org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor servletConfig = (org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor) servlet
.getConfig();
// (prefer /faces/error.xhtml)
String errorLocation = getAccessStrategy().getWebPaths(web.getWebResource(ERROR_XHTML)).get(1);
servletConfig.createErrorPage().errorCode("404").location(errorLocation);
servletConfig.createErrorPage().errorCode("500").location(errorLocation);
// Use the server timezone since we accept dates in that timezone, and it makes sense to display them in the
// same
boolean found = false;
for (org.jboss.shrinkwrap.descriptor.api.javaee7.ParamValueType<org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor> contextParam : servletConfig
.getAllContextParam())
{
if (contextParam.getParamName().equals("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE"))
{
found = true;
}
}
if (!found)
{
servletConfig.createContextParam()
.paramName("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE").paramValue("true");
}
servlet.saveConfig(servletConfig);
}
}