# HG changeset patch # User Mike Becker # Date 1589027191 -7200 # Node ID 27a0fdd7bca7888beac353603b0e11daf7071f29 # Parent cfc3d11884ad119547e5c6d3c9732eb361d3acb4 converts to maven project diff -r cfc3d11884ad -r 27a0fdd7bca7 .hgignore --- a/.hgignore Sun Apr 08 16:51:15 2018 +0200 +++ b/.hgignore Sat May 09 14:26:31 2020 +0200 @@ -1,9 +1,12 @@ syntax: regexp ^nbproject/private/ ^build/ +^target/ ^dist/ \.orig\..*$ \.orig$ \.chg\..*$ \.rej$ \.conflict\~$ +\.iml$ +\.idea/ diff -r cfc3d11884ad -r 27a0fdd7bca7 build.xml --- a/build.xml Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project LightPIT. - - - diff -r cfc3d11884ad -r 27a0fdd7bca7 nbproject/ant-deploy.xml --- a/nbproject/ant-deploy.xml Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r cfc3d11884ad -r 27a0fdd7bca7 nbproject/build-impl.xml --- a/nbproject/build-impl.xml Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1448 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set build.web.dir - Must set build.generated.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.war - - - - - - - - - -The Java EE server classpath is not correctly set up - server home directory is missing. -Either open the project in the IDE and assign the server or setup the server classpath manually. -For example like this: - ant -Dj2ee.server.home=<app_server_installation_directory> - - -The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. -Either open the project in the IDE and assign the server or setup the server classpath manually. -For example like this: - ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) -or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The libs.CopyLibs.classpath property is not set up. -This property must point to -org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part -of NetBeans IDE installation and is usually located at -<netbeans_installation>/java<version>/ant/extra folder. -Either open the project in the IDE and make sure CopyLibs library -exists or setup the property manually. For example like this: - ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.jsp.includes - - - - - - - - - - - - - - - - - - - - - - - - - - Must select a file in the IDE or set jsp.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. - - - Launching ${browse.url} - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r cfc3d11884ad -r 27a0fdd7bca7 nbproject/genfiles.properties --- a/nbproject/genfiles.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -build.xml.data.CRC32=40807f5e -build.xml.script.CRC32=1f023e98 -build.xml.stylesheet.CRC32=651128d4@1.77.1.1 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=40807f5e -nbproject/build-impl.xml.script.CRC32=0c71c5d8 -nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1 diff -r cfc3d11884ad -r 27a0fdd7bca7 nbproject/project.properties --- a/nbproject/project.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=true -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -build.classes.dir=${build.web.dir}/WEB-INF/classes -build.classes.excludes=**/*.java,**/*.form -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -build.web.dir=${build.dir}/web -build.web.excludes=${build.classes.excludes} -client.urlPart= -compile.jsps=false -conf.dir=${source.root}/conf -debug.classpath=${build.classes.dir}:${javac.classpath} -debug.test.classpath=\ - ${run.test.classpath} -display.browser=true -# Files to be excluded from distribution war -dist.archive.excludes= -dist.dir=dist -dist.ear.war=${dist.dir}/${war.ear.name} -dist.javadoc.dir=${dist.dir}/javadoc -dist.war=${dist.dir}/${war.name} -endorsed.classpath=\ - ${libs.javaee-endorsed-api-7.0.classpath} -excludes= -includes=** -j2ee.compile.on.save=true -j2ee.copy.static.files.on.save=true -j2ee.deploy.on.save=true -j2ee.platform=1.7-web -j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.6.3.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/postgresql-42.1.4.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar -j2ee.server.type=Tomcat -jar.compress=false -javac.classpath=\ - ${libs.jstl.classpath}:\ - ${libs.SLF4J-LOG4J2.classpath}:\ - ${libs.LOG4J2-WEB.classpath} -# Space-separated list of extra javac options -javac.compilerargs= -javac.debug=true -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.preview=true -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -lib.dir=${web.docbase.dir}/WEB-INF/lib -persistence.xml.dir=${conf.dir} -platform.active=default_platform -project.license=default -resource.dir=setup -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -# Space-separated list of JVM arguments used when running a class with a main method or a unit test -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): -runmain.jvmargs= -source.encoding=UTF-8 -source.root=src -src.dir=${source.root}/java -test.src.dir=test -war.content.additional= -war.ear.name=${war.name} -war.name=LightPIT.war -web.docbase.dir=web -webinf.dir=web/WEB-INF diff -r cfc3d11884ad -r 27a0fdd7bca7 nbproject/project.xml --- a/nbproject/project.xml Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ - - - org.netbeans.modules.web.project - - - LightPIT - 1.6.5 - - - ${libs.jstl.classpath} - WEB-INF/lib - - - ${libs.SLF4J-LOG4J2.classpath} - WEB-INF/lib - - - ${libs.LOG4J2-WEB.classpath} - WEB-INF/lib - - - - - - - - - - - - diff -r cfc3d11884ad -r 27a0fdd7bca7 pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pom.xml Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,74 @@ + + + 4.0.0 + de.uapcore + lightpit + 0.1-SNAPSHOT + war + + UTF-8 + 11 + 11 + 3.8.1 + 3.2.0 + 1.7.30 + 2.13.1 + + + + org.slf4j + slf4j-api + ${version.slf4j} + + + org.apache.logging.log4j + log4j-core + ${version.log4j} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${version.log4j} + + + javax.servlet + jstl + 1.2 + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + + ${project.artifactId} + + + org.apache.maven.plugins + maven-compiler-plugin + ${version.maven.compiler} + + + org.apache.maven.plugins + maven-war-plugin + ${version.maven.war} + + + + true + lib/ + + + + + ${project.basedir}/src/main/resources + + + + + + + diff -r cfc3d11884ad -r 27a0fdd7bca7 src/conf/MANIFEST.MF --- a/src/conf/MANIFEST.MF Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/AbstractLightPITServlet.java --- a/src/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,296 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A special implementation of a HTTPServlet which is focused on implementing - * the necessary functionality for {@link LightPITModule}s. - */ -public abstract class AbstractLightPITServlet extends HttpServlet { - - private static final Logger LOG = LoggerFactory.getLogger(AbstractLightPITServlet.class); - - private static final String HTML_FULL_DISPATCHER = Functions.jspPath("html_full"); - - /** - * Store a reference to the annotation for quicker access. - */ - private Optional moduleInfo = Optional.empty(); - - /** - * The EL proxy is necessary, because the EL resolver cannot handle annotation properties. - */ - private Optional moduleInfoELProxy = Optional.empty(); - - - @FunctionalInterface - private static interface HandlerMethod { - ResponseType apply(HttpServletRequest t, HttpServletResponse u) throws IOException, ServletException; - } - - /** - * Invocation mapping gathered from the {@link RequestMapping} annotations. - * - * Paths in this map must always start with a leading slash, although - * the specification in the annotation must not start with a leading slash. - * - * The reason for this is the different handling of empty paths in - * {@link HttpServletRequest#getPathInfo()}. - */ - private final Map> mappings = new HashMap<>(); - - /** - * Gives implementing modules access to the {@link ModuleManager}. - * @return the module manager - */ - protected final ModuleManager getModuleManager() { - return (ModuleManager) getServletContext().getAttribute(ModuleManager.SC_ATTR_NAME); - } - - /** - * Gives implementing modules access to the {@link DatabaseFacade}. - * @return the database facade - */ - protected final DatabaseFacade getDatabaseFacade() { - return (DatabaseFacade) getServletContext().getAttribute(DatabaseFacade.SC_ATTR_NAME); - } - - private ResponseType invokeMapping(Method method, HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { - try { - LOG.trace("invoke {}#{}", method.getDeclaringClass().getName(), method.getName()); - return (ResponseType) method.invoke(this, req, resp); - } catch (ReflectiveOperationException | ClassCastException ex) { - LOG.error(String.format("invocation of method %s failed", method.getName()), ex); - resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - return ResponseType.NONE; - } - } - - @Override - public void init() throws ServletException { - moduleInfo = Optional.ofNullable(this.getClass().getAnnotation(LightPITModule.class)); - moduleInfoELProxy = moduleInfo.map(LightPITModule.ELProxy::convert); - - if (moduleInfo.isPresent()) { - scanForRequestMappings(); - } - - LOG.trace("{} initialized", getServletName()); - } - - private void scanForRequestMappings() { - try { - Method[] methods = getClass().getDeclaredMethods(); - for (Method method : methods) { - Optional mapping = Optional.ofNullable(method.getAnnotation(RequestMapping.class)); - if (mapping.isPresent()) { - if (!Modifier.isPublic(method.getModifiers())) { - LOG.warn("{} is annotated with {} but is not public", - method.getName(), RequestMapping.class.getSimpleName() - ); - continue; - } - if (Modifier.isAbstract(method.getModifiers())) { - LOG.warn("{} is annotated with {} but is abstract", - method.getName(), RequestMapping.class.getSimpleName() - ); - continue; - } - if (!ResponseType.class.isAssignableFrom(method.getReturnType())) { - LOG.warn("{} is annotated with {} but has the wrong return type - 'ResponseType' required", - method.getName(), RequestMapping.class.getSimpleName() - ); - continue; - } - - Class[] params = method.getParameterTypes(); - if (params.length == 2 - && HttpServletRequest.class.isAssignableFrom(params[0]) - && HttpServletResponse.class.isAssignableFrom(params[1])) { - - final String requestPath = "/"+mapping.get().requestPath(); - - if (mappings.computeIfAbsent(mapping.get().method(), k -> new HashMap<>()). - putIfAbsent(requestPath, - (req, resp) -> invokeMapping(method, req, resp)) != null) { - LOG.warn("{} {} has multiple mappings", - mapping.get().method(), - mapping.get().requestPath() - ); - } - - LOG.debug("{} {} maps to {}::{}", - mapping.get().method(), - requestPath, - getClass().getSimpleName(), - method.getName() - ); - } else { - LOG.warn("{} is annotated with {} but has the wrong parameters - (HttpServletRequest,HttpServletResponse) required", - method.getName(), RequestMapping.class.getSimpleName() - ); - } - } - } - } catch (SecurityException ex) { - LOG.error("Scan for request mappings on declared methods failed.", ex); - } - } - - @Override - public void destroy() { - mappings.clear(); - LOG.trace("{} destroyed", getServletName()); - } - - /** - * Sets the name of the dynamic fragment. - * - * It is sufficient to specify the name without any extension. The extension - * is added automatically if not specified. - * - * The fragment must be located in the dynamic fragments folder. - * - * @param req the servlet request object - * @param fragmentName the name of the fragment - * @see Constants#DYN_FRAGMENT_PATH_PREFIX - */ - public void setDynamicFragment(HttpServletRequest req, String fragmentName) { - req.setAttribute(Constants.REQ_ATTR_FRAGMENT, Functions.dynFragmentPath(fragmentName)); - } - - /** - * Specifies the name of an additional stylesheet used by the module. - * - * Setting an additional stylesheet is optional, but quite common for HTML - * output. - * - * It is sufficient to specify the name without any extension. The extension - * is added automatically if not specified. - * - * @param req the servlet request object - * @param stylesheet the name of the stylesheet - */ - public void setStylesheet(HttpServletRequest req, String stylesheet) { - req.setAttribute(Constants.REQ_ATTR_STYLESHEET, Functions.enforceExt(stylesheet, ".css")); - } - - private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { - - req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu(getDatabaseFacade())); - req.getRequestDispatcher(HTML_FULL_DISPATCHER).forward(req, resp); - } - - private Optional findMapping(HttpMethod method, HttpServletRequest req) { - return Optional.ofNullable(mappings.get(method)).map( - (rm) -> rm.get(Optional.ofNullable(req.getPathInfo()).orElse("/")) - ); - } - - private void forwardAsSepcified(ResponseType type, HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - switch (type) { - case NONE: return; - case HTML_FULL: - forwardToFullView(req, resp); - return; - // TODO: implement remaining response types - default: - // this code should be unreachable - LOG.error("ResponseType switch is not exhaustive - this is a bug!"); - throw new UnsupportedOperationException(); - } - } - - private void doProcess(HttpMethod method, HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - // Synchronize module information with database - getModuleManager().syncWithDatabase(getDatabaseFacade()); - - // choose the requested language as session language (if available) or fall back to english, otherwise - HttpSession session = req.getSession(); - if (session.getAttribute(Constants.SESSION_ATTR_LANGUAGE) == null) { - Optional> availableLanguages = Functions.availableLanguages(getServletContext()).map(Arrays::asList); - Optional reqLocale = Optional.of(req.getLocale()); - Locale sessionLocale = reqLocale.filter((rl) -> availableLanguages.map((al) -> al.contains(rl.getLanguage())).orElse(false)).orElse(Locale.ENGLISH); - session.setAttribute(Constants.SESSION_ATTR_LANGUAGE, sessionLocale); - LOG.debug("Settng language for new session {}: {}", session.getId(), sessionLocale.getDisplayLanguage()); - } else { - Locale sessionLocale = (Locale) session.getAttribute(Constants.SESSION_ATTR_LANGUAGE); - resp.setLocale(sessionLocale); - LOG.trace("Continuing session {} with language {}", session.getId(), sessionLocale); - } - - // set some internal request attributes - req.setAttribute(Constants.REQ_ATTR_PATH, Functions.fullPath(req)); - req.setAttribute(Constants.REQ_ATTR_MODULE_CLASSNAME, this.getClass().getName()); - moduleInfoELProxy.ifPresent((proxy) -> req.setAttribute(Constants.REQ_ATTR_MODULE_INFO, proxy)); - - - // call the handler, if available, or send an HTTP 404 error - Optional mapping = findMapping(method, req); - if (mapping.isPresent()) { - forwardAsSepcified(mapping.get().apply(req, resp), req, resp); - } else { - resp.sendError(HttpServletResponse.SC_NOT_FOUND); - } - } - - @Override - protected final void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - doProcess(HttpMethod.GET, req, resp); - } - - @Override - protected final void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - doProcess(HttpMethod.POST, req, resp); - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/Constants.java --- a/src/java/de/uapcore/lightpit/Constants.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import static de.uapcore.lightpit.Functions.fqn; - -/** - * Contains all non-local scope constants used by the this application. - * - * Constants with (class) local scope are defined in their respective classes. - */ -public final class Constants { - public static final String JSP_PATH_PREFIX = "/WEB-INF/jsp/"; - - public static final String JSPF_PATH_PREFIX = "/WEB-INF/jspf/"; - - public static final String DYN_FRAGMENT_PATH_PREFIX = "/WEB-INF/dynamic_fragments/"; - - - /** - * Name for the context parameter specifying the available languages. - */ - public static final String CTX_ATTR_LANGUAGES = "available-languages"; - - /** - * Name for the context parameter optionally specifying the JNDI context; - */ - public static final String CTX_ATTR_JNDI_CONTEXT = "jndi-context"; - - /** - * Name for the context parameter optionally specifying a database schema. - */ - public static final String CTX_ATTR_DB_SCHEMA = "db-schema"; - - /** - * Name for the context parameter optionally specifying a database dialect. - */ - public static final String CTX_ATTR_DB_DIALECT = "db-dialect"; - - /** - * Key for the request attribute containing the class name of the currently dispatching module. - */ - public static final String REQ_ATTR_MODULE_CLASSNAME = fqn(AbstractLightPITServlet.class, "moduleClassname"); - - /** - * Key for the request attribute containing the {@link LightPITModule} information of the currently dispatching module. - */ - public static final String REQ_ATTR_MODULE_INFO = fqn(AbstractLightPITServlet.class, "moduleInfo"); - - /** - * Key for the request attribute containing the menu list. - */ - public static final String REQ_ATTR_MENU = fqn(AbstractLightPITServlet.class, "mainMenu"); - - /** - * Key for the request attribute containing the full path information (servlet path + path info). - */ - public static final String REQ_ATTR_PATH = fqn(AbstractLightPITServlet.class, "path"); - - /** - * Key for the name of the fragment which should be rendered. - */ - public static final String REQ_ATTR_FRAGMENT = fqn(AbstractLightPITServlet.class, "fragment"); - - /** - * Key for the name of the additional stylesheet used by a module. - */ - public static final String REQ_ATTR_STYLESHEET = fqn(AbstractLightPITServlet.class, "extraCss"); - - - /** - * Key for the current language selection within the session. - */ - public static final String SESSION_ATTR_LANGUAGE = fqn(AbstractLightPITServlet.class, "language"); - - /** - * This class is not instantiatable. - */ - private Constants() {} -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/DatabaseFacade.java --- a/src/java/de/uapcore/lightpit/DatabaseFacade.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; -import java.util.Optional; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.servlet.annotation.WebListener; -import javax.sql.DataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Provides access to different privilege layers within the database. - */ -@WebListener -public final class DatabaseFacade implements ServletContextListener { - - private static final Logger LOG = LoggerFactory.getLogger(DatabaseFacade.class); - - /** - * Timeout in seconds for the validation test. - */ - private static final int DB_TEST_TIMEOUT = 10; - - public static enum Dialect { - Postgres; - } - - /** - * The database dialect to use. - * - * May be override by context parameter. - * - * @see Constants#CTX_ATTR_DB_DIALECT - */ - private Dialect dialect = Dialect.Postgres; - - /** - * The default schema to test against when validating the connection. - * - * May be overridden by context parameter. - * - * @see Constants#CTX_ATTR_DB_SCHEMA - */ - private static final String DB_DEFAULT_SCHEMA = "lightpit"; - - /** - * The attribute name in the Servlet context under which an instance of this class can be found. - */ - public static final String SC_ATTR_NAME = DatabaseFacade.class.getName(); - private ServletContext sc; - - private static final String DS_JNDI_NAME = "jdbc/lightpit/app"; - private Optional dataSource; - - /** - * Returns the data source. - * - * The Optional returned should never be empty. However, if something goes - * wrong during initialization, the data source might be absent. - * Hence, users of this data source are forced to check the existence. - * - * @return a data source - */ - public Optional getDataSource() { - return dataSource; - } - - public Dialect getSQLDialect() { - return dialect; - } - - private static void checkConnection(DataSource ds, String testSchema, String errMsg) { - try (Connection conn = ds.getConnection()) { - if (!conn.isValid(DB_TEST_TIMEOUT)) { - throw new SQLException("Validation check failed."); - } - if (conn.isReadOnly()) { - throw new SQLException("Connection is read-only and thus unusable."); - } - if (!conn.getSchema().equals(testSchema)) { - throw new SQLException(String.format("Connection is not configured to use the schema %s.", testSchema)); - } - DatabaseMetaData metaData = conn.getMetaData(); - LOG.info("Connections as {} to {}/{} ready to go.", metaData.getUserName(), metaData.getURL(), conn.getSchema()); - } catch (SQLException ex) { - LOG.error(errMsg, ex); - } - } - - private static Optional retrieveDataSource(Context ctx) { - DataSource ret = null; - try { - ret = (DataSource)ctx.lookup(DS_JNDI_NAME); - LOG.info("Data source retrieved."); - } catch (NamingException ex) { - LOG.error("Data source {} not available.", DS_JNDI_NAME); - LOG.error("Reason for the missing data source: ", ex); - } - return Optional.ofNullable(ret); - } - - @Override - public void contextInitialized(ServletContextEvent sce) { - sc = sce.getServletContext(); - - dataSource = null; - - final String contextName = Optional - .ofNullable(sc.getInitParameter(Constants.CTX_ATTR_JNDI_CONTEXT)) - .orElse("java:comp/env"); - final String dbSchema = Optional - .ofNullable(sc.getInitParameter(Constants.CTX_ATTR_DB_SCHEMA)) - .orElse(DB_DEFAULT_SCHEMA); - final String dbDialect = sc.getInitParameter(Constants.CTX_ATTR_DB_DIALECT); - if (dbDialect != null) { - try { - dialect = Dialect.valueOf(dbDialect); - } catch (IllegalArgumentException ex) { - LOG.error("Unknown or unsupported database dialect {}. Defaulting to {}.", dbDialect, dialect); - } - } - - try { - LOG.debug("Trying to access JNDI context {}...", contextName); - Context initialCtx = new InitialContext(); - Context ctx = (Context) initialCtx.lookup(contextName); - - dataSource = retrieveDataSource(ctx); - - dataSource.ifPresent((ds) -> checkConnection(ds, dbSchema, "Checking database connection failed")); - } catch (NamingException | ClassCastException ex) { - LOG.error("Cannot access JNDI resources.", ex); - } - - sc.setAttribute(SC_ATTR_NAME, this); - LOG.info("Database facade injected into ServletContext."); - } - - @Override - public void contextDestroyed(ServletContextEvent sce) { - dataSource = null; - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/Functions.java --- a/src/java/de/uapcore/lightpit/Functions.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import java.util.Optional; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Contains common static functions. - */ -public final class Functions { - - private static final Logger LOG = LoggerFactory.getLogger(Functions.class); - - public static Optional availableLanguages(ServletContext ctx) { - return Optional.ofNullable(ctx.getInitParameter(Constants.CTX_ATTR_LANGUAGES)).map((x) -> x.split("\\s*,\\s*")); - } - - public static String enforceExt(String filename, String ext) { - return filename.endsWith(ext) ? filename : filename + ext; - } - - public static String jspPath(String filename) { - return enforceExt(Constants.JSP_PATH_PREFIX + filename, ".jsp"); - } - - public static String jspfPath(String filename) { - return enforceExt(Constants.JSPF_PATH_PREFIX + filename, ".jspf"); - } - - public static String dynFragmentPath(String filename) { - return enforceExt(Constants.DYN_FRAGMENT_PATH_PREFIX + filename, ".jsp"); - } - - public static String fqn(String base, String name) { - return base+"."+name; - } - - public static String fqn(Class clazz, String name) { - return fqn(clazz.getName(), name); - } - - public static String fullPath(LightPITModule module, RequestMapping mapping) { - StringBuilder sb = new StringBuilder(); - sb.append(module.modulePath()); - sb.append('/'); - if (!mapping.requestPath().isEmpty()) { - sb.append(mapping.requestPath().isEmpty()); - sb.append('/'); - } - return sb.toString(); - } - - public static String fullPath(HttpServletRequest req) { - return req.getServletPath() + Optional.ofNullable(req.getPathInfo()).orElse(""); - } - - /** - * Returns the module path of the given LightPIT Servlet module. - * - * If you specify a malformed LightPIT servlet, which does not have a module - * annotation, the path to the /error/404.html page is returned. - * - * @param clazz the servlet class - * @return the module path - */ - public static String modulePathOf(Class clazz) { - Optional moduleInfo = Optional.ofNullable(clazz.getAnnotation(LightPITModule.class)); - if (moduleInfo.isPresent()) { - return moduleInfo.get().modulePath(); - } else { - LOG.warn( - "{} is a LightPIT Servlet but is missing the module annotation.", - clazz.getName() - ); - return "/error/404.html"; - } - } - - /** - * This class is not instantiatable. - */ - private Functions() {} -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/HttpMethod.java --- a/src/java/de/uapcore/lightpit/HttpMethod.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - - -public enum HttpMethod { - GET, POST, PUT, DELETE, TRACE, HEAD, OPTIONS -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/LightPITModule.java --- a/src/java/de/uapcore/lightpit/LightPITModule.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import javax.servlet.annotation.WebServlet; - - -/** - * Contains information about a LightPIT module. - * - * This annotation is typically used to annotate the {@link WebServlet} which - * implements the module's functionality. - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface LightPITModule { - /** - * Base name of the module specific resource bundle. - * @return a base name suitable for the JSTL tag 'setBundle'. - */ - String bundleBaseName(); - - /** - * An array of required modules, identified by the string representation of - * their class names. - * @return an array of class names of required modules - */ - String[] requires() default {}; - - /** - * The path for this module, which will also be used for the menu entry. - * - * This path must adhere to the URL pattern of the Servlet but must not - * contain any starting or trailing slashes. - * - * @return the relative module path - */ - String modulePath(); - - /** - * Returns the properties key for the module name. - * - * @return the properties key - */ - String nameKey() default "name"; - - /** - * Returns the properties key for the module description. - * - * @return the properties key - */ - String descKey() default "description"; - - - /** - * Returns the properties key for the menu label. - * - * Set this string to empty string, if the module should be hidden from - * the menu. - * - * @return the properties key - */ - String menuKey() default "menuLabel"; - - /** - * Returns the properties key for the page title. - * - * By default this is the same as the menu label. - * - * @return the properties key - */ - String titleKey() default "menuLabel"; - - /** - * If set to true, this module is always loaded, but never - * visible in the menu or the Web UI module manager. - * - * @return true, if this is a system module - */ - boolean systemModule() default false; - - /** - * Class representing the annotation. - * This is necessary, because the EL resolver cannot deal with - * annotation objects. - * - * Note, that only the properties which are interesting for the JSP pages - * are proxied by this object. - */ - public static class ELProxy { - private final String bundleBaseName, modulePath, menuKey, titleKey, nameKey, descKey; - - public static ELProxy convert(LightPITModule annotation) { - return new ELProxy( - annotation.bundleBaseName(), - annotation.modulePath(), - annotation.menuKey(), - annotation.titleKey(), - annotation.nameKey(), - annotation.descKey() - ); - } - - private ELProxy(String bundleBaseName, String modulePath, String menuKey, String titleKey, String nameKey, String descKey) { - this.bundleBaseName = bundleBaseName; - this.modulePath = modulePath; - this.menuKey = menuKey; - this.titleKey = titleKey; - this.nameKey = nameKey; - this.descKey = descKey; - } - - public String getBundleBaseName() { - return bundleBaseName; - } - - public String getMenuKey() { - return menuKey; - } - - public String getModulePath() { - return modulePath; - } - - public String getTitleKey() { - return titleKey; - } - - public String getNameKey() { - return nameKey; - } - - public String getDescKey() { - return descKey; - } - - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/Menu.java --- a/src/java/de/uapcore/lightpit/Menu.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Maps a resource key for the menu label to the path name for the underlying - * site. - * - * Objects of this class are internally instantiated by the - * {@link ModuleManager}. - */ -public class Menu extends MenuEntry { - - private final List entries = new ArrayList<>(); - private final List immutableEntries = Collections.unmodifiableList(entries); - - /** - * Class name of the module for which this menu is built. - */ - private String moduleClassName; - - - public Menu() { - super(); - } - - public Menu(String moduleClassName, ResourceKey resourceKey, String pathName) { - super(resourceKey, pathName); - this.moduleClassName = moduleClassName; - } - - public void setModuleClassName(String moduleClassName) { - this.moduleClassName = moduleClassName; - } - - public String getModuleClassName() { - return moduleClassName; - } - - /** - * Sets a new list of menu entries for this menu. - * - * @param entries the list of new menu entries - */ - public void setEntries(List entries) { - // in case the given list is immutable, we copy the contents - this.entries.clear(); - this.entries.addAll(entries); - } - - /** - * Retrieves an immutable list of menu entries for this menu. - * - * @return the list of menu entries - */ - public List getEntries() { - return immutableEntries; - } - - /** - * Adds a new menu entry to this menu. - * @param entry the menu entry to add - */ - public void addMenuEntry(MenuEntry entry) { - entries.add(entry); - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/MenuEntry.java --- a/src/java/de/uapcore/lightpit/MenuEntry.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -/** - * Maps a resource key for the menu label to the path name for the underlying - * site. - * - * Objects of this class are internally instantiated by the - * {@link ModuleManager}. - */ -public class MenuEntry { - - /** - * Resource key for the menu label. - */ - private ResourceKey resourceKey; - - /** - * Path name of the module, linked by this menu entry. - */ - private String pathName; - - public MenuEntry() { - } - - public MenuEntry(ResourceKey resourceKey, String pathName) { - this.resourceKey = resourceKey; - this.pathName = pathName; - } - - public void setResourceKey(ResourceKey resourceKey) { - this.resourceKey = resourceKey; - } - - public ResourceKey getResourceKey() { - return resourceKey; - } - - public void setPathName(String pathName) { - this.pathName = pathName; - } - - public String getPathName() { - return pathName; - } - -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/ModuleManager.java --- a/src/java/de/uapcore/lightpit/ModuleManager.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,231 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import de.uapcore.lightpit.entities.CoreDAOFactory; -import de.uapcore.lightpit.entities.Module; -import de.uapcore.lightpit.entities.ModuleDao; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Collectors; -import javax.servlet.Registration; -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.servlet.annotation.WebListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Scans registered servlets for LightPIT modules. - */ -@WebListener -public final class ModuleManager implements ServletContextListener { - - private static final Logger LOG = LoggerFactory.getLogger(ModuleManager.class); - - /** - * The attribute name in the servlet context under which an instance of this class can be found. - */ - public static final String SC_ATTR_NAME = ModuleManager.class.getName(); - private ServletContext sc; - - /** - * Maps class names to module information. - */ - private final Map registeredModules = new HashMap<>(); - - /** - * This flag is true, when synchronization is needed. - */ - private final AtomicBoolean dirty = new AtomicBoolean(true); - - @Override - public void contextInitialized(ServletContextEvent sce) { - sc = sce.getServletContext(); - reloadAll(); - sc.setAttribute(SC_ATTR_NAME, this); - LOG.info("Module manager injected into ServletContext."); - } - - @Override - public void contextDestroyed(ServletContextEvent sce) { - unloadAll(); - } - - private Optional getModuleInfo(Registration reg) { - try { - final Class scclass = Class.forName(reg.getClassName()); - - final boolean lpservlet = AbstractLightPITServlet.class.isAssignableFrom(scclass); - final boolean lpmodule = scclass.isAnnotationPresent(LightPITModule.class); - - if (lpservlet && !lpmodule) { - LOG.warn( - "{} is a LightPIT Servlet but is missing the module annotation.", - reg.getClassName() - ); - } else if (!lpservlet && lpmodule) { - LOG.warn( - "{} is annotated as a LightPIT Module but does not extend {}.", - reg.getClassName(), - AbstractLightPITServlet.class.getSimpleName() - ); - } - - if (lpservlet && lpmodule) { - final Class clazz = scclass; - final LightPITModule moduleInfo = clazz.getAnnotation(LightPITModule.class); - return Optional.of(moduleInfo); - } else { - return Optional.empty(); - } - } catch (ClassNotFoundException ex) { - LOG.error( - "Servlet registration refers to class {} which cannot be found by the class loader (Reason: {})", - reg.getClassName(), - ex.getMessage() - ); - return Optional.empty(); - } - } - - private void handleServletRegistration(String name, Registration reg) { - final Optional moduleInfo = getModuleInfo(reg); - if (moduleInfo.isPresent()) { - registeredModules.put(reg.getClassName(), moduleInfo.get()); - LOG.info("Module detected: {}", name); - } else { - LOG.debug("Servlet {} is no module, skipping.", name); - } - } - - /** - * Scans for modules and reloads them all. - */ - public void reloadAll() { - registeredModules.clear(); - sc.getServletRegistrations().forEach(this::handleServletRegistration); - - // TODO: implement dependency resolver - - dirty.set(true); - LOG.info("Modules loaded."); - } - - /** - * Synchronizes module information with the database. - * - * This must be called from the {@link AbstractLightPITServlet}. - * Admittedly the call will perform the synchronization once after reload - * and be a no-op, afterwards. - * However, we since the DatabaseFacade might be loaded after the module - * manager, we must defer the synchronization to the first request - * handled by the Servlet. - * - * @param db interface to the database - */ - public void syncWithDatabase(DatabaseFacade db) { - if (dirty.compareAndSet(true, false)) { - if (db.getDataSource().isPresent()) { - try (Connection conn = db.getDataSource().get().getConnection()) { - final ModuleDao moduleDao = CoreDAOFactory.getModuleDao(db.getSQLDialect()); - moduleDao.syncRegisteredModuleClasses(conn, registeredModules.entrySet()); - } catch (SQLException ex) { - LOG.error("Unexpected SQL Exception", ex); - } - } else { - LOG.error("No datasource present. Cannot sync module information with database."); - } - } else { - LOG.trace("Module information clean - no synchronization required."); - } - } - - /** - * Unloads all found modules. - */ - public void unloadAll() { - registeredModules.clear(); - LOG.info("All modules unloaded."); - } - - /** - * Returns the main menu. - * - * @param db the interface to the database - * @return a list of menus belonging to the main menu - */ - public List getMainMenu(DatabaseFacade db) { - // TODO: user specific menu - - if (db.getDataSource().isPresent()) { - try (Connection conn = db.getDataSource().get().getConnection()) { - final ModuleDao dao = CoreDAOFactory.getModuleDao(db.getSQLDialect()); - final List modules = dao.listAll(conn); - - final List menu = modules - .stream() - .filter((mod) -> mod.isVisible()) - .collect(Collectors.mapping( - (mod) -> new Menu( - mod.getClassname(), - new ResourceKey( - registeredModules.get(mod.getClassname()).bundleBaseName(), - registeredModules.get(mod.getClassname()).menuKey()), - registeredModules.get(mod.getClassname()).modulePath()), - Collectors.toList()) - ); - return menu; - } catch (SQLException ex) { - LOG.error("Unexpected SQLException when loading the main menu", ex); - return Collections.emptyList(); - } - } else { - return Collections.emptyList(); - } - } - - /** - * Returns an unmodifiable map of all registered modules. - * - * The key is the classname of the module. - * - * @return the map of registered modules - */ - public Map getRegisteredModules() { - return Collections.unmodifiableMap(registeredModules); - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/RequestMapping.java --- a/src/java/de/uapcore/lightpit/RequestMapping.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * Maps requests to methods. - * - * This annotation is used to annotate methods within classes which - * override {@link AbstractLightPITServlet}. - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface RequestMapping { - - /** - * Specifies the HTTP method. - * - * @return the HTTP method handled by the annotated Java method - */ - HttpMethod method(); - - /** - * Specifies the request path relative to the module path. - * - * If a menu key is specified, this is also the path, which is linked - * by the menu entry. - * - * The path must be specified without leading and trailing slash. - * - * @return the request path the annotated method should handle - */ - String requestPath() default ""; - - /** - * Returns the properties key for the (sub) menu label. - * - * This should only be used for {@link HttpMethod#GET} requests. - * - * @return the properties key - */ - String menuKey() default ""; -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/ResourceKey.java --- a/src/java/de/uapcore/lightpit/ResourceKey.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - -/** - * Fully specifies a resource key by the bundle and the key name. - */ -public final class ResourceKey { - private String bundle; - private String key; - - public ResourceKey() { - - } - - public ResourceKey(String bundle, String key) { - this.bundle = bundle; - this.key = key; - } - - public void setBundle(String bundle) { - this.bundle = bundle; - } - - public String getBundle() { - return bundle; - } - - public void setKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/ResponseType.java --- a/src/java/de/uapcore/lightpit/ResponseType.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit; - - -public enum ResponseType { - /** - * Renders a full HTML view including the header. - */ - HTML_FULL, - /** - * Renders a HTML fragment only. - * May be used for AJAX responses. - */ - HTML_FRAGMENT, - /** - * Returns a fragment with content type 'text/plain'. - */ - PLAIN, - /** - * Returns an object in JSON format and with content type - * 'application/json'. - */ - JSON, - /** - * The handler already sent the output, nothing should be done - * additionally by the Servlet. - */ - NONE -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/entities/CoreDAOFactory.java --- a/src/java/de/uapcore/lightpit/entities/CoreDAOFactory.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.entities; - -import de.uapcore.lightpit.DatabaseFacade; - -public final class CoreDAOFactory { - - private CoreDAOFactory() {} - - private static class PostgresDaos { - static final ModuleDao MODULE_DAO = new PostgresModuleDao(); - } - - public static ModuleDao getModuleDao(DatabaseFacade.Dialect dialect) { - switch (dialect) { - case Postgres: return PostgresDaos.MODULE_DAO; - default: assert(false); return null; - } - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/entities/Module.java --- a/src/java/de/uapcore/lightpit/entities/Module.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.entities; - -import de.uapcore.lightpit.LightPITModule; - -public final class Module { - private int modID; - private String classname; - private boolean visible; - - private LightPITModule.ELProxy annotatedInfos; - - public int getModID() { - return modID; - } - - public void setModID(int modID) { - this.modID = modID; - } - - public String getClassname() { - return classname; - } - - public void setClassname(String classname) { - this.classname = classname; - } - - public boolean isVisible() { - return visible; - } - - public void setVisible(boolean visible) { - this.visible = visible; - } - - public LightPITModule.ELProxy getAnnotatedInfos() { - return annotatedInfos; - } - - public void setAnnotatedInfos(LightPITModule.ELProxy annotatedInfos) { - this.annotatedInfos = annotatedInfos; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 41 * hash + this.modID; - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } else { - return this.modID == ((Module) obj).modID; - } - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/entities/ModuleDao.java --- a/src/java/de/uapcore/lightpit/entities/ModuleDao.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.entities; - -import de.uapcore.lightpit.LightPITModule; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public abstract class ModuleDao { - - /** - * Maps database columns to POJO fields. - * @param result the database result set - * @param mod the POJO - * @throws SQLException - */ - protected void mapColumns(ResultSet result, Module mod) throws SQLException { - mod.setModID(result.getInt("modid")); - mod.setClassname(result.getString("classname")); - mod.setVisible(result.getBoolean("visible")); - } - - - /** - * Must return a prepared statement for a single object query with the specified properties. - * - *
    - *
  • Parameter 1: classname
  • - *
  • Result field 1: visible
  • - *
