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

1 parent 35b0b056
<?xml version="1.0" encoding="UTF-8"?> <?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" <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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" 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"> id="WebApp_ID" version="3.0">
<display-name>LanBortalWeb</display-name> <display-name>LanBortalWeb</display-name>
...@@ -8,6 +8,11 @@ ...@@ -8,6 +8,11 @@
<session-timeout>30</session-timeout> <session-timeout>30</session-timeout>
</session-config> </session-config>
<context-param> <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-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
...@@ -119,23 +124,12 @@ ...@@ -119,23 +124,12 @@
<servlet-name>PrintBill</servlet-name> <servlet-name>PrintBill</servlet-name>
<url-pattern>/PrintBill</url-pattern> <url-pattern>/PrintBill</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- <error-page> <!-- <error-page> <error-code>401</error-code> <location>/permissionDeniedRedirect.jsp</location>
<error-code>401</error-code> </error-page> <error-page> <error-code>403</error-code> <location>/permissionDeniedRedirect.jsp</location>
<location>/permissionDeniedRedirect.jsp</location> </error-page> <error-page> <exception-type>fi.insomnia.bortal.exceptions.PermissionDeniedException</exception-type>
</error-page> <location>/permissionDeniedRedirect.jsp</location> </error-page> <error-page>
<error-page> <exception-type>javax.servlet.ServletException</exception-type> <location>/permissionDeniedRedirect.jsp</location>
<error-code>403</error-code> </error-page> -->
<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>
<persistence-unit-ref-name>BortalEMF</persistence-unit-ref-name> <persistence-unit-ref-name>BortalEMF</persistence-unit-ref-name>
</persistence-unit-ref> </persistence-unit-ref>
...@@ -150,4 +144,6 @@ ...@@ -150,4 +144,6 @@
<url-pattern>/PlaceGroupPdf</url-pattern> <url-pattern>/PlaceGroupPdf</url-pattern>
</servlet-mapping> </servlet-mapping>
</web-app> </web-app>
\ No newline at end of file
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:define name="content"> <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> <h1>Insomnia lippukauppa</h1>
<h3>Lippujen hinnat</h3> <h3>Lippujen hinnat</h3>
<ul> <ul>
......
...@@ -19,7 +19,16 @@ ...@@ -19,7 +19,16 @@
<div id="header"> <div id="header">
<div id="logo"> <div id="logo">
<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" /> <img src="#{request.contextPath}/resources/style/insomnia2/img/logo.png" />
</c:otherwise>
</c:choose>
</div> </div>
<div id="login"> <div id="login">
<h:outputText rendered="#{sessionHandler.loggedIn}" <h:outputText rendered="#{sessionHandler.loggedIn}"
......
...@@ -2,6 +2,7 @@ package fi.insomnia.bortal; ...@@ -2,6 +2,7 @@ package fi.insomnia.bortal;
import java.io.IOException; import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
import javax.servlet.FilterConfig; import javax.servlet.FilterConfig;
...@@ -23,7 +24,9 @@ import fi.insomnia.bortal.model.User; ...@@ -23,7 +24,9 @@ import fi.insomnia.bortal.model.User;
*/ */
public class HostnameFilter implements Filter { 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. * Default constructor.
...@@ -44,7 +47,9 @@ public class HostnameFilter implements Filter { ...@@ -44,7 +47,9 @@ public class HostnameFilter implements Filter {
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/ */
@Override @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; HttpServletRequest httpRequest = null;
if (request != null && request instanceof HttpServletRequest) { if (request != null && request instanceof HttpServletRequest) {
...@@ -66,7 +71,8 @@ public class HostnameFilter implements Filter { ...@@ -66,7 +71,8 @@ public class HostnameFilter implements Filter {
} }
String hostname = url.substring(beginindex, lastindex); 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); BortalLocalContextHolder.setHostname(hostname);
...@@ -75,7 +81,8 @@ public class HostnameFilter implements Filter { ...@@ -75,7 +81,8 @@ public class HostnameFilter implements Filter {
httpRequest.login(User.ANONYMOUS_LOGINNAME, null); httpRequest.login(User.ANONYMOUS_LOGINNAME, null);
} catch (Throwable t) { } 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 { ...@@ -94,7 +101,16 @@ public class HostnameFilter implements Filter {
*/ */
@Override @Override
public void init(FilterConfig fConfig) throws ServletException { 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) { public static String getCurrentHostname(HttpSession sess) {
...@@ -108,4 +124,8 @@ public class HostnameFilter implements Filter { ...@@ -108,4 +124,8 @@ public class HostnameFilter implements Filter {
return ret; return ret;
} }
public static boolean isDevelopmentMode() {
return developmentMode;
}
} }
...@@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.HostnameFilter;
import fi.insomnia.bortal.beans.EventBeanLocal; import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PermissionBeanLocal; import fi.insomnia.bortal.beans.PermissionBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal; import fi.insomnia.bortal.beans.RoleBeanLocal;
...@@ -152,4 +153,7 @@ public class SessionHandler { ...@@ -152,4 +153,7 @@ public class SessionHandler {
} }
return preurlString; 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!