CCM NG: Today's result of getting Bebop running in a full Java EE environement

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3842 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-02-04 14:47:05 +00:00
parent 4527595438
commit c21ab1e5d7
5 changed files with 167 additions and 56 deletions

View File

@ -0,0 +1,65 @@
# -*- text -*-
# This file locates stylesheets, if you are using the
# "PatternStylesheetResolver". Please read the Javadoc for that file for
# the full story.
# Currently the "resource" part is actually "short-circuited", see
# Templating#transformURL(url). As long as we store and synchronize all theme
# files in each server's local file system, we use the direct file apprach to
# avoid unnecessary http request and traffic between client (user) and server!
# Additionally all modules are installed into one webapp context, so the
# webapp tag is redundant, but sort of required by some part of the code.
# Theme with single entry point (e.g Mandalay) managed by themedirector
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/start.xsl
http://::host::/::webapp::/themes/::themedir::/::theme::/start.xsl
# Theme with single entry point (e.g Mandalay) unmanaged default
#http://::host::/resource/::webapp::/themes/mandalay/start.xsl
#http://::host::/::webapp::/themes/mandalay/start.xsl
# Theme with single entry point (e.g Mandalay) unmanaged default
#http://::host::/resource/::webapp::/themes/mandalay/start.xsl
http://::host::/::webapp::/themes/foundry-base/start.xsl
# ==============================================================================
# The following is for multi-entry themes, not used in ScientificCMS
# ==============================================================================
# Output type is for things such as text/javascript
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::.xsl
# Grabs custom item xsl for CMS
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/themes/servlet/content-item/index.xsl?oid=::item_template_oid::&delegated=::item_delegated_url::
# Theme, with optional locale & prefix
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::-::prefix::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::-::prefix::.xsl
# Theme, with optional locale
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::.xsl
# APLAWS generic default, with locale and prefix
# XXX change ROOT -> ccm-ldn-aplaws
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::-::prefix::-::locale::.xsl
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::-::prefix::.xsl
# APLAWS generic default, with locale
# XXX change ROOT -> ccm-ldn-aplaws
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::-::locale::.xsl
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::.xsl
# Global default, from application's own web app
# NOT used by ScientificCMS
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::.xsl

View File

