Commit 1ca9d71a authored by Ate Douma's avatar Ate Douma

CMS7-7081: Separate and promote all hippo services modules into standalone projects

- move and rename services-contenttype under tmp1/trunk and rename it back to services-contenttype/trunk hereafter
parents
* text=auto !eol
/LICENSE -text
/NOTICE -text
/pom.xml svneol=native#text/plain
src/test/resources/org/onehippo/cms7/services/contenttype/nt-file.json -text
This diff is collapsed.
Hippo CMS7 Services - contenttype
Copyright 2013 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" encoding="UTF-8"?>
<!--
Copyright 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.
-->
<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>21</version>
</parent>
<name>Hippo CMS7 Services - contenttype</name>
<artifactId>hippo-services-contenttype</artifactId>
<version>1.03.00-SNAPSHOT</version>
<inceptionYear>2013</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 - contenttype</notice.project.name>
<hippo.services.version>1.03.00-SNAPSHOT</hippo.services.version>
<hippo.repository.version>2.25.00-SNAPSHOT</hippo.repository.version>
<hippo.cms.version>2.25.00-SNAPSHOT</hippo.cms.version>
</properties>
<scm>
<connection>scm:svn:http://svn.onehippo.org/repos/hippo/hippo-cms7/services/services-contenttype/trunk</connection>
<developerConnection>scm:svn:https://svn.onehippo.org/repos/hippo/hippo-cms7/services/services-contenttype/trunk</developerConnection>
<url>http://svn.onehippo.org/repos/hippo/hippo-cms7/services/services-contenttype/trunk</url>
</scm>
<repositories>
<repository>
<id>hippo</id>
<name>Hippo Maven 2</name>
<url>http://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-services</artifactId>
<version>${hippo.services.version}</version>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
<version>${hippo.repository.version}</version>
<scope>provided</scope>
</dependency>
<!-- Jackson Java JSON-processor -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<scope>test</scope>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-test</artifactId>
<version>${hippo.cms.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-editor-repository</artifactId>
<version>${hippo.cms.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Hippo-Modules>org.onehippo.cms7.services.contenttype.ContentTypeServiceModule</Hippo-Modules>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<org.onehippo.repository.test.keepserver>true</org.onehippo.repository.test.keepserver>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-editor-repository</artifactId>
<version>${hippo.cms.version}</version>
<type>jar</type>
<classifier>tests</classifier>
<scope>test</scope>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<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">
<!-- largely forked but heavily modified and simplified version of Jackrabbit 2.6 org.apache.jackrabbit.core.nodetype.BitSetENTCacheImpl.java
retaining its original AS2.0 license header
-->
<exclude>src/main/java/org/onehippo/cms7/services/contenttype/AggregatedDocumentTypesCache.java</exclude>
<!-- test output json file which cannot have embedded comments -->
<exclude>src/test/resources/org/onehippo/cms7/services/contenttype/nt-file.json</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
/*
* Copyright 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.contenttype;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.hippoecm.repository.ext.DaemonModule;
import org.onehippo.cms7.services.HippoServiceRegistry;
public class ContentTypeServiceModule implements DaemonModule {
private HippoContentTypeService service;
@Override
public void initialize(Session session) throws RepositoryException {
service = new HippoContentTypeService(session);
HippoServiceRegistry.registerService(service, ContentTypeService.class);
}
@Override
public void shutdown() {
HippoServiceRegistry.unregisterService(service, ContentTypeService.class);
service.shutdown();
}
}
/*
* Copyright 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.contenttype;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DocumentTypeFieldImpl extends Sealable implements DocumentTypeField {
private final String definingType;
private final String name;
private EffectiveNodeTypeItem nti;
private String caption;
private final boolean propertyField;
private boolean derivedField;
private final String fieldType;
private final String itemType;
private boolean primaryField;
private boolean multiple;
private boolean mandatory;
private boolean autoCreated;
private boolean protect;
private boolean ordered;
private List<String> validators = new ArrayList<String>();
private Map<String, List<String>> fieldProperties = new HashMap<String, List<String>>();
@Override
protected void doSeal() {
validators = Collections.unmodifiableList(validators);
for (Map.Entry<String,List<String>> entry : fieldProperties.entrySet()) {
entry.setValue(Collections.unmodifiableList(entry.getValue()));
}
fieldProperties = Collections.unmodifiableMap(fieldProperties);
}
public DocumentTypeFieldImpl(String definingType, String name, String fieldType, String itemType) {
this.definingType = definingType;
this.name = name;
this.fieldType = fieldType;
this.itemType = itemType;
this.propertyField = true;
}
public DocumentTypeFieldImpl(String definingType, String name, String fieldType) {
this.definingType = definingType;
this.name = name;
this.fieldType = fieldType;
this.itemType = fieldType;
this.propertyField = false;
}
public DocumentTypeFieldImpl(String definingType, EffectiveNodeTypeProperty property) {
this.definingType = definingType;
this.nti = property;
this.primaryField = false;
this.propertyField = true;
this.derivedField = true;
this.name = property.getName();
this.itemType = property.getType();
this.fieldType = this.itemType;
this.multiple = property.isMultiple();
this.mandatory = property.isMandatory();
this.autoCreated = property.isAutoCreated();
this.protect = property.isProtected();
this.ordered = false;
}
public DocumentTypeFieldImpl(String definingType, EffectiveNodeTypeChild child) {
this.definingType = definingType;
this.nti = child;
this.primaryField = false;
this.propertyField = false;
this.derivedField = true;
this.name = child.getName();
this.itemType = child.getType();
this.fieldType = this.itemType;
this.multiple = child.isMultiple();
this.mandatory = child.isMandatory();
this.autoCreated = child.isAutoCreated();
this.protect = child.isProtected();
this.ordered = false;
}
public DocumentTypeFieldImpl(DocumentTypeFieldImpl other) {
this.definingType = other.definingType;
this.nti = other.nti;
this.primaryField = other.primaryField;
this.propertyField = other.propertyField;
this.derivedField = other.derivedField;
this.name = other.name;
this.itemType = other.itemType;
this.fieldType = other.fieldType;
this.multiple = other.multiple;
this.mandatory = other.mandatory;
this.autoCreated = other.autoCreated;
this.protect = other.protect;
this.ordered = other.ordered;
this.validators.addAll(other.validators);
this.fieldProperties.putAll(other.fieldProperties);
}
@Override
public EffectiveNodeTypeItem getEffectiveNodeTypeItem() {
return nti;
}
public void setEffectiveNodeTypeItem(EffectiveNodeTypeItem nti) {
checkSealed();
this.nti = nti;
}
@Override
public String getName() {
return name;
}
@Override
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
checkSealed();
this.caption = caption;
}
@Override
public String getDefiningType() {
return definingType;
}
@Override
public boolean isPropertyField() {
return propertyField;
}
@Override
public boolean isDerivedField() {
return derivedField;
}
@Override
public String getFieldType() {
return fieldType;
}
@Override
public String getItemType() {
return itemType;
}
@Override
public boolean isPrimaryField() {
return primaryField;
}
public void setPrimaryField(boolean primaryField) {
checkSealed();
this.primaryField = primaryField;
}
@Override
public boolean isMultiple() {
return multiple;
}
public void setMultiple(boolean multiple) {
checkSealed();
this.multiple = multiple;
}
@Override
public boolean isMandatory() {
return mandatory;
}
public void setMandatory(boolean mandatory) {
checkSealed();
this.mandatory = mandatory;
}
@Override
public boolean isAutoCreated() {
return autoCreated;
}
public void setAutoCreated(boolean autoCreated) {
checkSealed();
this.autoCreated = autoCreated;
}
@Override
public boolean isProtected() {
return protect;
}
public void setProtected(boolean protect) {
checkSealed();
this.protect = protect;
}
@Override
public boolean isOrdered() {
return ordered;
}
public void setOrdered(boolean ordered) {
checkSealed();
this.ordered = ordered;
}
@Override
public List<String> getValidators() {
return validators;
}
@Override
public Map<String, List<String>> getFieldProperties() {
return fieldProperties;
}
}
/*
* Copyright 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.contenttype;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.jcr.PropertyType;
class DocumentTypesCache extends Sealable implements DocumentTypes {
private static Map<String, String> jcrPropertyTypesMap = new HashMap<String, String>();
static {
jcrPropertyTypesMap.put(PropertyType.TYPENAME_BINARY, PropertyType.TYPENAME_BINARY);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_BOOLEAN, PropertyType.TYPENAME_BOOLEAN);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_DATE, PropertyType.TYPENAME_DATE);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_DECIMAL, PropertyType.TYPENAME_DECIMAL);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_DOUBLE, PropertyType.TYPENAME_DOUBLE);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_LONG, PropertyType.TYPENAME_LONG);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_NAME, PropertyType.TYPENAME_NAME);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_PATH, PropertyType.TYPENAME_PATH);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_REFERENCE, PropertyType.TYPENAME_REFERENCE);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_STRING, PropertyType.TYPENAME_STRING);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_URI, PropertyType.TYPENAME_URI);
jcrPropertyTypesMap.put(PropertyType.TYPENAME_WEAKREFERENCE, PropertyType.TYPENAME_WEAKREFERENCE);
jcrPropertyTypesMap = Collections.unmodifiableMap(jcrPropertyTypesMap);
}
private volatile static long versionSequence = 0;
private final long version = ++versionSequence;
private final EffectiveNodeTypesCache entCache;
private Map<String, String> propertyTypeMappings = new HashMap<String, String>(jcrPropertyTypesMap);
private Map<String, DocumentTypeImpl> types = new TreeMap<String, DocumentTypeImpl>();
private Map<String, Set<DocumentType>> prefixesMap;
protected DocumentTypesCache(EffectiveNodeTypesCache entCache) {
this.entCache = entCache;
}
protected Map<String, String> getPropertyTypeMappings() {
return propertyTypeMappings;
}
protected Map<String, DocumentTypeImpl> getTypes() {
return types;
}
@Override
protected void doSeal() {
propertyTypeMappings = Collections.unmodifiableMap(propertyTypeMappings);
for (Sealable s : types.values()) {
s.seal();
}
types = Collections.unmodifiableMap(types);
// create the prefixesMap for accessing the predefined types by their prefix
prefixesMap = new TreeMap<String, Set<DocumentType>>();
for (Map.Entry<String, DocumentTypeImpl> entry : types.entrySet()) {
// recreate the prefix as the DocumentType itself may have been 'upgraded' to an aggregate without a (single) prefix
String prefix = entry.getKey().substring(0, entry.getKey().indexOf(":"));
Set<DocumentType> entries = prefixesMap.get(prefix);
if (entries == null) {
entries = new LinkedHashSet<DocumentType>();
prefixesMap.put(prefix, entries);
}
entries.add(entry.getValue());
}
for (Map.Entry<String, Set<DocumentType>> entry : prefixesMap.entrySet()) {
entry.setValue(Collections.unmodifiableSet(entry.getValue()));
}
prefixesMap = Collections.unmodifiableMap(prefixesMap);
}
@Override
public long version() {
return version;
}
@Override
public DocumentTypeImpl getType(String name) {
return types.get(name);
}
@Override
public Map<String, Set<DocumentType>> getTypesByPrefix() {
return prefixesMap;
}
@Override
public EffectiveNodeTypesCache getEffectiveNodeTypes() {
return entCache;
}
}
/*
* Copyright 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.contenttype;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
public class EffectiveNodeTypeChildImpl extends EffectiveNodeTypeItemImpl implements EffectiveNodeTypeChild {
private String defaultPrimaryType;
private String type;
private Set<String> requiredPrimaryTypes = new TreeSet<String>();
@Override
protected void doSeal() {
super.doSeal();
requiredPrimaryTypes = Collections.unmodifiableSet(requiredPrimaryTypes);
}
public EffectiveNodeTypeChildImpl(String name, String definingType) {
super(name, definingType);
}
@Override
public String getDefaultPrimaryType() {
return defaultPrimaryType;
}
public void setDefaultPrimaryType(final String defaultPrimaryType) {
this.defaultPrimaryType = defaultPrimaryType;
}
@Override
public Set<String> getRequiredPrimaryTypes() {
return requiredPrimaryTypes;
}
@Override
public String getType() {
if (type == null) {
Iterator<String> iterator = requiredPrimaryTypes.iterator();
StringBuilder sb = new StringBuilder(iterator.next());
while (iterator.hasNext()) {
sb.append(',');
sb.append(iterator.next());
}
type = sb.toString();
}
return type;
}
}
\ No newline at end of file
/*
* Copyright 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.contenttype;
public abstract class EffectiveNodeTypeItemImpl extends Sealable implements EffectiveNodeTypeItem {
private final String name;
private final String definingType;
private final boolean residual;
private boolean multiple;
private boolean mandatory;
private boolean autoCreated;
private boolean protect;
protected void doSeal() {
}
protected EffectiveNodeTypeItemImpl(String name, String definingType) {
this.name = name;
this.definingType = definingType;
this.residual = "*".equals(name);
}