Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c5d3b550
authored
Dec 17, 2011
by
Tuukka Kivilahti, TKffTK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added product stage and nice image when in development-mode.
1 parent
35b0b056
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
27 deletions
code/LanBortalWeb/WebContent/WEB-INF/web.xml
code/LanBortalWeb/WebContent/index.xhtml
code/LanBortalWeb/WebContent/layout/insomnia2/template.xhtml
code/LanBortalWeb/WebContent/resources/style/insomnia2/img/devel_logo.png
code/LanBortalWeb/src/fi/insomnia/bortal/HostnameFilter.java
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
code/LanBortalWeb/WebContent/WEB-INF/web.xml
View file @
c5d3b55
<?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
code/LanBortalWeb/WebContent/index.xhtml
View file @
c5d3b55
...
...
@@ -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>
...
...
code/LanBortalWeb/WebContent/layout/insomnia2/template.xhtml
View file @
c5d3b55
...
...
@@ -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}"
...
...
code/LanBortalWeb/WebContent/resources/style/insomnia2/img/devel_logo.png
0 → 100644
View file @
c5d3b55
14.6 KB
code/LanBortalWeb/src/fi/insomnia/bortal/HostnameFilter.java
View file @
c5d3b55
...
...
@@ -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
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
View file @
c5d3b55
...
...
@@ -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
()
{
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment