Commit 9ee4b2ae authored by Ate Douma's avatar Ate Douma

TRIVIAL cleanup master

parent 3bcbf75e
* text=auto !eol
/LICENSE -text
/NOTICE -text
src/main/java/org/onehippo/cms7/services/HippoServiceException.java -text
src/main/java/org/onehippo/cms7/services/SingletonService.java -text
src/main/java/org/onehippo/cms7/services/autoreload/AutoReloadService.java -text
src/main/java/org/onehippo/cms7/services/environment/EnvironmentSettings.java -text
src/main/java/org/onehippo/cms7/services/eventbus/HippoEventListener.java -text svneol=unset#text/plain
src/main/java/org/onehippo/cms7/services/eventbus/Subscribe.java -text
src/main/java/org/onehippo/cms7/services/googleanalytics/GoogleAnalyticsService.java -text
src/main/java/org/onehippo/cms7/services/webfiles/WebFile.java -text
src/main/java/org/onehippo/cms7/services/webfiles/WebFileEvent.java -text
src/main/java/org/onehippo/cms7/services/webfiles/WebFilesService.java -text
src/test/java/org/onehippo/cms7/services/ServletContextRegistryTest.java -text
/*.iml
/.classpath
/.idea
/.project
/.settings
/target
log4j.log
\ No newline at end of file
This diff is collapsed.
Hippo CMS7 Services
Copyright 2012-2018 Hippo B.V. (http://www.onehippo.com)
This product includes software developed by:
Hippo B.V., Amsterdam, The Netherlands (http://www.onehippo.com/);
The Apache Software Foundation (http://www.apache.org/).
NOTICE: Only our own original work is licensed under the terms of the
Apache License Version 2.0. The licenses of some libraries might impose
different redistribution or general licensing terms than those stated in the
Apache License. Users and redistributors are hereby requested to verify these
conditions and agree upon them.
# This is not the branch you're looking for...
BloomReach only provides the git trees for the release tags of Hippo CMS, as explained on https://www.onehippo.org/about/open-source-release-policy.html
To checkout the code for a specific release tag, after cloning this repository, use the following:
## to show the available tags
git tag
## to checkout a specific tag
git checkout <tag name>
## to modify a project
If you want to make modifications to a project, for example to create a patch, create a new fork branch from the specific tag like this:
git checkout -b forked-<tag name> <tag name>
For the latter, also see the **Build from Source** documentation at https://www.onehippo.org/library/development/build-hippo-cms-from-scratch.html
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012-2018 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms7-project</artifactId>
<version>29.4-SNAPSHOT</version>
</parent>
<name>Hippo CMS7 Services</name>
<artifactId>hippo-services</artifactId>
<version>4.3.0-SNAPSHOT</version>
<inceptionYear>2012</inceptionYear>
<properties>
<!-- use root project name for all project modules NOTICE files, should be the same as in the root NOTICE file -->
<notice.project.name>Hippo CMS7 Services</notice.project.name>
<hippo.commons.version>4.3.0-SNAPSHOT</hippo.commons.version>
<easymock.version>3.0</easymock.version>
</properties>
<scm>
<connection>scm:git:https://code.onehippo.org/cms-community/hippo-services-api.git</connection>
<developerConnection>scm:git:git@code.onehippo.org:cms-community/hippo-services-api.git</developerConnection>
<url>https://code.onehippo.org/cms-community/hippo-services-api</url>
</scm>
<repositories>
<repository>
<id>hippo</id>
<name>Hippo Maven 2</name>
<url>https://maven.onehippo.com/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms7-commons</artifactId>
<version>${hippo.commons.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>${easymock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>pedantic</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<excludes combine.children="append">
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services;
public class HippoServiceException extends RuntimeException {
public HippoServiceException(String message) {
super(message);
}
public HippoServiceException(String message, Throwable cause) {
super(message, cause);
}
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services;
/**
* The Service Registration represents a service with its context.
* Services that are obtained in this way, e.g. because they were registered as extensions with the whiteboard pattern,
* must be invoked with the context classloader set to the classloader in this registration object.
*/
public class HippoServiceRegistration {
private final ClassLoader classLoader;
private final Object service;
HippoServiceRegistration(final ClassLoader classLoader, final Object service) {
this.classLoader = classLoader;
this.service = service;
}
public Object getService() {
return service;
}
public ClassLoader getClassLoader() {
return classLoader;
}
}
/*
* Copyright 2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
/**
* The ServletContextRegistry provides a central registration of web applications their {@link ServletContext} using
* their contextPath as key and optionally a {@link WebAppType} which gets set as {@link ServletContext} attribute as follows:
* {@link javax.servlet.ServletContext#setAttribute(String, Object)
* ServletContext#setAttribute(org.onehippo.cms7.services.ServletContextRegistry.WebAppType, WebAppType)}.
* <p>
* ServletContexts can/should be registered/unregistered via init/destroy methods of a {@link javax.servlet.Servlet}
* or {@link javax.servlet.Filter}, or a {@link javax.servlet.ServletContextListener} its
* contextInitialized/contextDestroyed event methods.
* </p>
* <p>
* Registered ServletContexts can be looked up by their {@link #getContext(String) contextPath} or as an
* unmodifiable {@link #getContexts() map} by their context paths.
* </p>
*/
public final class ServletContextRegistry {
public enum WebAppType {
HST, REPO, OTHER
}
private static Map<String, ServletContext> registry = new HashMap<>();
/**
* Register a {@link ServletContext}
* @throws IllegalStateException if the ServletContext already has been registered by its contextPath
* @param ctx the servletContext to register
* @param type the <code>WebAppType</code> to which the <code>ctx</code> belongs. Not allowed to be <code>null</code>
*/
public synchronized static void register(final ServletContext ctx, final WebAppType type) {
if (registry.containsKey(ctx.getContextPath())) {
throw new IllegalStateException("ServletContext "+ctx.getContextPath()+" already registered");
}
if (type == null) {
throw new IllegalArgumentException("WebAppType argument is not allowed to be null.");
}
Map<String, ServletContext> newMap = new HashMap<>(registry);
newMap.put(ctx.getContextPath(), ctx);
if (type != null) {
ctx.setAttribute(WebAppType.class.getName(), type);
}
registry = Collections.unmodifiableMap(newMap);
}
/**
* Unregister a {@link ServletContext}
* @throws IllegalStateException if the ServletContext has not been registered by its contextPath
* @param ctx the servletContext to unregister
*/
public synchronized static void unregister(final ServletContext ctx) {
if (!registry.containsKey(ctx.getContextPath())) {
throw new IllegalStateException("ServletContext "+ctx.getContextPath()+" not registered");
}
Map<String, ServletContext> newMap = new HashMap<>(registry);
newMap.remove(ctx.getContextPath());
registry = Collections.unmodifiableMap(newMap);
}
/**
* @param contextPath The contextPath for which to lookup the ServletContext
* @return the ServletContext registered under the parameter contextPath
*/
public static ServletContext getContext(final String contextPath) {
return registry.get(contextPath);
}
/**
* @return unmodifiable map of all currently registered ServletContexts mapped by their contextPath
*/
public static Map<String, ServletContext> getContexts() {
return registry;
}
/**
* @return unmodifiable map of all currently registered ServletContexts of WebAppType <code>type</code> mapped by their contextPath
*/
public static Map<String, ServletContext> getContexts(final WebAppType type) {
if (type == null) {
throw new IllegalArgumentException("WebAppType argument is not allowed to be null.");
}
Map<String, ServletContext> newMap = new HashMap<>();
for (Map.Entry<String, ServletContext> entry : registry.entrySet()) {
final Object attribute = entry.getValue().getAttribute(WebAppType.class.getName());
if (attribute == type) {
newMap.put(entry.getKey(), entry.getValue());
}
}
return Collections.unmodifiableMap(newMap);
}
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Singleton annotation for a service interface. When this annotation is present, a service can be registered and
* retrieved using the singleton support methods on the {@link HippoServiceRegistry}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SingletonService {
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Whiteboard annotation for a service interface. When this annotation is present, a service can be registered and
* retrieved using the singleton support methods on the {@link org.onehippo.cms7.services.HippoServiceRegistry}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface WhiteboardService {
}
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.autoreload;
import org.onehippo.cms7.services.SingletonService;
import org.onehippo.cms7.services.WhiteboardService;
/**
* Automatically reloads the current page in connected browsers. If auto-reload is disabled, nothing happens when
* {@link #broadcastPageReload()} is called.
*/
@SingletonService
@WhiteboardService
@SuppressWarnings("UnusedDeclaration")
public interface AutoReloadService {
/**
* @return true if auto-reload is enabled, false otherwise.
*/
boolean isEnabled();
/**
* Enables or disabled auto-reload.
* @param isEnabled true when auto-reload should be enabled, false when it should be disabled.
*/
void setEnabled(boolean isEnabled);
/**
* @param contextPath the current context path of the page in which the JavaScript will be included. The context
* path can be an empty string when the page is served at URL path '/' (e.g. when the web
* application is deployed as ROOT.war). When the context path is not empty, it must start with
* a slash, followed by the context path string. The context path must not end with a slash.
* For example, valid context paths are "/site", "/intranet" and "".
* @return the JavaScript to include in a browser that handles the auto-reloading.
* @throws IllegalArgumentException if the context path is not well-formed.
*/
String getJavaScript(String contextPath);
/**
* Reloads the current page in all connected browsers. If auto-reload is disabled, nothing happens.
*/
void broadcastPageReload();
}
/*
* Copyright 2016 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.cmscontext;
import javax.servlet.http.HttpSession;
import org.onehippo.cms7.services.SingletonService;
@SingletonService
public interface CmsContextService {
/** Returns the unique identifier for this service **/
String getId();
/**
* Returns the CmsSessionContext by its unique id
* @param ctxId The id for the CmsSessionContext to return
* @return the CmsSessionContext
*/
CmsSessionContext getSessionContext(final String ctxId);
/**
* Creates a new CmsSessionContext attached to an existing (CMS Application HttpSession based) CmsSessionContext and
* stores it in the provided HttpSession under attribute {@link CmsSessionContext#SESSION_KEY}.
* <p>
* The attached CmsSessionContext will be automatically destroyed and removed from its HttpSession when the
* underlying CMS application CmsSessionContext is destroyed.
* </p>
* <p>
* When the provided HttpSession expires or invalidated <em>OR</em> the attached CmsSessionContext
* is removed from its HttpSession otherwise, the attached CmsSessionContext is automatically destroyed and detached
* from the underlying CmsSessionContext.
* </p>
* @param ctxId Id for the CmsSessionContext to attach a new CmsSessionContext to
* @param session The HttpSession in which to bind the new attached CmsSessionContext
* @return the attached CmsSessionContext, also bound to the provided HttpSession attribute {@link CmsSessionContext#SESSION_KEY}
*/
CmsSessionContext attachSessionContext(final String ctxId, HttpSession session);
}
/*
* Copyright 2016 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.cmscontext;
import java.io.Serializable;
import java.util.Locale;
import java.util.Map;
import javax.jcr.SimpleCredentials;
import javax.servlet.http.HttpSession;
/**
* Provides access to CMS Application Session Context specific information
*/
public interface CmsSessionContext {
/**
* Attribute name under which the CmsSessionContext is bind in its HttpSession
*/
String SESSION_KEY = CmsSessionContext.class.getName();
/**
* Key to the the SimpleCredentials with which the CMS session authenticates with the Repository.
*
* @see #getRepositoryCredentials()
*/
String REPOSITORY_CREDENTIALS = "repository.credentials";
/**
* Key to retrieve the locale applicable to the current CMS session.
*
* @see #getLocale()
*/
String LOCALE = "locale";
/**
* Key to retrieve the context payload
*/
String CMS_SESSION_CONTEXT_PAYLOAD_KEY = CmsSessionContext.class.getName() + ".contextPayload";
/**
* Static method to retrieve the CmsSessionContext from a HttpSession
*
* @param session the HttpSession
* @return the CmsSessionContext bound to the provided HttpSession
*/
static CmsSessionContext getContext(HttpSession session) {
return (CmsSessionContext) session.getAttribute(SESSION_KEY);
}
/**
* @return Unique identifier for this CmsSessionContext
*/
String getId();
/**
* @return Unique identifier for the CmsContextService which created this CmsSessionContext
*/
String getCmsContextServiceId();
/**
* Retrieve CMS Session Context specific information by key
*
* @param key the key of the information
* @return the information
*/
Object get(String key);
/**
* @return the SimpleCredentials with which the CMS session authenticates with the Repository
*/
default SimpleCredentials getRepositoryCredentials() {
return (SimpleCredentials) get(REPOSITORY_CREDENTIALS);
}
/**
* @return the Locale applicable to the current CMS session
*/
default Locale getLocale() {
return (Locale) get(LOCALE);
}
/**
* Returns a mutable map bound to the http session. It can e.g. be used to manage user specific properties.
*
* @return mutable map of properties bound to the http session
*/
default Map<String, Serializable> getContextPayload() {
return (Map<String, Serializable>) get(CMS_SESSION_CONTEXT_PAYLOAD_KEY);
}
}
/*
* Copyright 2013-2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.contenttype;
import java.util.Map;
import java.util.SortedSet;
/**
* An immutable Hippo Content Type representation providing a more relaxed and enhanced form of an {@link EffectiveNodeType}
* exposing only non-residual {@link ContentTypeProperty} and {@link ContentTypeChild} elements with additional meta-data describing these {@link ContentTypeItem ContentTypeItems}.
* <p>
* A ContentType is always backed by an underlying EffectiveNodeType, and for all EffectiveNodeTypes a ContentType is provided.
* For EffectiveNodeTypes which do not have a corresponding ContentType pre-defined, a ContentType definition is automatically derived, see {@link #isDerivedType()}.
* </p>
* <p>
* The {@link #getProperties()} and {@link #getChildren()} methods provides direct access to these elements, but also can be access separately by name through {@link #getItem(String)}
* <br/>
* <em>Note that in case of a {@link #isDerivedType()} both a ContentTypeProperty and ContentTypeChild element may be defined by the same name, in which case {@link #getItem(String)} will
* only provide access to the corresponding child element (see also JCR-2.0 5.1.8).</em>
* </p>
* <p>
* Some pre-defined ContentTypes may represent an aggregate ({@link #isAggregate()}) which means that the ContentType also combines one or more mixin types, besides possibly having superTypes as well.
* This can happen when a pre-defined ContentType is enhanced with one or more mixins after its initial definition, as well as its underlying JCR NodeType definition was created,
* Currently the Jackrabbit JCR repository doesn't support adding extra mixins to an existing NodeType definition, thus for ContentTypes these must be aggregated separately.
* </p>
* <p>
* ContentType definitions representing existing the EffectiveNodeType of an JCR Node instance can also be an aggregate if the Node instance has additional mixins besides its primary NodeType.
* </p>
*/
public interface ContentType {
/**
* @return The immutable version of the ContentTypes instance used to create this definition
*/
long version();
/**
* @return True if there is no ContentType definition backing this type but it only and fully is derived from the underlying EffectiveNodeType
*/
boolean isDerivedType();
/**
* @return True if this is an aggregation of multiple ContentTypes like through a combination of ContentTypes or JCR Node Type mixins
*/
boolean isAggregate();
/**
* @return the immutable and aggregated or effective JCR Repository {@link javax.jcr.nodetype.NodeType} representation
* which underlies this ContentType definition
*/
EffectiveNodeType getEffectiveNodeType();
/**
* @return the Qualified name of the ContentType (see also JCR-2.0 3.2.5.2); or the list of aggregated ContentType names as [<name>,...] if {@link #isAggregate()}
* @see javax.jcr.nodetype.NodeTypeDefinition#getName()
*/
String getName();