@ -399,8 +399,8 @@ public class PatternStylesheetResolver implements StylesheetResolver {
try {
// Read the source file.
ClassLoader cload = Thread.currentThread().getContextClassLoader();
InputStream stream = cload.getResourceAsStream(path.substring(1));
s_log.debug("got stream using path " + path.substring(1));
InputStream stream = cload.getResourceAsStream(path.substring(0));
s_log.debug("got stream using path " + path.substring(0));
s_log.debug("stream.available is " + stream.available());
m_paths = new ArrayList();

View File

@ -31,20 +31,21 @@ import com.arsdigita.web.LoginSignal;
import com.arsdigita.xml.Document;
import org.apache.shiro.subject.Subject;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.security.PermissionChecker;
import org.libreccm.web.CcmApplication;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.inject.spi.CDI;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import
javax.servlet.http.HttpServletResponse;
import org.libreccm.cdi.utils.CdiUtil;
import static com.arsdigita.ui.admin.AdminConstants.*;
@ -111,7 +112,8 @@ public class AdminServlet
// /////// Some preparational steps ///////////////
/* Determine access privilege: only logged in users may access */
final CdiUtil cdiUtil = new CdiUtil();
final Subject subject = cdiUtil.findBean(Subject.class);
// final Subject subject = cdiUtil.findBean(Subject.class);
final Subject subject = CDI.current().select(Subject.class).get();
final PermissionChecker permissionChecker = cdiUtil.findBean(
PermissionChecker.class);

View File

@ -45,6 +45,7 @@ import com.arsdigita.bebop.parameters.URLParameter;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.kernel.security.SecurityConfig;
import com.arsdigita.ui.UI;
import com.arsdigita.util.UncheckedWrapperException;
import static com.arsdigita.ui.login.LoginConstants.*;
@ -52,6 +53,12 @@ import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.RedirectSignal;
import com.arsdigita.web.ReturnSignal;
import com.arsdigita.web.URL;
import java.util.Iterator;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.CDI;
import javax.servlet.http.HttpServletRequest;
@ -61,6 +68,7 @@ import org.apache.shiro.authc.UsernamePasswordToken;
import org.libreccm.cdi.utils.CdiUtil;
import org.apache.shiro.subject.Subject;
import org.libreccm.configuration.ConfigurationManager;
/**
* A Bebop form that accepts login and password from the user and attempts to
@ -128,14 +136,34 @@ public class UserLoginForm extends Form implements LoginConstants,
final boolean autoRegistrationOn) {
super(FORM_NAME, panel);
securityConfig = SecurityConfig.getConfig();
// final ConfigurationManager confManager = CDI.current().select(
// ConfigurationManager.class).get();
final BeanManager beanManager = CDI.current().getBeanManager();
final Set<Bean<?>> beans = beanManager.getBeans(
ConfigurationManager.class);
final Iterator<Bean<?>> iterator = beans.iterator();
final ConfigurationManager confManager;
if (iterator.hasNext()) {
final Bean<ConfigurationManager> bean = (Bean<ConfigurationManager>) iterator.
next();
final CreationalContext<ConfigurationManager> ctx = beanManager.
createCreationalContext(bean);
confManager = (ConfigurationManager) beanManager.getReference(
bean, ConfigurationManager.class, ctx);
} else {
throw new UncheckedWrapperException(
"Failed to lookup ConfigurationManager");
}
securityConfig = confManager.findConfiguration(SecurityConfig.class);
setMethod(Form.POST);
addInitListener(this);
addValidationListener(this);
addProcessListener(this);
final KernelConfig kernelConfig = KernelConfig.getConfig();
final KernelConfig kernelConfig = confManager.findConfiguration(
KernelConfig.class);
m_autoRegistrationOn = autoRegistrationOn;

View File

@ -19,28 +19,32 @@
package com.arsdigita.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
/**
* Provides the system name of the CCM Spin off (eg aplaws or ScientificCMS) and the version number.
* It's primary use is to provide the theme engine with that information for display. The data
* displayed is stored in the /WEB-INF/systeminformation.properties, which is usually provided by
* the bundle. The ccm-sci-bundle for example provides this file, which can be found in
* {@code ccm-sci-bundle/web/WEB-INF} directory. At the moment it is necessary to update this
* (these) file(s) manually.
* Provides the system name of the CCM Spin off (eg aplaws or ScientificCMS) and
* the version number. It's primary use is to provide the theme engine with that
* information for display. The data displayed is stored in the
* /WEB-INF/systeminformation.properties, which is usually provided by the
* bundle. The ccm-sci-bundle for example provides this file, which can be found
* in {@code ccm-sci-bundle/web/WEB-INF} directory. At the moment it is
* necessary to update this (these) file(s) manually.
*
* A {@code systeminformations.properties} should contain at least these three properties:
* A {@code systeminformations.properties} should contain at least these three
* properties:
* <dl>
* <dt>version</dt>
* <dd>The version of the specific CCM distribution.</dd>
* <dt>appname</dt>
* <dd>The name of the CCM distribution, for example <strong>ScientificCMS</strong>
* <dd>The name of the CCM distribution, for example
* <strong>ScientificCMS</strong>
* <dt>apphomepage</dt>
* <dd>
The URL of the website of the CCM distribution, for example
* The URL of the website of the CCM distribution, for example
* {@code http://www.scientificcms.org}
* </dd>
* </dl>
@ -52,7 +56,8 @@ import java.util.Properties;
public class SystemInformation {
/**
* Map containing all informations provided by the {@code systeminformation.properties} file.
* Map containing all informations provided by the
* {@code systeminformation.properties} file.
*/
private final Map<String, String> sysInfo = new HashMap<String, String>();
/**
@ -61,18 +66,28 @@ public class SystemInformation {
private final static SystemInformation INSTANCE = new SystemInformation();
/**
* The constructor takes care of loading the data from the properties file and placing them into
* {@code HashMap}.
* The constructor takes care of loading the data from the properties file
* and placing them into {@code HashMap}.
*/
public SystemInformation() {
final Properties properties = new Properties();
try {
properties.load(getClass().getResourceAsStream(
"/WEB-INF/systeminformation.properties"));
final InputStream stream = getClass().getResourceAsStream(
"WEB-INF/systeminformation.properties");
if (stream == null) {
properties.put("version", "");
properties.put("appname", "LibreCCM");
properties.put("apphomepage", "http://www.libreccm.org");
} else {
properties.load(stream);
}
// properties.load(getClass().getResourceAsStream(
// "WEB-INF/systeminformation.properties"));
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
for (String key : properties.stringPropertyNames()) {
sysInfo.put(key, properties.getProperty(key));
}
@ -97,7 +112,8 @@ public class SystemInformation {
*/
final public String get(final String key) throws IllegalArgumentException {
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("Parameter key must not be null or empty.");
throw new IllegalArgumentException(
"Parameter key must not be null or empty.");
}
return sysInfo.get(key);
}