Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
20332a86
Commit
20332a86
authored
Apr 27, 2021
by
michael.simon
Browse files
Add some template classes
parent
12c276de
Changes
18
Hide whitespace changes
Inline
Side-by-side
bwreg-entities/src/main/java/edu/kit/scc/webreg/entity/VelocityTemplateEntity.java
0 → 100644
View file @
20332a86
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package
edu.kit.scc.webreg.entity
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Inheritance
;
import
javax.persistence.InheritanceType
;
import
javax.persistence.Lob
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.Type
;
@Entity
(
name
=
"VelocityTemplateEntity"
)
@Table
(
name
=
"velocity_template"
)
@Inheritance
(
strategy
=
InheritanceType
.
SINGLE_TABLE
)
public
class
VelocityTemplateEntity
extends
AbstractBaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"tpl_name"
,
length
=
256
)
private
String
name
;
@Column
(
name
=
"tpl_content"
)
@Lob
@Type
(
type
=
"org.hibernate.type.TextType"
)
private
String
template
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getTemplate
()
{
return
template
;
}
public
void
setTemplate
(
String
template
)
{
this
.
template
=
template
;
}
}
bwreg-entities/src/main/java/edu/kit/scc/webreg/entity/VelocityTemplateEntity_.java
0 → 100644
View file @
20332a86
package
edu.kit.scc.webreg.entity
;
import
javax.annotation.Generated
;
import
javax.persistence.metamodel.SingularAttribute
;
import
javax.persistence.metamodel.StaticMetamodel
;
@Generated
(
value
=
"org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor"
)
@StaticMetamodel
(
VelocityTemplateEntity
.
class
)
public
abstract
class
VelocityTemplateEntity_
extends
edu
.
kit
.
scc
.
webreg
.
entity
.
AbstractBaseEntity_
{
public
static
volatile
SingularAttribute
<
EmailTemplateEntity
,
String
>
name
;
public
static
volatile
SingularAttribute
<
EmailTemplateEntity
,
String
>
template
;
}
bwreg-jpa/src/main/java/edu/kit/scc/webreg/dao/VelocityTemplateDao.java
0 → 100644
View file @
20332a86
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package
edu.kit.scc.webreg.dao
;
import
edu.kit.scc.webreg.entity.VelocityTemplateEntity
;
public
interface
VelocityTemplateDao
extends
BaseDao
<
VelocityTemplateEntity
,
Long
>
{
VelocityTemplateEntity
findByName
(
String
name
);
}
bwreg-jpa/src/main/java/edu/kit/scc/webreg/dao/jpa/JpaVelocityTemplateDao.java
0 → 100644
View file @
20332a86
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package
edu.kit.scc.webreg.dao.jpa
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.inject.Named
;
import
javax.persistence.NoResultException
;
import
edu.kit.scc.webreg.dao.VelocityTemplateDao
;
import
edu.kit.scc.webreg.entity.VelocityTemplateEntity
;
@Named
@ApplicationScoped
public
class
JpaVelocityTemplateDao
extends
JpaBaseDao
<
VelocityTemplateEntity
,
Long
>
implements
VelocityTemplateDao
{
@Override
public
VelocityTemplateEntity
findByName
(
String
name
)
{
try
{
return
(
VelocityTemplateEntity
)
em
.
createQuery
(
"select e from VelocityTemplateEntity e where e.name = :name"
)
.
setParameter
(
"name"
,
name
).
getSingleResult
();
}
catch
(
NoResultException
e
)
{
return
null
;
}
}
@Override
public
Class
<
VelocityTemplateEntity
>
getEntityClass
()
{
return
VelocityTemplateEntity
.
class
;
}
}
bwreg-service/src/main/java/edu/kit/scc/webreg/service/tpl/VelocityPageRenderer.java
0 → 100644
View file @
20332a86
package
edu.kit.scc.webreg.service.tpl
;
public
interface
VelocityPageRenderer
{
}
bwreg-service/src/main/java/edu/kit/scc/webreg/service/tpl/VelocityPageRendererImpl.java
0 → 100644
View file @
20332a86
package
edu.kit.scc.webreg.service.tpl
;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
org.slf4j.Logger
;
import
edu.kit.scc.webreg.service.mail.TemplateRenderer
;
@Stateless
public
class
VelocityPageRendererImpl
implements
VelocityPageRenderer
{
@Inject
private
Logger
logger
;
@Inject
private
TemplateRenderer
renderer
;
}
bwreg-service/src/main/java/edu/kit/scc/webreg/service/tpl/VelocityTemplateService.java
0 → 100644
View file @
20332a86
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package
edu.kit.scc.webreg.service.tpl
;
import
edu.kit.scc.webreg.entity.VelocityTemplateEntity
;
import
edu.kit.scc.webreg.service.BaseService
;
public
interface
VelocityTemplateService
extends
BaseService
<
VelocityTemplateEntity
,
Long
>
{
VelocityTemplateEntity
findByName
(
String
name
);
}
bwreg-service/src/main/java/edu/kit/scc/webreg/service/tpl/VelocityTemplateServiceImpl.java
0 → 100644
View file @
20332a86
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package
edu.kit.scc.webreg.service.tpl
;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
edu.kit.scc.webreg.dao.BaseDao
;
import
edu.kit.scc.webreg.dao.VelocityTemplateDao
;
import
edu.kit.scc.webreg.entity.VelocityTemplateEntity
;
import
edu.kit.scc.webreg.service.impl.BaseServiceImpl
;
@Stateless
public
class
VelocityTemplateServiceImpl
extends
BaseServiceImpl
<
VelocityTemplateEntity
,
Long
>
implements
VelocityTemplateService
{
private
static
final
long
serialVersionUID
=
1L
;
@Inject
private
VelocityTemplateDao
dao
;
@Override
protected
BaseDao
<
VelocityTemplateEntity
,
Long
>
getDao
()
{
return
dao
;
}
@Override
public
VelocityTemplateEntity
findByName
(
String
name
)
{
return
dao
.
findByName
(
name
);
}
}
bwreg-webapp/src/main/java/edu/kit/scc/webreg/bean/HeadBarBean.java
View file @
20332a86
...
...
@@ -87,7 +87,6 @@ public class HeadBarBean {
}
else
{
return
defaultString
;
}
}
}
}
\ No newline at end of file
bwreg-webapp/src/main/java/edu/kit/scc/webreg/bean/tpl/TemplateBean.java
0 → 100644
View file @
20332a86
package
edu.kit.scc.webreg.bean.tpl
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.servlet.http.HttpServletRequest
;
import
edu.kit.scc.webreg.bootstrap.ApplicationConfig
;
import
edu.kit.scc.webreg.service.tpl.VelocityPageRenderer
;
@Named
(
"templateBean"
)
@RequestScoped
public
class
TemplateBean
{
@Inject
private
ApplicationConfig
appConfig
;
@Inject
private
HttpServletRequest
request
;
@Inject
private
VelocityPageRenderer
pageRenderer
;
public
String
getTemplated
()
{
return
getOrDefault
(
request
.
getServerName
()
+
"_templated"
,
"false"
);
}
public
String
getOrDefault
(
String
key
,
String
defaultString
)
{
if
(
appConfig
.
getConfigValue
(
key
)
!=
null
)
{
return
appConfig
.
getConfigValue
(
key
);
}
else
{
return
defaultString
;
}
}
}
bwreg-webapp/src/main/java/edu/kit/scc/webreg/sec/SecurityFilter.java
View file @
20332a86
...
...
@@ -103,6 +103,12 @@ public class SecurityFilter implements Filter {
HttpSession
httpSession
=
request
.
getSession
(
false
);
Boolean
templated
=
false
;
if
(
appConfig
.
getConfigValue
(
request
.
getServerName
()
+
"_templated"
)
!=
null
&&
appConfig
.
getConfigValue
(
request
.
getServerName
()
+
"_templated"
).
equalsIgnoreCase
(
"true"
))
{
templated
=
true
;
}
if
(
logger
.
isTraceEnabled
())
logger
.
trace
(
"Prechain Session is: {}"
,
httpSession
);
...
...
@@ -209,7 +215,12 @@ public class SecurityFilter implements Filter {
/*
* Normal pages are handled here
*/
chain
.
doFilter
(
servletRequest
,
servletResponse
);
if
(
templated
)
{
request
.
getServletContext
().
getRequestDispatcher
(
"/tpl"
+
path
).
forward
(
servletRequest
,
servletResponse
);
}
else
{
chain
.
doFilter
(
servletRequest
,
servletResponse
);
}
}
}
else
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/sec/TemplateRendererServlet.java
0 → 100644
View file @
20332a86
package
edu.kit.scc.webreg.sec
;
import
java.io.IOException
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.servlet.Servlet
;
import
javax.servlet.ServletConfig
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.slf4j.Logger
;
@Named
@WebServlet
(
urlPatterns
=
{
"/tpl/*"
})
public
class
TemplateRendererServlet
implements
Servlet
{
@Inject
private
Logger
logger
;
@Override
public
void
init
(
ServletConfig
config
)
throws
ServletException
{
}
@Override
public
void
service
(
ServletRequest
servletRequest
,
ServletResponse
servletResponse
)
throws
ServletException
,
IOException
{
HttpServletRequest
request
=
(
HttpServletRequest
)
servletRequest
;
HttpServletResponse
response
=
(
HttpServletResponse
)
servletResponse
;
String
context
=
request
.
getServletContext
().
getContextPath
();
String
path
=
request
.
getRequestURI
().
substring
(
context
.
length
());
logger
.
debug
(
"Template requested context '{}' path '{}'"
,
context
,
path
);
}
@Override
public
ServletConfig
getServletConfig
()
{
return
null
;
}
@Override
public
String
getServletInfo
()
{
return
null
;
}
@Override
public
void
destroy
()
{
}
}
bwreg-webapp/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia
View file @
20332a86
<?xml version="1.0" encoding="UTF-8"?>
<PROCESS
model-entity=
"JSFProcess"
/>
<?xml version="1.0" encoding="UTF-8"?>
<PROCESS
model-entity=
"JSFProcess"
/>
bwreg-webapp/src/main/webapp/template/default.xhtml
View file @
20332a86
...
...
@@ -22,7 +22,6 @@
<ui:define
name=
"footer"
>
<ui:include
src=
"footer.xhtml"
/>
</ui:define>
</ui:composition>
</body>
</html>
\ No newline at end of file
bwreg-webapp/src/main/webapp/template/footer.xhtml
View file @
20332a86
...
...
@@ -11,12 +11,9 @@
</head>
<body>
<ui:composition>
<div
id=
"footer-content"
>
${project.artifactId}${bwreg.name.suffix}-${project.version}
</div>
<div
id=
"owner"
>
<span
id=
"owner-text"
>
KIT – Die Forschungsuniversität in der Helmholtz-Gemeinschaft
</span>
</div>
<div
class=
"content-wrap"
>
<span
class=
"copyright"
>
${project.artifactId}${bwreg.name.suffix}-${project.version}
</span>
</div>
</ui:composition>
</body>
</html>
\ No newline at end of file
bwreg-webapp/src/main/webapp/template/head-bar.xhtml
View file @
20332a86
...
...
@@ -4,7 +4,7 @@
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:p=
"http://primefaces.org/ui"
xmlns:c=
"http://java.sun.com/jstl/core"
>
<head>
<title>
Head bar
</title>
...
...
@@ -12,6 +12,11 @@
<body>
<ui:composition>
<c:if
test=
"#{templateBean.templated eq 'true'}"
>
</c:if>
<c:if
test=
"#{templateBean.templated ne 'true'}"
>
<header
class=
"page-header"
>
<div
class=
"content-wrap"
>
...
...
@@ -45,6 +50,8 @@
</div>
</header>
</c:if>
</ui:composition>
</body>
</html>
\ No newline at end of file
bwreg-webapp/src/main/webapp/template/layout-template.xhtml
View file @
20332a86
...
...
@@ -4,55 +4,67 @@
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jstl/core"
class=
"no-js"
lang=
"de-de"
>
<f:view
contentType=
"text/html"
locale=
"#{sessionManager.locale != null ? sessionManager.locale : ''}"
>
<h:head>
<ui:insert
name=
"metadata"
/>
<f:facet
name=
"first"
>
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
name=
"theme-color"
content=
"#009682"
/>
<meta
http-equiv=
"cleartype"
content=
"on"
/>
<title>
#{headBarBean.headerTitle}
</title>
</f:facet>
<link
rel=
"stylesheet"
href=
"/resources/static/jquery.fancybox.min.css"
/>
<h:outputStylesheet
library=
"webjars"
name=
"font-awesome/5.12.0/css/all.min-jsf.css"
/>
<h:outputStylesheet
library=
"webjars"
name=
"font-awesome/5.12.0/css/v4-shims.min-jsf.css"
/>
<link
rel=
"stylesheet"
href=
"#{headBarBean.overrideStdStylesheet}"
/>
<link
rel=
"stylesheet"
href=
"#{headBarBean.stylesheetExtended}"
/>
<h:panelGroup
rendered=
"#{not empty headBarBean.stylesheet}"
>
<link
rel=
"stylesheet"
href=
"#{headBarBean.stylesheet}"
/>
</h:panelGroup>
<c:if
test=
"#{templateBean.templated eq 'true'}"
>
</c:if>
<c:if
test=
"#{templateBean.templated ne 'true'}"
>
<f:facet
name=
"first"
>
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
name=
"theme-color"
content=
"#009682"
/>
<meta
http-equiv=
"cleartype"
content=
"on"
/>
<title>
#{headBarBean.headerTitle}
</title>
</f:facet>
<link
rel=
"stylesheet"
href=
"/resources/static/jquery.fancybox.min.css"
/>
<h:outputStylesheet
library=
"webjars"
name=
"font-awesome/5.12.0/css/all.min-jsf.css"
/>
<h:outputStylesheet
library=
"webjars"
name=
"font-awesome/5.12.0/css/v4-shims.min-jsf.css"
/>
<link
rel=
"stylesheet"
href=
"#{headBarBean.overrideStdStylesheet}"
/>
<link
rel=
"stylesheet"
href=
"#{headBarBean.stylesheetExtended}"
/>
<h:panelGroup
rendered=
"#{not empty headBarBean.stylesheet}"
>
<link
rel=
"stylesheet"
href=
"#{headBarBean.stylesheet}"
/>
</h:panelGroup>
<script
src=
"/resources/static/main.js"
></script>
</c:if>
<h:outputScript
library=
"javax.faces"
name=
"jsf.js"
target=
"head"
/>
<script
src=
"/resources/static/main.js"
></script>
</h:head>
<h:body
class=
"oe-page"
vocab=
"http://schema.org/"
typeof=
"WebPage"
>
<ui:insert
name=
"header"
>
Default header
</ui:insert>
<main>
<section
class=
"stage stage-small"
><img
src=
"#{headBarBean.appImage}"
alt=
"#{headBarBean.appTitle}"
loading=
"lazy"
/>
<div
class=
"content-wrap"
><a
href=
"#{headBarBean.appLink}"
>
#{headBarBean.appTitle}
</a></div>
</section>
<section
class=
"content-wrap"
>
<div
class=
"content"
>
<ui:insert
name=
"content"
>
Default content
</ui:insert>
</div>
</section>
</main>
<button
class=
"to-top-button"
aria-label=
"scroll back to top"
></button>
<c:if
test=
"#{templateBean.templated eq 'true'}"
>
<ui:insert
name=
"content"
>
Default content
</ui:insert>
</c:if>
<c:if
test=
"#{templateBean.templated ne 'true'}"
>
<main>
<section
class=
"stage stage-small"
><img
src=
"#{headBarBean.appImage}"
alt=
"#{headBarBean.appTitle}"
loading=
"lazy"
/>
<div
class=
"content-wrap"
><a
href=
"#{headBarBean.appLink}"
>
#{headBarBean.appTitle}
</a></div>
</section>
<section
class=
"content-wrap"
>
<div
class=
"content"
>
<ui:insert
name=
"content"
>
Default content
</ui:insert>
</div>
</section>
</main>
<button
class=
"to-top-button"
aria-label=
"scroll back to top"
></button>
<div
class=
"footer-meta-navigation"
>
<ui:insert
name=
"footer"
>
Default footer
</ui:insert>
</div>
</c:if>
</h:body>
</f:view>
...
...
bwreg-webapp/src/main/webapp/template/left-side-bar.xhtml
View file @
20332a86
...
...
@@ -13,6 +13,12 @@
</head>
<body>
<ui:composition>
<c:if
test=
"#{templateBean.templated eq 'true'}"
>
</c:if>
<c:if
test=
"#{templateBean.templated ne 'true'}"
>
<ul
class=
"navigation-l1"
>
<h:panelGroup
rendered=
"#{sessionManager.isLoggedIn()}"
>
<li
class=
"flyout"
><a
href=
"#{request.contextPath}/index.xhtml"
>
#{messages.index}
</a>
...
...
@@ -190,6 +196,7 @@
</h:panelGroup>
</ul>
</c:if>
</ui:composition>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment