Tobias Jeger pushed to branch release/3.2 at cms-community / hippo-testsuite
Commits: 3c844b07 by Woonsan Ko at 2017-06-06T13:19:10-04:00 HSTTWO-4034: Adding an example custom InternalLocationMapperEntries. - - - - - 3 changed files: - + cms/src/main/java/org/onehippo/cms7/testsuite/cms/demo/MyCustomInternalLocationMapperEntries.java - dependencies/cms/pom.xml - pom.xml Changes: ===================================== cms/src/main/java/org/onehippo/cms7/testsuite/cms/demo/MyCustomInternalLocationMapperEntries.java ===================================== --- /dev/null +++ b/cms/src/main/java/org/onehippo/cms7/testsuite/cms/demo/MyCustomInternalLocationMapperEntries.java @@ -0,0 +1,64 @@ +/* + * 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.cms7.testsuite.cms.demo; + +import java.util.ArrayList; +import java.util.List; + +import org.onehippo.cms7.autoexport.InternalLocationMapperEntries; + +/** + * An example custom <code>InternalLocationMapperEntries</code> implementation to override mapping entries used + * by auto-export module. This example overrides the behavior of auto-export for updater script items and HST container + * component items, just for demonstration purpose. + * <P> + * <EM>Note:</EM> This example is not supposed to be copied or used in real development projects without full understandings + * and this kind of customization is not guaranteed to work as-is in the future product upgrades. Developers for + * end projects are required to understand what this kind of customization means and what kind of things they need + * to do by themselves in the future product upgrade process, for instance. + * </P> + */ +public class MyCustomInternalLocationMapperEntries extends InternalLocationMapperEntries { + + private List<Entry> customEntries; + + @Override + protected List<Entry> getEntries() { + if (customEntries == null) { + List<Entry> tempEntries = new ArrayList<>(); + tempEntries.addAll(super.getEntries()); + + // /hippo:configuration/hippo:update/hippo:registry/* + String[] nodePatterns = new String[] { "/hippo:configuration/hippo:update/hippo:registry/" + NAME }; + String[] propertyPatterns = new String[] { "/hippo:configuration/hippo:update/hippo:registry/" + NAME + "/" + ANY }; + String contextNode = "/hippo:configuration/hippo:update/hippo:registry/$1"; + String file = "configuration/update/registry/$1.xml"; + tempEntries.add(0, createEntry(nodePatterns, propertyPatterns, contextNode, file)); + + // /hst:hst/hst:configurations/project/hst:workspace/hst:containers/*/* + nodePatterns = new String[] { "/hst:hst/hst:configurations/" + NAME + "/hst:workspace/hst:containers/" + NAME + "/" + NAME }; + propertyPatterns = new String[] { "/hst:hst/hst:configurations/" + NAME + "/hst:workspace/hst:containers/" + NAME + "/" + NAME + "/" + ANY }; + contextNode = "/hst:hst/hst:configurations/$1/hst:workspace/hst:containers/$2/$3"; + file = "hst/configurations/$1/workspace/containers/$2/$3.xml"; + tempEntries.add(1, createEntry(nodePatterns, propertyPatterns, contextNode, file)); + + customEntries = tempEntries; + } + + return customEntries; + } + +} ===================================== dependencies/cms/pom.xml ===================================== --- a/dependencies/cms/pom.xml +++ b/dependencies/cms/pom.xml @@ -104,6 +104,12 @@ <artifactId>hippo-plugin-resourcebundle-editor</artifactId> </dependency> + <!-- For MyCustomInternalLocationMapperEntries.java --> + <dependency> + <groupId>org.onehippo.cms7</groupId> + <artifactId>hippo-cms-automatic-export-repository</artifactId> + </dependency> + </dependencies> </project> ===================================== pom.xml ===================================== --- a/pom.xml +++ b/pom.xml @@ -246,6 +246,9 @@ <rebel.log4j-plugin>true</rebel.log4j-plugin> <solr.data.dir>${solr.data.dir}</solr.data.dir> <project.basedir>${project.basedir}</project.basedir> + <!-- + <org.onehippo.cms7.autoexport.InternalLocationMapperEntries>org.onehippo.cms7.testsuite.cms.demo.MyCustomInternalLocationMapperEntries</org.onehippo.cms7.autoexport.InternalLocationMapperEntries> + --> </systemProperties> </container> <deployables> View it on GitLab: https://code.onehippo.org/cms-community/hippo-testsuite/commit/3c844b07f4b884b6bcb79b3d7f4da5745973963f
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn