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 34291704
authored
Feb 07, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pyörivä pohja
1 parent
b2cf48b4
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
474 additions
and
42 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MailMessageBean.java
code/MoyaEar/.settings/org.eclipse.wst.common.component
code/MoyaEar/EarContent/META-INF/application.xml
code/MoyaEar/pom.xml
code/MoyaEventMgmtWeb/WebContent/WEB-INF/web.xml
code/MoyaEventMgmtWeb/WebContent/frontpage.xhtml
code/MoyaEventMgmtWeb/WebContent/index.xhtml
code/MoyaEventMgmtWeb/WebContent/resources/templates/template1/template.xhtml
code/MoyaEventMgmtWeb/WebContent/resources/tools/login/login.xhtml
code/MoyaEventMgmtWeb/WebContent/resources/tools/login/loginLogout.xhtml
code/MoyaEventMgmtWeb/pom.xml
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/FrontpageView.java
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/GenericView.java
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/handler/SessionHandler.java
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/handler/SessionStore.java
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/resources/i18n.properties
code/MoyaWeb/WebContent/WEB-INF/faces-config.xml
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MailMessageBean.java
View file @
3429170
...
...
@@ -25,12 +25,12 @@ import fi.codecrew.moya.util.MailMessage;
* Message-Driven Bean implementation class for: MailMessageBean
*
*/
@MessageDriven
(
activationConfig
=
{
@ActivationConfigProperty
(
propertyName
=
"destinationType"
,
propertyValue
=
"javax.jms.Queue"
)
},
mappedName
=
"jms/moyaMailQueue"
)
@MessageDriven
(
mappedName
=
"jms/moyaMailQueue"
,
activationConfig
=
{
@ActivationConfigProperty
(
propertyName
=
"destinationType"
,
propertyValue
=
"javax.jms.Queue"
)
}
)
public
class
MailMessageBean
implements
MessageListener
{
@Resource
(
name
=
"mail/moya"
)
...
...
code/MoyaEar/.settings/org.eclipse.wst.common.component
View file @
3429170
...
...
@@ -38,9 +38,6 @@
<dependent-module
archiveName=
"httpcore-4.3-beta2.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/org/apache/httpcomponents/httpcore/4.3-beta2/httpcore-4.3-beta2.jar"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
<dependent-module
archiveName=
"commons-logging-1.1.1.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
<dependent-module
archiveName=
"commons-codec-1.6.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/commons-codec/commons-codec/1.6/commons-codec-1.6.jar"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
...
...
@@ -65,5 +62,17 @@
<dependent-module
archiveName=
"jrobin-1.5.9.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
<dependent-module
archiveName=
"moya-mgmt-web-0.2.0.war"
deploy-path=
"/"
handle=
"module:/resource/MoyaEventMgmtWeb/MoyaEventMgmtWeb"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
<dependent-module
archiveName=
"commons-digester-2.1.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/commons-digester/commons-digester/2.1/commons-digester-2.1.jar"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
<dependent-module
archiveName=
"commons-beanutils-1.8.3.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
<dependent-module
archiveName=
"commons-logging-1.1.1.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
</wb-module>
</project-modules>
code/MoyaEar/EarContent/META-INF/application.xml
View file @
3429170
...
...
@@ -13,7 +13,11 @@
<context-root>
/MoyaWeb
</context-root>
</web>
</module>
<!-- <module> <web> <web-uri>MoyaEventMgmtWeb.war</web-uri> <context-root>EventMgmt</context-root>
</web> </module> -->
<module>
<web>
<web-uri>
moya-mgmt-web-0.2.0.war
</web-uri>
<context-root>
/EventMgmt
</context-root>
</web>
</module>
<library-directory>
lib
</library-directory>
</application>
\ No newline at end of file
code/MoyaEar/pom.xml
View file @
3429170
...
...
@@ -85,8 +85,18 @@
<version>
1.5.9
</version>
</dependency>
<dependency>
<groupId>
fi.codecrew.moya
</groupId>
<artifactId>
moya-mgmt-web
</artifactId>
<version>
0.2.0
</version>
<type>
war
</type>
</dependency>
<dependency>
<groupId>
commons-digester
</groupId>
<artifactId>
commons-digester
</artifactId>
<version>
2.1
</version>
</dependency>
</dependencies>
<repositories>
...
...
code/MoyaEventMgmtWeb/WebContent/WEB-INF/web.xml
View file @
3429170
...
...
@@ -14,7 +14,7 @@
<param-name>
javax.faces.FACELETS_SKIP_COMMENTS
</param-name>
<param-value>
true
</param-value>
</context-param>
<!-- Asetetaan PROJECT_STAGE JNDI:llä, ja fallbackataan arvoon Development -->
<!-- Asetetaan PROJ
w
ECT_STAGE JNDI:llä, ja fallbackataan arvoon Development -->
<resource-ref>
<res-ref-name>
jsf/ProjectStage
</res-ref-name>
<res-type>
java.lang.String
</res-type>
...
...
@@ -23,7 +23,12 @@
<param-name>
javax.faces.PROJECT_STAGE
</param-name>
<param-value>
Development
</param-value>
</context-param>
<filter>
<display-name>
PrimefacesFileupload
</display-name>
<filter-name>
PrimefacesFileupload
</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
</filter>
<servlet>
<servlet-name>
Faces Servlet
</servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
...
...
code/MoyaEventMgmtWeb/WebContent/frontpage.xhtml
0 → 100644
View file @
3429170
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition
template=
"#{mgmtSessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{frontpageView.initIndexView}"
/>
</f:metadata>
<ui:define
name=
"content"
>
<h:outputLabel
rendered=
"#{mgmtSessionHandler.isInDevelopmentMode()}"
>
Development-tilassa.
Täällä voit huoletta rikkoa.
</h:outputLabel>
Hurrdurr. #{frontpageView.content}
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/MoyaEventMgmtWeb/WebContent/index.xhtml
0 → 100644
View file @
3429170
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<h:head>
<meta
http-equiv=
"refresh"
content=
"1;url=#{request.contextPath}/frontpage.jsf"
/>
<script
type=
"text/javascript"
>
window
.
location
.
href
=
"#{request.contextPath}/frontpage.jsf"
</script>
<title></title>
</h:head>
<h:body>
Redirecting to
<a
href=
"#{request.contextPath}/frontpage.jsf"
>
Frontpage
</a>
</h:body>
</html>
\ No newline at end of file
code/MoyaEventMgmtWeb/WebContent/resources/templates/template1/template.xhtml
View file @
3429170
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html
class=
"no-js"
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:
tools=
"http://java.sun.com/jsf/composite/cditools
"
<html
class=
"no-js"
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:
login=
"http://java.sun.com/jsf/composite/tools/login
"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
>
<f:view
contentType=
"text/html"
locale=
"#{sessionHandler.locale}"
>
...
...
@@ -120,7 +120,7 @@
<b><h:outputText
value=
"#{sessionHandler.currentUser.nick}"
/></b>
</ui:fragment>
<div>
<
tools
:loginLogout
/>
<
login
:loginLogout
/>
</div>
</div>
<br
/>
...
...
code/MoyaEventMgmtWeb/WebContent/resources/tools/login/login.xhtml
0 → 100644
View file @
3429170
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
>
<composite:interface>
<composite:attribute
name=
"isOneliner"
required=
"false"
/>
<composite:attribute
name=
"onError"
required=
"false"
/>
</composite:interface>
<composite:implementation>
<h:form
id=
"login"
>
<c:choose>
<c:when
test=
"#{not empty cc.attrs.isOneliner}"
>
<p:inputText
styleClass=
"form"
id=
"linelogin"
value=
"#{authView.login}"
/>
<p:password
styleClass=
"form"
id=
"linepwd"
value=
"#{authView.password}"
/>
<p:commandButton
styleClass=
"button"
id=
"onelinesubmit"
action=
"#{authView.executeLoginAction}"
ajax=
"false"
value=
"#{i18n['login.submit']}"
/>
</c:when>
<c:otherwise>
<h:panelGrid
columns=
"2"
>
<h:outputLabel
for=
"gridLogin"
value=
"#{i18n['login.username']}"
/>
<p:inputText
id=
"gridLogin"
value=
"#{authView.login}"
/>
<h:outputLabel
for=
"gridPwd"
value=
"#{i18n['login.password']}"
/>
<p:password
id=
"gridPwd"
value=
"#{authView.password}"
/>
</h:panelGrid>
<p:commandButton
id=
"gridsubmit"
actionListener=
"#{authView.executeLogin(cc.attrs.onerror)}"
ajax=
"false"
value=
"#{i18n['login.submit']}"
/>
</c:otherwise>
</c:choose>
</h:form>
</composite:implementation>
</html>
\ No newline at end of file
code/MoyaEventMgmtWeb/WebContent/resources/tools/login/loginLogout.xhtml
0 → 100644
View file @
3429170
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:login=
"http://java.sun.com/jsf/composite/tools/login"
xmlns:p=
"http://primefaces.org/ui"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<c:choose>
<c:when
test=
'#{sessionHandler.isLoggedIn() }'
>
<h:form>
<p:commandLink
actionListener=
"#{authView.doLogout}"
ajax=
"false"
>
<h:outputText
value=
"#{i18n['login.logout']}"
/>
</p:commandLink>
</h:form>
</c:when>
<c:otherwise>
<login:login
isOneliner=
"true"
/>
<br/>
<h:link
value=
"#{i18n['submenu.user.create']}"
outcome=
"/user/create"
/>
<br/>
<h:link
value=
"#{i18n['submenu.auth.sendResetMail']}"
outcome=
"/auth/sendResetMail"
/>
</c:otherwise>
</c:choose>
</composite:implementation>
</html>
\ No newline at end of file
code/MoyaEventMgmtWeb/pom.xml
View file @
3429170
...
...
@@ -22,19 +22,13 @@
<configuration>
<warSourceDirectory>
WebContent
</warSourceDirectory>
<failOnMissingWebXml>
false
</failOnMissingWebXml>
<packagingIncludes>
WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*
</packagingIncludes>
<packagingIncludes>
WEB-INF/lib/
prettyfaces-core*,WEB-INF/lib/
javamelody-core*,WEB-INF/lib/primefaces*,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*
</packagingIncludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>
prime-repo
</id>
<name>
PrimeFaces Maven Repository
</name>
<url>
http://repository.primefaces.org
</url>
<layout>
default
</layout>
</repository>
<repository>
<id>
iudex
</id>
<url>
http://iudex.fi/maven/
</url>
</repository>
...
...
@@ -55,7 +49,17 @@
<artifactId>
primefaces
</artifactId>
<version>
4.0
</version>
</dependency>
<dependency>
<groupId>
commons-fileupload
</groupId>
<artifactId>
commons-fileupload
</artifactId>
<version>
1.3
</version>
</dependency>
<dependency>
<groupId>
com.ocpsoft
</groupId>
<artifactId>
prettyfaces-core
</artifactId>
<version>
3.3.2
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/FrontpageView.java
0 → 100644
View file @
3429170
package
fi
.
codecrew
.
moyamgmt
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
@Named
@RequestScoped
public
class
FrontpageView
extends
GenericView
{
private
static
final
long
serialVersionUID
=
-
3187538351756262504L
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FrontpageView
.
class
);
public
void
initIndexView
()
{
logger
.
info
(
"Initializing index view"
);
}
public
String
getContent
()
{
return
"asdasdasd"
;
}
}
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/GenericView.java
0 → 100644
View file @
3429170
package
fi
.
codecrew
.
moyamgmt
;
import
java.io.Serializable
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.Conversation
;
import
javax.faces.application.FacesMessage
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.enums.apps.IAppPermission
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moyamgmt.handler.NavigationHandler
;
public
abstract
class
GenericView
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
4000065015178815761L
;
@Inject
private
Conversation
conversation
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GenericView
.
class
);
@Inject
protected
NavigationHandler
navihandler
;
@EJB
protected
PermissionBeanLocal
permbean
;
@EJB
private
EventBeanLocal
eventbean
;
public
void
beginConversation
()
{
if
(
conversation
.
isTransient
())
{
conversation
.
begin
();
}
}
public
void
endConversation
()
{
if
(!
conversation
.
isTransient
())
conversation
.
end
();
}
public
boolean
hasPermission
(
IAppPermission
perm
)
{
// boolean ret =
// FacesContext.getCurrentInstance().getExternalContext().isUserInRole(perm.getFullName());
return
permbean
.
hasPermission
(
perm
);
}
protected
boolean
requirePermissions
(
IAppPermission
perm
,
boolean
...
externalChecks
)
{
boolean
ret
=
requirePermissions
(
hasPermission
(
perm
));
if
(
ret
&&
externalChecks
.
length
>
0
)
{
ret
=
requirePermissions
(
externalChecks
);
}
if
(!
ret
)
{
logger
.
info
(
"Permission required failed for {} Permission: {} (or extrachecks)"
,
perm
.
getFullName
(),
perm
);
}
return
ret
;
}
protected
boolean
requirePermissions
(
boolean
...
externalChecks
)
{
boolean
ret
=
true
;
for
(
boolean
check
:
externalChecks
)
{
if
(!
check
)
{
ret
=
false
;
break
;
}
}
if
(!
ret
)
{
FacesContext
fcont
=
FacesContext
.
getCurrentInstance
();
HttpServletRequest
req
=
(
HttpServletRequest
)
fcont
.
getExternalContext
().
getRequest
();
StringBuilder
viewidbuilder
=
new
StringBuilder
().
append
(
req
.
getContextPath
()).
append
(
req
.
getServletPath
());
if
(
req
.
getQueryString
()
!=
null
)
{
viewidbuilder
.
append
(
"?"
).
append
(
req
.
getQueryString
());
}
navihandler
.
saveDestination
(
viewidbuilder
.
toString
());
logger
.
debug
(
"Permission denied. Saving navi {} for later use"
,
viewidbuilder
.
toString
());
// navihandler.navigateTo("/permissionDenied");
fcont
.
getApplication
().
getNavigationHandler
().
handleNavigation
(
fcont
,
null
,
"/permissionDenied?faces-redirect=true"
);
}
return
ret
;
}
protected
void
addFaceMessage
(
String
string
,
Object
...
params
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
I18n
.
get
(
string
,
params
)));
}
}
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/handler/SessionHandler.java
View file @
3429170
...
...
@@ -6,11 +6,13 @@
package
fi
.
codecrew
.
moyamgmt
.
handler
;
import
java.util.EnumMap
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -22,13 +24,15 @@ import fi.codecrew.moya.beans.PermissionBeanLocal;
import
fi.codecrew.moya.beans.RoleBeanLocal
;
import
fi.codecrew.moya.clientutils.BortalLocalContextHolder
;
import
fi.codecrew.moya.enums.apps.IAppPermission
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEventProperty
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
/**
*
* @author tuukka
*/
@Named
()
@Named
(
"mgmtSessionHandler"
)
@RequestScoped
public
class
SessionHandler
{
...
...
@@ -44,6 +48,9 @@ public class SessionHandler {
@EJB
private
PermissionBeanLocal
permbean
;
@Inject
private
SessionStore
sessionStore
;
private
String
template
;
public
TimeZone
getTimezone
()
{
...
...
@@ -52,33 +59,107 @@ public class SessionHandler {
}
public
String
getLocale
()
{
// TODO: Locale selection code missing
// return "en_ST_v7"
;
String
ret
=
eventbean
.
getCurrentEvent
().
getOrganiser
().
getBundleCountry
()
;
if
(
ret
==
null
||
ret
.
isEmpty
())
{
ret
=
"fi_FI"
;
Locale
ret
=
sessionStore
.
getLocale
()
;
String
ret
Str
=
"fi_FI"
;
if
(
ret
!=
null
)
{
retStr
=
ret
.
toLanguageTag
();
logger
.
info
(
"Got langtag {}"
,
retStr
)
;
}
return
ret
;
return
retStr
;
}
public
String
getFullscreen
()
{
template
=
"blipview"
;
return
template
;
}
public
String
getAdduserfullscreen
()
{
template
=
"adduser"
;
return
template
;
}
public
String
getTemplateName
()
{
if
(
template
==
null
)
{
template
=
eventbean
.
getPropertyString
(
LanEventPropertyKey
.
EVENT_LAYOUT
);
}
if
(
template
==
null
)
{
template
=
"insomnia2"
;
return
"template1"
;
}
return
template
;
}
public
String
getTemplatePath
()
{
return
"/resources/templates/"
+
getTemplateName
();
}
public
String
getTemplate
File
()
{
public
String
getTemplate
()
{
return
getTemplatePath
()
+
"/template.xhtml"
;
}
private
EnumMap
<
LanEventPropertyKey
,
Boolean
>
boolPropertyCache
=
new
EnumMap
<>(
LanEventPropertyKey
.
class
);
public
boolean
isEventBoolProperty
(
String
property
)
{
LanEventPropertyKey
prop
=
LanEventPropertyKey
.
valueOf
(
property
);
if
(!
prop
.
isBoolean
())
{
throw
new
RuntimeException
(
"Trying to fetch boolean value for non-boolean property!"
);
}
boolean
value
=
false
;
if
(
boolPropertyCache
.
containsKey
(
prop
))
{
value
=
boolPropertyCache
.
get
(
prop
);
}
else
{
LanEventProperty
propertyValue
=
eventbean
.
getProperty
(
prop
);
if
(
propertyValue
==
null
)
{
if
(
prop
.
getDefaultvalue
()
!=
null
&&
prop
.
getDefaultvalue
().
equals
(
"1"
))
value
=
true
;
}
else
{
value
=
propertyValue
.
isBooleanValue
();
}
boolPropertyCache
.
put
(
prop
,
value
);
}
return
value
;
}
// public boolean hasPermission(String target, String permission) {
// RolePermission perm = RolePermission.valueOf(permission.toUpperCase());
// // RolePermission perm = null;
// // if (permission.equalsIgnoreCase("read")) {
// // perm = RolePermission.READ;
// // } else if (permission.equals("write")) {
// // perm = RolePermission.WRITE;
// // } else if (permission.equals("execute")) {
// // perm = RolePermission.EXECUTE;
// // }else {
// // throw new RuntimeException("permission " + permission +
// // " does not match any")
// // }
// if (perm == null) {
// logger.warn("Permission {} does not have matching value in RolePermission enum!");
// throw new
// RuntimeException("Matching role permission could not be found!");
// }
//
// return hasPermission(target, perm);
// }
//
// private HttpSession getHttpSession() {
// FacesContext ctx = FacesContext.getCurrentInstance();
// HttpSession sess = (HttpSession)
// ctx.getExternalContext().getSession(false);
// return sess;
// }
// public boolean hasPermission(String perm) {
// return permbean.hasPermission(perm);
// }
public
String
getDateFormat
()
{
return
"dd.MM.yyyy"
;
...
...
@@ -115,6 +196,10 @@ public class SessionHandler {
}
public
EventUser
getCurrentUser
()
{
return
permbean
.
getCurrentUser
();
}
public
String
flushCache
()
{
return
eventbean
.
flushCache
();
...
...
@@ -148,4 +233,12 @@ public class SessionHandler {
return
BortalLocalContextHolder
.
isInDevelopmentMode
();
}
public
SessionStore
getSessionStore
()
{
return
sessionStore
;
}
public
void
setSessionStore
(
SessionStore
sessionStore
)
{
this
.
sessionStore
=
sessionStore
;
}
}
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/handler/SessionStore.java
0 → 100644
View file @
3429170
package
fi
.
codecrew
.
moyamgmt
.
handler
;
import
java.io.Serializable
;
import
java.util.Locale
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.SessionScoped
;
import
javax.faces.context.FacesContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
@SessionScoped
public
class
SessionStore
implements
Serializable
{
private
static
final
long
serialVersionUID
=
594517648650107916L
;
private
static
final
Locale
DEFAULT_LOCALE
=
new
Locale
(
"fi"
);
@EJB
private
EventBeanLocal
eventbean
;
private
Locale
locale
;
private
boolean
manageContentLinks
=
false
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SessionStore
.
class
);
public
Locale
getLocale
()
{
Locale
ret
=
locale
;
if
(
ret
==
null
)
{
String
retStr
=
eventbean
.
getCurrentEvent
().
getOrganiser
().
getBundleCountry
();
if
(
retStr
!=
null
&&
!
retStr
.
isEmpty
())
{
try
{
ret
=
Locale
.
forLanguageTag
(
retStr
);
}
catch
(
Throwable
t
)
{
logger
.
warn
(
"Error setting locale from current event for {}"
,
retStr
);
ret
=
null
;
}
}
if
(
ret
==
null
)
{
ret
=
DEFAULT_LOCALE
;
}
locale
=
ret
;
}
return
ret
;
}
public
void
setLocale
(
Locale
locale
)
{
this
.
locale
=
locale
;
FacesContext
.
getCurrentInstance
().
getViewRoot
().
setLocale
(
locale
);
}
public
boolean
isManageContentLinks
()
{
return
manageContentLinks
;
}
public
void
setManageContentLinks
(
boolean
manageContentLinks
)
{
this
.
manageContentLinks
=
manageContentLinks
;
}
}
code/MoyaEventMgmtWeb/src/fi/codecrew/moyamgmt/resources/i18n.properties
0 → 100644
View file @
3429170
test
=
foo
\ No newline at end of file
code/MoyaWeb/WebContent/WEB-INF/faces-config.xml
View file @
3429170
...
...
@@ -9,14 +9,9 @@
<var>
i18n
</var>
</resource-bundle>
<message-bundle>
fi.codecrew.moya.resources.i18n
</message-bundle>
<!-- Legal Country codes: http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm -->
<!-- Assigned Country codes: -->
<!-- Insomnia: IN (INDIA) -->
<!-- Stream: ST (SAO TOME AND PRINCIPE ) -->
<!-- Vector VE (VENEZUELA, BOLIVARIAN REPUBLIC OF) -->
<locale-config>
<default-locale>
fi_FI
</default-locale>
<supported-locale>
en_UK
</supported-locale>
<locale-config>
<default-locale>
fi
</default-locale>
<supported-locale>
en
</supported-locale>
</locale-config>
</application>
...
...
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