Commit 67378eff authored by Ate Douma's avatar Ate Douma

HIPPLUG-970: initial import of the taxonomy standard plugin for CMS 7.10,...

HIPPLUG-970: initial import of the taxonomy standard plugin for CMS 7.10, cloned (unmodified) from the Forge taxonomy plugin
parents
* text=auto !eol
/LICENSE -text
/NOTICE -text
addon/frontend/pom.xml svneol=native#text/plain
addon/frontend/src/main/java/org/onehippo/taxonomy/plugin/res/new-category-16.png -text svneol=unset#image/png
addon/frontend/src/main/java/org/onehippo/taxonomy/plugin/res/picker-back.gif -text
addon/frontend/src/main/java/org/onehippo/taxonomy/plugin/res/remove-category-16.png -text svneol=unset#image/png
addon/frontend/src/main/java/org/onehippo/taxonomy/plugin/tree/folder-closed.gif -text
addon/frontend/src/main/java/org/onehippo/taxonomy/plugin/tree/folder-open.gif -text
addon/pom.xml svneol=native#text/plain
addon/repository/pom.xml svneol=native#text/plain
addon/repository/src/main/resources/classifiable-dao-service.xml svneol=native#text/plain
addon/repository/src/main/resources/hippoecm-extension.xml svneol=native#text/plain
addon/repository/src/main/resources/hippotaxonomy.cnd -text
addon/repository/src/main/resources/namespace-hippotaxonomy.xml svneol=native#text/plain
addon/repository/src/main/resources/navigator.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-deny-namespace-filter.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-deny-prototype.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-deny-section.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-domain.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-folder-view.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-hide-namespace.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-section-loader.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-section-translation.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-service.xml svneol=native#text/plain
addon/repository/src/main/resources/taxonomy-tree-view.xml svneol=native#text/plain
api/pom.xml svneol=native#text/plain
hst-api/pom.xml svneol=native#text/plain
hst/pom.xml svneol=native#text/plain
/pom.xml svneol=native#text/plain
src/site/resources/avail-locales-conf.png -text svneol=unset#image/png
src/site/resources/choose-taxonomy-term.png -text svneol=unset#image/png
src/site/resources/custom-taxonomy-editor.png -text svneol=unset#image/png
src/site/resources/custom-taxonomy-picker.png -text svneol=unset#image/png
src/site/resources/double-taxonomy-document.png -text svneol=unset#image/png
src/site/resources/double-taxonomy.png -text svneol=unset#image/png
src/site/resources/extra-taxonomy-added.png -text svneol=unset#image/png
src/site/resources/locale-selection.png -text svneol=unset#image/png
src/site/resources/mixin-added.png -text svneol=unset#image/png
src/site/resources/mixin-doctype-editor.png -text svneol=unset#image/png
src/site/resources/taxonomy-editor.png -text svneol=unset#image/png
src/site/resources/taxonomy-terms-in-editor.png -text svneol=unset#image/png
src/site/resources/translator.xml svneol=native#text/plain
src/site/site.xml svneol=native#text/plain
src/site/xdoc/add-extra-taxonomy.xml svneol=native#text/plain
src/site/xdoc/build-demo.xml svneol=native#text/plain
src/site/xdoc/category-detail-customization.xml svneol=native#text/plain
src/site/xdoc/category-localization.xml svneol=native#text/plain
src/site/xdoc/cms-configuration.xml svneol=native#text/plain
src/site/xdoc/hst-configuration.xml svneol=native#text/plain
src/site/xdoc/hst-configuration_7_8.xml svneol=native#text/plain
src/site/xdoc/index.xml svneol=native#text/plain
src/site/xdoc/install.xml svneol=native#text/plain
src/site/xdoc/release-notes.xml svneol=native#text/plain
src/site/xdoc/screenshots.xml svneol=native#text/plain
This diff is collapsed.
Hippo Forge Taxonomy Plugin
Copyright 2009-2014 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.
<?xml version="1.0"?>
<!--
Copyright 2007-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.
-->
<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/maven-v4_0_0.xsd">
<parent>
<groupId>org.onehippo</groupId>
<artifactId>taxonomy-addon</artifactId>
<version>1.12.00-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>taxonomy-addon-frontend</artifactId>
<name>Hippo Taxonomy CMS Addon</name>
<dependencies>
<dependency>
<groupId>org.onehippo</groupId>
<artifactId>taxonomy-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-engine</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-editor-frontend</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-test</artifactId>
<version>${hippo.cms.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo</groupId>
<artifactId>taxonomy-addon-repository</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-engine</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-config</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-workflow</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-api</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.html</include>
<include>**/*.css</include>
<include>**/*.gif</include>
<include>**/*.png</include>
<include>**/*.js</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>always</forkMode>
<workingDirectory>${project.build.directory}</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
<!-- maven 2.0.x support. Why, oh why? -->
<profiles>
<profile>
<id>tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-engine</artifactId>
<version>${hippo.repository.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
/*
* Copyright 2011-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.taxonomy.plugin;
import java.io.Serializable;
import java.util.Locale;
import org.onehippo.taxonomy.api.Category;
import org.onehippo.taxonomy.api.Taxonomy;
import org.onehippo.taxonomy.plugin.api.TaxonomyHelper;
public class CanonicalCategory implements Serializable {
private static final long serialVersionUID = 1L;
private final Taxonomy taxonomy;
private final String key;
private final String language;
public CanonicalCategory(Taxonomy taxonomy, String key, Locale locale) {
this(taxonomy, key, locale.getLanguage());
}
public CanonicalCategory(Taxonomy taxonomy, String key, String language) {
this.taxonomy = taxonomy;
this.key = key;
this.language = language;
}
public String getName() {
Category category = taxonomy.getCategoryByKey(key);
if (category != null) {
return TaxonomyHelper.getCategoryName(category, language);
}
return null;
}
public String getKey() {
return key;
}
}
\ No newline at end of file
/*
* Copyright 2009-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.taxonomy.plugin;
import java.util.List;
import org.apache.wicket.util.io.IClusterable;
import org.onehippo.taxonomy.api.Taxonomy;
import org.onehippo.taxonomy.plugin.api.JcrCategoryFilter;
public interface ITaxonomyService extends IClusterable {
static final String DEFAULT_SERVICE_TAXONOMY_ID = "service.taxonomy";
/**
* Name of the (configuration) property that contains the
* name of the service that implements ITaxonomyService.
* If this property is not present, the name to be used is
* the default registration point (ITaxonomyService.class.getName()).
*/
static final String SERVICE_ID = "taxonomy.id";
/**
* Name of the configuration property that corresponds to
* the name of the taxonomy to use. Use this name to achieve
* cross-plugin consistency of configuration.
*/
static final String TAXONOMY_NAME = "taxonomy.name";
/**
* @param name
* @return the taxonomy of the specified name.
*/
Taxonomy getTaxonomy(String name);
/**
* @return the list of names of the available taxonomies
*/
List<String> getTaxonomies();
/**
* @return unmodifiable List of categoryFilters, empty is non configured
*/
List<JcrCategoryFilter> getCategoryFilters();
}
/*
* Copyright 2009-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.taxonomy.plugin;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.jcr.Node;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.model.map.JcrValueList;
import org.hippoecm.frontend.model.properties.JcrPropertyModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.Plugin;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.onehippo.taxonomy.api.TaxonomyNodeTypes;
import org.onehippo.taxonomy.plugin.model.Classification;
import org.onehippo.taxonomy.plugin.model.ClassificationDao;
import org.onehippo.taxonomy.plugin.model.JcrHelper;
/**
* This plugin provides a data access service to a taxonomy plugin.
*
* The multiple property where selected keys are stored is configurable in 'fieldPath' parameter.
*/
public class MixinClassificationDaoPlugin extends Plugin implements ClassificationDao {
private static final long serialVersionUID = 1L;
// Name of the multiple property where selected keys are stored
public static final String CONFIG_FIELD_PATH = "fieldPath";
/**
* Constructor
*/
public MixinClassificationDaoPlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
context.registerService(this, config.getString(SERVICE_ID));
}
/**{@inheritDoc} */
@Override
public Classification getClassification(Node node) {
List<String> values;
String nodePath = null;
String canonicalKeyValue = null;
try {
nodePath = node.getPath();
if (JcrHelper.isNodeType(node, TaxonomyNodeTypes.NODETYPE_HIPPOTAXONOMY_CLASSIFIABLE)) {
if (node.hasProperty(getFieldPath())) {
values = new ArrayList<>(new JcrValueList<String>(
new JcrPropertyModel<String>(node.getProperty(getFieldPath())), PropertyType.STRING));
} else {
values = new LinkedList<>();
}
if (JcrHelper.isNodeType(node, TaxonomyNodeTypes.NODETYPE_HIPPOTAXONOMY_CANONISED)) {
if (node.hasProperty(TaxonomyNodeTypes.HIPPOTAXONOMY_CANONICALKEY)) {
canonicalKeyValue = node.getProperty(TaxonomyNodeTypes.HIPPOTAXONOMY_CANONICALKEY).getString();
}
}
} else {
throw new IllegalStateException("node with path " + nodePath + " is not classifiable");
}
} catch (RepositoryException e) {
throw new RuntimeException("RepositoryException creating classification object for node with path " + nodePath, e);
}
return new Classification(values, new JcrNodeModel(node), canonicalKeyValue);
}
/**{@inheritDoc} */
@Override
public void save(Classification classification) {
String nodePath = null;
final JcrNodeModel id = (JcrNodeModel) classification.getId();
try {
final Node node = id.getNode();
nodePath = node.getPath();
if (JcrHelper.isNodeType(node, TaxonomyNodeTypes.NODETYPE_HIPPOTAXONOMY_CLASSIFIABLE)) {
List<String> keys = classification.getKeys();
node.setProperty(getFieldPath(), keys.toArray(new String[keys.size()]));
if (JcrHelper.isNodeType(node, TaxonomyNodeTypes.NODETYPE_HIPPOTAXONOMY_CANONISED)) {
String canonKey = classification.getCanonical();
// when null, save empty string because it is mandatory at JCR level (see hippotaxonomy.cnd)
node.setProperty(TaxonomyNodeTypes.HIPPOTAXONOMY_CANONICALKEY, (canonKey == null) ? "" : canonKey);
}
} else {
throw new IllegalStateException("node with path " + node.getPath() + " is not classifiable");
}
} catch (RepositoryException e) {
throw new RuntimeException("RepositoryException saving classification object for node with path " + nodePath, e);
}
}
/**
* Get a configured field path, or the default
*/
protected String getFieldPath() {
return getPluginConfig().getString(CONFIG_FIELD_PATH, TaxonomyNodeTypes.HIPPOTAXONOMY_KEYS);
}
}
<!--
* Copyright 2007-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.
-->
<html xmlns:wicket="http://wicket.apache.org/">
<wicket:extend>
<table class="hippo-window-form">
<tr>
<td><label><wicket:message key="name" />:</label></td>
<td><input wicket:id="name" /></td>
</tr>
<tr>
<td><label><wicket:message key="key" />:</label></td>
<td><input wicket:id="key" /></td>
</tr>
</table>
</wicket:extend>
</html>
\ No newline at end of file
/*
* Copyright 2009-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.taxonomy.plugin;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.util.value.IValueMap;
import org.hippoecm.frontend.dialog.AbstractDialog;
import org.hippoecm.repository.api.StringCodec;
import org.onehippo.taxonomy.api.Taxonomy;
import org.onehippo.taxonomy.plugin.api.KeyCodec;
public abstract class NewCategoryDialog extends AbstractDialog<Taxonomy> {
private static final long serialVersionUID = 1L;
private String key;
private String name;
public NewCategoryDialog(IModel<Taxonomy> taxonomyModel) {
super(taxonomyModel);
name = "new category";
add(new AttributeAppender("class", new Model<String>("hippo-editor"), " "));
final FormComponent<String> keyField = new TextField<String>("key", new IModel<String>() {
private static final long serialVersionUID = 1L;
public String getObject() {
return getKey();
}
public void setObject(String object) {
key = object;
}
public void detach() {
}
});
keyField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
keyField.setOutputMarkupId(true);
add(keyField);
FormComponent<String> nameField = new TextField<String>("name", new IModel<String>() {
private static final long serialVersionUID = 1L;
public String getObject() {
return name;
}
public void setObject(String object) {
name = object;
}
public void detach() {
}
});
nameField.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(keyField);
}
});
add(nameField);
}
protected String getKey() {
if (key != null) {
return key;
}
if (name == null) {
return null;
}
String encoded = useKeyUrlEncoding() ? getNodeNameCodec().encode(name) : KeyCodec.encode(name);
String myKey = encoded;
int index = 0;
Taxonomy taxonomy = getModelObject();
// make sure we have unique keys:
while (taxonomy.getCategoryByKey(myKey) != null) {
myKey = encoded + '_' + (++index);
}
return myKey;
}
protected String getName() {
return name;
}
@Override
public IValueMap getProperties() {
return SMALL;
}
public IModel<String> getTitle() {
return new StringResourceModel("new-category", this, null);
}
/**
* Get the CMS's URL friendly node name encoder
*/
protected abstract StringCodec getNodeNameCodec();
/**
*
* Check if we should use ULR ending
* @return true if using url encoding
*/
protected abstract boolean useKeyUrlEncoding();
}
name: Name
key: Schl\u00FCssel
new-category: Neue Kategorie
\ No newline at end of file