Added product stage and nice image when in development-mode.

1 parent 35b0b056
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>LanBortalWeb</display-name>
......@@ -8,6 +8,11 @@
<session-timeout>30</session-timeout>
</session-config>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
<!-- param-value>Production</param-value -->
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
......@@ -49,7 +54,7 @@
<servlet-name>UserCardServlet</servlet-name>
<url-pattern>/UserCard</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>CardTemplateServlet</servlet-name>
<servlet-class>fi.insomnia.bortal.servlet.CardTemplateServlet</servlet-class>
......@@ -58,7 +63,7 @@
<servlet-name>CardTemplateServlet</servlet-name>
<url-pattern>/CardTemplate</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>PlaceMap</servlet-name>
......@@ -119,23 +124,12 @@
<servlet-name>PrintBill</servlet-name>
<url-pattern>/PrintBill</url-pattern>
</servlet-mapping>
<!-- <error-page>
<error-code>401</error-code>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
<error-page>
<exception-type>fi.insomnia.bortal.exceptions.PermissionDeniedException</exception-type>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
-->
<!-- <error-page> <error-code>401</error-code> <location>/permissionDeniedRedirect.jsp</location>
</error-page> <error-page> <error-code>403</error-code> <location>/permissionDeniedRedirect.jsp</location>
</error-page> <error-page> <exception-type>fi.insomnia.bortal.exceptions.PermissionDeniedException</exception-type>
<location>/permissionDeniedRedirect.jsp</location> </error-page> <error-page>
<exception-type>javax.servlet.ServletException</exception-type> <location>/permissionDeniedRedirect.jsp</location>
</error-page> -->
<persistence-unit-ref>
<persistence-unit-ref-name>BortalEMF</persistence-unit-ref-name>
</persistence-unit-ref>
......@@ -150,4 +144,6 @@
<url-pattern>/PlaceGroupPdf</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
......@@ -9,6 +9,12 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:define name="content">
<h:outputText rendered="#{sessionHandler.isInDevelopmentMode()}">
Development-tilassa.
Vaihda web.xml-tiedostosta ohjelman tila (javax.faces.PROJECT_STAGE) Productioniksi ennen kuin julkaiset ohjelman tuotantoon.
</h:outputText>
<h1>Insomnia lippukauppa</h1>
<h3>Lippujen hinnat</h3>
<ul>
......
......@@ -19,7 +19,16 @@
<div id="header">
<div id="logo">
<img src="#{request.contextPath}/resources/style/insomnia2/img/logo.png" />
<c:choose>
<c:when test="#{sessionHandler.isInDevelopmentMode()}">
<img src="#{request.contextPath}/resources/style/insomnia2/img/devel_logo.png" />
</c:when>
<c:otherwise>
<img src="#{request.contextPath}/resources/style/insomnia2/img/logo.png" />
</c:otherwise>
</c:choose>
</div>
<div id="login">
<h:outputText rendered="#{sessionHandler.loggedIn}"
......
......@@ -2,6 +2,7 @@ package fi.insomnia.bortal;
import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
......@@ -23,7 +24,9 @@ import fi.insomnia.bortal.model.User;
*/
public class HostnameFilter implements Filter {
private static final Logger logger = LoggerFactory.getLogger(HostnameFilter.class);
private static final Logger logger = LoggerFactory
.getLogger(HostnameFilter.class);
private static boolean developmentMode = false;
/**
* Default constructor.
......@@ -44,7 +47,9 @@ public class HostnameFilter implements Filter {
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = null;
if (request != null && request instanceof HttpServletRequest) {
......@@ -66,7 +71,8 @@ public class HostnameFilter implements Filter {
}
String hostname = url.substring(beginindex, lastindex);
httpRequest.getSession().setAttribute(EventBeanLocal.HTTP_URL_HOSTNAME, hostname);
httpRequest.getSession().setAttribute(
EventBeanLocal.HTTP_URL_HOSTNAME, hostname);
BortalLocalContextHolder.setHostname(hostname);
......@@ -75,7 +81,8 @@ public class HostnameFilter implements Filter {
httpRequest.login(User.ANONYMOUS_LOGINNAME, null);
} catch (Throwable t) {
logger.warn("Error logging in as anonymous... ignoring.. ", t);
logger.warn("Error logging in as anonymous... ignoring.. ",
t);
}
}
......@@ -94,7 +101,16 @@ public class HostnameFilter implements Filter {
*/
@Override
public void init(FilterConfig fConfig) throws ServletException {
// Nothing...
// check if software is in development -mode
FacesContext fc = FacesContext.getCurrentInstance();
String stage = fc.getExternalContext().getInitParameter(
"javax.faces.PROJECT_STAGE");
if (stage.trim().equalsIgnoreCase("Development")) {
developmentMode = true;
}
}
public static String getCurrentHostname(HttpSession sess) {
......@@ -108,4 +124,8 @@ public class HostnameFilter implements Filter {
return ret;
}
public static boolean isDevelopmentMode() {
return developmentMode;
}
}
......@@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.HostnameFilter;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PermissionBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal;
......@@ -152,4 +153,7 @@ public class SessionHandler {
}
return preurlString;
}
public boolean isInDevelopmentMode() {
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!