CCM NG: Finished migiration to new configuration system. Now all jUnit tests have to be checked.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3809 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
127ff16e59
commit
54f8c657f7
|
|
@ -29,6 +29,7 @@ import com.arsdigita.templating.XSLParameterGenerator;
|
||||||
import com.arsdigita.templating.XSLTemplate;
|
import com.arsdigita.templating.XSLTemplate;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import com.arsdigita.web.CCMDispatcherServlet;
|
||||||
import com.arsdigita.web.Debugger;
|
import com.arsdigita.web.Debugger;
|
||||||
import com.arsdigita.web.TransformationDebugger;
|
import com.arsdigita.web.TransformationDebugger;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
|
|
@ -99,8 +100,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
@Override
|
@Override
|
||||||
public String generateValue(
|
public String generateValue(
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
return Web.getConfig()
|
return CCMDispatcherServlet
|
||||||
.getDispatcherContextPath();
|
.getContextPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -210,8 +211,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
public String generateValue(
|
public String generateValue(
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
Locale selectedLocale
|
Locale selectedLocale
|
||||||
= com.arsdigita.globalization.GlobalizationHelper.
|
= com.arsdigita.globalization.GlobalizationHelper
|
||||||
getSelectedLocale(request);
|
.getSelectedLocale(request);
|
||||||
return (selectedLocale != null)
|
return (selectedLocale != null)
|
||||||
? selectedLocale
|
? selectedLocale
|
||||||
.toString() : "";
|
.toString() : "";
|
||||||
|
|
|
||||||
|
|
@ -1,143 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.arsdigita.runtime;
|
|
||||||
|
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
|
||||||
import com.arsdigita.util.parameter.ErrorList;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AbstractConfig is a base class for groups of customizable
|
|
||||||
* configuration {@link com.arsdigita.util.parameter parameters}. A
|
|
||||||
* CCM Developer wishing to add a new group of configuration
|
|
||||||
* parameters to his application will extend this class and provide a
|
|
||||||
* public noargs constructer that registers his parameters with the
|
|
||||||
* superclass. For example:
|
|
||||||
*
|
|
||||||
* <blockquote><pre>
|
|
||||||
* package com.arsdigita.exampleApp;
|
|
||||||
*
|
|
||||||
* public final class ExampleConfig extends AbstractConfig {
|
|
||||||
*
|
|
||||||
* private Parameter m_string = new StringParameter
|
|
||||||
* ("example.string", Parameter.OPTIONAL, "default");
|
|
||||||
* private Parameter m_integer = new IntegerParameter
|
|
||||||
* ("example.integer", Parameter.OPTIONAL, new Integer(0));
|
|
||||||
* private Parameter m_boolean = new BooleanParameter
|
|
||||||
* ("example.boolean", Parameter.OPTIONAL, Boolean.TRUE);
|
|
||||||
*
|
|
||||||
* public ExampleConfig() {
|
|
||||||
* register(m_string);
|
|
||||||
* register(m_integer);
|
|
||||||
* register(m_boolean);
|
|
||||||
* loadInfo();
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* public String getString() {
|
|
||||||
* return (String) get(m_string);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* public int getInteger() {
|
|
||||||
* return ((Integer) get(m_integer)).intValue();
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* public boolean getBoolean() {
|
|
||||||
* return Boolean.TRUE.equals(get(m_boolean));
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* }
|
|
||||||
* </pre></blockquote>
|
|
||||||
*
|
|
||||||
* When this pattern is followed, the resulting subclass of abstract
|
|
||||||
* config may be used by developers writing java code to access the
|
|
||||||
* values of customizable configuration parameters in a convenient and
|
|
||||||
* type safe manner. In addition, the very same class is also usable
|
|
||||||
* by the ccm configuration tools to allow customization and
|
|
||||||
* validation of the new parameters.
|
|
||||||
*
|
|
||||||
* @author Justin Ross <jross@redhat.com>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public abstract class AbstractConfig extends AbstractParameterContext {
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger
|
|
||||||
(AbstractConfig.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor for subclasses.
|
|
||||||
*/
|
|
||||||
protected AbstractConfig() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads this AbstractConfig object with values from the default
|
|
||||||
* configuration registry. Any errors encountered during
|
|
||||||
* unmarshaling and loading of configuration values are added to
|
|
||||||
* the <code>errors</code> ErrorList. This method should not be
|
|
||||||
* called from the constructor of a config object since the ccm
|
|
||||||
* configuration tools need to be able to construct empty config
|
|
||||||
* objects.
|
|
||||||
*
|
|
||||||
* @param errors The ErrorList used to record errors during
|
|
||||||
* unmarshaling and loading.
|
|
||||||
*
|
|
||||||
* @see ConfigRegistry
|
|
||||||
*/
|
|
||||||
public final void load(ErrorList errors) {
|
|
||||||
ConfigRegistry reg = new ConfigRegistry();
|
|
||||||
reg.load(this, errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invokes the {@link #load(ErrorList)} method with a new and
|
|
||||||
* empty ErrorList for accumulating errors, and returns that
|
|
||||||
* ErrorList. This method can be used in combination with the
|
|
||||||
* {@link ErrorList#check()} method to load and assert that this
|
|
||||||
* configuration object is valid in one simple idiom. For example:
|
|
||||||
*
|
|
||||||
* <blockquote><pre>
|
|
||||||
* ExampleConfig conf = new ExampleConfig();
|
|
||||||
* conf.load().check();
|
|
||||||
* ...
|
|
||||||
* </pre></blockquote>
|
|
||||||
*
|
|
||||||
* @return Errors that may have been encountered during
|
|
||||||
* configuration loading.
|
|
||||||
*
|
|
||||||
* @see #load(ErrorList)
|
|
||||||
*/
|
|
||||||
public final ErrorList load() {
|
|
||||||
ErrorList errs = new ErrorList();
|
|
||||||
load(errs);
|
|
||||||
return errs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use @{link #load()} instead.
|
|
||||||
*/
|
|
||||||
public final ErrorList load(final String resource) {
|
|
||||||
return load();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use @{link #load()} instead.
|
|
||||||
*/
|
|
||||||
public final ErrorList require(final String resource) {
|
|
||||||
return load();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.arsdigita.runtime;
|
|
||||||
|
|
||||||
import com.arsdigita.util.Assert;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subject to change.
|
|
||||||
*
|
|
||||||
* An error to indicate invalid configurations.
|
|
||||||
*
|
|
||||||
* Usage: throw new ConfigError( "message" );
|
|
||||||
*
|
|
||||||
* @author Justin Ross <jross@redhat.com>
|
|
||||||
*/
|
|
||||||
public class ConfigError extends Error {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 5224480607138738741L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new configuration error with the content
|
|
||||||
* <code>message</code>.
|
|
||||||
*
|
|
||||||
* @param message A <code>String</code> describing what's wrong; it cannot
|
|
||||||
* be null
|
|
||||||
*/
|
|
||||||
public ConfigError(final String message) {
|
|
||||||
super(message);
|
|
||||||
|
|
||||||
Assert.exists(message, String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new configuration error with a default message.
|
|
||||||
*/
|
|
||||||
public ConfigError() {
|
|
||||||
super("Configuration is invalid");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,351 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.arsdigita.runtime;
|
|
||||||
|
|
||||||
import com.arsdigita.util.Classes;
|
|
||||||
import com.arsdigita.util.JavaPropertyReader;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
|
||||||
import com.arsdigita.util.parameter.ErrorList;
|
|
||||||
import com.arsdigita.util.parameter.ParameterContext;
|
|
||||||
import com.arsdigita.util.parameter.ParameterReader;
|
|
||||||
import com.arsdigita.xml.XML;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ConfigRegistry class maps between config classes (subclasses of
|
|
||||||
* {@link com.arsdigita.runtime.AbstractConfig}), and a location used
|
|
||||||
* for persisting the values in a config class.
|
|
||||||
*
|
|
||||||
* The ConfigRegistry also stores the set of configured packages for a
|
|
||||||
* particular CCMResourceManager instance.
|
|
||||||
* Additionally it stores a list of URLs for parent configurations that are
|
|
||||||
* used for defaulting values not present in the local configuration.
|
|
||||||
* This mapping is maintained and extended by CCMResourceManager developers through
|
|
||||||
* the use of an XML configuration file placed in the src tree for a
|
|
||||||
* particular package. If a particular package is configured, the
|
|
||||||
* ConfigRegistry class will look in the classpath for a registry
|
|
||||||
* configuration file named <i>package-key</i>.config, and parse the
|
|
||||||
* file according to the following specification:
|
|
||||||
*
|
|
||||||
* <blockquite><pre>
|
|
||||||
* <?xml version="1.0" encoding="utf-8"?>
|
|
||||||
* <registry>
|
|
||||||
* ...
|
|
||||||
* <config class="CLASSNAME"
|
|
||||||
* storage="FILENAME"/>
|
|
||||||
* ...
|
|
||||||
* </registry>
|
|
||||||
* </pre></blockquite>
|
|
||||||
*
|
|
||||||
* The mappings stored by this ConfigRegistry will then be extended to include
|
|
||||||
* the classes and storage locations specified in the configuration file. These
|
|
||||||
* mappings are then used by the ConfigRegistry instance to load config objects.
|
|
||||||
*
|
|
||||||
* @author Rafael H. Schloming <rhs@mit.edu>
|
|
||||||
* @version $Revision$ $Date$
|
|
||||||
* @version $Id$
|
|
||||||
**/
|
|
||||||
public class ConfigRegistry {
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(ConfigRegistry.class);
|
|
||||||
/**
|
|
||||||
* Base url for registry location(s).
|
|
||||||
* (i.e. $CATALINA_HOME/webapps/$context/WEB-INF/conf/registry in a
|
|
||||||
* standard installation)
|
|
||||||
*/
|
|
||||||
private URL m_url;
|
|
||||||
private ClassLoader m_loader;
|
|
||||||
private List m_packages = new ArrayList();
|
|
||||||
private List m_contexts = new ArrayList();
|
|
||||||
private Map m_storage = new HashMap();
|
|
||||||
private List m_loaders = new ArrayList();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new config registry that will resolve all
|
|
||||||
* locations relative to <code>url</code>, and use
|
|
||||||
* <code>loader</code> when searching the classpath for registry
|
|
||||||
* configuration files.
|
|
||||||
*
|
|
||||||
* @param url The base url for registry locations.
|
|
||||||
* @param loader The ClassLoader to use for retrieving registry
|
|
||||||
* configuration files.
|
|
||||||
**/
|
|
||||||
public ConfigRegistry(URL url, ClassLoader loader) {
|
|
||||||
m_url = url;
|
|
||||||
m_loader = loader;
|
|
||||||
addContext(RegistryConfig.class, "registry.properties");
|
|
||||||
initialize(m_url, new ErrorList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience class which invokes {@link #ConfigRegistry(URL, ClassLoader)}
|
|
||||||
* defaulting the loader to the current context class loader.
|
|
||||||
*
|
|
||||||
* @see Thread#getContextClassLoader()
|
|
||||||
*
|
|
||||||
* @param url The base url for registry locations.
|
|
||||||
*/
|
|
||||||
public ConfigRegistry(URL url) {
|
|
||||||
this(url, Thread.currentThread().getContextClassLoader());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience class which invokes {@link #ConfigRegistry(URL, ClassLoader)}
|
|
||||||
* defaulting the URL to
|
|
||||||
* <code>new File(System.getProperty("ccm.conf")).toURL()</code>. The value
|
|
||||||
* of the ccm.conf system property may or may not include a trailing slash.
|
|
||||||
*
|
|
||||||
* @param loader The ClassLoader to use when searching for
|
|
||||||
* registry configuration files.
|
|
||||||
*/
|
|
||||||
public ConfigRegistry(ClassLoader loader) {
|
|
||||||
this(CCMResourceManager.getConfigURL(), loader);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invokes {@link #ConfigRegistry(URL)} defaulting the URL to <code>new
|
|
||||||
* File(System.getProperty("ccm.conf")).toURL()</code>. The value of the
|
|
||||||
* ccm.conf system property may or may not include a trailing slash.
|
|
||||||
*/
|
|
||||||
public ConfigRegistry() {
|
|
||||||
this(CCMResourceManager.getConfigURL());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param url Base url for registry location(s).
|
|
||||||
* @param errs Errorlist
|
|
||||||
*/
|
|
||||||
private void initialize(URL url, ErrorList errs) {
|
|
||||||
|
|
||||||
ClassLoader ldr = new URLClassLoader(new URL[]{url}, null);
|
|
||||||
|
|
||||||
RegistryConfig rc = new RegistryConfig();
|
|
||||||
load(rc, errs, ldr);
|
|
||||||
|
|
||||||
String[] packages = rc.getPackages();
|
|
||||||
URL[] parents = rc.getParents();
|
|
||||||
|
|
||||||
for (int i = 0; i < packages.length; i++) {
|
|
||||||
if (!m_packages.contains(packages[i])) {
|
|
||||||
initialize(packages[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = parents.length - 1; i >= 0; i--) {
|
|
||||||
initialize(parents[i], errs);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_loaders.add(ldr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is <strong>not</strong> supported API.
|
|
||||||
*/
|
|
||||||
public final void initialize(String key) {
|
|
||||||
s_log.debug(String.format("Initalizing for key '%s'", key));
|
|
||||||
if (m_packages.contains(key)) {
|
|
||||||
throw new IllegalArgumentException("already loaded: " + key);
|
|
||||||
}
|
|
||||||
|
|
||||||
InputStream is = m_loader.getResourceAsStream(key + ".config");
|
|
||||||
if (is == null) {
|
|
||||||
throw new UncheckedWrapperException(String.format("No .config for key '%s' found", key));
|
|
||||||
}
|
|
||||||
if (is != null) {
|
|
||||||
try {
|
|
||||||
XML.parse(is, new ConfigRegistryParser());
|
|
||||||
m_packages.add(key);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new UncheckedWrapperException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of configured packages for this ConfigRegistry.
|
|
||||||
*
|
|
||||||
* @return A list of package keys represented as Strings.
|
|
||||||
**/
|
|
||||||
public List getPackages() {
|
|
||||||
return m_packages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of config classes for this ConfigRegistry.
|
|
||||||
*
|
|
||||||
* @return A list of Class objects.
|
|
||||||
**/
|
|
||||||
public List getContexts() {
|
|
||||||
return m_contexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the relative location used to store values for the
|
|
||||||
* given config class.
|
|
||||||
*
|
|
||||||
* @param context a subclass of {@link
|
|
||||||
* com.arsdigita.runtime.AbstractConfig}
|
|
||||||
*
|
|
||||||
* @return the relative storage location for <code>context</code>
|
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException if this ConfigRegistry does
|
|
||||||
* not contain a mapping for <code>context</code>
|
|
||||||
**/
|
|
||||||
public String getStorage(Class context) {
|
|
||||||
if (!m_contexts.contains(context)) {
|
|
||||||
throw new IllegalArgumentException("no such context: " + context
|
|
||||||
+ "; available contexts="
|
|
||||||
+ m_contexts
|
|
||||||
+ "; context->storage map: "
|
|
||||||
+ m_storage);
|
|
||||||
}
|
|
||||||
return (String) m_storage.get(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addContext(Class context, String storage) {
|
|
||||||
s_log.debug(String.format("Adding context '%s', storage '%s'...",
|
|
||||||
context.getName(), storage));
|
|
||||||
m_contexts.add(context);
|
|
||||||
m_storage.put(context, storage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this ConfigRegistry contains a mapping for
|
|
||||||
* <code>context</code>
|
|
||||||
*
|
|
||||||
* @param context a subclass of {@link
|
|
||||||
* com.arsdigita.runtime.AbstractConfig}
|
|
||||||
*
|
|
||||||
* @return true if this ConfigRegistry contains a mapping for
|
|
||||||
* <code>context</code>
|
|
||||||
**/
|
|
||||||
public boolean isConfigured(Class context) {
|
|
||||||
return m_contexts.contains(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given config object from the correct location based
|
|
||||||
* on its class. Defaults all values based on the value of the
|
|
||||||
* <code>waf.config.parents</code> parameter. Any errors
|
|
||||||
* encountered during loading are reported in the given ErrorList.
|
|
||||||
*
|
|
||||||
* @param ctx the config object to load
|
|
||||||
* @param errs used to accumulate errors during loading
|
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException if this ConfigRegistry does
|
|
||||||
* not contain a mapping for <code>ctx.getClass()</code>
|
|
||||||
**/
|
|
||||||
public void load(ParameterContext ctx, ErrorList errs) {
|
|
||||||
for (Iterator it = m_loaders.iterator(); it.hasNext();) {
|
|
||||||
ClassLoader ldr = (ClassLoader) it.next();
|
|
||||||
load(ctx, errs, ldr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches through this ConfigRegistry and its parents for the
|
|
||||||
* given resource. If it is not found it is also searched for in
|
|
||||||
* the classpath specified by the loader passed to this
|
|
||||||
* ConfigRegistry on construction. This may be used to load
|
|
||||||
* configuration information that is not stored in a config
|
|
||||||
* object.
|
|
||||||
*
|
|
||||||
* @param resource the path to the resource
|
|
||||||
*
|
|
||||||
* @return an input stream containing the contents of the resource
|
|
||||||
* or null if the resource is not found
|
|
||||||
*/
|
|
||||||
public InputStream load(String resource) {
|
|
||||||
for (int i = m_loaders.size() - 1; i >= 0; i--) {
|
|
||||||
ClassLoader ldr = (ClassLoader) m_loaders.get(i);
|
|
||||||
InputStream is = ldr.getResourceAsStream(resource);
|
|
||||||
if (is != null) {
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_loader.getResourceAsStream(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void load(ParameterContext ctx, ErrorList errs, ClassLoader ldr) {
|
|
||||||
Properties props = getProperties(ldr, getStorage(ctx.getClass()));
|
|
||||||
ParameterReader reader = new JavaPropertyReader(props);
|
|
||||||
ctx.load(reader, errs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Properties getProperties(ClassLoader ldr, String resource) {
|
|
||||||
Properties props = new Properties();
|
|
||||||
InputStream is = ldr.getResourceAsStream(resource);
|
|
||||||
if (is != null) {
|
|
||||||
try {
|
|
||||||
props.load(is);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new UncheckedWrapperException(e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new UncheckedWrapperException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return props;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ConfigRegistryParser extends DefaultHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startElement(String uri, String localName, String qn,
|
|
||||||
Attributes attrs) {
|
|
||||||
if (localName.equals("config")) {
|
|
||||||
String klass = attrs.getValue(uri, "class");
|
|
||||||
String storage = attrs.getValue(uri, "storage");
|
|
||||||
// XXX: Is there a better way to handle errors that
|
|
||||||
// includes line number information?
|
|
||||||
if ((klass == null) || (storage == null)) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"class and storage attributes are required");
|
|
||||||
}
|
|
||||||
|
|
||||||
Class context = Classes.loadClass(klass);
|
|
||||||
addContext(context, storage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.arsdigita.runtime;
|
|
||||||
|
|
||||||
// import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.StringUtils;
|
|
||||||
import com.arsdigita.util.parameter.ErrorList;
|
|
||||||
import com.arsdigita.util.parameter.Parameter;
|
|
||||||
import com.arsdigita.util.parameter.ParameterError;
|
|
||||||
import com.arsdigita.util.parameter.StringParameter;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A config class used by the registry itself.
|
|
||||||
*
|
|
||||||
* Contains the parameters:
|
|
||||||
* waf.config.packages: comma separated package-key list of installed packages
|
|
||||||
* waf.config.parents :
|
|
||||||
*
|
|
||||||
* @author Rafael H. Schloming <rhs@mit.edu>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class RegistryConfig extends AbstractConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to unmarshal parameter values.
|
|
||||||
* @param str A String of comma separated values
|
|
||||||
* @return StringArray of the values
|
|
||||||
*/
|
|
||||||
private static String[] array(String str) {
|
|
||||||
if (str == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return StringUtils.split(str, ',');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of installed packages.
|
|
||||||
*
|
|
||||||
* Provided as a comma separated package-key list of installed packages.
|
|
||||||
* The parameter overwrites the default marshal and unmarshal methods to
|
|
||||||
* allow the String parameter to hold a list of values.
|
|
||||||
*
|
|
||||||
* TODO: Replace the type String parameter by StringArray parameter which
|
|
||||||
* provides exactly the required functionality (doesn't it?).
|
|
||||||
*/
|
|
||||||
private Parameter m_packages = new StringParameter
|
|
||||||
("waf.config.packages", Parameter.OPTIONAL, new String[0]) {
|
|
||||||
@Override
|
|
||||||
protected Object unmarshal(String value, ErrorList errs) {
|
|
||||||
return array(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String marshal(Object obj) {
|
|
||||||
return StringUtils.join((String[]) obj, ',');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of parameter values, purpose currently unkown.
|
|
||||||
*
|
|
||||||
* The parameter overwrites the default marshal and unmarshal methods to
|
|
||||||
* allow the String parameter to hold a list of values.
|
|
||||||
*/
|
|
||||||
private Parameter m_parents = new StringParameter
|
|
||||||
("waf.config.parents", Parameter.OPTIONAL, new URL[0]) {
|
|
||||||
@Override
|
|
||||||
protected Object unmarshal(String value, ErrorList errs) {
|
|
||||||
String[] strs = array(value);
|
|
||||||
URL[] result = new URL[strs.length];
|
|
||||||
for (int i = 0; i < result.length; i++) {
|
|
||||||
try {
|
|
||||||
result[i] = new URL(strs[i]);
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
errs.add(new ParameterError(this, e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!errs.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String marshal(Object obj) {
|
|
||||||
URL[] urls = (URL[]) obj;
|
|
||||||
String[] strs = new String[urls.length];
|
|
||||||
for (int i = 0; i < strs.length; i++) {
|
|
||||||
strs[i] = urls[i].toExternalForm();
|
|
||||||
}
|
|
||||||
return StringUtils.join(strs, ',');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new and empty config object.
|
|
||||||
*/
|
|
||||||
public RegistryConfig() {
|
|
||||||
register(m_packages);
|
|
||||||
register(m_parents);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value of the waf.config.packages parameter.
|
|
||||||
*
|
|
||||||
* @return the value of the waf.config.packages parameter
|
|
||||||
*/
|
|
||||||
public String[] getPackages() {
|
|
||||||
return (String[]) get(m_packages);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value of the waf.config.parents parameter.
|
|
||||||
*
|
|
||||||
* @return the value of the waf.config.parents parameter
|
|
||||||
*/
|
|
||||||
public URL[] getParents() {
|
|
||||||
return (URL[]) get(m_parents);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -20,48 +20,53 @@ package com.arsdigita.templating;
|
||||||
|
|
||||||
import com.arsdigita.util.servlet.HttpHost;
|
import com.arsdigita.util.servlet.HttpHost;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
|
import com.arsdigita.web.WebConfig;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a set of patterns corresponding to the current
|
* Generates a set of patterns corresponding to the current host name. (actually
|
||||||
* host name. (actually just retrieves the current hostname from configuration
|
* just retrieves the current hostname from configuration file, StringArray
|
||||||
* file, StringArray returned is for sake of methods consistency)
|
* returned is for sake of methods consistency)
|
||||||
*/
|
*/
|
||||||
public class HostPatternGenerator implements PatternGenerator {
|
public class HostPatternGenerator implements PatternGenerator {
|
||||||
|
|
||||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
/**
|
||||||
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
|
* Internal logger instance to faciliate debugging. Enable logging output by
|
||||||
* and set com.arsdigita.templating.HostPatternGenerator=DEBUG
|
* editing /WEB-INF/conf/log4j.properties int the runtime environment and
|
||||||
* by uncommenting or adding the line. */
|
* set com.arsdigita.templating.HostPatternGenerator=DEBUG by uncommenting
|
||||||
private static final Logger s_log =
|
* or adding the line.
|
||||||
Logger.getLogger(HostPatternGenerator.class);
|
*/
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
HostPatternGenerator.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up the hostname from configuration and returns it as String.
|
* Looks up the hostname from configuration and returns it as String. The
|
||||||
* The Return type is (unneccessarily) String[] due to the current API, but
|
* Return type is (unneccessarily) String[] due to the current API, but
|
||||||
* currently never returns more than just one value (one hostname:port).
|
* currently never returns more than just one value (one hostname:port).
|
||||||
*
|
*
|
||||||
* @param key placeholder from the pattern string, without surrounding
|
* @param key placeholder from the pattern string, without surrounding
|
||||||
* colons, constantly "host" here.
|
* colons, constantly "host" here.
|
||||||
* @param req current HttpServletRequest
|
* @param req current HttpServletRequest
|
||||||
|
*
|
||||||
* @return Hostname (including port if any), retrieved from CCM
|
* @return Hostname (including port if any), retrieved from CCM
|
||||||
* configuration
|
* configuration
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String[] generateValues(String key,
|
public String[] generateValues(String key,
|
||||||
HttpServletRequest req) {
|
HttpServletRequest req) {
|
||||||
HttpHost host = Web.getConfig().getHost();
|
final HttpHost host = new HttpHost(WebConfig.getConfig().getHostName(),
|
||||||
String hostName = host.toString();
|
WebConfig.getConfig().getHostPort());
|
||||||
|
final String hostName = host.toString();
|
||||||
|
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Generating Values for key: " + key + " [" +
|
s_log.debug("Generating Values for key: " + key + " ["
|
||||||
"Hostname retrieved: >>" + hostName + "<<]");
|
+ "Hostname retrieved: >>" + hostName + "<<]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String[]{host.toString()};
|
return new String[]{host.toString()};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import com.arsdigita.util.Exceptions;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.servlet.HttpHost;
|
import com.arsdigita.util.servlet.HttpHost;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
|
import com.arsdigita.web.WebConfig;
|
||||||
import com.arsdigita.xml.Document;
|
import com.arsdigita.xml.Document;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
|
|
@ -346,7 +347,9 @@ public class Templating {
|
||||||
* to a servlet which manages database retrieval.
|
* to a servlet which manages database retrieval.
|
||||||
*/
|
*/
|
||||||
static URL transformURL(URL url) {
|
static URL transformURL(URL url) {
|
||||||
HttpHost self = Web.getConfig().getHost();
|
final WebConfig webConfig = WebConfig.getConfig();
|
||||||
|
final HttpHost self = new HttpHost(webConfig.getHostName(),
|
||||||
|
webConfig.getHostPort());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether url refers to a local resource inside the running
|
* Indicates whether url refers to a local resource inside the running
|
||||||
|
|
@ -427,11 +430,9 @@ public class Templating {
|
||||||
}
|
}
|
||||||
} else // url is not the (local) running CCM host, no transformation
|
} else // url is not the (local) running CCM host, no transformation
|
||||||
// is done
|
// is done
|
||||||
{
|
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("URL " + url + " is not local");
|
s_log.debug("URL " + url + " is not local");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return url; // returns the original, unmodified url here
|
return url; // returns the original, unmodified url here
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ package com.arsdigita.web;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
import org.libreccm.web.CcmApplication;
|
|
||||||
import org.libreccm.web.ApplicationRepository;
|
import org.libreccm.web.ApplicationRepository;
|
||||||
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.web;
|
package com.arsdigita.web;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.servlet.RequestDispatcher;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
|
import javax.servlet.RequestDispatcher;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default implementation deals with templates files belonging to a specific
|
* The default implementation deals with templates files belonging to a specific
|
||||||
|
|
|
||||||
|
|
@ -1,319 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.web;
|
|
||||||
|
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.parameter.BooleanParameter;
|
|
||||||
import com.arsdigita.util.parameter.EnumerationParameter;
|
|
||||||
import com.arsdigita.util.parameter.ErrorList;
|
|
||||||
import com.arsdigita.util.parameter.Parameter;
|
|
||||||
import com.arsdigita.util.parameter.ParameterError;
|
|
||||||
import com.arsdigita.util.parameter.SingletonParameter;
|
|
||||||
import com.arsdigita.util.parameter.StringArrayParameter;
|
|
||||||
import com.arsdigita.util.parameter.StringParameter;
|
|
||||||
import com.arsdigita.util.servlet.HttpHost;
|
|
||||||
import com.arsdigita.util.servlet.HttpHostParameter;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A record containing server-session scoped configuration properties.
|
|
||||||
*
|
|
||||||
* Accessors of this class may return null. Developers should take care to trap
|
|
||||||
* null return values in their code.
|
|
||||||
*
|
|
||||||
* @see com.arsdigita.web.Web
|
|
||||||
* @author Justin Ross <jross@redhat.com>
|
|
||||||
* @author <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class LegacyWebConfig extends AbstractConfig {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(LegacyWebConfig.class);
|
|
||||||
|
|
||||||
private static LegacyWebConfig config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the singleton configuration record for the content section
|
|
||||||
* environment.
|
|
||||||
*
|
|
||||||
* @return The <code>CMSConfig</code> record; it cannot be null
|
|
||||||
*/
|
|
||||||
public static synchronized LegacyWebConfig getInstanceOf() {
|
|
||||||
if (config == null) {
|
|
||||||
config = new LegacyWebConfig();
|
|
||||||
config.load();
|
|
||||||
}
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
// /////////////////////////////////////////////////////////////////////////
|
|
||||||
// Configuration parameter section
|
|
||||||
// /////////////////////////////////////////////////////////////////////////
|
|
||||||
/**
|
|
||||||
* Determines what HTTP scheme prefix is used by default to generate URLs
|
|
||||||
* (either http od https)
|
|
||||||
*/
|
|
||||||
private final Parameter m_scheme = new DefaultSchemeParameter(
|
|
||||||
"waf.web.default_scheme",
|
|
||||||
Parameter.REQUIRED, "http");
|
|
||||||
/**
|
|
||||||
* Sets the name and port that users of a site will see in URLs generated by
|
|
||||||
* CCM for the site. This is a required parameter during installation, e.g.
|
|
||||||
* example.com:80
|
|
||||||
*/
|
|
||||||
private final Parameter m_server = new HttpHostParameter("waf.web.server");
|
|
||||||
/**
|
|
||||||
* Name and port that users of a site will see in secure URLs generated by
|
|
||||||
* CCM for the site. As an example: example.com:443
|
|
||||||
*/
|
|
||||||
private final Parameter m_secureServer = new HttpHostParameter(
|
|
||||||
"waf.web.secure_server",
|
|
||||||
Parameter.OPTIONAL, null);
|
|
||||||
/**
|
|
||||||
* The name of your website, for use in page footers for example. It's not
|
|
||||||
* necessarily the URL but rather a title, e.g. "House of HTML". If not
|
|
||||||
* specified set to the server's URL.
|
|
||||||
*/
|
|
||||||
private final Parameter m_site = new StringParameter("waf.web.site_name",
|
|
||||||
Parameter.OPTIONAL,
|
|
||||||
null) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Object getDefaultValue() {
|
|
||||||
final HttpHost host = getServer();
|
|
||||||
if (host == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return host.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Sets the name and port of the machine on which the CCM instance is
|
|
||||||
* running. Used to fetch some resources by a local URL avoiding external
|
|
||||||
* internet traffic (and delay). If not specified set to the servers's name
|
|
||||||
* redirecting all traffic to external internet address.
|
|
||||||
*/
|
|
||||||
private final Parameter m_host = new HttpHostParameter("waf.web.host",
|
|
||||||
Parameter.OPTIONAL,
|
|
||||||
null) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Object getDefaultValue() {
|
|
||||||
return getServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of URLs which accessed by insecure (normal HTTP) connection produce
|
|
||||||
* a redirect to a HTTPS equivalent. List is comma separated.
|
|
||||||
*/
|
|
||||||
private final Parameter m_secureRequired = new StringArrayParameter(
|
|
||||||
"waf.web.secure_required", Parameter.OPTIONAL, null);
|
|
||||||
/**
|
|
||||||
* List of URLs which accessed by secure (HTTPS) connection produce a
|
|
||||||
* redirect to a HTTP equivalent. List is comma separated.
|
|
||||||
*/
|
|
||||||
private final Parameter m_secureSwitchBack = new StringArrayParameter(
|
|
||||||
"waf.web.secure_switchback", Parameter.OPTIONAL, null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatcher servlet path. It's the prefix to the main entry point for any
|
|
||||||
* application request (CCMDispatcherServlet). By default /ccm
|
|
||||||
*/
|
|
||||||
private final Parameter m_servlet = new StringParameter(
|
|
||||||
"waf.web.dispatcher_servlet_path", Parameter.REQUIRED, "/ccm");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies by name which implementation of ApplicationFileResolver is used
|
|
||||||
* to dynamically resolve static files. By default
|
|
||||||
* DefaultApplicationFileResolver() is used.
|
|
||||||
*/
|
|
||||||
private final Parameter m_resolver = new SingletonParameter(
|
|
||||||
"waf.web.application_file_resolver",
|
|
||||||
Parameter.OPTIONAL,
|
|
||||||
new DefaultApplicationFileResolver());
|
|
||||||
|
|
||||||
private final Parameter m_deactivate_cache_host_notifications
|
|
||||||
= new BooleanParameter(
|
|
||||||
"waf.web.deactivate_cache_host_notifications",
|
|
||||||
Parameter.OPTIONAL, Boolean.FALSE);
|
|
||||||
|
|
||||||
private final Parameter m_dynamic_host_provider = new StringParameter(
|
|
||||||
"waf.web.dynamic_host_provider",
|
|
||||||
Parameter.OPTIONAL, "");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor, but do NOT instantiate this class directly, use
|
|
||||||
* getInstanceOf() instead. (Singleton pattern!)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public LegacyWebConfig() {
|
|
||||||
|
|
||||||
register(m_scheme);
|
|
||||||
register(m_server);
|
|
||||||
register(m_secureServer);
|
|
||||||
register(m_site);
|
|
||||||
register(m_host);
|
|
||||||
register(m_secureRequired);
|
|
||||||
register(m_secureSwitchBack);
|
|
||||||
register(m_servlet);
|
|
||||||
register(m_resolver);
|
|
||||||
register(m_deactivate_cache_host_notifications);
|
|
||||||
register(m_dynamic_host_provider);
|
|
||||||
|
|
||||||
loadInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getDefaultScheme() {
|
|
||||||
return (String) get(m_scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final HttpHost getServer() {
|
|
||||||
return (HttpHost) get(m_server);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final HttpHost getSecureServer() {
|
|
||||||
return (HttpHost) get(m_secureServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean isSecureRequired(String uri) {
|
|
||||||
String[] secured = (String[]) get(m_secureRequired);
|
|
||||||
if (secured != null) {
|
|
||||||
for (int i = 0, n = secured.length; i < n; i++) {
|
|
||||||
if (uri.startsWith(secured[i])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean isNonSecureSwitchRequired(String uri) {
|
|
||||||
String[] switchBack = (String[]) get(m_secureSwitchBack);
|
|
||||||
if (switchBack != null) {
|
|
||||||
for (int i = 0, n = switchBack.length; i < n; i++) {
|
|
||||||
if (uri.startsWith(switchBack[i])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getDispatcherServletPath() {
|
|
||||||
return (String) get(m_servlet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final ApplicationFileResolver getApplicationFileResolver() {
|
|
||||||
return (ApplicationFileResolver) get(m_resolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final HttpHost getHost() {
|
|
||||||
return (HttpHost) get(m_host);
|
|
||||||
}
|
|
||||||
|
|
||||||
final void setHost(final HttpHost host) {
|
|
||||||
set(m_host, host);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getSiteName() {
|
|
||||||
return (String) get(m_site);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @deprecated use Web.getContextPath() instead. The installation context
|
|
||||||
* must no longer manually configured
|
|
||||||
*/
|
|
||||||
// NO LONGER configured by configuration option but determined at runtime
|
|
||||||
// by CCMDispatcherServlet itself.
|
|
||||||
// // dispatcherContextPath option in old Initializer, set to ""
|
|
||||||
// m_context = new StringParameter
|
|
||||||
// ("waf.web.dispatcher_context_path", Parameter.REQUIRED, "");
|
|
||||||
public final String getDispatcherContextPath() {
|
|
||||||
// return (String) get(m_context);
|
|
||||||
return CCMDispatcherServlet.getContextPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static class DispatcherServletPathParameter
|
|
||||||
extends StringParameter {
|
|
||||||
|
|
||||||
DispatcherServletPathParameter(final String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doValidate(final Object value, final ErrorList errors) {
|
|
||||||
final String string = (String) value;
|
|
||||||
|
|
||||||
if (string.endsWith("/")) {
|
|
||||||
final ParameterError error = new ParameterError(this,
|
|
||||||
"The value must not end in a '/'");
|
|
||||||
errors.add(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DefaultSchemeParameter extends EnumerationParameter {
|
|
||||||
|
|
||||||
DefaultSchemeParameter(final String name,
|
|
||||||
final int multiplicity,
|
|
||||||
final Object defaalt) {
|
|
||||||
super(name, multiplicity, defaalt);
|
|
||||||
|
|
||||||
put("http", "http");
|
|
||||||
put("https", "https");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DynamicHostProvider dhProvider = null;
|
|
||||||
protected boolean dhProviderInited = false;
|
|
||||||
|
|
||||||
public final DynamicHostProvider getDynamicHostProvider() {
|
|
||||||
if (dhProviderInited == false) {
|
|
||||||
String classname = (String) get(m_dynamic_host_provider);
|
|
||||||
if (classname != null) {
|
|
||||||
try {
|
|
||||||
Class klass = Class.forName(classname);
|
|
||||||
dhProvider = (DynamicHostProvider) klass.newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error(
|
|
||||||
"Could not instantiate DynamicHostProvider using classname : "
|
|
||||||
+ classname, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dhProviderInited = true;
|
|
||||||
}
|
|
||||||
return dhProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean getDeactivateCacheHostNotifications() {
|
|
||||||
return ((Boolean) get(m_deactivate_cache_host_notifications))
|
|
||||||
.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package com.arsdigita.web;
|
package com.arsdigita.web;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
||||||
|
|
@ -612,11 +612,11 @@ public class URL {
|
||||||
* @return a <code>URL</code> to your server's root path
|
* @return a <code>URL</code> to your server's root path
|
||||||
*/
|
*/
|
||||||
public static final URL root() {
|
public static final URL root() {
|
||||||
final LegacyWebConfig config = Web.getConfig();
|
final WebConfig config = Web.getConfig();
|
||||||
|
|
||||||
URL url = new URL(config.getDefaultScheme(),
|
URL url = new URL(config.getDefaultScheme(),
|
||||||
config.getServer().getName(),
|
config.getServerName(),
|
||||||
config.getServer().getPort(),
|
config.getServerPort(),
|
||||||
"",
|
"",
|
||||||
"/",
|
"/",
|
||||||
null,
|
null,
|
||||||
|
|
@ -679,7 +679,7 @@ public class URL {
|
||||||
public static final URL there(final HttpServletRequest sreq,
|
public static final URL there(final HttpServletRequest sreq,
|
||||||
final String path,
|
final String path,
|
||||||
final ParameterMap params) {
|
final ParameterMap params) {
|
||||||
final LegacyWebConfig config = Web.getConfig();
|
final WebConfig config = Web.getConfig();
|
||||||
|
|
||||||
Assert.exists(sreq, "HttpServletRequest sreq");
|
Assert.exists(sreq, "HttpServletRequest sreq");
|
||||||
Assert.exists(config, "WebConfig config");
|
Assert.exists(config, "WebConfig config");
|
||||||
|
|
@ -693,7 +693,7 @@ public class URL {
|
||||||
return new URL(sreq.getScheme(),
|
return new URL(sreq.getScheme(),
|
||||||
host.getName(),
|
host.getName(),
|
||||||
host.getPort(),
|
host.getPort(),
|
||||||
config.getDispatcherContextPath(),
|
CCMDispatcherServlet.getContextPath(),
|
||||||
config.getDispatcherServletPath(),
|
config.getDispatcherServletPath(),
|
||||||
path,
|
path,
|
||||||
params);
|
params);
|
||||||
|
|
@ -715,9 +715,8 @@ public class URL {
|
||||||
public static final URL dynamicHostThere(final HttpServletRequest sreq,
|
public static final URL dynamicHostThere(final HttpServletRequest sreq,
|
||||||
final String path,
|
final String path,
|
||||||
final ParameterMap params) {
|
final ParameterMap params) {
|
||||||
final LegacyWebConfig config = Web.getConfig();
|
final WebConfig config = Web.getConfig();
|
||||||
DynamicHostProvider provider = Web.getConfig().getDynamicHostProvider();
|
DynamicHostProvider provider = Web.getConfig().getDynamicHostProvider();
|
||||||
|
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
return there(sreq, path, params);
|
return there(sreq, path, params);
|
||||||
}
|
}
|
||||||
|
|
@ -734,7 +733,7 @@ public class URL {
|
||||||
return new URL(sreq.getScheme(),
|
return new URL(sreq.getScheme(),
|
||||||
provider.getName(),
|
provider.getName(),
|
||||||
provider.getPort(),
|
provider.getPort(),
|
||||||
config.getDispatcherContextPath(),
|
CCMDispatcherServlet.getContextPath(),
|
||||||
config.getDispatcherServletPath(),
|
config.getDispatcherServletPath(),
|
||||||
path,
|
path,
|
||||||
params);
|
params);
|
||||||
|
|
@ -755,7 +754,7 @@ public class URL {
|
||||||
*/
|
*/
|
||||||
public static final URL there(final HttpServletRequest sreq,
|
public static final URL there(final HttpServletRequest sreq,
|
||||||
final String path) {
|
final String path) {
|
||||||
final LegacyWebConfig config = Web.getConfig();
|
final WebConfig config = Web.getConfig();
|
||||||
|
|
||||||
Assert.exists(sreq, "HttpServletRequest sreq");
|
Assert.exists(sreq, "HttpServletRequest sreq");
|
||||||
Assert.exists(config, "WebConfig config");
|
Assert.exists(config, "WebConfig config");
|
||||||
|
|
@ -765,7 +764,7 @@ public class URL {
|
||||||
return new URL(sreq.getScheme(),
|
return new URL(sreq.getScheme(),
|
||||||
host.getName(),
|
host.getName(),
|
||||||
host.getPort(),
|
host.getPort(),
|
||||||
config.getDispatcherContextPath(),
|
CCMDispatcherServlet.getContextPath(),
|
||||||
config.getDispatcherServletPath(),
|
config.getDispatcherServletPath(),
|
||||||
path,
|
path,
|
||||||
(ParameterMap) s_empty.get());
|
(ParameterMap) s_empty.get());
|
||||||
|
|
@ -847,11 +846,11 @@ public class URL {
|
||||||
*/
|
*/
|
||||||
public static final URL there(final String path,
|
public static final URL there(final String path,
|
||||||
final ParameterMap params) {
|
final ParameterMap params) {
|
||||||
final LegacyWebConfig config = Web.getConfig();
|
final WebConfig config = Web.getConfig();
|
||||||
|
|
||||||
return new URL(config.getDefaultScheme(),
|
return new URL(config.getDefaultScheme(),
|
||||||
config.getServer().getName(),
|
config.getServerName(),
|
||||||
config.getServer().getPort(),
|
config.getServerPort(),
|
||||||
"",
|
"",
|
||||||
config.getDispatcherServletPath(),
|
config.getDispatcherServletPath(),
|
||||||
path,
|
path,
|
||||||
|
|
@ -949,10 +948,10 @@ public class URL {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getDispatcherPath() {
|
public static String getDispatcherPath() {
|
||||||
final LegacyWebConfig config = Web.getConfig();
|
final WebConfig config = Web.getConfig();
|
||||||
final HttpServletRequest req = Web.getRequest();
|
final HttpServletRequest req = Web.getRequest();
|
||||||
|
|
||||||
final String context = config.getDispatcherContextPath();
|
final String context = CCMDispatcherServlet.getContextPath();
|
||||||
final String servlet = config.getDispatcherServletPath();
|
final String servlet = config.getDispatcherServletPath();
|
||||||
|
|
||||||
if (req == null) {
|
if (req == null) {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class Web {
|
||||||
*/
|
*/
|
||||||
private static final Logger s_log = Logger.getLogger(Web.class);
|
private static final Logger s_log = Logger.getLogger(Web.class);
|
||||||
|
|
||||||
private static final LegacyWebConfig s_config = LegacyWebConfig.getInstanceOf();
|
private static final WebConfig s_config = WebConfig.getConfig();
|
||||||
|
|
||||||
private static final ThreadLocal s_request = new InternalRequestLocal();
|
private static final ThreadLocal s_request = new InternalRequestLocal();
|
||||||
private static final ThreadLocal s_servletContext
|
private static final ThreadLocal s_servletContext
|
||||||
|
|
@ -90,9 +90,9 @@ public class Web {
|
||||||
/**
|
/**
|
||||||
* Provide the configuration record for code in the web package.
|
* Provide the configuration record for code in the web package.
|
||||||
*
|
*
|
||||||
* @return A <code>LegacyWebConfig</code> configuration record; it cannot be null
|
* @return A <code>WebConfig</code> configuration record; it cannot be null
|
||||||
*/
|
*/
|
||||||
public static LegacyWebConfig getConfig() {
|
public static WebConfig getConfig() {
|
||||||
return s_config;
|
return s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintViolation;
|
import javax.validation.ConstraintViolation;
|
||||||
import javax.validation.Validation;
|
import javax.validation.Validation;
|
||||||
|
|
@ -74,7 +72,7 @@ public final class WebConfig {
|
||||||
private Boolean deactiveCacheHostNotifications = false;
|
private Boolean deactiveCacheHostNotifications = false;
|
||||||
|
|
||||||
@Setting
|
@Setting
|
||||||
private String dynamicHostProvider;
|
private String dynamicHostProviderClass;
|
||||||
|
|
||||||
public static WebConfig getConfig() {
|
public static WebConfig getConfig() {
|
||||||
final CdiUtil cdiUtil = new CdiUtil();
|
final CdiUtil cdiUtil = new CdiUtil();
|
||||||
|
|
@ -95,6 +93,14 @@ public final class WebConfig {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getServerName() {
|
||||||
|
return server.split(":")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getServerPort() {
|
||||||
|
return Integer.parseInt(server.split(":")[1]);
|
||||||
|
}
|
||||||
|
|
||||||
public void setServer(
|
public void setServer(
|
||||||
@Pattern(regexp = "[\\w-.]*:[0-9]{1,5}") final String server) {
|
@Pattern(regexp = "[\\w-.]*:[0-9]{1,5}") final String server) {
|
||||||
final Method method;
|
final Method method;
|
||||||
|
|
@ -122,6 +128,14 @@ public final class WebConfig {
|
||||||
return secureServer;
|
return secureServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSecureServerName() {
|
||||||
|
return secureServer.split(":")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSecureServerPort() {
|
||||||
|
return Integer.parseInt(secureServer.split(":")[1]);
|
||||||
|
}
|
||||||
|
|
||||||
public void setSecureServer(
|
public void setSecureServer(
|
||||||
@Pattern(regexp = "[\\w-.]*:[0-9]{1,5}") final String secureServer) {
|
@Pattern(regexp = "[\\w-.]*:[0-9]{1,5}") final String secureServer) {
|
||||||
final Method method;
|
final Method method;
|
||||||
|
|
@ -157,6 +171,14 @@ public final class WebConfig {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getHostName() {
|
||||||
|
return host.split(":")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getHostPort() {
|
||||||
|
return Integer.parseInt(host.split(":")[1]);
|
||||||
|
}
|
||||||
|
|
||||||
public void setHost(
|
public void setHost(
|
||||||
@Pattern(regexp = "[\\w-.]*:[0-9]{1,5}") final String host) {
|
@Pattern(regexp = "[\\w-.]*:[0-9]{1,5}") final String host) {
|
||||||
|
|
||||||
|
|
@ -243,12 +265,46 @@ public final class WebConfig {
|
||||||
this.deactiveCacheHostNotifications = deactiveCacheHostNotifications;
|
this.deactiveCacheHostNotifications = deactiveCacheHostNotifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDynamicHostProvider() {
|
public String getDynamicHostProviderClass() {
|
||||||
return dynamicHostProvider;
|
return dynamicHostProviderClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDynamicHostProvider(final String dynamicHostProvider) {
|
public DynamicHostProvider getDynamicHostProvider() {
|
||||||
this.dynamicHostProvider = dynamicHostProvider;
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Class<DynamicHostProvider> clazz
|
||||||
|
= (Class<DynamicHostProvider>) Class
|
||||||
|
.forName(dynamicHostProviderClass);
|
||||||
|
return clazz.newInstance();
|
||||||
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
|
||||||
|
throw new UncheckedWrapperException(
|
||||||
|
String.format("Failed to create instance of DynamicHostProvider"
|
||||||
|
+ "implenentation \"%s\".",
|
||||||
|
dynamicHostProviderClass),
|
||||||
|
ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDynamicHostProviderClass(
|
||||||
|
final String dynamicHostProviderClass) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final Class<?> clazz = Class.forName(dynamicHostProviderClass);
|
||||||
|
if (!DynamicHostProvider.class.isAssignableFrom(clazz)) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("Provided class \"%s\" is not an"
|
||||||
|
+ "implementation of the interface \"%s\".",
|
||||||
|
dynamicHostProviderClass,
|
||||||
|
DynamicHostProvider.class.getName()));
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("Unable to retrieve class \"%s\".",
|
||||||
|
dynamicHostProviderClass),
|
||||||
|
ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dynamicHostProviderClass = dynamicHostProviderClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<ConstraintViolation<WebConfig>> validateHostParameter(
|
private Set<ConstraintViolation<WebConfig>> validateHostParameter(
|
||||||
|
|
|
||||||
|
|
@ -18,25 +18,23 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
|
import static org.libreccm.core.CoreConstants.*;
|
||||||
|
|
||||||
|
import org.libreccm.core.CcmObject;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.libreccm.core.CcmObject;
|
|
||||||
|
|
||||||
import static org.libreccm.core.CoreConstants.*;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Association class describing the association between a category and an
|
* Association class describing the association between a category and an
|
||||||
|
|
|
||||||
|
|
@ -18,33 +18,29 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
|
import static org.libreccm.core.CoreConstants.*;
|
||||||
|
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
import org.hibernate.validator.constraints.NotBlank;
|
||||||
import org.libreccm.core.CcmObject;
|
import org.libreccm.core.CcmObject;
|
||||||
|
import org.libreccm.l10n.LocalizedString;
|
||||||
import static org.libreccm.core.CoreConstants.*;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.persistence.AssociationOverride;
|
import javax.persistence.AssociationOverride;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.libreccm.l10n.LocalizedString;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
import java.util.List;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.libreccm.core.CcmObject;
|
import org.libreccm.core.CcmObject;
|
||||||
|
import org.libreccm.core.CcmObjectRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
@ -28,10 +31,6 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.NoResultException;
|
import javax.persistence.NoResultException;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.core.CcmObjectRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code CategoryManager} provides several helper methods for managing
|
* The {@code CategoryManager} provides several helper methods for managing
|
||||||
* categories, their sub categories and the objects assigned to a categories.
|
* categories, their sub categories and the objects assigned to a categories.
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.message.FormattedMessage;
|
||||||
import org.libreccm.core.AbstractEntityRepository;
|
import org.libreccm.core.AbstractEntityRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -28,10 +31,6 @@ import javax.inject.Inject;
|
||||||
import javax.persistence.NoResultException;
|
import javax.persistence.NoResultException;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.logging.log4j.message.FormattedMessage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import org.hibernate.validator.constraints.URL;
|
|
||||||
|
|
||||||
import static org.libreccm.categorization.CategorizationConstants.*;
|
import static org.libreccm.categorization.CategorizationConstants.*;
|
||||||
|
|
||||||
import org.libreccm.core.CcmObject;
|
|
||||||
|
|
||||||
import static org.libreccm.core.CoreConstants.*;
|
import static org.libreccm.core.CoreConstants.*;
|
||||||
|
|
||||||
|
import org.hibernate.validator.constraints.NotBlank;
|
||||||
|
import org.hibernate.validator.constraints.URL;
|
||||||
|
import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.jpa.utils.UriConverter;
|
import org.libreccm.jpa.utils.UriConverter;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
|
import org.omg.CORBA.DomainManager;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
@ -54,9 +52,6 @@ import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
|
|
||||||
import org.omg.CORBA.DomainManager;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
|
import org.libreccm.web.ApplicationRepository;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import org.libreccm.web.ApplicationRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides several methods when managing the relations between {@link Domain}s
|
* Provides several methods when managing the relations between {@link Domain}s
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.categorization;
|
package org.libreccm.categorization;
|
||||||
|
|
||||||
|
import static org.libreccm.core.CoreConstants.*;
|
||||||
|
|
||||||
|
import org.libreccm.core.CcmObject;
|
||||||
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
@ -29,12 +34,6 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.libreccm.core.CcmObject;
|
|
||||||
|
|
||||||
import static org.libreccm.core.CoreConstants.*;
|
|
||||||
|
|
||||||
import org.libreccm.web.CcmApplication;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Association class for the association between a {@link Domain} and a
|
* Association class for the association between a {@link Domain} and a
|
||||||
|
|
|
||||||
|
|
@ -18,21 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.configuration;
|
package org.libreccm.configuration;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
|
|
||||||
import org.libreccm.categorization.CategoryManager;
|
|
||||||
import org.libreccm.categorization.Domain;
|
|
||||||
import org.libreccm.categorization.DomainRepository;
|
|
||||||
|
|
||||||
import static org.libreccm.configuration.ConfigurationConstants.*;
|
import static org.libreccm.configuration.ConfigurationConstants.*;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.message.FormattedMessage;
|
||||||
import org.libreccm.categorization.Categorization;
|
import org.libreccm.categorization.Categorization;
|
||||||
import org.libreccm.categorization.Category;
|
import org.libreccm.categorization.Category;
|
||||||
|
import org.libreccm.categorization.CategoryManager;
|
||||||
import org.libreccm.categorization.CategoryRepository;
|
import org.libreccm.categorization.CategoryRepository;
|
||||||
|
import org.libreccm.categorization.Domain;
|
||||||
|
import org.libreccm.categorization.DomainRepository;
|
||||||
import org.libreccm.core.CcmObject;
|
import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
@ -42,12 +38,13 @@ import java.math.BigDecimal;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.apache.logging.log4j.message.FormattedMessage;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps between configuration classes and the values stored in the registry.
|
* Maps between configuration classes and the values stored in the registry.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,6 @@ import javax.servlet.annotation.WebServlet;
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
public @interface ServletPath {
|
public @interface ServletPath {
|
||||||
|
|
||||||
String value() default URL.SERVLET_DIR + "/legacy-adapter";
|
String value() default "/templates/servlet/legacy-adapter";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.kernel.security;
|
package com.arsdigita.kernel.security;
|
||||||
|
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.JavaPropertyReader;
|
import com.arsdigita.util.JavaPropertyReader;
|
||||||
import com.arsdigita.util.parameter.AbstractParameter;
|
import com.arsdigita.util.parameter.AbstractParameter;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -111,7 +110,6 @@ public class SecurityConfigTest {
|
||||||
.addPackage(ApplicationRepository.class.getPackage())
|
.addPackage(ApplicationRepository.class.getPackage())
|
||||||
.addPackage(EntityManagerProducer.class.getPackage())
|
.addPackage(EntityManagerProducer.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameter.class.getPackage())
|
.addPackage(AbstractParameter.class.getPackage())
|
||||||
.addPackage(JavaPropertyReader.class.getPackage())
|
.addPackage(JavaPropertyReader.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,10 @@ public class WebConfigTest {
|
||||||
|
|
||||||
assertThat(webConfig.getHost(),
|
assertThat(webConfig.getHost(),
|
||||||
is(equalTo("zeus.example.org:8080")));
|
is(equalTo("zeus.example.org:8080")));
|
||||||
|
assertThat(webConfig.getHostName(),
|
||||||
|
is(equalTo("zeus.example.org")));
|
||||||
|
assertThat(webConfig.getHostPort(),
|
||||||
|
is(equalTo(8080)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
|
@ -129,6 +133,10 @@ public class WebConfigTest {
|
||||||
|
|
||||||
assertThat(webConfig.getServer(),
|
assertThat(webConfig.getServer(),
|
||||||
is(equalTo("zeus.example.org:8080")));
|
is(equalTo("zeus.example.org:8080")));
|
||||||
|
assertThat(webConfig.getServerName(),
|
||||||
|
is(equalTo("zeus.example.org")));
|
||||||
|
assertThat(webConfig.getServerPort(),
|
||||||
|
is(equalTo(8080)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
|
@ -167,6 +175,10 @@ public class WebConfigTest {
|
||||||
|
|
||||||
assertThat(webConfig.getSecureServer(),
|
assertThat(webConfig.getSecureServer(),
|
||||||
is(equalTo("zeus.example.org:8080")));
|
is(equalTo("zeus.example.org:8080")));
|
||||||
|
assertThat(webConfig.getSecureServerName(),
|
||||||
|
is(equalTo("zeus.example.org")));
|
||||||
|
assertThat(webConfig.getSecureServerPort(),
|
||||||
|
is(equalTo(8080)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
import com.arsdigita.kernel.security.SecurityConfig;
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
import com.arsdigita.util.parameter.AbstractParameterContext;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -136,7 +135,6 @@ public class AuthorizationInterceptorTest {
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage(EqualsVerifier.class.getPackage())
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage(IntegrationTest.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage(AbstractParameterContext.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage(XML.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
import com.arsdigita.kernel.security.SecurityConfig;
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
import com.arsdigita.util.parameter.AbstractParameterContext;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -146,7 +145,6 @@ public class PermissionCheckerTest {
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage(EqualsVerifier.class.getPackage())
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage(IntegrationTest.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage(AbstractParameterContext.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage(XML.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
import com.arsdigita.kernel.security.SecurityConfig;
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
import com.arsdigita.util.parameter.AbstractParameterContext;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -137,7 +136,6 @@ public class PermissionManagerTest {
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage(EqualsVerifier.class.getPackage())
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage(IntegrationTest.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage(AbstractParameterContext.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage(XML.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
import com.arsdigita.kernel.security.SecurityConfig;
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
import com.arsdigita.util.parameter.AbstractParameterContext;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -132,7 +131,6 @@ public class RoleManagerTest {
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage(EqualsVerifier.class.getPackage())
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage(IntegrationTest.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage(AbstractParameterContext.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage(XML.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
import com.arsdigita.kernel.security.SecurityConfig;
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
import com.arsdigita.util.parameter.AbstractParameterContext;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -163,7 +162,6 @@ public class SecuredCollectionTest {
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage(EqualsVerifier.class.getPackage())
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage(IntegrationTest.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage(AbstractParameterContext.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage(XML.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
import com.arsdigita.kernel.security.SecurityConfig;
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
import com.arsdigita.util.parameter.AbstractParameterContext;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -163,7 +162,6 @@ public class SecuredIteratorTest {
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage(EqualsVerifier.class.getPackage())
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage(IntegrationTest.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage(AbstractParameterContext.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage(XML.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
|
||||||
import com.arsdigita.xml.XML;
|
|
||||||
import com.arsdigita.xml.formatters.DateTimeFormatter;
|
|
||||||
|
|
||||||
import org.apache.shiro.authc.AuthenticationException;
|
import org.apache.shiro.authc.AuthenticationException;
|
||||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||||
|
|
||||||
|
|
@ -58,15 +50,7 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.libreccm.categorization.Categorization;
|
|
||||||
import org.libreccm.core.CcmObject;
|
|
||||||
import org.libreccm.jpa.EntityManagerProducer;
|
|
||||||
import org.libreccm.jpa.utils.MimeTypeConverter;
|
|
||||||
import org.libreccm.l10n.LocalizedString;
|
|
||||||
import org.libreccm.tests.categories.IntegrationTest;
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
import org.libreccm.testutils.EqualsVerifier;
|
|
||||||
import org.libreccm.web.CcmApplication;
|
|
||||||
import org.libreccm.workflow.Workflow;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -121,53 +105,54 @@ public class ShiroTest {
|
||||||
return ShrinkWrap
|
return ShrinkWrap
|
||||||
.create(WebArchive.class,
|
.create(WebArchive.class,
|
||||||
"LibreCCM-org.libreccm.security.ShiroTest.war")
|
"LibreCCM-org.libreccm.security.ShiroTest.war")
|
||||||
.addPackage(User.class.getPackage())
|
.addPackage("org.libreccm.cdi.utils") //Checked
|
||||||
.addPackage(CcmObject.class.getPackage())
|
.addPackage("org.libreccm.categorization") //Checked
|
||||||
.addPackage(Categorization.class.getPackage())
|
.addPackage("org.libreccm.configuration") //Checked
|
||||||
.addPackage(LocalizedString.class.getPackage())
|
.addPackage("org.libreccm.core") //Checked
|
||||||
.addPackage(CcmApplication.class.getPackage())
|
.addPackage("org.libreccm.jpa") //Checked
|
||||||
.addPackage(Workflow.class.getPackage())
|
.addPackage("org.libreccm.jpa.utils") //Checked
|
||||||
.addPackage(EntityManagerProducer.class.getPackage())
|
.addPackage("org.libreccm.l10n") //Checked
|
||||||
.addPackage(MimeTypeConverter.class.getPackage())
|
.addPackage("org.libreccm.modules") //Checked
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage("org.libreccm.security") //Checked
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage("org.libreccm.tests.categories") //Checked
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage("org.libreccm.testutils") //Checked
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
.addPackage("org.libreccm.web") //Checked
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage("org.libreccm.workflow") //Checked
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage("com.arsdigita.kernel") //Checked
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage("com.arsdigita.kernel.security") //Checked
|
||||||
.addPackage(DateTimeFormatter.class.getPackage())
|
.addPackage("com.arsdigita.util") //Checked
|
||||||
.addPackage(UncheckedWrapperException.class.getPackage())
|
.addPackage("com.arsdigita.util.parameter") //Checked
|
||||||
|
// .addPackage(CcmCore.class.getPackage())
|
||||||
|
// .addPackage(CcmModule.class.getPackage())
|
||||||
|
// .addPackage(CcmObject.class.getPackage())
|
||||||
|
// .addPackage(CdiUtil.class.getPackage())
|
||||||
|
// .addPackage(Categorization.class.getPackage())
|
||||||
|
// .addPackage(Configuration.class.getPackage())
|
||||||
|
// .addPackage(LocalizedString.class.getPackage())
|
||||||
|
// .addPackage(CcmApplication.class.getPackage())
|
||||||
|
// .addPackage(Workflow.class.getPackage())
|
||||||
|
// .addPackage(EntityManagerProducer.class.getPackage())
|
||||||
|
// .addPackage(MimeTypeConverter.class.getPackage())
|
||||||
|
// .addPackage(EqualsVerifier.class.getPackage())
|
||||||
|
// .addPackage(IntegrationTest.class.getPackage())
|
||||||
|
// .addPackage(SecurityConfig.class.getPackage())
|
||||||
|
// .addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
|
// .addPackage(XML.class.getPackage())
|
||||||
|
// .addPackage(DateTimeFormatter.class.getPackage())
|
||||||
|
// .addPackage(AbstractParameterContext.class.getPackage())
|
||||||
|
// .addPackage(UncheckedWrapperException.class.getPackage())
|
||||||
|
// .addPackage(CCMResourceManager.class.getPackage())
|
||||||
|
// .addPackage(DispatcherHelper.class.getPackage())
|
||||||
|
// .addPackage(UI.class.getPackage())
|
||||||
|
// .addPackage(KernelConfig.class.getPackage())
|
||||||
|
// .addPackage(BasePage.class.getPackage())
|
||||||
.addAsLibraries(libs)
|
.addAsLibraries(libs)
|
||||||
.addAsResource("test-persistence.xml",
|
.addAsResource("test-persistence.xml",
|
||||||
"META-INF/persistence.xml")
|
"META-INF/persistence.xml")
|
||||||
.addAsResource("com/arsdigita/kernel/"
|
|
||||||
+ "KernelConfig_parameter.properties",
|
|
||||||
"com/arsdigita/kernel/"
|
|
||||||
+ "KernelConfig_parameter.properties")
|
|
||||||
.addAsResource("com/arsdigita/kernel/security/"
|
|
||||||
+ "SecurityConfig_parameter.properties",
|
|
||||||
"com/arsdigita/kernel/security/"
|
|
||||||
+ "SecurityConfig_parameter.properties")
|
|
||||||
.addAsWebInfResource(
|
|
||||||
"configs/org/libreccm/security/UserManagerTest/"
|
|
||||||
+ "registry.properties",
|
|
||||||
"conf/registry/registry.properties")
|
|
||||||
.addAsResource(
|
|
||||||
"configs/org/libreccm/security/UserManagerTest/ccm-core.config",
|
|
||||||
"ccm-core.config")
|
|
||||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||||
.addAsResource(
|
.addAsResource(
|
||||||
"configs/org/libreccm/security/ShiroTest/log4j2.xml",
|
"configs/org/libreccm/security/ShiroTest/log4j2.xml",
|
||||||
"log4j2.xml")
|
"log4j2.xml")
|
||||||
.addAsWebInfResource(
|
|
||||||
"configs/org/libreccm/security/ShiroTest/"
|
|
||||||
+ "kernel.properties",
|
|
||||||
"conf/registry/ccm-core/kernel.properties")
|
|
||||||
.addAsWebInfResource(
|
|
||||||
"configs/org/libreccm//security/ShiroTest/"
|
|
||||||
+ "security.properties",
|
|
||||||
"conf/registry/ccm-core/security.properties")
|
|
||||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import com.arsdigita.kernel.security.SecurityConfig;
|
import com.arsdigita.kernel.security.SecurityConfig;
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.util.parameter.AbstractParameterContext;
|
import com.arsdigita.util.parameter.AbstractParameterContext;
|
||||||
import com.arsdigita.web.CCMApplicationContextListener;
|
import com.arsdigita.web.CCMApplicationContextListener;
|
||||||
|
|
@ -133,7 +132,6 @@ public class UserManagerTest {
|
||||||
.addPackage(EqualsVerifier.class.getPackage())
|
.addPackage(EqualsVerifier.class.getPackage())
|
||||||
.addPackage(IntegrationTest.class.getPackage())
|
.addPackage(IntegrationTest.class.getPackage())
|
||||||
.addPackage(SecurityConfig.class.getPackage())
|
.addPackage(SecurityConfig.class.getPackage())
|
||||||
.addPackage(AbstractConfig.class.getPackage())
|
|
||||||
.addPackage(AbstractParameterContext.class.getPackage())
|
.addPackage(AbstractParameterContext.class.getPackage())
|
||||||
.addPackage(CCMApplicationContextListener.class.getPackage())
|
.addPackage(CCMApplicationContextListener.class.getPackage())
|
||||||
.addPackage(XML.class.getPackage())
|
.addPackage(XML.class.getPackage())
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="DEBUG">
|
||||||
|
<Appenders>
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
|
</Console>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="error">
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Root>
|
||||||
|
<Logger name="org.libreccm.configuration.ConfigurationManager"
|
||||||
|
level="debug">
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Logger>
|
||||||
|
<Logger name="org.libreccm.categorization.CategoryRepository"
|
||||||
|
level="debug">
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Logger>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="WARN">
|
||||||
|
<Appenders>
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
|
</Console>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="error">
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Root>
|
||||||
|
<Logger name="org.libreccm.security.Shiro"
|
||||||
|
level="debug">
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Logger>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
[main]
|
||||||
|
|
||||||
|
passwordMatcher = org.apache.shiro.authc.credential.PasswordMatcher
|
||||||
|
passwordService = org.apache.shiro.authc.credential.DefaultPasswordService
|
||||||
|
passwordMatcher.passwordService = $passwordService
|
||||||
|
|
||||||
|
ccmRealm = org.libreccm.security.CcmShiroRealm
|
||||||
|
ccmRealm.credentialsMatcher = $passwordMatcher
|
||||||
|
|
||||||
|
securityManager.realms = $ccmRealm
|
||||||
Loading…
Reference in New Issue