- * - * @param conn the connection to use - * @return the prepared statement - * @throws SQLException - */ - protected PreparedStatement moduleCheckStatement(Connection conn) throws SQLException { - return conn.prepareStatement("SELECT visible FROM lpitcore_module WHERE classname = ?"); - } - - /** - * Must return a prepared statement for insertion with the specified properties. - * - *
    - *
  • Parameter 1: classname
  • - *
  • Parameter 2: visible
  • - *
- * - * @param conn the connection to use - * @return the prepared statement - * @throws SQLException - */ - protected PreparedStatement moduleInsertStatement(Connection conn) throws SQLException { - return conn.prepareStatement("INSERT INTO lpitcore_module (classname, visible) VALUES (?, ?)"); - } - - /** - * Synchronizes a set of registered module classes with the database. - * - * Inserts module classes which are not known to the database and sets them to be visible by default. - * Module classes known to the database, which are not in the given set, are ignored. - * - * @param conn the connection to use - * @param moduleSet the module set to synchronize - * @throws SQLException - */ - public final void syncRegisteredModuleClasses(Connection conn, Set> moduleSet) throws SQLException { - - PreparedStatement - check = moduleCheckStatement(conn), - insert = moduleInsertStatement(conn); - insert.setBoolean(2, true); - // update/delete not required, we do this in the module management UI - - for (Map.Entry modEntry : moduleSet) { - if (modEntry.getValue().systemModule()) continue; - - check.setString(1, modEntry.getKey()); - try (ResultSet r = check.executeQuery()) { - if (!r.next()) { - insert.setString(1, modEntry.getKey()); - insert.executeUpdate(); - } - } - } - } - - /** - * Returns a list of all modules known by the database. - * - * Keep in mind, that system modules are never known to the database. - * - * @param conn the connection to use - * @return a list of all modules known by the database - * @throws SQLException - */ - public List listAll(Connection conn) throws SQLException { - List list = new ArrayList<>(); - try (Statement stmt = conn.createStatement(); - ResultSet result = stmt.executeQuery("SELECT * FROM lpitcore_module")) { - while (result.next()) { - final Module mod = new Module(); - mapColumns(result, mod); - list.add(mod); - } - } - return list; - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/entities/PostgresModuleDao.java --- a/src/java/de/uapcore/lightpit/entities/PostgresModuleDao.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.entities; - -public class PostgresModuleDao extends ModuleDao { - // No overrides needed. -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/entities/User.java --- a/src/java/de/uapcore/lightpit/entities/User.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.entities; - -import java.util.Optional; - -public final class User { - - public static final int ANONYMOUS_USERID = -1; - - private int userID; - private String username; - private Optional givenname; - private Optional lastname; - - public int getUserID() { - return userID; - } - - public void setUserID(int userID) { - this.userID = userID; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public Optional getGivenname() { - return givenname; - } - - public void setGivenname(Optional givenname) { - this.givenname = givenname; - } - - public Optional getLastname() { - return lastname; - } - - public void setLastname(Optional lastname) { - this.lastname = lastname; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 41 * hash + this.userID; - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } else { - return this.userID == ((User) obj).userID; - } - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/entities/UserDao.java --- a/src/java/de/uapcore/lightpit/entities/UserDao.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.entities; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -public abstract class UserDao { - - /** - * Maps SQL columns to POJO fields. - * @param result the database result set - * @param user the POJO - * @throws SQLException - */ - protected void mapColumns(ResultSet result, User user) throws SQLException { - user.setUserID(result.getInt("userid")); - user.setUsername(result.getString("username")); - user.setGivenname(Optional.ofNullable(result.getString("givenname"))); - user.setLastname(Optional.ofNullable(result.getString("lastname"))); - } - - /** - * Returns a list of all users ordered by their username. - * - * Does not return reserved system users with negative user IDs. - * - * @param conn the connection to use - * @return a list of all users - * @throws SQLException - */ - public List listAll(Connection conn) throws SQLException { - List list = new ArrayList<>(); - try ( - Statement stmt = conn.createStatement(); - ResultSet result = stmt.executeQuery( - "SELECT * FROM lpitcore_user WHERE userid >= 0 ORDER BY username")) { - while (result.next()) { - final User user = new User(); - mapColumns(result, user); - list.add(user); - } - } - return list; - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/modules/ErrorModule.java --- a/src/java/de/uapcore/lightpit/modules/ErrorModule.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.modules; - -import de.uapcore.lightpit.LightPITModule; -import de.uapcore.lightpit.AbstractLightPITServlet; -import de.uapcore.lightpit.HttpMethod; -import de.uapcore.lightpit.RequestMapping; -import de.uapcore.lightpit.ResponseType; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Entry point for the application. - */ -@LightPITModule( - bundleBaseName = "de.uapcore.lightpit.resources.localization.error", - modulePath = "error", - titleKey = "title", - systemModule = true -) -@WebServlet( - name = "ErrorModule", - urlPatterns = "/error/*" -) -public final class ErrorModule extends AbstractLightPITServlet { - - public static final String REQ_ATTR_ERROR_CODE = "errorCode"; - - private ResponseType handle(HttpServletRequest req, HttpServletResponse resp, int sc) { - - req.setAttribute(REQ_ATTR_ERROR_CODE, sc); - setStylesheet(req, "error"); - setDynamicFragment(req, "error"); - - return ResponseType.HTML_FULL; - } - - @RequestMapping(requestPath = "404", method = HttpMethod.GET) - public ResponseType handle404(HttpServletRequest req, HttpServletResponse resp) { - return handle(req, resp, 404); - } - - @RequestMapping(requestPath = "403", method = HttpMethod.GET) - public ResponseType handle403(HttpServletRequest req, HttpServletResponse resp) { - return handle(req, resp, 403); - } - - @RequestMapping(requestPath = "500", method = HttpMethod.GET) - public ResponseType handle500(HttpServletRequest req, HttpServletResponse resp) { - return handle(req, resp, 500); - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/modules/HomeModule.java --- a/src/java/de/uapcore/lightpit/modules/HomeModule.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.modules; - -import de.uapcore.lightpit.LightPITModule; -import de.uapcore.lightpit.AbstractLightPITServlet; -import de.uapcore.lightpit.HttpMethod; -import de.uapcore.lightpit.RequestMapping; -import de.uapcore.lightpit.ResponseType; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Entry point for the application. - */ -@LightPITModule( - bundleBaseName = "de.uapcore.lightpit.resources.localization.home", - modulePath = "home" -) -@WebServlet( - name = "HomeModule", - urlPatterns = "/home/*" -) -public final class HomeModule extends AbstractLightPITServlet { - - @RequestMapping(method = HttpMethod.GET) - public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) { - - return ResponseType.HTML_FULL; - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/modules/LanguageModule.java --- a/src/java/de/uapcore/lightpit/modules/LanguageModule.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.modules; - -import de.uapcore.lightpit.LightPITModule; -import de.uapcore.lightpit.AbstractLightPITServlet; -import de.uapcore.lightpit.Constants; -import de.uapcore.lightpit.Functions; -import de.uapcore.lightpit.HttpMethod; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import de.uapcore.lightpit.RequestMapping; -import de.uapcore.lightpit.ResponseType; -import java.util.ArrayList; -import java.util.IllformedLocaleException; -import java.util.List; -import java.util.Locale; -import java.util.Optional; -import javax.servlet.ServletException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -@LightPITModule( - bundleBaseName = "de.uapcore.lightpit.resources.localization.language", - modulePath = "language" -) -@WebServlet( - name = "LanguageModule", - urlPatterns = "/language/*" -) -public final class LanguageModule extends AbstractLightPITServlet { - - private static final Logger LOG = LoggerFactory.getLogger(LanguageModule.class); - - private final List languages = new ArrayList<>(); - - @Override - public void init() throws ServletException { - super.init(); - - Optional langs = Functions.availableLanguages(getServletContext()); - if (langs.isPresent()) { - for (String lang : langs.get()) { - try { - Locale locale = Locale.forLanguageTag(lang); - if (locale.getLanguage().isEmpty()) { - throw new IllformedLocaleException(); - } - languages.add(locale); - } catch (IllformedLocaleException ex) { - LOG.warn("Specified lanaguge {} in context parameter cannot be mapped to an existing locale - skipping.", lang); - } - } - - } else { - languages.add(Locale.ENGLISH); - LOG.warn("Context parameter 'available-languges' not found. Only english will be available."); - } - } - - @Override - public void destroy() { - super.destroy(); - languages.clear(); - } - - @RequestMapping(method = HttpMethod.GET) - public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) { - - req.setAttribute("languages", languages); - req.setAttribute("browserLanguage", req.getLocale()); - - setStylesheet(req, "language"); - setDynamicFragment(req, "language"); - return ResponseType.HTML_FULL; - } - - @RequestMapping(method = HttpMethod.POST) - public ResponseType switchLanguage(HttpServletRequest req, HttpServletResponse resp) { - - Optional chosenLanguage = Optional.ofNullable(req.getParameter("language")) - .map(Locale::forLanguageTag) - .filter((l) -> !l.getLanguage().isEmpty()); - - chosenLanguage.ifPresent((l) -> req.getSession().setAttribute(Constants.SESSION_ATTR_LANGUAGE, l)); - chosenLanguage.ifPresent(resp::setLocale); - - return handle(req, resp); - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/modules/ModuleManagerModule.java --- a/src/java/de/uapcore/lightpit/modules/ModuleManagerModule.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.modules; - -import de.uapcore.lightpit.LightPITModule; -import de.uapcore.lightpit.AbstractLightPITServlet; -import de.uapcore.lightpit.HttpMethod; -import de.uapcore.lightpit.LightPITModule.ELProxy; -import de.uapcore.lightpit.RequestMapping; -import de.uapcore.lightpit.ResponseType; -import de.uapcore.lightpit.entities.CoreDAOFactory; -import de.uapcore.lightpit.entities.Module; -import java.io.IOException; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.sql.DataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Entry point for the application. - */ -@LightPITModule( - bundleBaseName = "de.uapcore.lightpit.resources.localization.modmgmt", - modulePath = "modmgmt" -) -@WebServlet( - name = "ModuleManagerModule", - urlPatterns = "/modmgmt/*" -) -public final class ModuleManagerModule extends AbstractLightPITServlet { - - private static final Logger LOG = LoggerFactory.getLogger(ModuleManagerModule.class); - - private static final String REQ_ATTR_MODULES = "modules"; - - - @RequestMapping(method = HttpMethod.GET) - public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) throws IOException { - - Optional ds = getDatabaseFacade().getDataSource(); - if (ds.isPresent()) { - try (Connection conn = ds.get().getConnection()) { - final List modules = CoreDAOFactory.getModuleDao(getDatabaseFacade().getSQLDialect()).listAll(conn); - - final Map registeredModules = getModuleManager().getRegisteredModules(); - modules.forEach((mod) -> mod.setAnnotatedInfos(ELProxy.convert(registeredModules.get(mod.getClassname())))); - - req.setAttribute(REQ_ATTR_MODULES, modules); - setDynamicFragment(req, "modules"); - return ResponseType.HTML_FULL; - } catch (SQLException ex) { - LOG.error("Unexpected SQL Exception", ex); - resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - return ResponseType.NONE; - } - } else { - resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - return ResponseType.NONE; - } - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/modules/VersionsModule.java --- a/src/java/de/uapcore/lightpit/modules/VersionsModule.java Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ -package de.uapcore.lightpit.modules; - -import de.uapcore.lightpit.LightPITModule; -import de.uapcore.lightpit.AbstractLightPITServlet; -import de.uapcore.lightpit.HttpMethod; -import de.uapcore.lightpit.RequestMapping; -import de.uapcore.lightpit.ResponseType; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - - -@LightPITModule( - bundleBaseName = "de.uapcore.lightpit.resources.localization.versions", - modulePath = "versions" -) -@WebServlet( - name = "VersionsModule", - urlPatterns = "/versions/*" -) -public final class VersionsModule extends AbstractLightPITServlet { - @RequestMapping(method = HttpMethod.GET) - public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) { - - return ResponseType.HTML_FULL; - } -} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/error.properties --- a/src/java/de/uapcore/lightpit/resources/localization/error.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -title = Error - -h1 = The requested page cannot be displayed. -errorCode = Code - -errorMessage = Message -errorMessage.404 = Page not found -errorMessage.403 = Access denied -errorMessage.500 = Internal error - -errorTimestamp = Timestamp -errorExceptionText = Internal Exception diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/error_de.properties --- a/src/java/de/uapcore/lightpit/resources/localization/error_de.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -title = Fehler - -h1 = Die angeforderte Seite kann nicht angezeigt werden. -errorCode = Fehlercode - -errorMessage = Nachricht -errorMessage.404 = Seite nicht gefunden -errorMessage.403 = Zugriff verboten -errorMessage.500 = Interner Fehler - -errorTimestamp = Zeitstempel -errorExceptionText = Interne Ausnahme diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/home.properties --- a/src/java/de/uapcore/lightpit/resources/localization/home.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Home Page -description = The default page that is displayed when visiting the site. -menuLabel = Home diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/home_de.properties --- a/src/java/de/uapcore/lightpit/resources/localization/home_de.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Startseite -description = Die Seite, die dem Benutzer standardm\u00e4\u00dfig beim Besuch angezeigt wird. -menuLabel = Startseite diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/language.properties --- a/src/java/de/uapcore/lightpit/resources/localization/language.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Language Selector -description = Where the user can choose his / her language setting. -menuLabel = Languages - -submit = Switch language -browserLanguage = Browser language -browserLanguageNotAvailable = Browser language not available. diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/language_de.properties --- a/src/java/de/uapcore/lightpit/resources/localization/language_de.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Sprachauswahl -description = Hier kann der Benutzer die Sprache f\u00fcr die Website ausw\u00e4hlen. - -menuLabel = Sprache - -submit = Sprache ausw\u00e4hlen -browserLanguage = Browsersprache -browserLanguageNotAvailable = Browsersprache nicht verf\u00fcgbar. diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/modmgmt.properties --- a/src/java/de/uapcore/lightpit/resources/localization/modmgmt.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Module Management -description = Configure the visible LightPIT modules and the required access powers. -menuLabel = Modules - -section.modlist.title = List of Modules - -caption.module = Module -caption.path = Path -caption.desc = Description -caption.active = Active -caption.class = Class -caption.bundle = Resource Bundle - diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/modmgmt_de.properties --- a/src/java/de/uapcore/lightpit/resources/localization/modmgmt_de.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Modulverwaltung -description = Konfiguration der sichtbaren LightPIT Module und deren Zugriffsrechte. -menuLabel = Module - -section.modlist.title = Liste der Module - -caption.module = Modul -caption.path = Pfad -caption.desc = Beschreibung -caption.active = Aktiv -caption.class = Klasse -caption.bundle = Ressourcen-Datei diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/versions.properties --- a/src/java/de/uapcore/lightpit/resources/localization/versions.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Version Management -description = Allows the configuration of versions and milestones within your project. -menuLabel = Versions diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/de/uapcore/lightpit/resources/localization/versions_de.properties --- a/src/java/de/uapcore/lightpit/resources/localization/versions_de.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -name = Versionsverwaltung -description = Erlaubt die Konfiguration von Versionen und Meilensteinen im Projekt. -menuLabel = Versionen diff -r cfc3d11884ad -r 27a0fdd7bca7 src/java/log4j2.properties --- a/src/java/log4j2.properties Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -# Copyright 2018 Mike Becker. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -status = warn -dest = err -name = PropertiesConfig - -appender.console.type = Console -appender.console.name = STDOUT -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = %d{ISO8601} [%highlight{%p}] %c{1}: %m %n - -rootLogger.appenderRef.stdout.ref = STDOUT - -rootLogger.level = debug diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,296 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A special implementation of a HTTPServlet which is focused on implementing + * the necessary functionality for {@link LightPITModule}s. + */ +public abstract class AbstractLightPITServlet extends HttpServlet { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractLightPITServlet.class); + + private static final String HTML_FULL_DISPATCHER = Functions.jspPath("html_full"); + + /** + * Store a reference to the annotation for quicker access. + */ + private Optional moduleInfo = Optional.empty(); + + /** + * The EL proxy is necessary, because the EL resolver cannot handle annotation properties. + */ + private Optional moduleInfoELProxy = Optional.empty(); + + + @FunctionalInterface + private static interface HandlerMethod { + ResponseType apply(HttpServletRequest t, HttpServletResponse u) throws IOException, ServletException; + } + + /** + * Invocation mapping gathered from the {@link RequestMapping} annotations. + * + * Paths in this map must always start with a leading slash, although + * the specification in the annotation must not start with a leading slash. + * + * The reason for this is the different handling of empty paths in + * {@link HttpServletRequest#getPathInfo()}. + */ + private final Map> mappings = new HashMap<>(); + + /** + * Gives implementing modules access to the {@link ModuleManager}. + * @return the module manager + */ + protected final ModuleManager getModuleManager() { + return (ModuleManager) getServletContext().getAttribute(ModuleManager.SC_ATTR_NAME); + } + + /** + * Gives implementing modules access to the {@link DatabaseFacade}. + * @return the database facade + */ + protected final DatabaseFacade getDatabaseFacade() { + return (DatabaseFacade) getServletContext().getAttribute(DatabaseFacade.SC_ATTR_NAME); + } + + private ResponseType invokeMapping(Method method, HttpServletRequest req, HttpServletResponse resp) + throws IOException, ServletException { + try { + LOG.trace("invoke {}#{}", method.getDeclaringClass().getName(), method.getName()); + return (ResponseType) method.invoke(this, req, resp); + } catch (ReflectiveOperationException | ClassCastException ex) { + LOG.error(String.format("invocation of method %s failed", method.getName()), ex); + resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ResponseType.NONE; + } + } + + @Override + public void init() throws ServletException { + moduleInfo = Optional.ofNullable(this.getClass().getAnnotation(LightPITModule.class)); + moduleInfoELProxy = moduleInfo.map(LightPITModule.ELProxy::convert); + + if (moduleInfo.isPresent()) { + scanForRequestMappings(); + } + + LOG.trace("{} initialized", getServletName()); + } + + private void scanForRequestMappings() { + try { + Method[] methods = getClass().getDeclaredMethods(); + for (Method method : methods) { + Optional mapping = Optional.ofNullable(method.getAnnotation(RequestMapping.class)); + if (mapping.isPresent()) { + if (!Modifier.isPublic(method.getModifiers())) { + LOG.warn("{} is annotated with {} but is not public", + method.getName(), RequestMapping.class.getSimpleName() + ); + continue; + } + if (Modifier.isAbstract(method.getModifiers())) { + LOG.warn("{} is annotated with {} but is abstract", + method.getName(), RequestMapping.class.getSimpleName() + ); + continue; + } + if (!ResponseType.class.isAssignableFrom(method.getReturnType())) { + LOG.warn("{} is annotated with {} but has the wrong return type - 'ResponseType' required", + method.getName(), RequestMapping.class.getSimpleName() + ); + continue; + } + + Class[] params = method.getParameterTypes(); + if (params.length == 2 + && HttpServletRequest.class.isAssignableFrom(params[0]) + && HttpServletResponse.class.isAssignableFrom(params[1])) { + + final String requestPath = "/"+mapping.get().requestPath(); + + if (mappings.computeIfAbsent(mapping.get().method(), k -> new HashMap<>()). + putIfAbsent(requestPath, + (req, resp) -> invokeMapping(method, req, resp)) != null) { + LOG.warn("{} {} has multiple mappings", + mapping.get().method(), + mapping.get().requestPath() + ); + } + + LOG.debug("{} {} maps to {}::{}", + mapping.get().method(), + requestPath, + getClass().getSimpleName(), + method.getName() + ); + } else { + LOG.warn("{} is annotated with {} but has the wrong parameters - (HttpServletRequest,HttpServletResponse) required", + method.getName(), RequestMapping.class.getSimpleName() + ); + } + } + } + } catch (SecurityException ex) { + LOG.error("Scan for request mappings on declared methods failed.", ex); + } + } + + @Override + public void destroy() { + mappings.clear(); + LOG.trace("{} destroyed", getServletName()); + } + + /** + * Sets the name of the dynamic fragment. + * + * It is sufficient to specify the name without any extension. The extension + * is added automatically if not specified. + * + * The fragment must be located in the dynamic fragments folder. + * + * @param req the servlet request object + * @param fragmentName the name of the fragment + * @see Constants#DYN_FRAGMENT_PATH_PREFIX + */ + public void setDynamicFragment(HttpServletRequest req, String fragmentName) { + req.setAttribute(Constants.REQ_ATTR_FRAGMENT, Functions.dynFragmentPath(fragmentName)); + } + + /** + * Specifies the name of an additional stylesheet used by the module. + * + * Setting an additional stylesheet is optional, but quite common for HTML + * output. + * + * It is sufficient to specify the name without any extension. The extension + * is added automatically if not specified. + * + * @param req the servlet request object + * @param stylesheet the name of the stylesheet + */ + public void setStylesheet(HttpServletRequest req, String stylesheet) { + req.setAttribute(Constants.REQ_ATTR_STYLESHEET, Functions.enforceExt(stylesheet, ".css")); + } + + private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp) + throws IOException, ServletException { + + req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu(getDatabaseFacade())); + req.getRequestDispatcher(HTML_FULL_DISPATCHER).forward(req, resp); + } + + private Optional findMapping(HttpMethod method, HttpServletRequest req) { + return Optional.ofNullable(mappings.get(method)).map( + (rm) -> rm.get(Optional.ofNullable(req.getPathInfo()).orElse("/")) + ); + } + + private void forwardAsSepcified(ResponseType type, HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + switch (type) { + case NONE: return; + case HTML_FULL: + forwardToFullView(req, resp); + return; + // TODO: implement remaining response types + default: + // this code should be unreachable + LOG.error("ResponseType switch is not exhaustive - this is a bug!"); + throw new UnsupportedOperationException(); + } + } + + private void doProcess(HttpMethod method, HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + // Synchronize module information with database + getModuleManager().syncWithDatabase(getDatabaseFacade()); + + // choose the requested language as session language (if available) or fall back to english, otherwise + HttpSession session = req.getSession(); + if (session.getAttribute(Constants.SESSION_ATTR_LANGUAGE) == null) { + Optional> availableLanguages = Functions.availableLanguages(getServletContext()).map(Arrays::asList); + Optional reqLocale = Optional.of(req.getLocale()); + Locale sessionLocale = reqLocale.filter((rl) -> availableLanguages.map((al) -> al.contains(rl.getLanguage())).orElse(false)).orElse(Locale.ENGLISH); + session.setAttribute(Constants.SESSION_ATTR_LANGUAGE, sessionLocale); + LOG.debug("Settng language for new session {}: {}", session.getId(), sessionLocale.getDisplayLanguage()); + } else { + Locale sessionLocale = (Locale) session.getAttribute(Constants.SESSION_ATTR_LANGUAGE); + resp.setLocale(sessionLocale); + LOG.trace("Continuing session {} with language {}", session.getId(), sessionLocale); + } + + // set some internal request attributes + req.setAttribute(Constants.REQ_ATTR_PATH, Functions.fullPath(req)); + req.setAttribute(Constants.REQ_ATTR_MODULE_CLASSNAME, this.getClass().getName()); + moduleInfoELProxy.ifPresent((proxy) -> req.setAttribute(Constants.REQ_ATTR_MODULE_INFO, proxy)); + + + // call the handler, if available, or send an HTTP 404 error + Optional mapping = findMapping(method, req); + if (mapping.isPresent()) { + forwardAsSepcified(mapping.get().apply(req, resp), req, resp); + } else { + resp.sendError(HttpServletResponse.SC_NOT_FOUND); + } + } + + @Override + protected final void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + doProcess(HttpMethod.GET, req, resp); + } + + @Override + protected final void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + doProcess(HttpMethod.POST, req, resp); + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/Constants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/Constants.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,106 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import static de.uapcore.lightpit.Functions.fqn; + +/** + * Contains all non-local scope constants used by the this application. + * + * Constants with (class) local scope are defined in their respective classes. + */ +public final class Constants { + public static final String JSP_PATH_PREFIX = "/WEB-INF/jsp/"; + + public static final String JSPF_PATH_PREFIX = "/WEB-INF/jspf/"; + + public static final String DYN_FRAGMENT_PATH_PREFIX = "/WEB-INF/dynamic_fragments/"; + + + /** + * Name for the context parameter specifying the available languages. + */ + public static final String CTX_ATTR_LANGUAGES = "available-languages"; + + /** + * Name for the context parameter optionally specifying the JNDI context; + */ + public static final String CTX_ATTR_JNDI_CONTEXT = "jndi-context"; + + /** + * Name for the context parameter optionally specifying a database schema. + */ + public static final String CTX_ATTR_DB_SCHEMA = "db-schema"; + + /** + * Name for the context parameter optionally specifying a database dialect. + */ + public static final String CTX_ATTR_DB_DIALECT = "db-dialect"; + + /** + * Key for the request attribute containing the class name of the currently dispatching module. + */ + public static final String REQ_ATTR_MODULE_CLASSNAME = fqn(AbstractLightPITServlet.class, "moduleClassname"); + + /** + * Key for the request attribute containing the {@link LightPITModule} information of the currently dispatching module. + */ + public static final String REQ_ATTR_MODULE_INFO = fqn(AbstractLightPITServlet.class, "moduleInfo"); + + /** + * Key for the request attribute containing the menu list. + */ + public static final String REQ_ATTR_MENU = fqn(AbstractLightPITServlet.class, "mainMenu"); + + /** + * Key for the request attribute containing the full path information (servlet path + path info). + */ + public static final String REQ_ATTR_PATH = fqn(AbstractLightPITServlet.class, "path"); + + /** + * Key for the name of the fragment which should be rendered. + */ + public static final String REQ_ATTR_FRAGMENT = fqn(AbstractLightPITServlet.class, "fragment"); + + /** + * Key for the name of the additional stylesheet used by a module. + */ + public static final String REQ_ATTR_STYLESHEET = fqn(AbstractLightPITServlet.class, "extraCss"); + + + /** + * Key for the current language selection within the session. + */ + public static final String SESSION_ATTR_LANGUAGE = fqn(AbstractLightPITServlet.class, "language"); + + /** + * This class is not instantiatable. + */ + private Constants() {} +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/DatabaseFacade.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/DatabaseFacade.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,178 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.util.Optional; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; +import javax.sql.DataSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides access to different privilege layers within the database. + */ +@WebListener +public final class DatabaseFacade implements ServletContextListener { + + private static final Logger LOG = LoggerFactory.getLogger(DatabaseFacade.class); + + /** + * Timeout in seconds for the validation test. + */ + private static final int DB_TEST_TIMEOUT = 10; + + public static enum Dialect { + Postgres; + } + + /** + * The database dialect to use. + * + * May be override by context parameter. + * + * @see Constants#CTX_ATTR_DB_DIALECT + */ + private Dialect dialect = Dialect.Postgres; + + /** + * The default schema to test against when validating the connection. + * + * May be overridden by context parameter. + * + * @see Constants#CTX_ATTR_DB_SCHEMA + */ + private static final String DB_DEFAULT_SCHEMA = "lightpit"; + + /** + * The attribute name in the Servlet context under which an instance of this class can be found. + */ + public static final String SC_ATTR_NAME = DatabaseFacade.class.getName(); + private ServletContext sc; + + private static final String DS_JNDI_NAME = "jdbc/lightpit/app"; + private Optional dataSource; + + /** + * Returns the data source. + * + * The Optional returned should never be empty. However, if something goes + * wrong during initialization, the data source might be absent. + * Hence, users of this data source are forced to check the existence. + * + * @return a data source + */ + public Optional getDataSource() { + return dataSource; + } + + public Dialect getSQLDialect() { + return dialect; + } + + private static void checkConnection(DataSource ds, String testSchema, String errMsg) { + try (Connection conn = ds.getConnection()) { + if (!conn.isValid(DB_TEST_TIMEOUT)) { + throw new SQLException("Validation check failed."); + } + if (conn.isReadOnly()) { + throw new SQLException("Connection is read-only and thus unusable."); + } + if (!conn.getSchema().equals(testSchema)) { + throw new SQLException(String.format("Connection is not configured to use the schema %s.", testSchema)); + } + DatabaseMetaData metaData = conn.getMetaData(); + LOG.info("Connections as {} to {}/{} ready to go.", metaData.getUserName(), metaData.getURL(), conn.getSchema()); + } catch (SQLException ex) { + LOG.error(errMsg, ex); + } + } + + private static Optional retrieveDataSource(Context ctx) { + DataSource ret = null; + try { + ret = (DataSource)ctx.lookup(DS_JNDI_NAME); + LOG.info("Data source retrieved."); + } catch (NamingException ex) { + LOG.error("Data source {} not available.", DS_JNDI_NAME); + LOG.error("Reason for the missing data source: ", ex); + } + return Optional.ofNullable(ret); + } + + @Override + public void contextInitialized(ServletContextEvent sce) { + sc = sce.getServletContext(); + + dataSource = null; + + final String contextName = Optional + .ofNullable(sc.getInitParameter(Constants.CTX_ATTR_JNDI_CONTEXT)) + .orElse("java:comp/env"); + final String dbSchema = Optional + .ofNullable(sc.getInitParameter(Constants.CTX_ATTR_DB_SCHEMA)) + .orElse(DB_DEFAULT_SCHEMA); + final String dbDialect = sc.getInitParameter(Constants.CTX_ATTR_DB_DIALECT); + if (dbDialect != null) { + try { + dialect = Dialect.valueOf(dbDialect); + } catch (IllegalArgumentException ex) { + LOG.error("Unknown or unsupported database dialect {}. Defaulting to {}.", dbDialect, dialect); + } + } + + try { + LOG.debug("Trying to access JNDI context {}...", contextName); + Context initialCtx = new InitialContext(); + Context ctx = (Context) initialCtx.lookup(contextName); + + dataSource = retrieveDataSource(ctx); + + dataSource.ifPresent((ds) -> checkConnection(ds, dbSchema, "Checking database connection failed")); + } catch (NamingException | ClassCastException ex) { + LOG.error("Cannot access JNDI resources.", ex); + } + + sc.setAttribute(SC_ATTR_NAME, this); + LOG.info("Database facade injected into ServletContext."); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + dataSource = null; + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/Functions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/Functions.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,113 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import java.util.Optional; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Contains common static functions. + */ +public final class Functions { + + private static final Logger LOG = LoggerFactory.getLogger(Functions.class); + + public static Optional availableLanguages(ServletContext ctx) { + return Optional.ofNullable(ctx.getInitParameter(Constants.CTX_ATTR_LANGUAGES)).map((x) -> x.split("\\s*,\\s*")); + } + + public static String enforceExt(String filename, String ext) { + return filename.endsWith(ext) ? filename : filename + ext; + } + + public static String jspPath(String filename) { + return enforceExt(Constants.JSP_PATH_PREFIX + filename, ".jsp"); + } + + public static String jspfPath(String filename) { + return enforceExt(Constants.JSPF_PATH_PREFIX + filename, ".jspf"); + } + + public static String dynFragmentPath(String filename) { + return enforceExt(Constants.DYN_FRAGMENT_PATH_PREFIX + filename, ".jsp"); + } + + public static String fqn(String base, String name) { + return base+"."+name; + } + + public static String fqn(Class clazz, String name) { + return fqn(clazz.getName(), name); + } + + public static String fullPath(LightPITModule module, RequestMapping mapping) { + StringBuilder sb = new StringBuilder(); + sb.append(module.modulePath()); + sb.append('/'); + if (!mapping.requestPath().isEmpty()) { + sb.append(mapping.requestPath().isEmpty()); + sb.append('/'); + } + return sb.toString(); + } + + public static String fullPath(HttpServletRequest req) { + return req.getServletPath() + Optional.ofNullable(req.getPathInfo()).orElse(""); + } + + /** + * Returns the module path of the given LightPIT Servlet module. + * + * If you specify a malformed LightPIT servlet, which does not have a module + * annotation, the path to the /error/404.html page is returned. + * + * @param clazz the servlet class + * @return the module path + */ + public static String modulePathOf(Class clazz) { + Optional moduleInfo = Optional.ofNullable(clazz.getAnnotation(LightPITModule.class)); + if (moduleInfo.isPresent()) { + return moduleInfo.get().modulePath(); + } else { + LOG.warn( + "{} is a LightPIT Servlet but is missing the module annotation.", + clazz.getName() + ); + return "/error/404.html"; + } + } + + /** + * This class is not instantiatable. + */ + private Functions() {} +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/HttpMethod.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/HttpMethod.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,34 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + + +public enum HttpMethod { + GET, POST, PUT, DELETE, TRACE, HEAD, OPTIONS +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/LightPITModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/LightPITModule.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,170 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.servlet.annotation.WebServlet; + + +/** + * Contains information about a LightPIT module. + * + * This annotation is typically used to annotate the {@link WebServlet} which + * implements the module's functionality. + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface LightPITModule { + /** + * Base name of the module specific resource bundle. + * @return a base name suitable for the JSTL tag 'setBundle'. + */ + String bundleBaseName(); + + /** + * An array of required modules, identified by the string representation of + * their class names. + * @return an array of class names of required modules + */ + String[] requires() default {}; + + /** + * The path for this module, which will also be used for the menu entry. + * + * This path must adhere to the URL pattern of the Servlet but must not + * contain any starting or trailing slashes. + * + * @return the relative module path + */ + String modulePath(); + + /** + * Returns the properties key for the module name. + * + * @return the properties key + */ + String nameKey() default "name"; + + /** + * Returns the properties key for the module description. + * + * @return the properties key + */ + String descKey() default "description"; + + + /** + * Returns the properties key for the menu label. + * + * Set this string to empty string, if the module should be hidden from + * the menu. + * + * @return the properties key + */ + String menuKey() default "menuLabel"; + + /** + * Returns the properties key for the page title. + * + * By default this is the same as the menu label. + * + * @return the properties key + */ + String titleKey() default "menuLabel"; + + /** + * If set to true, this module is always loaded, but never + * visible in the menu or the Web UI module manager. + * + * @return true, if this is a system module + */ + boolean systemModule() default false; + + /** + * Class representing the annotation. + * This is necessary, because the EL resolver cannot deal with + * annotation objects. + * + * Note, that only the properties which are interesting for the JSP pages + * are proxied by this object. + */ + public static class ELProxy { + private final String bundleBaseName, modulePath, menuKey, titleKey, nameKey, descKey; + + public static ELProxy convert(LightPITModule annotation) { + return new ELProxy( + annotation.bundleBaseName(), + annotation.modulePath(), + annotation.menuKey(), + annotation.titleKey(), + annotation.nameKey(), + annotation.descKey() + ); + } + + private ELProxy(String bundleBaseName, String modulePath, String menuKey, String titleKey, String nameKey, String descKey) { + this.bundleBaseName = bundleBaseName; + this.modulePath = modulePath; + this.menuKey = menuKey; + this.titleKey = titleKey; + this.nameKey = nameKey; + this.descKey = descKey; + } + + public String getBundleBaseName() { + return bundleBaseName; + } + + public String getMenuKey() { + return menuKey; + } + + public String getModulePath() { + return modulePath; + } + + public String getTitleKey() { + return titleKey; + } + + public String getNameKey() { + return nameKey; + } + + public String getDescKey() { + return descKey; + } + + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/Menu.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/Menu.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,97 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Maps a resource key for the menu label to the path name for the underlying + * site. + * + * Objects of this class are internally instantiated by the + * {@link ModuleManager}. + */ +public class Menu extends MenuEntry { + + private final List entries = new ArrayList<>(); + private final List immutableEntries = Collections.unmodifiableList(entries); + + /** + * Class name of the module for which this menu is built. + */ + private String moduleClassName; + + + public Menu() { + super(); + } + + public Menu(String moduleClassName, ResourceKey resourceKey, String pathName) { + super(resourceKey, pathName); + this.moduleClassName = moduleClassName; + } + + public void setModuleClassName(String moduleClassName) { + this.moduleClassName = moduleClassName; + } + + public String getModuleClassName() { + return moduleClassName; + } + + /** + * Sets a new list of menu entries for this menu. + * + * @param entries the list of new menu entries + */ + public void setEntries(List entries) { + // in case the given list is immutable, we copy the contents + this.entries.clear(); + this.entries.addAll(entries); + } + + /** + * Retrieves an immutable list of menu entries for this menu. + * + * @return the list of menu entries + */ + public List getEntries() { + return immutableEntries; + } + + /** + * Adds a new menu entry to this menu. + * @param entry the menu entry to add + */ + public void addMenuEntry(MenuEntry entry) { + entries.add(entry); + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/MenuEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/MenuEntry.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,74 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +/** + * Maps a resource key for the menu label to the path name for the underlying + * site. + * + * Objects of this class are internally instantiated by the + * {@link ModuleManager}. + */ +public class MenuEntry { + + /** + * Resource key for the menu label. + */ + private ResourceKey resourceKey; + + /** + * Path name of the module, linked by this menu entry. + */ + private String pathName; + + public MenuEntry() { + } + + public MenuEntry(ResourceKey resourceKey, String pathName) { + this.resourceKey = resourceKey; + this.pathName = pathName; + } + + public void setResourceKey(ResourceKey resourceKey) { + this.resourceKey = resourceKey; + } + + public ResourceKey getResourceKey() { + return resourceKey; + } + + public void setPathName(String pathName) { + this.pathName = pathName; + } + + public String getPathName() { + return pathName; + } + +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/ModuleManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/ModuleManager.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,231 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import de.uapcore.lightpit.entities.CoreDAOFactory; +import de.uapcore.lightpit.entities.Module; +import de.uapcore.lightpit.entities.ModuleDao; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; +import javax.servlet.Registration; +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Scans registered servlets for LightPIT modules. + */ +@WebListener +public final class ModuleManager implements ServletContextListener { + + private static final Logger LOG = LoggerFactory.getLogger(ModuleManager.class); + + /** + * The attribute name in the servlet context under which an instance of this class can be found. + */ + public static final String SC_ATTR_NAME = ModuleManager.class.getName(); + private ServletContext sc; + + /** + * Maps class names to module information. + */ + private final Map registeredModules = new HashMap<>(); + + /** + * This flag is true, when synchronization is needed. + */ + private final AtomicBoolean dirty = new AtomicBoolean(true); + + @Override + public void contextInitialized(ServletContextEvent sce) { + sc = sce.getServletContext(); + reloadAll(); + sc.setAttribute(SC_ATTR_NAME, this); + LOG.info("Module manager injected into ServletContext."); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + unloadAll(); + } + + private Optional getModuleInfo(Registration reg) { + try { + final Class scclass = Class.forName(reg.getClassName()); + + final boolean lpservlet = AbstractLightPITServlet.class.isAssignableFrom(scclass); + final boolean lpmodule = scclass.isAnnotationPresent(LightPITModule.class); + + if (lpservlet && !lpmodule) { + LOG.warn( + "{} is a LightPIT Servlet but is missing the module annotation.", + reg.getClassName() + ); + } else if (!lpservlet && lpmodule) { + LOG.warn( + "{} is annotated as a LightPIT Module but does not extend {}.", + reg.getClassName(), + AbstractLightPITServlet.class.getSimpleName() + ); + } + + if (lpservlet && lpmodule) { + final Class clazz = scclass; + final LightPITModule moduleInfo = clazz.getAnnotation(LightPITModule.class); + return Optional.of(moduleInfo); + } else { + return Optional.empty(); + } + } catch (ClassNotFoundException ex) { + LOG.error( + "Servlet registration refers to class {} which cannot be found by the class loader (Reason: {})", + reg.getClassName(), + ex.getMessage() + ); + return Optional.empty(); + } + } + + private void handleServletRegistration(String name, Registration reg) { + final Optional moduleInfo = getModuleInfo(reg); + if (moduleInfo.isPresent()) { + registeredModules.put(reg.getClassName(), moduleInfo.get()); + LOG.info("Module detected: {}", name); + } else { + LOG.debug("Servlet {} is no module, skipping.", name); + } + } + + /** + * Scans for modules and reloads them all. + */ + public void reloadAll() { + registeredModules.clear(); + sc.getServletRegistrations().forEach(this::handleServletRegistration); + + // TODO: implement dependency resolver + + dirty.set(true); + LOG.info("Modules loaded."); + } + + /** + * Synchronizes module information with the database. + * + * This must be called from the {@link AbstractLightPITServlet}. + * Admittedly the call will perform the synchronization once after reload + * and be a no-op, afterwards. + * However, we since the DatabaseFacade might be loaded after the module + * manager, we must defer the synchronization to the first request + * handled by the Servlet. + * + * @param db interface to the database + */ + public void syncWithDatabase(DatabaseFacade db) { + if (dirty.compareAndSet(true, false)) { + if (db.getDataSource().isPresent()) { + try (Connection conn = db.getDataSource().get().getConnection()) { + final ModuleDao moduleDao = CoreDAOFactory.getModuleDao(db.getSQLDialect()); + moduleDao.syncRegisteredModuleClasses(conn, registeredModules.entrySet()); + } catch (SQLException ex) { + LOG.error("Unexpected SQL Exception", ex); + } + } else { + LOG.error("No datasource present. Cannot sync module information with database."); + } + } else { + LOG.trace("Module information clean - no synchronization required."); + } + } + + /** + * Unloads all found modules. + */ + public void unloadAll() { + registeredModules.clear(); + LOG.info("All modules unloaded."); + } + + /** + * Returns the main menu. + * + * @param db the interface to the database + * @return a list of menus belonging to the main menu + */ + public List getMainMenu(DatabaseFacade db) { + // TODO: user specific menu + + if (db.getDataSource().isPresent()) { + try (Connection conn = db.getDataSource().get().getConnection()) { + final ModuleDao dao = CoreDAOFactory.getModuleDao(db.getSQLDialect()); + final List modules = dao.listAll(conn); + + final List menu = modules + .stream() + .filter((mod) -> mod.isVisible()) + .collect(Collectors.mapping( + (mod) -> new Menu( + mod.getClassname(), + new ResourceKey( + registeredModules.get(mod.getClassname()).bundleBaseName(), + registeredModules.get(mod.getClassname()).menuKey()), + registeredModules.get(mod.getClassname()).modulePath()), + Collectors.toList()) + ); + return menu; + } catch (SQLException ex) { + LOG.error("Unexpected SQLException when loading the main menu", ex); + return Collections.emptyList(); + } + } else { + return Collections.emptyList(); + } + } + + /** + * Returns an unmodifiable map of all registered modules. + * + * The key is the classname of the module. + * + * @return the map of registered modules + */ + public Map getRegisteredModules() { + return Collections.unmodifiableMap(registeredModules); + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/RequestMapping.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/RequestMapping.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,76 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Maps requests to methods. + * + * This annotation is used to annotate methods within classes which + * override {@link AbstractLightPITServlet}. + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface RequestMapping { + + /** + * Specifies the HTTP method. + * + * @return the HTTP method handled by the annotated Java method + */ + HttpMethod method(); + + /** + * Specifies the request path relative to the module path. + * + * If a menu key is specified, this is also the path, which is linked + * by the menu entry. + * + * The path must be specified without leading and trailing slash. + * + * @return the request path the annotated method should handle + */ + String requestPath() default ""; + + /** + * Returns the properties key for the (sub) menu label. + * + * This should only be used for {@link HttpMethod#GET} requests. + * + * @return the properties key + */ + String menuKey() default ""; +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/ResourceKey.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/ResourceKey.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + +/** + * Fully specifies a resource key by the bundle and the key name. + */ +public final class ResourceKey { + private String bundle; + private String key; + + public ResourceKey() { + + } + + public ResourceKey(String bundle, String key) { + this.bundle = bundle; + this.key = key; + } + + public void setBundle(String bundle) { + this.bundle = bundle; + } + + public String getBundle() { + return bundle; + } + + public void setKey(String key) { + this.key = key; + } + + public String getKey() { + return key; + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/ResponseType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/ResponseType.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,56 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit; + + +public enum ResponseType { + /** + * Renders a full HTML view including the header. + */ + HTML_FULL, + /** + * Renders a HTML fragment only. + * May be used for AJAX responses. + */ + HTML_FRAGMENT, + /** + * Returns a fragment with content type 'text/plain'. + */ + PLAIN, + /** + * Returns an object in JSON format and with content type + * 'application/json'. + */ + JSON, + /** + * The handler already sent the output, nothing should be done + * additionally by the Servlet. + */ + NONE +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/entities/CoreDAOFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/entities/CoreDAOFactory.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,47 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.entities; + +import de.uapcore.lightpit.DatabaseFacade; + +public final class CoreDAOFactory { + + private CoreDAOFactory() {} + + private static class PostgresDaos { + static final ModuleDao MODULE_DAO = new PostgresModuleDao(); + } + + public static ModuleDao getModuleDao(DatabaseFacade.Dialect dialect) { + switch (dialect) { + case Postgres: return PostgresDaos.MODULE_DAO; + default: assert(false); return null; + } + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/entities/Module.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/entities/Module.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,90 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.entities; + +import de.uapcore.lightpit.LightPITModule; + +public final class Module { + private int modID; + private String classname; + private boolean visible; + + private LightPITModule.ELProxy annotatedInfos; + + public int getModID() { + return modID; + } + + public void setModID(int modID) { + this.modID = modID; + } + + public String getClassname() { + return classname; + } + + public void setClassname(String classname) { + this.classname = classname; + } + + public boolean isVisible() { + return visible; + } + + public void setVisible(boolean visible) { + this.visible = visible; + } + + public LightPITModule.ELProxy getAnnotatedInfos() { + return annotatedInfos; + } + + public void setAnnotatedInfos(LightPITModule.ELProxy annotatedInfos) { + this.annotatedInfos = annotatedInfos; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 41 * hash + this.modID; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } else { + return this.modID == ((Module) obj).modID; + } + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/entities/ModuleDao.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/entities/ModuleDao.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,141 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.entities; + +import de.uapcore.lightpit.LightPITModule; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public abstract class ModuleDao { + + /** + * Maps database columns to POJO fields. + * @param result the database result set + * @param mod the POJO + * @throws SQLException + */ + protected void mapColumns(ResultSet result, Module mod) throws SQLException { + mod.setModID(result.getInt("modid")); + mod.setClassname(result.getString("classname")); + mod.setVisible(result.getBoolean("visible")); + } + + + /** + * Must return a prepared statement for a single object query with the specified properties. + * + *
    + *
  • Parameter 1: classname
  • + *
  • Result field 1: visible
  • + *
+ * + * @param conn the connection to use + * @return the prepared statement + * @throws SQLException + */ + protected PreparedStatement moduleCheckStatement(Connection conn) throws SQLException { + return conn.prepareStatement("SELECT visible FROM lpitcore_module WHERE classname = ?"); + } + + /** + * Must return a prepared statement for insertion with the specified properties. + * + *
    + *
  • Parameter 1: classname
  • + *
  • Parameter 2: visible
  • + *
+ * + * @param conn the connection to use + * @return the prepared statement + * @throws SQLException + */ + protected PreparedStatement moduleInsertStatement(Connection conn) throws SQLException { + return conn.prepareStatement("INSERT INTO lpitcore_module (classname, visible) VALUES (?, ?)"); + } + + /** + * Synchronizes a set of registered module classes with the database. + * + * Inserts module classes which are not known to the database and sets them to be visible by default. + * Module classes known to the database, which are not in the given set, are ignored. + * + * @param conn the connection to use + * @param moduleSet the module set to synchronize + * @throws SQLException + */ + public final void syncRegisteredModuleClasses(Connection conn, Set> moduleSet) throws SQLException { + + PreparedStatement + check = moduleCheckStatement(conn), + insert = moduleInsertStatement(conn); + insert.setBoolean(2, true); + // update/delete not required, we do this in the module management UI + + for (Map.Entry modEntry : moduleSet) { + if (modEntry.getValue().systemModule()) continue; + + check.setString(1, modEntry.getKey()); + try (ResultSet r = check.executeQuery()) { + if (!r.next()) { + insert.setString(1, modEntry.getKey()); + insert.executeUpdate(); + } + } + } + } + + /** + * Returns a list of all modules known by the database. + * + * Keep in mind, that system modules are never known to the database. + * + * @param conn the connection to use + * @return a list of all modules known by the database + * @throws SQLException + */ + public List listAll(Connection conn) throws SQLException { + List list = new ArrayList<>(); + try (Statement stmt = conn.createStatement(); + ResultSet result = stmt.executeQuery("SELECT * FROM lpitcore_module")) { + while (result.next()) { + final Module mod = new Module(); + mapColumns(result, mod); + list.add(mod); + } + } + return list; + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/entities/PostgresModuleDao.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/entities/PostgresModuleDao.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,33 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.entities; + +public class PostgresModuleDao extends ModuleDao { + // No overrides needed. +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/entities/User.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/entities/User.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,92 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.entities; + +import java.util.Optional; + +public final class User { + + public static final int ANONYMOUS_USERID = -1; + + private int userID; + private String username; + private Optional givenname; + private Optional lastname; + + public int getUserID() { + return userID; + } + + public void setUserID(int userID) { + this.userID = userID; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Optional getGivenname() { + return givenname; + } + + public void setGivenname(Optional givenname) { + this.givenname = givenname; + } + + public Optional getLastname() { + return lastname; + } + + public void setLastname(Optional lastname) { + this.lastname = lastname; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 41 * hash + this.userID; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } else { + return this.userID == ((User) obj).userID; + } + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/entities/UserDao.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/entities/UserDao.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,77 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.entities; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public abstract class UserDao { + + /** + * Maps SQL columns to POJO fields. + * @param result the database result set + * @param user the POJO + * @throws SQLException + */ + protected void mapColumns(ResultSet result, User user) throws SQLException { + user.setUserID(result.getInt("userid")); + user.setUsername(result.getString("username")); + user.setGivenname(Optional.ofNullable(result.getString("givenname"))); + user.setLastname(Optional.ofNullable(result.getString("lastname"))); + } + + /** + * Returns a list of all users ordered by their username. + * + * Does not return reserved system users with negative user IDs. + * + * @param conn the connection to use + * @return a list of all users + * @throws SQLException + */ + public List listAll(Connection conn) throws SQLException { + List list = new ArrayList<>(); + try ( + Statement stmt = conn.createStatement(); + ResultSet result = stmt.executeQuery( + "SELECT * FROM lpitcore_user WHERE userid >= 0 ORDER BY username")) { + while (result.next()) { + final User user = new User(); + mapColumns(result, user); + list.add(user); + } + } + return list; + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/modules/ErrorModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/modules/ErrorModule.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,80 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.modules; + +import de.uapcore.lightpit.LightPITModule; +import de.uapcore.lightpit.AbstractLightPITServlet; +import de.uapcore.lightpit.HttpMethod; +import de.uapcore.lightpit.RequestMapping; +import de.uapcore.lightpit.ResponseType; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Entry point for the application. + */ +@LightPITModule( + bundleBaseName = "localization.error", + modulePath = "error", + titleKey = "title", + systemModule = true +) +@WebServlet( + name = "ErrorModule", + urlPatterns = "/error/*" +) +public final class ErrorModule extends AbstractLightPITServlet { + + public static final String REQ_ATTR_ERROR_CODE = "errorCode"; + + private ResponseType handle(HttpServletRequest req, HttpServletResponse resp, int sc) { + + req.setAttribute(REQ_ATTR_ERROR_CODE, sc); + setStylesheet(req, "error"); + setDynamicFragment(req, "error"); + + return ResponseType.HTML_FULL; + } + + @RequestMapping(requestPath = "404", method = HttpMethod.GET) + public ResponseType handle404(HttpServletRequest req, HttpServletResponse resp) { + return handle(req, resp, 404); + } + + @RequestMapping(requestPath = "403", method = HttpMethod.GET) + public ResponseType handle403(HttpServletRequest req, HttpServletResponse resp) { + return handle(req, resp, 403); + } + + @RequestMapping(requestPath = "500", method = HttpMethod.GET) + public ResponseType handle500(HttpServletRequest req, HttpServletResponse resp) { + return handle(req, resp, 500); + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/modules/HomeModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/modules/HomeModule.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,58 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.modules; + +import de.uapcore.lightpit.LightPITModule; +import de.uapcore.lightpit.AbstractLightPITServlet; +import de.uapcore.lightpit.HttpMethod; +import de.uapcore.lightpit.RequestMapping; +import de.uapcore.lightpit.ResponseType; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Entry point for the application. + */ +@LightPITModule( + bundleBaseName = "localization.home", + modulePath = "home" +) +@WebServlet( + name = "HomeModule", + urlPatterns = "/home/*" +) +public final class HomeModule extends AbstractLightPITServlet { + + @RequestMapping(method = HttpMethod.GET) + public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) { + + return ResponseType.HTML_FULL; + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/modules/LanguageModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/modules/LanguageModule.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,118 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.modules; + +import de.uapcore.lightpit.LightPITModule; +import de.uapcore.lightpit.AbstractLightPITServlet; +import de.uapcore.lightpit.Constants; +import de.uapcore.lightpit.Functions; +import de.uapcore.lightpit.HttpMethod; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import de.uapcore.lightpit.RequestMapping; +import de.uapcore.lightpit.ResponseType; +import java.util.ArrayList; +import java.util.IllformedLocaleException; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import javax.servlet.ServletException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +@LightPITModule( + bundleBaseName = "localization.language", + modulePath = "language" +) +@WebServlet( + name = "LanguageModule", + urlPatterns = "/language/*" +) +public final class LanguageModule extends AbstractLightPITServlet { + + private static final Logger LOG = LoggerFactory.getLogger(LanguageModule.class); + + private final List languages = new ArrayList<>(); + + @Override + public void init() throws ServletException { + super.init(); + + Optional langs = Functions.availableLanguages(getServletContext()); + if (langs.isPresent()) { + for (String lang : langs.get()) { + try { + Locale locale = Locale.forLanguageTag(lang); + if (locale.getLanguage().isEmpty()) { + throw new IllformedLocaleException(); + } + languages.add(locale); + } catch (IllformedLocaleException ex) { + LOG.warn("Specified lanaguge {} in context parameter cannot be mapped to an existing locale - skipping.", lang); + } + } + + } else { + languages.add(Locale.ENGLISH); + LOG.warn("Context parameter 'available-languges' not found. Only english will be available."); + } + } + + @Override + public void destroy() { + super.destroy(); + languages.clear(); + } + + @RequestMapping(method = HttpMethod.GET) + public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) { + + req.setAttribute("languages", languages); + req.setAttribute("browserLanguage", req.getLocale()); + + setStylesheet(req, "language"); + setDynamicFragment(req, "language"); + return ResponseType.HTML_FULL; + } + + @RequestMapping(method = HttpMethod.POST) + public ResponseType switchLanguage(HttpServletRequest req, HttpServletResponse resp) { + + Optional chosenLanguage = Optional.ofNullable(req.getParameter("language")) + .map(Locale::forLanguageTag) + .filter((l) -> !l.getLanguage().isEmpty()); + + chosenLanguage.ifPresent((l) -> req.getSession().setAttribute(Constants.SESSION_ATTR_LANGUAGE, l)); + chosenLanguage.ifPresent(resp::setLocale); + + return handle(req, resp); + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/modules/ModuleManagerModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/modules/ModuleManagerModule.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,94 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.modules; + +import de.uapcore.lightpit.LightPITModule; +import de.uapcore.lightpit.AbstractLightPITServlet; +import de.uapcore.lightpit.HttpMethod; +import de.uapcore.lightpit.LightPITModule.ELProxy; +import de.uapcore.lightpit.RequestMapping; +import de.uapcore.lightpit.ResponseType; +import de.uapcore.lightpit.entities.CoreDAOFactory; +import de.uapcore.lightpit.entities.Module; +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.sql.DataSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Entry point for the application. + */ +@LightPITModule( + bundleBaseName = "localization.modmgmt", + modulePath = "modmgmt" +) +@WebServlet( + name = "ModuleManagerModule", + urlPatterns = "/modmgmt/*" +) +public final class ModuleManagerModule extends AbstractLightPITServlet { + + private static final Logger LOG = LoggerFactory.getLogger(ModuleManagerModule.class); + + private static final String REQ_ATTR_MODULES = "modules"; + + + @RequestMapping(method = HttpMethod.GET) + public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) throws IOException { + + Optional ds = getDatabaseFacade().getDataSource(); + if (ds.isPresent()) { + try (Connection conn = ds.get().getConnection()) { + final List modules = CoreDAOFactory.getModuleDao(getDatabaseFacade().getSQLDialect()).listAll(conn); + + final Map registeredModules = getModuleManager().getRegisteredModules(); + modules.forEach((mod) -> mod.setAnnotatedInfos(ELProxy.convert(registeredModules.get(mod.getClassname())))); + + req.setAttribute(REQ_ATTR_MODULES, modules); + setDynamicFragment(req, "modules"); + return ResponseType.HTML_FULL; + } catch (SQLException ex) { + LOG.error("Unexpected SQL Exception", ex); + resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ResponseType.NONE; + } + } else { + resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ResponseType.NONE; + } + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/de/uapcore/lightpit/modules/VersionsModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/uapcore/lightpit/modules/VersionsModule.java Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,55 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +package de.uapcore.lightpit.modules; + +import de.uapcore.lightpit.LightPITModule; +import de.uapcore.lightpit.AbstractLightPITServlet; +import de.uapcore.lightpit.HttpMethod; +import de.uapcore.lightpit.RequestMapping; +import de.uapcore.lightpit.ResponseType; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +@LightPITModule( + bundleBaseName = "localization.versions", + modulePath = "versions" +) +@WebServlet( + name = "VersionsModule", + urlPatterns = "/versions/*" +) +public final class VersionsModule extends AbstractLightPITServlet { + @RequestMapping(method = HttpMethod.GET) + public ResponseType handle(HttpServletRequest req, HttpServletResponse resp) { + + return ResponseType.HTML_FULL; + } +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/java/log4j2.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/log4j2.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,36 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +status = warn +dest = err +name = LightPITLoggingConfig + +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = %d{ISO8601} [%highlight{%p}] %c{1}: %m %n + +rootLogger.appenderRef.stdout.ref = STDOUT + +rootLogger.level = debug diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/META-INF/context.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/META-INF/context.xml Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,6 @@ + + + + diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/error.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/error.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,35 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +title = Error + +h1 = The requested page cannot be displayed. +errorCode = Code + +errorMessage = Message +errorMessage.404 = Page not found +errorMessage.403 = Access denied +errorMessage.500 = Internal error + +errorTimestamp = Timestamp +errorExceptionText = Internal Exception diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/error_de.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/error_de.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,35 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +title = Fehler + +h1 = Die angeforderte Seite kann nicht angezeigt werden. +errorCode = Fehlercode + +errorMessage = Nachricht +errorMessage.404 = Seite nicht gefunden +errorMessage.403 = Zugriff verboten +errorMessage.500 = Interner Fehler + +errorTimestamp = Zeitstempel +errorExceptionText = Interne Ausnahme diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/home.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/home.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,26 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Home Page +description = The default page that is displayed when visiting the site. +menuLabel = Home diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/home_de.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/home_de.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,26 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Startseite +description = Die Seite, die dem Benutzer standardm\u00e4\u00dfig beim Besuch angezeigt wird. +menuLabel = Startseite diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/language.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/language.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,30 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Language Selector +description = Where the user can choose his / her language setting. +menuLabel = Languages + +submit = Switch language +browserLanguage = Browser language +browserLanguageNotAvailable = Browser language not available. diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/language_de.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/language_de.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,31 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Sprachauswahl +description = Hier kann der Benutzer die Sprache f\u00fcr die Website ausw\u00e4hlen. + +menuLabel = Sprache + +submit = Sprache ausw\u00e4hlen +browserLanguage = Browsersprache +browserLanguageNotAvailable = Browsersprache nicht verf\u00fcgbar. diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/modmgmt.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/modmgmt.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,36 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Module Management +description = Configure the visible LightPIT modules and the required access powers. +menuLabel = Modules + +section.modlist.title = List of Modules + +caption.module = Module +caption.path = Path +caption.desc = Description +caption.active = Active +caption.class = Class +caption.bundle = Resource Bundle + diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/modmgmt_de.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/modmgmt_de.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,35 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Modulverwaltung +description = Konfiguration der sichtbaren LightPIT Module und deren Zugriffsrechte. +menuLabel = Module + +section.modlist.title = Liste der Module + +caption.module = Modul +caption.path = Pfad +caption.desc = Beschreibung +caption.active = Aktiv +caption.class = Klasse +caption.bundle = Ressourcen-Datei diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/versions.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/versions.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,26 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Version Management +description = Allows the configuration of versions and milestones within your project. +menuLabel = Versions diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/resources/localization/versions_de.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/localization/versions_de.properties Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,26 @@ +# Copyright 2018 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +name = Versionsverwaltung +description = Erlaubt die Konfiguration von Versionen und Meilensteinen im Projekt. +menuLabel = Versionen diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/WEB-INF/dynamic_fragments/error.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/WEB-INF/dynamic_fragments/error.jsp Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,56 @@ +<%-- +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + +Copyright 2018 Mike Becker. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--%> +<%@page pageEncoding="UTF-8" session="true" %> +<%@page import="de.uapcore.lightpit.modules.ErrorModule" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> + + + +
+

+ + + + + + + + + + + + + + + + + + + +
:${errorCode}
:
:
:${exception.class.name} - ${exception.message}
+
diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/WEB-INF/dynamic_fragments/language.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/WEB-INF/dynamic_fragments/language.jsp Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,47 @@ +<%-- +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + +Copyright 2018 Mike Becker. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--%> +<%@page pageEncoding="UTF-8" session="true" %> +<%@page import="de.uapcore.lightpit.Constants" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> + + + +
+ + + + + + + "/> +
diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/WEB-INF/dynamic_fragments/modules.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/WEB-INF/dynamic_fragments/modules.jsp Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,54 @@ +<%-- +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + +Copyright 2018 Mike Becker. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--%> +<%@page pageEncoding="UTF-8" session="true" %> +<%@page import="de.uapcore.lightpit.Constants" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> + +

+ + + + + + + + + + + + + + + + + + + + + +
${module.visible}/${module.annotatedInfos.modulePath}${module.classname}${module.annotatedInfos.bundleBaseName}
\ No newline at end of file diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/WEB-INF/jsp/html_full.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/WEB-INF/jsp/html_full.jsp Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,91 @@ +<%-- +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + +Copyright 2018 Mike Becker. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--%> +<%@page contentType="text/html" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" session="true" %> +<%@page import="de.uapcore.lightpit.Constants" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> + +<%-- Define an alias for the main menu --%> + + +<%-- Define an alias for the fragment name --%> + + +<%-- Define an alias for the additional stylesheet --%> + + +<%-- Define an alias for the module info --%> + + +<%-- Apply the session locale (should always be present, but check nevertheless) --%> + + + + + + + + + LightPIT - + <fmt:bundle basename="${moduleInfo.bundleBaseName}"> + <fmt:message key="${moduleInfo.titleKey}" /> + </fmt:bundle> + + + + + + + + + + +
+ + + + +
+ + diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/WEB-INF/web.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/WEB-INF/web.xml Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,24 @@ + + + + + 30 + + + + available-languages + en,de + + + 404 + /error/404 + + + 403 + /error/403 + + + 500 + /error/500 + + diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/error.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/error.css Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,55 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#error-page h1 { + font-size: 1.5em; +} + +#error-page table { + width: 100%; + + border-top-style: solid; + border-top-width: 1pt; + border-top-color: #606060; + + border-bottom-style: solid; + border-bottom-width: 1pt; + border-bottom-color: #505050; + + border-collapse: separate; + border-spacing: .5em; +} + +#error-page table th { + text-align: right; +} + +#error-page table td { + width: 100%; +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/index.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/index.jsp Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,32 @@ +<%-- +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + +Copyright 2018 Mike Becker. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--%> +<%@page import="de.uapcore.lightpit.Functions" %> +<%@page import="de.uapcore.lightpit.modules.HomeModule" %> +<% +response.setStatus(response.SC_MOVED_TEMPORARILY); +response.setHeader("Location", "./"+Functions.modulePathOf(HomeModule.class)); +%> diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/language.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/language.css Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,46 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#lang-selector { + max-width: 30%; + display: flex; + flex-basis: content; + flex-direction: column; +} + +input { + margin: .5em; +} + +span.blNA { + margin: .5em; + color: red; + font-style: italic; + font-size: smaller; +} diff -r cfc3d11884ad -r 27a0fdd7bca7 src/main/webapp/lightpit.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/lightpit.css Sat May 09 14:26:31 2020 +0200 @@ -0,0 +1,129 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2018 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +html { + background: #f8f8f8; +} + +body { + background: white; + font-family: serif; + + border-color: #505050; + border-style: solid; + border-width: 1pt; + + color: #1c202e; +} + +h1, h2, h3, h4, #mainMenu, #subMenu { + font-family: sans-serif; +} + +a { + color: #3060f8; + text-decoration: none; +} + +#mainMenu { + width: 100%; + display: flex; + flex-flow: row wrap; + background: #f0f0f5; +} + +#subMenu { + background: #f7f7ff; + + border-image: linear-gradient(to right, #606060, rgba(60,60,60,.25)); + border-image-slice: 1; + border-top-style: solid; + border-top-width: 1pt; + border-bottom-style: solid; + border-bottom-width: 1pt; +} + +.menuEntry { + padding: .25em 1em .25em 1em; + border-right-style: solid; + border-right-width: 1pt; + border-right-color: #9095a1; +} + +#mainMenu .menuEntry[data-active] { + background: #e0e0e5; +} + +#subMenu .menuEntry[data-active] { + background: #e7e7ef +} + +#content-area { + padding: 1em; +} + +th { + text-align: left; +} + +table.datatable { + width: 100%; + border-style: solid; + border-width: 1pt; + border-color: black; + border-collapse: collapse; +} + +table.datatable th { + font-weight: bold; + background: lightsteelblue; +} + +table.datatable th, table.datatable td { + border-style: solid; + border-width: 1pt; + border-color: black; + padding: .4em; +} + +table.datatable tr:nth-child(2n) { + background: lightblue; +} + +.hcenter { + text-align: center; +} + +.smalltext { + font-size: smaller; +} + +.nowrap { + white-space: nowrap; +} \ No newline at end of file diff -r cfc3d11884ad -r 27a0fdd7bca7 web/META-INF/context.xml --- a/web/META-INF/context.xml Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ - - - - diff -r cfc3d11884ad -r 27a0fdd7bca7 web/WEB-INF/dynamic_fragments/error.jsp --- a/web/WEB-INF/dynamic_fragments/error.jsp Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -<%-- -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 2018 Mike Becker. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---%> -<%@page pageEncoding="UTF-8" session="true" %> -<%@page import="de.uapcore.lightpit.modules.ErrorModule" %> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - - -
-

- - - - - - - - - - - - - - - - - - - -
:${errorCode}
:
:
:${exception.class.name} - ${exception.message}
-
diff -r cfc3d11884ad -r 27a0fdd7bca7 web/WEB-INF/dynamic_fragments/language.jsp --- a/web/WEB-INF/dynamic_fragments/language.jsp Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -<%-- -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 2018 Mike Becker. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---%> -<%@page pageEncoding="UTF-8" session="true" %> -<%@page import="de.uapcore.lightpit.Constants" %> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - - -
- - - - - - - "/> -
diff -r cfc3d11884ad -r 27a0fdd7bca7 web/WEB-INF/dynamic_fragments/modules.jsp --- a/web/WEB-INF/dynamic_fragments/modules.jsp Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -<%-- -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 2018 Mike Becker. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---%> -<%@page pageEncoding="UTF-8" session="true" %> -<%@page import="de.uapcore.lightpit.Constants" %> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - -

- - - - - - - - - - - - - - - - - - - - - -
${module.visible}/${module.annotatedInfos.modulePath}${module.classname}${module.annotatedInfos.bundleBaseName}
\ No newline at end of file diff -r cfc3d11884ad -r 27a0fdd7bca7 web/WEB-INF/glassfish-web.xml --- a/web/WEB-INF/glassfish-web.xml Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - - /lightpit - - - - Keep a copy of the generated servlet class' java code. - - - diff -r cfc3d11884ad -r 27a0fdd7bca7 web/WEB-INF/jsp/html_full.jsp --- a/web/WEB-INF/jsp/html_full.jsp Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -<%-- -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 2018 Mike Becker. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---%> -<%@page contentType="text/html" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" session="true" %> -<%@page import="de.uapcore.lightpit.Constants" %> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> - -<%-- Define an alias for the main menu --%> - - -<%-- Define an alias for the fragment name --%> - - -<%-- Define an alias for the additional stylesheet --%> - - -<%-- Define an alias for the module info --%> - - -<%-- Apply the session locale (should always be present, but check nevertheless) --%> - - - - - - - - - LightPIT - - <fmt:bundle basename="${moduleInfo.bundleBaseName}"> - <fmt:message key="${moduleInfo.titleKey}" /> - </fmt:bundle> - - - - - - - - - - -
- - - - -
- - diff -r cfc3d11884ad -r 27a0fdd7bca7 web/WEB-INF/web.xml --- a/web/WEB-INF/web.xml Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ - - - - - 30 - - - - available-languages - en,de - - - 404 - /error/404 - - - 403 - /error/403 - - - 500 - /error/500 - - diff -r cfc3d11884ad -r 27a0fdd7bca7 web/error.css --- a/web/error.css Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#error-page h1 { - font-size: 1.5em; -} - -#error-page table { - width: 100%; - - border-top-style: solid; - border-top-width: 1pt; - border-top-color: #606060; - - border-bottom-style: solid; - border-bottom-width: 1pt; - border-bottom-color: #505050; - - border-collapse: separate; - border-spacing: .5em; -} - -#error-page table th { - text-align: right; -} - -#error-page table td { - width: 100%; -} diff -r cfc3d11884ad -r 27a0fdd7bca7 web/index.jsp --- a/web/index.jsp Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -<%-- -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 2018 Mike Becker. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---%> -<%@page import="de.uapcore.lightpit.Functions" %> -<%@page import="de.uapcore.lightpit.modules.HomeModule" %> -<% -response.setStatus(response.SC_MOVED_TEMPORARILY); -response.setHeader("Location", "./"+Functions.modulePathOf(HomeModule.class)); -%> diff -r cfc3d11884ad -r 27a0fdd7bca7 web/language.css --- a/web/language.css Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#lang-selector { - max-width: 30%; - display: flex; - flex-basis: content; - flex-direction: column; -} - -input { - margin: .5em; -} - -span.blNA { - margin: .5em; - color: red; - font-style: italic; - font-size: smaller; -} diff -r cfc3d11884ad -r 27a0fdd7bca7 web/lightpit.css --- a/web/lightpit.css Sun Apr 08 16:51:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2018 Mike Becker. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -html { - background: #f8f8f8; -} - -body { - background: white; - font-family: serif; - - border-color: #505050; - border-style: solid; - border-width: 1pt; - - color: #1c202e; -} - -h1, h2, h3, h4, #mainMenu, #subMenu { - font-family: sans-serif; -} - -a { - color: #3060f8; - text-decoration: none; -} - -#mainMenu { - width: 100%; - display: flex; - flex-flow: row wrap; - background: #f0f0f5; -} - -#subMenu { - background: #f7f7ff; - - border-image: linear-gradient(to right, #606060, rgba(60,60,60,.25)); - border-image-slice: 1; - border-top-style: solid; - border-top-width: 1pt; - border-bottom-style: solid; - border-bottom-width: 1pt; -} - -.menuEntry { - padding: .25em 1em .25em 1em; - border-right-style: solid; - border-right-width: 1pt; - border-right-color: #9095a1; -} - -#mainMenu .menuEntry[data-active] { - background: #e0e0e5; -} - -#subMenu .menuEntry[data-active] { - background: #e7e7ef -} - -#content-area { - padding: 1em; -} - -th { - text-align: left; -} - -table.datatable { - width: 100%; - border-style: solid; - border-width: 1pt; - border-color: black; - border-collapse: collapse; -} - -table.datatable th { - font-weight: bold; - background: lightsteelblue; -} - -table.datatable th, table.datatable td { - border-style: solid; - border-width: 1pt; - border-color: black; - padding: .4em; -} - -table.datatable tr:nth-child(2n) { - background: lightblue; -} - -.hcenter { - text-align: center; -} - -.smalltext { - font-size: smaller; -} - -.nowrap { - white-space: nowrap; -} \ No newline at end of file