Commit f30f3c98 authored by Ate Douma's avatar Ate Douma

TRIVIAL cleanup master

parent d83ee853
*.log
*.iml
.settings
.idea/
.project/
target/
node_modules/
coverage/
cache/
dll/
.awcache/
This diff is collapsed.
Hippo Addon Channel Manager
Copyright 2011-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.
# Build
Build with testing:
# This is not the branch you're looking for...
$ mvn clean install
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
Build without testing:
To checkout the code for a specific release tag, after cloning this repository, use the following:
$ mvn clean install -DskipTests
## to show the available tags
Build with snapshot dependencies:
git tag
$ mvn clean install -Dhippo.snapshots
## to checkout a specific tag
$ mvn clean install "-Dhippo.snapshots" //WINDOWS USERS
git checkout <tag name>
Note: only needed when the project refers to SNAPSHOT dependencies!
## 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:
Note: only effective when your Maven settings.xml file contains a profile
with this property for the Hippo snapshot repository. For details, see
http://www.onehippo.org/library/development/build-hippo-cms-from-scratch.html
git checkout -b forked-<tag name> <tag name>
# Develop AngularJS UI
See the frontent-ng/README.md
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 2016-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">
<parent>
<artifactId>hippo-addon-channel-manager</artifactId>
<groupId>org.onehippo.cms7</groupId>
<version>5.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hippo-addon-channel-manager-content-service</artifactId>
<name>Addon Channel Manager Content Service</name>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-ckeditor-config</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-services</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-json</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-api</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-builtin</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-utilities</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-plugin-gallerypicker</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-services-htmlprocessor</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!--test dependencies-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-testutils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-testutils</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
/*
* Copyright 2017 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.cms.channelmanager.content;
import java.io.Serializable;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.observation.EventIterator;
import javax.servlet.http.HttpServletRequest;
import org.hippoecm.repository.util.JcrUtils;
import org.onehippo.cms.channelmanager.content.document.DocumentsServiceImpl;
import org.onehippo.cms.channelmanager.content.document.util.HintsInspector;
import org.onehippo.cms.channelmanager.content.document.util.HintsInspectorImpl;
import org.onehippo.cms.channelmanager.content.documenttype.DocumentTypesService;
import org.onehippo.cms7.services.cmscontext.CmsSessionContext;
import org.onehippo.repository.jaxrs.api.JsonResourceServiceModule;
import org.onehippo.repository.jaxrs.api.ManagedUserSessionInvoker;
import org.onehippo.repository.jaxrs.api.SessionRequestContextProvider;
import org.onehippo.repository.jaxrs.event.JcrEventListener;
import static org.hippoecm.repository.util.JcrUtils.ALL_EVENTS;
/**
* ChannelContentServiceModule registers and manages a JAX-RS endpoint of the repository module.
* <p>
* That endpoint represents the REST resource {@link ContentResource} and the resource's root address (configurable, but
* defaulting to "content"), and it registers the {@link ManagedUserSessionInvoker} to take care of authentication and
* authorization.
*/
public class ChannelContentServiceModule extends JsonResourceServiceModule {
private final DocumentsServiceImpl documentsService;
private Function<HttpServletRequest, Map<String, Serializable>> contextPayloadService;
public ChannelContentServiceModule() {
this.documentsService = new DocumentsServiceImpl();
this.contextPayloadService = request -> Optional.ofNullable(CmsSessionContext.getContext(request.getSession()).getContextPayload()).orElse(Collections.emptyMap());
addEventListener(new HippoNamespacesEventListener() {
@Override
public void onEvent(final EventIterator events) {
DocumentTypesService.get().invalidateCache();
}
});
}
@Override
protected void doInitialize(final Session session) throws RepositoryException {
super.doInitialize(session);
final String propertyPath = moduleConfigPath + "/hintsInspectorClass";
final String defaultValue = HintsInspectorImpl.class.getName();
final String hintsInspectorClassName = JcrUtils.getStringProperty(session, propertyPath, defaultValue);
try {
final HintsInspector hintsInspector = (HintsInspector) Class.forName(hintsInspectorClassName).newInstance();
documentsService.setHintsInspector(hintsInspector);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RepositoryException(e);
}
}
@Override
protected Object getRestResource(final SessionRequestContextProvider sessionRequestContextProvider) {
return new ContentResource(sessionRequestContextProvider, documentsService, contextPayloadService);
}
private abstract static class HippoNamespacesEventListener extends JcrEventListener {
static final String HIPPO_NAMESPACES = "/hippo:namespaces";
HippoNamespacesEventListener() {
super(ALL_EVENTS, HIPPO_NAMESPACES, true, null, null);
}
}
}
/*
* Copyright 2017 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.cms.channelmanager.content;
import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import javax.jcr.Session;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.onehippo.cms.channelmanager.content.document.DocumentsService;
import org.onehippo.cms.channelmanager.content.document.model.Document;
import org.onehippo.cms.channelmanager.content.document.model.FieldValue;
import org.onehippo.cms.channelmanager.content.document.model.NewDocumentInfo;
import org.onehippo.cms.channelmanager.content.document.util.FieldPath;
import org.onehippo.cms.channelmanager.content.documenttype.DocumentTypesService;
import org.onehippo.cms.channelmanager.content.error.ErrorWithPayloadException;
import org.onehippo.cms.channelmanager.content.folder.FoldersService;
import org.onehippo.cms.channelmanager.content.slug.SlugFactory;
import org.onehippo.cms.channelmanager.content.templatequery.TemplateQueryService;
import org.onehippo.repository.jaxrs.api.SessionRequestContextProvider;
@Produces("application/json")
@Path("/")
public class ContentResource {
private static final CacheControl NO_CACHE = new CacheControl();
static {
NO_CACHE.setNoCache(true);
}