Author: rhauch
Date: 2009-05-05 18:09:15 -0400 (Tue, 05 May 2009)
New Revision: 886
Added:
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ImmutableProblems.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrItemDefinitionTemplate.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinitionTemplate.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeTemplate.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinitionTemplate.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/InvalidNodeTypeDefinitionException.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeDefinitionTemplate.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeDefinition.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeExistsException.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeTemplate.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/PropertyDefinitionTemplate.java
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/jsr_170_builtins.cnd
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java
trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/
trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/existingType.cnd
trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/validType.cnd
trunk/dna-jcr/src/test/resources/tck_test_types.cnd
Removed:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNodeTypeSource.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java
Modified:
trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java
trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
trunk/dna-jcr/pom.xml
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinition.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeType.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeSource.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrReadingTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWritingTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/Vehicles.java
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java
trunk/docs/examples/gettingstarted/repositories/src/test/resources/log4j.properties
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java
trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatingRequestProcessorTest.java
Log:
DNA-363 Define node types via CND files
Applied the for_review and delta patches. Made a few minor changes, including adding some
JavaDoc, added JCIP concurrency annotations, and created a new ImmutableProblems wrapper
so that some classes could be marked as @Immutable.
Modified: trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java
===================================================================
--- trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java 2009-05-05 16:30:45 UTC
(rev 885)
+++ trunk/dna-cnd/src/main/java/org/jboss/dna/cnd/CndImporter.java 2009-05-05 22:09:15 UTC
(rev 886)
@@ -577,6 +577,7 @@
factory.create(JcrLexicon.HAS_ORDERABLE_CHILD_NODES,
hasOrderableChildNodes),
factory.create(JcrLexicon.IS_MIXIN, isMixin),
factory.create(JcrLexicon.IS_QUERYABLE, isQueryable),
+ factory.create(JcrLexicon.NODE_TYPE_NAME, name),
factory.create(JcrLexicon.PRIMARY_ITEM_NAME,
primaryItemName));
return path;
@@ -599,7 +600,7 @@
// Create the node for the node type ...
if (name == null) return null;
- Path path = pathFactory().create(parentPath, name);
+ Path path = pathFactory().create(parentPath,
JcrLexicon.PROPERTY_DEFINITION);
PropertyFactory factory = context.getPropertyFactory();
destination.create(path,
@@ -608,6 +609,7 @@
factory.create(JcrLexicon.DEFAULT_VALUES,
(Object[])defaultValues),
factory.create(JcrLexicon.MULTIPLE, multiple),
factory.create(JcrLexicon.MANDATORY, mandatory),
+ factory.create(JcrLexicon.NAME, name),
factory.create(JcrLexicon.AUTO_CREATED, autoCreated),
factory.create(JcrLexicon.PROTECTED, isProtected),
factory.create(JcrLexicon.ON_PARENT_VERSION,
onParentVersion),
@@ -632,7 +634,7 @@
// Create the node for the node type ...
if (name == null) return null;
- Path path = pathFactory().create(parentPath, name);
+ Path path = pathFactory().create(parentPath,
JcrLexicon.CHILD_NODE_DEFINITION);
PropertyFactory factory = context.getPropertyFactory();
destination.create(path,
@@ -640,6 +642,7 @@
factory.create(JcrLexicon.REQUIRED_PRIMARY_TYPES,
(Object[])requiredPrimaryTypes),
factory.create(JcrLexicon.DEFAULT_PRIMARY_TYPE,
defaultPrimaryType),
factory.create(JcrLexicon.MANDATORY, mandatory),
+ factory.create(JcrLexicon.NAME, name),
factory.create(JcrLexicon.AUTO_CREATED, autoCreated),
factory.create(JcrLexicon.PROTECTED, isProtected),
factory.create(JcrLexicon.ON_PARENT_VERSION,
onParentVersion),
Modified: trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java
===================================================================
--- trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-cnd/src/test/java/org/jboss/dna/cnd/CndImporterTest.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -32,6 +32,7 @@
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.jboss.dna.common.collection.Problem;
import org.jboss.dna.common.collection.SimpleProblems;
@@ -40,12 +41,14 @@
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.JcrLexicon;
import org.jboss.dna.graph.JcrNtLexicon;
+import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.io.Destination;
import org.jboss.dna.graph.io.GraphBatchDestination;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
import org.junit.Before;
import org.junit.Test;
@@ -98,6 +101,22 @@
}
}
+ protected Node node( String pathToNode, String childNodeName, String nameValue ) {
+ Node a = graph.getNodeAt("/a/" + pathToNode);
+ List<Location> children = a.getChildren();
+
+ for (Location childLocation : a.getChildren()) {
+ if
(!childLocation.getPath().getLastSegment().getName().equals(name(childNodeName)))
continue;
+ Node child = graph.getNodeAt(childLocation);
+ Property nameProp = child.getProperty(JcrLexicon.NAME);
+ if (nameProp != null &&
nameProp.getFirstValue().equals(name(nameValue))) {
+ return child;
+ }
+ }
+
+ return null;
+ }
+
protected Node node( String pathToNode ) {
return graph.getNodeAt("/a/" + pathToNode);
}
@@ -162,7 +181,8 @@
context.getNamespaceRegistry().register("ex",
"http://namespace.com/ns");
Node nodeType = node("ex:NodeType");
assertThat(nodeType, hasProperty(JcrLexicon.IS_ABSTRACT, true));
- Node prop = node("ex:NodeType/ex:property");
+ Node prop = node("ex:NodeType/jcr:propertyDefinition");
+ assertThat(prop, hasProperty(JcrLexicon.NAME, name("ex:property")));
assertThat(prop, hasProperty(JcrLexicon.REQUIRED_TYPE, "STRING"));
assertThat(prop, hasProperty(JcrLexicon.DEFAULT_VALUES, new Object[]
{"default1", "default2"}));
assertThat(prop, hasProperty(JcrLexicon.AUTO_CREATED, true));
@@ -173,7 +193,8 @@
assertThat(prop, hasProperty(JcrLexicon.VALUE_CONSTRAINTS, new Object[]
{"constraint1", "constraint2"}));
assertThat(prop, hasProperty(JcrLexicon.IS_FULL_TEXT_SEARCHABLE, false));
assertThat(prop, hasProperty(JcrLexicon.IS_QUERY_ORDERABLE, false));
- Node node = node("ex:NodeType/ex:node");
+ Node node = node("ex:NodeType/jcr:childNodeDefinition");
+ assertThat(node, hasProperty(JcrLexicon.NAME, name("ex:node")));
assertThat(node, hasProperty(JcrLexicon.REQUIRED_PRIMARY_TYPES, new Object[]
{name("ex:reqType1"), name("ex:reqType2")}));
assertThat(node, hasProperty(JcrLexicon.DEFAULT_PRIMARY_TYPE,
name("ex:defaultType")));
assertThat(node, hasProperty(JcrLexicon.AUTO_CREATED, true));
@@ -223,9 +244,10 @@
// - * (undefined)
// + * (nt:base) = nt:unstructured multiple version
assertNodeType("nt:unstructured", NO_SUPERTYPES, NO_PRIMARY_NAME,
NodeOptions.Ordered);
- assertProperty("nt:unstructured", "*[1]",
"Undefined", NO_DEFAULTS, PropertyOptions.Multiple);
- assertProperty("nt:unstructured", "*[2]",
"Undefined", NO_DEFAULTS);
- assertChild("nt:unstructured", "*[3]", "nt:base",
"nt:unstructured", OnParentVersion.Version, ChildOptions.Multiple);
+ assertProperty("nt:unstructured", "*", "Undefined",
NO_DEFAULTS, PropertyOptions.Multiple);
+ // We should test for this, but we'd have to rewrite node() to look more like
RepositoryNodeTypeManager.findChildNodeDefinition
+ // assertProperty("nt:unstructured", "*",
"Undefined", NO_DEFAULTS);
+ assertChild("nt:unstructured", "*", "nt:base",
"nt:unstructured", OnParentVersion.Version, ChildOptions.Multiple);
// [mix:referenceable]
// mixin
@@ -311,9 +333,10 @@
// - * (undefined)
// + * (nt:base) = nt:unstructured multiple version
assertNodeType("nt:unstructured", NO_SUPERTYPES, NO_PRIMARY_NAME,
NodeOptions.Ordered);
- assertProperty("nt:unstructured", "*[1]",
"Undefined", NO_DEFAULTS, PropertyOptions.Multiple);
- assertProperty("nt:unstructured", "*[2]",
"Undefined", NO_DEFAULTS);
- assertChild("nt:unstructured", "*[3]", "nt:base",
"nt:unstructured", OnParentVersion.Version, ChildOptions.Multiple);
+ assertProperty("nt:unstructured", "*", "Undefined",
NO_DEFAULTS, PropertyOptions.Multiple);
+ // We should test for this, but we'd have to rewrite node() to look more like
RepositoryNodeTypeManager.findChildNodeDefinition
+ //assertProperty("nt:unstructured", "*",
"Undefined", NO_DEFAULTS);
+ assertChild("nt:unstructured", "*", "nt:base",
"nt:unstructured", OnParentVersion.Version, ChildOptions.Multiple);
// [mix:referenceable]
// mixin
@@ -496,7 +519,7 @@
for (PropertyOptions option : propertyOptions)
options.add(option);
- Node nodeType = node(nodeTypeName + "/" + propertyName);
+ Node nodeType = node(nodeTypeName, "jcr:propertyDefinition",
propertyName);
assertThat(nodeType, hasProperty(JcrLexicon.REQUIRED_TYPE,
requiredType.toUpperCase()));
assertThat(nodeType, hasProperty(JcrLexicon.MULTIPLE,
options.contains(PropertyOptions.Multiple)));
assertThat(nodeType, hasProperty(JcrLexicon.MANDATORY,
options.contains(PropertyOptions.Mandatory)));
@@ -569,7 +592,7 @@
for (ChildOptions option : childOptions)
options.add(option);
- Node nodeType = node(nodeTypeName + "/" + childName);
+ Node nodeType = node(nodeTypeName, "jcr:childNodeDefinition",
childName);
assertThat(nodeType, hasProperty(JcrLexicon.DEFAULT_PRIMARY_TYPE,
name(defaultPrimaryType)));
assertThat(nodeType, hasProperty(JcrLexicon.SAME_NAME_SIBLINGS,
options.contains(ChildOptions.Multiple)));
assertThat(nodeType, hasProperty(JcrLexicon.MANDATORY,
options.contains(ChildOptions.Mandatory)));
Added:
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ImmutableProblems.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ImmutableProblems.java
(rev 0)
+++
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ImmutableProblems.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,413 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.common.collection;
+
+import java.util.Iterator;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.common.util.CheckArg;
+
+/**
+ * An immutable wrapper for a mutable {@link Problems}.
+ */
+@Immutable
+public class ImmutableProblems implements Problems {
+
+ private final Problems delegate;
+
+ public ImmutableProblems( Problems delegate ) {
+ CheckArg.isNotNull(delegate, "delegate");
+ this.delegate = delegate;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.collection.Problems#addError(org.jboss.dna.common.i18n.I18n,
java.lang.Object[])
+ */
+ public void addError( I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.collection.Problems#addError(org.jboss.dna.common.i18n.I18n,
java.lang.String, java.lang.String,
+ * java.lang.Object[])
+ */
+ public void addError( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addError(int,
org.jboss.dna.common.i18n.I18n, java.lang.Object[])
+ */
+ public void addError( int code,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addError(int,
org.jboss.dna.common.i18n.I18n, java.lang.String,
+ * java.lang.String, java.lang.Object[])
+ */
+ public void addError( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addError(java.lang.Throwable,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.Object[])
+ */
+ public void addError( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addError(java.lang.Throwable,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.String, java.lang.String, java.lang.Object[])
+ */
+ public void addError( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addError(java.lang.Throwable, int,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.Object[])
+ */
+ public void addError( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addError(java.lang.Throwable, int,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.String, java.lang.String, java.lang.Object[])
+ */
+ public void addError( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.collection.Problems#addInfo(org.jboss.dna.common.i18n.I18n,
java.lang.Object[])
+ */
+ public void addInfo( I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.collection.Problems#addInfo(org.jboss.dna.common.i18n.I18n,
java.lang.String, java.lang.String,
+ * java.lang.Object[])
+ */
+ public void addInfo( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addInfo(int,
org.jboss.dna.common.i18n.I18n, java.lang.Object[])
+ */
+ public void addInfo( int code,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addInfo(int,
org.jboss.dna.common.i18n.I18n, java.lang.String,
+ * java.lang.String, java.lang.Object[])
+ */
+ public void addInfo( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addInfo(java.lang.Throwable,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.Object[])
+ */
+ public void addInfo( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addInfo(java.lang.Throwable,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.String, java.lang.String, java.lang.Object[])
+ */
+ public void addInfo( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addInfo(java.lang.Throwable, int,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.Object[])
+ */
+ public void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addInfo(java.lang.Throwable, int,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.String, java.lang.String, java.lang.Object[])
+ */
+ public void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.collection.Problems#addWarning(org.jboss.dna.common.i18n.I18n,
java.lang.Object[])
+ */
+ public void addWarning( I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.collection.Problems#addWarning(org.jboss.dna.common.i18n.I18n,
java.lang.String,
+ * java.lang.String, java.lang.Object[])
+ */
+ public void addWarning( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addWarning(int,
org.jboss.dna.common.i18n.I18n, java.lang.Object[])
+ */
+ public void addWarning( int code,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addWarning(int,
org.jboss.dna.common.i18n.I18n, java.lang.String,
+ * java.lang.String, java.lang.Object[])
+ */
+ public void addWarning( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addWarning(java.lang.Throwable,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.Object[])
+ */
+ public void addWarning( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addWarning(java.lang.Throwable,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.String, java.lang.String, java.lang.Object[])
+ */
+ public void addWarning( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addWarning(java.lang.Throwable, int,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.Object[])
+ */
+ public void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#addWarning(java.lang.Throwable, int,
org.jboss.dna.common.i18n.I18n,
+ * java.lang.String, java.lang.String, java.lang.Object[])
+ */
+ public void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#hasErrors()
+ */
+ public boolean hasErrors() {
+ return delegate.hasErrors();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#hasInfo()
+ */
+ public boolean hasInfo() {
+ return delegate.hasInfo();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#hasProblems()
+ */
+ public boolean hasProblems() {
+ return delegate.hasProblems();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#hasWarnings()
+ */
+ public boolean hasWarnings() {
+ return delegate.hasWarnings();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#isEmpty()
+ */
+ public boolean isEmpty() {
+ return delegate.isEmpty();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#iterator()
+ */
+ public Iterator<Problem> iterator() {
+ return new ReadOnlyIterator<Problem>(delegate.iterator());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.collection.Problems#size()
+ */
+ public int size() {
+ return delegate.size();
+ }
+
+}
Property changes on:
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ImmutableProblems.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -60,6 +60,7 @@
public static final Name IS_QUERYABLE = new BasicName(Namespace.URI,
"isQueryable");
public static final Name MANDATORY = new BasicName(Namespace.URI,
"mandatory");
public static final Name MULTIPLE = new BasicName(Namespace.URI,
"multiple");
+ public static final Name NODE_TYPE_NAME = new BasicName(Namespace.URI,
"nodeTypeName");
public static final Name ON_PARENT_VERSION = new BasicName(Namespace.URI,
"onParentVersion");
public static final Name PRIMARY_ITEM_NAME = new BasicName(Namespace.URI,
"primaryItemName");
public static final Name PROPERTY_DEFINITION = new BasicName(Namespace.URI,
"propertyDefinition");
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -472,7 +472,6 @@
* @see #getString(NamespaceRegistry, TextEncoder, TextEncoder)
*/
public String getString( NamespaceRegistry namespaceRegistry ) {
- CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
return getString(namespaceRegistry, null, null);
}
@@ -491,7 +490,6 @@
*/
public String getString( NamespaceRegistry namespaceRegistry,
TextEncoder encoder ) {
- CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
return getString(namespaceRegistry, encoder, null);
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -143,6 +143,7 @@
CheckArg.isNotNull(parent, "request.under().getPath()");
InMemoryNode node = null;
// Look up the parent node, which must exist ...
+ // System.err.println(request.toString());
InMemoryNode parentNode = workspace.getNode(parent);
if (parentNode == null) {
Path lowestExisting = workspace.getLowestExistingPath(parent);
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -146,7 +146,6 @@
* {@inheritDoc}
*/
public String getString( NamespaceRegistry namespaceRegistry ) {
- CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
return getString(namespaceRegistry, null, null);
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -81,11 +81,6 @@
this.namespaceProperties = Collections.unmodifiableList(properties);
createNamespaceParentIfNeeded();
initializeCacheFromStore(cache);
-
- // Load in the namespaces from the execution context used by the store ...
- for (Namespace namespace :
store.getContext().getNamespaceRegistry().getNamespaces()) {
- register(namespace.getPrefix(), namespace.getNamespaceUri());
- }
}
private void createNamespaceParentIfNeeded() {
@@ -220,6 +215,9 @@
}
protected void initializeCacheFromStore( NamespaceRegistry cache ) {
+ // Get the namespaces that the store is using ...
+ Set<Namespace> toRegister = new
HashSet<Namespace>(store.getContext().getNamespaceRegistry().getNamespaces());
+
// Read the store ...
try {
Subgraph nsGraph = store.getSubgraphOfDepth(2).at(parentOfNamespaceNodes);
@@ -231,14 +229,36 @@
if (uri != null) {
String prefix = getPrefixFor(nsLocation.getPath());
cache.register(prefix, uri);
+ // If we found it, we don't need to register it ...
+ toRegister.remove(new BasicNamespace(prefix, uri));
}
}
// Empty prefix to namespace mapping is built-in
cache.register("", "");
+ toRegister.remove(cache.getNamespaceForPrefix(""));
+
+ // Persist any namespaces that we didn't find ...
+ if (!toRegister.isEmpty()) {
+ Graph.Batch batch = store.batch();
+ PathFactory pathFactory =
store.getContext().getValueFactories().getPathFactory();
+ for (Namespace namespace : toRegister) {
+ String prefix = namespace.getPrefix();
+ if (prefix.length() == 0) continue;
+ String uri = namespace.getNamespaceUri();
+ Path pathToNamespaceNode = pathFactory.create(parentOfNamespaceNodes,
prefix);
+
batch.create(pathToNamespaceNode).with(namespaceProperties).and(uriPropertyName,
uri).and();
+ }
+ batch.execute();
+ }
+
} catch (PathNotFoundException e) {
// Nothing to read
}
+ // Load in the namespaces from the execution context used by the store ...
+ for (Namespace namespace :
store.getContext().getNamespaceRegistry().getNamespaces()) {
+ register(namespace.getPrefix(), namespace.getNamespaceUri());
+ }
}
protected String readUriFor( String prefix ) {
@@ -291,10 +311,10 @@
// Generated prefixes are simply "ns" followed by the SNS index
...
PathFactory pathFactory =
store.getContext().getValueFactories().getPathFactory();
Path pathToNamespaceNode = pathFactory.create(parentOfNamespaceNodes,
GENERATED_PREFIX);
- Location actualLocation = store.createAt(pathToNamespaceNode)
- .with(namespaceProperties)
- .and(uriPropertyName, namespaceUri)
- .getLocation();
+ Property uriProperty =
store.getContext().getPropertyFactory().create(uriPropertyName, namespaceUri);
+ List<Property> props = new
ArrayList<Property>(namespaceProperties);
+ props.add(uriProperty);
+ Location actualLocation = store.createIfMissing(pathToNamespaceNode,
props).andReturn().getLocation();
return getPrefixFor(actualLocation.getPath());
}
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -817,16 +817,8 @@
assertNextRequestIsMove(Location.create(validUuid), Location.create(validPath));
assertNoMoreRequests();
- graph.batch()
- .move(validPath)
- .into(validIdProperty1, validIdProperty2)
- .and()
- .move(validPathString)
- .into(validIdProperty1, validIdProperty2)
- .and()
- .move(validUuid)
- .into(validPath)
- .execute();
+ graph.batch().move(validPath).into(validIdProperty1,
validIdProperty2).and().move(validPathString).into(validIdProperty1,
+
validIdProperty2).and().move(validUuid).into(validPath).execute();
assertThat(numberOfExecutions, is(1));
extractRequestsFromComposite();
assertNextRequestIsMove(Location.create(validPath),
Location.create(validIdProperty1, validIdProperty2));
@@ -852,16 +844,8 @@
assertNextRequestIsCopy(Location.create(validUuid), Location.create(validPath));
assertNoMoreRequests();
- graph.batch()
- .copy(validPath)
- .into(validIdProperty1, validIdProperty2)
- .and()
- .copy(validPathString)
- .into(validIdProperty1, validIdProperty2)
- .and()
- .copy(validUuid)
- .into(validPath)
- .execute();
+ graph.batch().copy(validPath).into(validIdProperty1,
validIdProperty2).and().copy(validPathString).into(validIdProperty1,
+
validIdProperty2).and().copy(validUuid).into(validPath).execute();
assertThat(numberOfExecutions, is(1));
extractRequestsFromComposite();
assertNextRequestIsCopy(Location.create(validPath),
Location.create(validIdProperty1, validIdProperty2));
Modified: trunk/dna-jcr/pom.xml
===================================================================
--- trunk/dna-jcr/pom.xml 2009-05-05 16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/pom.xml 2009-05-05 22:09:15 UTC (rev 886)
@@ -44,6 +44,11 @@
<groupId>org.jboss.dna</groupId>
<artifactId>dna-repository</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-cnd</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
<!--
Testing (note the scope)
-->
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -99,6 +99,10 @@
final UUID internalUuid() {
return nodeUuid;
}
+
+ final Name name() throws RepositoryException {
+ return cache.getNameOf(nodeUuid);
+ }
final NodeInfo nodeInfo() throws ItemNotFoundException, RepositoryException {
return cache.findNodeInfo(nodeUuid);
@@ -1552,4 +1556,21 @@
public void save() throws RepositoryException {
cache.save(nodeUuid);
}
+
+ @Override
+ public String toString() {
+
+ try {
+ PropertyIterator iter = this.getProperties();
+ StringBuffer propertyBuff = new StringBuffer();
+ while (iter.hasNext()) {
+ AbstractJcrProperty prop = (AbstractJcrProperty) iter.nextProperty();
+ propertyBuff.append(prop.toString()).append(", ");
+ }
+ return this.getPath() + " {" + propertyBuff.toString() +
"}";
+ }
+ catch (RepositoryException re) {
+ return re.getMessage();
+ }
+ }
}
Deleted: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNodeTypeSource.java
===================================================================
---
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNodeTypeSource.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNodeTypeSource.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -1,135 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import javax.jcr.PropertyType;
-import javax.jcr.Value;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.graph.property.Name;
-
-/**
- * Implementation of {@link JcrNodeTypeSource} that supports chaining of node type
sources.
- */
-abstract class AbstractJcrNodeTypeSource implements JcrNodeTypeSource {
-
- // Convenience constants to help improve readability
- protected static final Value[] NO_DEFAULT_VALUES = new Value[0];
- protected static final String[] NO_CONSTRAINTS = new String[0];
- protected static final List<JcrNodeType> NO_SUPERTYPES =
Collections.<JcrNodeType>emptyList();
- protected static final List<JcrNodeDefinition> NO_CHILD_NODES =
Collections.<JcrNodeDefinition>emptyList();
- protected static final List<JcrPropertyDefinition> NO_PROPERTIES =
Collections.<JcrPropertyDefinition>emptyList();
- protected static final String[] ALL_PROPERTY_TYPES_WITH_UNDEFINED = new String[] {
- PropertyType.nameFromValue(PropertyType.BINARY),
PropertyType.nameFromValue(PropertyType.BOOLEAN),
- PropertyType.nameFromValue(PropertyType.DATE),
PropertyType.nameFromValue(PropertyType.DOUBLE),
- PropertyType.nameFromValue(PropertyType.LONG),
PropertyType.nameFromValue(PropertyType.NAME),
- PropertyType.nameFromValue(PropertyType.PATH),
PropertyType.nameFromValue(PropertyType.REFERENCE),
- PropertyType.nameFromValue(PropertyType.STRING),
PropertyType.nameFromValue(PropertyType.UNDEFINED),};
-
- /** Indicates that the node type has no primary item name - added for readability */
- protected static final Name NO_PRIMARY_ITEM_NAME = null;
- /** Indicates that the definition should apply to all property definition or child
node definitions - added for readability */
- protected static final Name ALL_NODES = null;
-
- // Indicates whether or not the node type is a mixin - added for readability
- protected static final boolean IS_A_MIXIN = true;
- protected static final boolean NOT_MIXIN = false;
-
- // Indicates whether or not the node type has orderable children - added for
readability
- protected static final boolean ORDERABLE_CHILD_NODES = true;
- protected static final boolean UNORDERABLE_CHILD_NODES = false;
-
- /** Link to the repository node type manager to which the nodes defined in this
source belong. */
- protected static final RepositoryNodeTypeManager NO_NODE_TYPE_MANAGER = null;
-
- /** The predecessor node type source. */
- private final JcrNodeTypeSource predecessor;
-
- AbstractJcrNodeTypeSource() {
- this(null);
- }
-
- AbstractJcrNodeTypeSource( JcrNodeTypeSource parent ) {
- this.predecessor = parent;
- }
-
- /**
- * Returns the list of node types declared in this type source.
- *
- * @return the list of node types declared in this type source.
- * @see org.jboss.dna.jcr.JcrNodeTypeSource#getNodeTypes()
- */
- public abstract Collection<JcrNodeType> getDeclaredNodeTypes();
-
- /**
- * Returns the list of node types returned by this and any predecessor source.
- *
- * @return the list of node types returned by this and any predecessor source.
- * @see org.jboss.dna.jcr.JcrNodeTypeSource#getNodeTypes()
- */
- public Collection<JcrNodeType> getNodeTypes() {
- if (predecessor == null) {
- return getDeclaredNodeTypes();
- }
-
- Collection<JcrNodeType> declaredTypes = getDeclaredNodeTypes();
- Collection<JcrNodeType> predecessorTypes = predecessor.getNodeTypes();
-
- List<JcrNodeType> primaries = new
ArrayList<JcrNodeType>(declaredTypes.size() + predecessorTypes.size());
- primaries.addAll(predecessorTypes);
- primaries.addAll(declaredTypes);
-
- return primaries;
- }
-
- /**
- * Finds the type with the given name and returns its definition.
- * <p>
- * This implementation delegates to the <code>predecessor</code> (if it
exists) if the type is not found within the declared
- * primary and mixin types.
- * </p>
- *
- * @param typeName the name of the type to return
- * @return the type named <code>typeName</code> if it exists, otherwise
<code>null</code>.
- * @throw IllegalArgumentException if <code>typeName</code> is
<code>null</code>.
- * @see
org.jboss.dna.jcr.JcrNodeTypeSource#findType(org.jboss.dna.graph.property.Name)
- */
- public JcrNodeType findType( Name typeName ) {
- CheckArg.isNotNull(typeName, "typeName");
- for (JcrNodeType type : getDeclaredNodeTypes()) {
- if (typeName.equals(type.getInternalName())) {
- return type;
- }
- }
-
- if (predecessor != null) {
- return predecessor.findType(typeName);
- }
-
- return null;
- }
-}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,143 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.cnd.CndImporter;
+import org.jboss.dna.common.collection.ImmutableProblems;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.graph.io.Destination;
+import org.jboss.dna.graph.io.GraphBatchDestination;
+import org.jboss.dna.graph.property.PathFactory;
+
+/**
+ * Class to parse one or more Compact Node Definition (CND) files containing custom node
type definitions into a format that can
+ * be registered with the {@link RepositoryNodeTypeManager}.
+ * <p>
+ * The class contains methods for determining whether the CND files were parsed
successfully and what errors occurred. Typically,
+ * the class will be used like this:
+ *
+ * <pre>
+ * try {
+ * String[] cndFilePaths = // The URIs for the resource files on the classpath
+ * JcrNodeTypeSource nodeTypeSource = new CndNodeTypeSource(cndFilePaths);
+ *
+ * if (!nodeTypeSource.isValid()) {
+ * Problems problems = nodeTypeSource.getProblems();
+ * // Report problems
+ * }
+ * else {
+ * repositoryNodeTypeManager.registerNodeTypes(nodeTypeSource);
+ * }
+ * }
+ * catch (IOException ioe) {
+ * System.err.println("Could not find one of the CND files.");
+ * ioe.printStackTrace();
+ * }
+ *
+ * </pre>
+ *
+ * </p>
+ */
+@Immutable
+public class CndNodeTypeSource implements JcrNodeTypeSource {
+
+ private final Graph graph;
+ private final Problems problems;
+
+ /**
+ * Creates a new {@link JcrNodeTypeSource} with based on the CND file with the given
resource name.
+ *
+ * @param resourceName the name of the resource; this resource must be on the
classpath
+ * @throws IOException if an error loading or reading the resource occurs
+ */
+ public CndNodeTypeSource( String resourceName ) throws IOException {
+ this(new String[] {resourceName});
+ }
+
+ /**
+ * Creates a new {@link JcrNodeTypeSource} based on the CND files at the given
resource names.
+ *
+ * @param resourceNames the name of the resources to load; these resources must be on
the classpath
+ * @throws IOException if an error loading or reading the any of the resources
occurs
+ */
+ public CndNodeTypeSource( String resourceNames[] ) throws IOException {
+
+ Problems problems = new SimpleProblems();
+
+ // Graph creation requires a context, but there are no security implications for
this and namespace mappings are
+ // specified in the CND file itself
+ ExecutionContext context = new ExecutionContext();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ InMemoryRepositorySource source = new InMemoryRepositorySource();
+ source.setName("CND Import Source");
+ this.graph = Graph.create(source, context);
+ for (String resourceName : Arrays.asList(resourceNames)) {
+ Graph.Batch batch = graph.batch();
+ Destination destination = new GraphBatchDestination(batch);
+ CndImporter importer = new CndImporter(destination,
pathFactory.createRootPath());
+ InputStream is = getClass().getResourceAsStream(resourceName);
+
+ // This submits the batch
+ importer.importFrom(is, problems, resourceName);
+ }
+ this.problems = new ImmutableProblems(problems);
+ }
+
+ /**
+ * Returns true if no errors were encountered while parsing the CND file or files
+ *
+ * @return true if no errors were encountered while parsing the CND file or files
+ */
+ public boolean isValid() {
+ return !problems.hasErrors();
+ }
+
+ /**
+ * Returns the problems (if any) that were encountered parsing the CND files. Node
type registration errors or warnings will
+ * NOT be added to this set of problems.
+ *
+ * @return returns the problems (if any) that were encountered parsing the CND
files.
+ */
+ public Problems getProblems() {
+ return problems;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.JcrNodeTypeSource#getNodeTypes()
+ */
+ public final Graph getNodeTypes() {
+ return graph;
+ }
+
+}
Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -1,176 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import javax.jcr.PropertyType;
-import net.jcip.annotations.Immutable;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.JcrMixLexicon;
-
-/**
- * {@link JcrNodeTypeSource} that provides built-in node types provided by DNA.
- */
-@Immutable
-class DnaBuiltinNodeTypeSource extends AbstractJcrNodeTypeSource {
-
- /** The list of node types. */
- private final List<JcrNodeType> nodeTypes;
-
- DnaBuiltinNodeTypeSource( ExecutionContext context,
- JcrNodeTypeSource predecessor ) {
- super(predecessor);
-
- nodeTypes = new ArrayList<JcrNodeType>();
-
- JcrNodeType base = findType(JcrNtLexicon.BASE);
-
- if (base == null) {
- String baseTypeName =
JcrNtLexicon.BASE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
DnaLexicon.NAMESPACE.getString(context.getNamespaceRegistry());
- throw new IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName,
namespaceTypeName));
- }
-
- JcrNodeType referenceable = findType(JcrMixLexicon.REFERENCEABLE);
-
- if (referenceable == null) {
- String baseTypeName =
JcrMixLexicon.REFERENCEABLE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
DnaLexicon.SYSTEM.getString(context.getNamespaceRegistry());
- throw new IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName,
namespaceTypeName));
- }
-
- JcrNodeType nodeType = findType(JcrNtLexicon.NODE_TYPE);
-
- if (nodeType == null) {
- String baseTypeName =
JcrNtLexicon.NODE_TYPE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
DnaLexicon.NODE_TYPES.getString(context.getNamespaceRegistry());
- throw new IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName,
namespaceTypeName));
- }
-
- // Stubbing in child node and property definitions for now
- JcrNodeType namespace = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- DnaLexicon.NAMESPACE,
- Arrays.asList(new JcrNodeType[] {base}),
- DnaLexicon.URI,
- NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[]
{new JcrPropertyDefinition(
-
context,
-
null,
-
DnaLexicon.URI,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
true,
-
true,
-
true,
-
NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
NO_CONSTRAINTS,
-
false)}),
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- JcrNodeType namespaces = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- DnaLexicon.NAMESPACES,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
true,
-
false,
-
DnaLexicon.NAMESPACE,
-
new JcrNodeType[] {namespace})}),
- NO_PROPERTIES, NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- JcrNodeType dnaNodeTypes = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- DnaLexicon.NODE_TYPES,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
true,
-
true,
-
JcrNtLexicon.NODE_TYPE,
-
new JcrNodeType[] {nodeType})}),
- NO_PROPERTIES, NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- JcrNodeType system = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
DnaLexicon.SYSTEM,
- Arrays.asList(new JcrNodeType[] {base}),
NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {
- new JcrNodeDefinition(context, null,
DnaLexicon.NAMESPACES,
-
OnParentVersionBehavior.VERSION.getJcrValue(), true, true,
- true, false,
DnaLexicon.NAMESPACES,
- new JcrNodeType[]
{namespaces}),
-
- new JcrNodeDefinition(context, null,
JcrLexicon.NODE_TYPES,
-
OnParentVersionBehavior.VERSION.getJcrValue(), true, true,
- true, false,
DnaLexicon.NODE_TYPES,
- new JcrNodeType[]
{dnaNodeTypes})}), NO_PROPERTIES,
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- JcrNodeType root = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
DnaLexicon.ROOT, Arrays.asList(new JcrNodeType[] {base,
- referenceable}), NO_PRIMARY_ITEM_NAME, Arrays.asList(new JcrNodeDefinition[]
{
- new JcrNodeDefinition(context, null, JcrLexicon.SYSTEM,
OnParentVersionBehavior.IGNORE.getJcrValue(), true, true,
- true, false, DnaLexicon.SYSTEM, new JcrNodeType[]
{system}),
- new JcrNodeDefinition(context, null, ALL_NODES,
OnParentVersionBehavior.VERSION.getJcrValue(), false, false, false,
- true, JcrNtLexicon.UNSTRUCTURED, new JcrNodeType[]
{base}),
-
- }), Arrays.asList(new JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context, null, ALL_NODES,
OnParentVersionBehavior.COPY.getJcrValue(), false, false, false,
- NO_DEFAULT_VALUES, PropertyType.UNDEFINED,
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context, null, ALL_NODES,
OnParentVersionBehavior.COPY.getJcrValue(), false, false, false,
- NO_DEFAULT_VALUES, PropertyType.UNDEFINED,
NO_CONSTRAINTS, true),}), NOT_MIXIN,
- ORDERABLE_CHILD_NODES);
-
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {root, system, dnaNodeTypes,
namespaces, namespace,}));
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.jcr.JcrNodeTypeSource#getNodeTypes()
- */
- @Override
- public Collection<JcrNodeType> getDeclaredNodeTypes() {
- return nodeTypes;
- }
-
-}
Deleted: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -1,689 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import javax.jcr.PropertyType;
-import javax.jcr.Value;
-import net.jcip.annotations.Immutable;
-import org.jboss.dna.graph.ExecutionContext;
-
-/**
- * {@link JcrNodeTypeSource} that provides built-in node types per the 1.0
specification.
- */
-@Immutable
-class JcrBuiltinNodeTypeSource extends AbstractJcrNodeTypeSource {
-
- protected static final String[] ON_PARENT_VERSION_VALUES = new String[]
{OnParentVersionBehavior.ABORT.getName(),
- OnParentVersionBehavior.COMPUTE.getName(),
OnParentVersionBehavior.COPY.getName(),
- OnParentVersionBehavior.IGNORE.getName(),
OnParentVersionBehavior.INITIALIZE.getName(),
- OnParentVersionBehavior.VERSION.getName(),};
-
- protected static final boolean NT_NODE_TYPES_PROTECTED = false; // JSR-170 requires
they not be protected, but JSR-283 says
- // they are.
-
- /** The list of primary node types. */
- private final List<JcrNodeType> nodeTypes;
-
- JcrBuiltinNodeTypeSource( ExecutionContext context ) {
- this(context, null);
- }
-
- JcrBuiltinNodeTypeSource( ExecutionContext context,
- JcrNodeTypeSource predecessor ) {
- super(predecessor);
-
- nodeTypes = new ArrayList<JcrNodeType>();
-
- /*
- * These values get created without a session cache, as they aren't tied to
any particular session.
- */
- // Value trueValue = new JcrValue(context.getValueFactories(), null,
PropertyType.BOOLEAN, Boolean.TRUE);
- Value ntBaseValue = new JcrValue(context.getValueFactories(), null,
PropertyType.NAME, JcrNtLexicon.BASE);
-
- JcrNodeType defined = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
DnaLexicon.BASE, NO_SUPERTYPES,
- DnaIntLexicon.NODE_DEFINITON,
NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[]
{
- new JcrPropertyDefinition(context,
null, DnaIntLexicon.NODE_DEFINITON,
-
OnParentVersionBehavior.INITIALIZE.getJcrValue(),
- false, false,
true, NO_DEFAULT_VALUES,
-
PropertyType.STRING, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, DnaIntLexicon.MULTI_VALUED_PROPERTIES,
-
OnParentVersionBehavior.INITIALIZE.getJcrValue(),
- false, false,
true, NO_DEFAULT_VALUES,
-
PropertyType.STRING, NO_CONSTRAINTS, true),}),
- IS_A_MIXIN, UNORDERABLE_CHILD_NODES);
- // Stubbing in child node and property definitions for now
- JcrNodeType base = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
JcrNtLexicon.BASE,
- Arrays.asList(new JcrNodeType[] {defined}),
NO_PRIMARY_ITEM_NAME, NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context, null,
JcrLexicon.PRIMARY_TYPE,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), true,
- true, true,
NO_DEFAULT_VALUES, PropertyType.NAME,
- NO_CONSTRAINTS,
false),
- new JcrPropertyDefinition(context, null,
JcrLexicon.MIXIN_TYPES,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, true,
NO_DEFAULT_VALUES, PropertyType.NAME,
- NO_CONSTRAINTS,
true)}), NOT_MIXIN,
- UNORDERABLE_CHILD_NODES);
-
- // This needs to be declared early, as some of the primary types reference it
- JcrNodeType referenceable = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- JcrMixLexicon.REFERENCEABLE,
- NO_SUPERTYPES,
- NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.UUID,
-
OnParentVersionBehavior.INITIALIZE.getJcrValue(),
-
true,
-
true,
-
true,
-
NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
NO_CONSTRAINTS,
-
false),}),
- IS_A_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- JcrNodeType childNodeDefinition = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
-
JcrNtLexicon.CHILD_NODE_DEFINITION,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.AUTO_CREATED,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.DEFAULT_PRIMARY_TYPE,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, false, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.NAME,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.MANDATORY,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.NAME,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, false, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.NAME,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.ON_PARENT_VERSION,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.PROTECTED,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.REQUIRED_PRIMARY_TYPES,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
new Value[] {ntBaseValue},
-
PropertyType.NAME, NO_CONSTRAINTS, true),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.SAME_NAME_SIBLINGS,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false)}), NOT_MIXIN,
- UNORDERABLE_CHILD_NODES);
-
- JcrNodeType hierarchyNode = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- JcrNtLexicon.HIERARCHY_NODE,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.CREATED,
-
OnParentVersionBehavior.INITIALIZE.getJcrValue(),
-
true,
-
false,
-
true,
-
NO_DEFAULT_VALUES,
-
PropertyType.DATE,
-
NO_CONSTRAINTS,
-
false),}),
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- JcrNodeType file = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- JcrNtLexicon.FILE,
- Arrays.asList(new JcrNodeType[]
{hierarchyNode}),
- JcrLexicon.CONTENT,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
JcrLexicon.CONTENT,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, false,
-
false, null,
-
new JcrNodeType[] {base})}),
- NO_PROPERTIES, NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- JcrNodeType folder = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- JcrNtLexicon.FOLDER,
- Arrays.asList(new JcrNodeType[]
{hierarchyNode}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
null,
-
new JcrNodeType[] {hierarchyNode})}),
- NO_PROPERTIES, NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- JcrNodeType frozenNode = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- JcrNtLexicon.FROZEN_NODE,
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
ALL_NODES,
-
OnParentVersionBehavior.ABORT.getJcrValue(),
-
false,
-
false,
-
true,
-
true,
-
null,
-
new JcrNodeType[] {base})}),
- Arrays.asList(new
JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context,
null, JcrLexicon.FROZEN_MIXIN_TYPES,
-
OnParentVersionBehavior.ABORT.getJcrValue(),
- false,
false, true, NO_DEFAULT_VALUES,
-
PropertyType.NAME, NO_CONSTRAINTS, true),
- new JcrPropertyDefinition(context,
null, JcrLexicon.FROZEN_PRIMARY_TYPE,
-
OnParentVersionBehavior.ABORT.getJcrValue(), true,
- true,
true, NO_DEFAULT_VALUES, PropertyType.NAME,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.FROZEN_UUID,
-
OnParentVersionBehavior.ABORT.getJcrValue(), true,
- true,
true, NO_DEFAULT_VALUES,
-
PropertyType.STRING, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, ALL_NODES,
-
OnParentVersionBehavior.ABORT.getJcrValue(),
- false,
false, true, NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, ALL_NODES,
-
OnParentVersionBehavior.ABORT.getJcrValue(),
- false,
false, true, NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED, NO_CONSTRAINTS, true),}),
- NOT_MIXIN, ORDERABLE_CHILD_NODES);
-
- JcrNodeType linkedFile = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- JcrNtLexicon.LINKED_FILE,
- Arrays.asList(new JcrNodeType[]
{hierarchyNode}),
- JcrLexicon.CONTENT,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.CONTENT,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false,
-
true,
-
false,
-
NO_DEFAULT_VALUES,
-
PropertyType.REFERENCE,
-
NO_CONSTRAINTS,
-
false),}),
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- // Had to be moved above nodeType due to dependency
- JcrNodeType propertyDefinition = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
-
JcrNtLexicon.PROPERTY_DEFINITION,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.AUTO_CREATED,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.DEFAULT_VALUES,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, false, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.UNDEFINED,
-
NO_CONSTRAINTS, true),
- // new
JcrPropertyDefinition(
- // context,
- // null,
- //
JcrLexicon.IS_FULL_TEXT_SEARCHABLE,
- //
OnParentVersionBehavior.COPY.getJcrValue(),
- // false, true,
NT_NODE_TYPES_PROTECTED,
- // NO_DEFAULT_VALUES,
PropertyType.BOOLEAN,
- // NO_CONSTRAINTS, false),
- // new
JcrPropertyDefinition(
- // context,
- // null,
- //
JcrLexicon.IS_QUERY_ORDERABLE,
- //
OnParentVersionBehavior.COPY.getJcrValue(),
- // false, true,
NT_NODE_TYPES_PROTECTED,
- // NO_DEFAULT_VALUES,
PropertyType.BOOLEAN,
- // NO_CONSTRAINTS, false),
- // new
JcrPropertyDefinition(
- // context,
- // null,
- // JcrLexicon.IS_QUERYABLE,
- //
OnParentVersionBehavior.COPY.getJcrValue(),
- // false, true,
NT_NODE_TYPES_PROTECTED,
- // NO_DEFAULT_VALUES,
PropertyType.BOOLEAN,
- // NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.MANDATORY,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.MULTIPLE,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.NAME,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, false, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.NAME,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.ON_PARENT_VERSION,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.STRING,
-
ON_PARENT_VERSION_VALUES, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.PROTECTED,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.REQUIRED_TYPE,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, true, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.STRING,
-
ALL_PROPERTY_TYPES_WITH_UNDEFINED, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.VALUE_CONSTRAINTS,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, false, NT_NODE_TYPES_PROTECTED,
-
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, true)}), NOT_MIXIN,
- UNORDERABLE_CHILD_NODES);
-
- JcrNodeType nodeType = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
JcrNtLexicon.NODE_TYPE,
- Arrays.asList(new JcrNodeType[] {base}),
NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {
- new JcrNodeDefinition(context, null,
JcrLexicon.CHILD_NODE_DEFINITION,
-
OnParentVersionBehavior.VERSION.getJcrValue(), false,
- false,
NT_NODE_TYPES_PROTECTED, true,
-
JcrNtLexicon.CHILD_NODE_DEFINITION,
- new
JcrNodeType[] {childNodeDefinition}),
- new JcrNodeDefinition(context, null,
JcrLexicon.PROPERTY_DEFINITION,
-
OnParentVersionBehavior.VERSION.getJcrValue(), false,
- false,
NT_NODE_TYPES_PROTECTED, true,
-
JcrNtLexicon.PROPERTY_DEFINITION,
- new
JcrNodeType[] {propertyDefinition})}),
- Arrays.asList(new JcrPropertyDefinition[]
{
- new JcrPropertyDefinition(context,
null, JcrLexicon.HAS_ORDERABLE_CHILD_NODES,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- true,
NT_NODE_TYPES_PROTECTED, NO_DEFAULT_VALUES,
-
PropertyType.BOOLEAN, NO_CONSTRAINTS, false),
- // new JcrPropertyDefinition(context,
null, JcrLexicon.IS_ABSTRACT,
- //
OnParentVersionBehavior.COPY.getJcrValue(), false,
- // true, NT_NODE_TYPES_PROTECTED,
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
- // NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.IS_MIXIN,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- true,
NT_NODE_TYPES_PROTECTED, NO_DEFAULT_VALUES,
-
PropertyType.BOOLEAN, NO_CONSTRAINTS, false),
- // new JcrPropertyDefinition(context,
null, JcrLexicon.IS_QUERYABLE,
- //
OnParentVersionBehavior.COPY.getJcrValue(), false,
- // true, NT_NODE_TYPES_PROTECTED,
NO_DEFAULT_VALUES, PropertyType.BOOLEAN,
- // NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.NODE_TYPE_NAME,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- true,
NT_NODE_TYPES_PROTECTED, NO_DEFAULT_VALUES,
-
PropertyType.NAME, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.PRIMARY_ITEM_NAME,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- false,
NT_NODE_TYPES_PROTECTED, NO_DEFAULT_VALUES,
-
PropertyType.NAME, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.SUPERTYPES,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- false,
NT_NODE_TYPES_PROTECTED, NO_DEFAULT_VALUES,
-
PropertyType.NAME, NO_CONSTRAINTS, true),}),
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- JcrNodeType query = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
JcrNtLexicon.QUERY,
- Arrays.asList(new JcrNodeType[] {base}),
NO_PRIMARY_ITEM_NAME, NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context, null,
JcrLexicon.LANGUAGE,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.STRING,
- NO_CONSTRAINTS,
false),
- new JcrPropertyDefinition(context, null,
JcrLexicon.STATEMENT,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.STRING,
- NO_CONSTRAINTS,
false),}), NOT_MIXIN,
- UNORDERABLE_CHILD_NODES);
-
- JcrNodeType resource = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
JcrNtLexicon.RESOURCE,
- Arrays.asList(new JcrNodeType[] {base,
referenceable}), JcrLexicon.DATA,
- NO_CHILD_NODES, Arrays.asList(new
JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context,
null, JcrLexicon.DATA,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- true, false,
NO_DEFAULT_VALUES, PropertyType.BINARY,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.ENCODING,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- false,
false, NO_DEFAULT_VALUES,
-
PropertyType.STRING, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.LAST_MODIFIED,
-
OnParentVersionBehavior.IGNORE.getJcrValue(), false,
- true, false,
NO_DEFAULT_VALUES, PropertyType.DATE,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.MIMETYPE,
-
OnParentVersionBehavior.COPY.getJcrValue(), false,
- true, false,
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, false),}), NOT_MIXIN,
- UNORDERABLE_CHILD_NODES);
-
- JcrNodeType unstructured = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- JcrNtLexicon.UNSTRUCTURED,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
ALL_NODES,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
true,
-
JcrNtLexicon.UNSTRUCTURED,
-
new JcrNodeType[] {base}),}),
- Arrays.asList(new
JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context,
null, ALL_NODES,
-
OnParentVersionBehavior.COPY.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, ALL_NODES,
-
OnParentVersionBehavior.COPY.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED, NO_CONSTRAINTS, true),}),
- NOT_MIXIN, ORDERABLE_CHILD_NODES);
-
- // JcrNodeType version = new JcrNodeType(
- // context,
- // NO_NODE_TYPE_MANAGER,
- // JcrNtLexicon.VERSION,
- // Arrays.asList(new JcrNodeType[] {base, referenceable}),
- // NO_PRIMARY_ITEM_NAME,
- // Arrays.asList(new JcrNodeDefinition[] {new JcrNodeDefinition(
- // context,
- // null,
- // JcrLexicon.FROZEN_NODE,
- // OnParentVersionBehavior.ABORT.getJcrValue(),
- // false,
- // false,
- // true,
- // false,
- // null,
- // new JcrNodeType[] {frozenNode}),}),
- // Arrays.asList(new JcrPropertyDefinition[] {
- // new JcrPropertyDefinition(context, null, JcrLexicon.CREATED,
- // OnParentVersionBehavior.ABORT.getJcrValue(), true,
- // true, true, NO_DEFAULT_VALUES, PropertyType.DATE,
- // NO_CONSTRAINTS, false),
- // new JcrPropertyDefinition(context, null, JcrLexicon.PREDECESSORS,
- // OnParentVersionBehavior.ABORT.getJcrValue(), false,
- // false, true, NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE, NO_CONSTRAINTS, true),
- // new JcrPropertyDefinition(context, null, JcrLexicon.SUCCESSORS,
- // OnParentVersionBehavior.ABORT.getJcrValue(), false,
- // false, true, NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE, NO_CONSTRAINTS, true),}),
- // NOT_MIXIN, UNORDERABLE_CHILD_NODES);
- //
- // JcrNodeType versionLabels = new JcrNodeType(
- // context,
- // NO_NODE_TYPE_MANAGER,
- // JcrNtLexicon.VERSION_LABELS,
- // Arrays.asList(new JcrNodeType[] {base}),
- // NO_PRIMARY_ITEM_NAME,
- // NO_CHILD_NODES,
- // Arrays.asList(new JcrPropertyDefinition[] {new JcrPropertyDefinition(
- // context,
- // null,
- // ALL_NODES,
- // OnParentVersionBehavior.ABORT.getJcrValue(),
- // false,
- // false,
- // true,
- // NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE,
- // NO_CONSTRAINTS,
- // false),}),
- // NOT_MIXIN, UNORDERABLE_CHILD_NODES);
- //
- // JcrNodeType versionHistory = new JcrNodeType(
- // context,
- // NO_NODE_TYPE_MANAGER,
- // JcrNtLexicon.VERSION_HISTORY,
- // Arrays.asList(new JcrNodeType[] {base, referenceable}),
- // NO_PRIMARY_ITEM_NAME,
- // Arrays.asList(new JcrNodeDefinition[] {
- // new JcrNodeDefinition(context, null, JcrLexicon.ROOT_VERSION,
- // OnParentVersionBehavior.ABORT.getJcrValue(), true,
- // true, true, false, JcrNtLexicon.VERSION,
- // new JcrNodeType[] {version}),
- // new JcrNodeDefinition(context, null, JcrLexicon.VERSION_LABELS,
- // OnParentVersionBehavior.ABORT.getJcrValue(), true,
- // true, true, false, JcrNtLexicon.VERSION_LABELS,
- // new JcrNodeType[] {versionLabels}),
- // new JcrNodeDefinition(context, null, ALL_NODES,
- // OnParentVersionBehavior.ABORT.getJcrValue(),
- // false, false, true, false, JcrNtLexicon.VERSION,
- // new JcrNodeType[] {version}),}),
- // Arrays.asList(new JcrPropertyDefinition[] {new JcrPropertyDefinition(
- // context,
- // null,
- // JcrLexicon.VERSIONABLE_UUID,
- // OnParentVersionBehavior.ABORT.getJcrValue(),
- // true,
- // true,
- // true,
- // NO_DEFAULT_VALUES,
- // PropertyType.STRING,
- // NO_CONSTRAINTS,
- // false),}),
- // NOT_MIXIN, UNORDERABLE_CHILD_NODES);
- //
- // Name CHILD_VERSION_HISTORY = new BasicName(JcrLexicon.Namespace.URI,
"childVersionHistory");
- // JcrNodeType versionedChild = new JcrNodeType(
- // context,
- // NO_NODE_TYPE_MANAGER,
- // JcrNtLexicon.VERSIONED_CHILD,
- // Arrays.asList(new JcrNodeType[] {base}),
- // NO_PRIMARY_ITEM_NAME,
- // NO_CHILD_NODES,
- // Arrays.asList(new JcrPropertyDefinition[] {new JcrPropertyDefinition(
- // context,
- // null,
- // CHILD_VERSION_HISTORY,
- // OnParentVersionBehavior.ABORT.getJcrValue(),
- // true,
- // true,
- // true,
- // NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE,
- // NO_CONSTRAINTS,
- // false),}),
- // NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- // Disabling version-related types until DNA supports versioning, as per section
4.11 of the 1.0.1 specification
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {defined, base, unstructured,
childNodeDefinition, file, folder,
- frozenNode, hierarchyNode, linkedFile, nodeType, propertyDefinition, query,
resource, nodeType /*, version, versionHistory,
-
versionLabels, versionedChild */}));
-
- JcrNodeType lockable = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
JcrMixLexicon.LOCKABLE, NO_SUPERTYPES,
- NO_PRIMARY_ITEM_NAME, NO_CHILD_NODES,
Arrays.asList(new JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context,
null, JcrLexicon.LOCK_IS_DEEP,
-
OnParentVersionBehavior.IGNORE.getJcrValue(), false,
- false, true,
NO_DEFAULT_VALUES,
-
PropertyType.BOOLEAN, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, JcrLexicon.LOCK_OWNER,
-
OnParentVersionBehavior.IGNORE.getJcrValue(), false,
- false, true,
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, false)}), IS_A_MIXIN,
- UNORDERABLE_CHILD_NODES);
-
- // JcrNodeType versionable = new JcrNodeType(
- // context,
- // NO_NODE_TYPE_MANAGER,
- // JcrMixLexicon.VERSIONABLE,
- // Arrays.asList(new JcrNodeType[] {referenceable}),
- // NO_PRIMARY_ITEM_NAME,
- // NO_CHILD_NODES,
- // Arrays.asList(new JcrPropertyDefinition[] {
- // new JcrPropertyDefinition(context, null, JcrLexicon.BASE_VERSION,
- // OnParentVersionBehavior.IGNORE.getJcrValue(),
- // false, true, true, NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE, NO_CONSTRAINTS, false),
- // new JcrPropertyDefinition(context, null, JcrLexicon.IS_CHECKED_OUT,
- // OnParentVersionBehavior.IGNORE.getJcrValue(),
- // true, true, true, new Value[] {trueValue},
- // PropertyType.BOOLEAN, NO_CONSTRAINTS, false),
- // new JcrPropertyDefinition(context, null, JcrLexicon.MERGE_FAILED,
- // OnParentVersionBehavior.ABORT.getJcrValue(),
- // false, false, true, NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE, NO_CONSTRAINTS, true),
- // new JcrPropertyDefinition(context, null, JcrLexicon.PREDECESSORS,
- // OnParentVersionBehavior.COPY.getJcrValue(),
- // false, true, true, NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE, NO_CONSTRAINTS, true),
- // new JcrPropertyDefinition(context, null, JcrLexicon.VERSION_HISTORY,
- // OnParentVersionBehavior.COPY.getJcrValue(),
- // false, true, true, NO_DEFAULT_VALUES,
- // PropertyType.REFERENCE, NO_CONSTRAINTS, false),}),
- // IS_A_MIXIN, UNORDERABLE_CHILD_NODES);
-
- // Removing lockable as per section 4.11 of the JCR 1.0.1 specification
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {lockable, referenceable /*,
versionable */}));
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.jcr.JcrNodeTypeSource#getNodeTypes()
- */
- @Override
- public Collection<JcrNodeType> getDeclaredNodeTypes() {
- return nodeTypes;
- }
-}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-05-05 16:30:45 UTC
(rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-05-05 22:09:15 UTC
(rev 886)
@@ -133,6 +133,8 @@
public static I18n noSnsDefinition;
public static I18n missingMandatoryItem;
+ public static I18n allNodeTypeTemplatesMustComeFromSameSession;
+
static {
try {
I18n.initialize(JcrI18n.class);
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrItemDefinitionTemplate.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrItemDefinitionTemplate.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrItemDefinitionTemplate.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,135 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import javax.jcr.nodetype.ItemDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.OnParentVersionAction;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.graph.ExecutionContext;
+
+/**
+ * DNA convenience implementation to support the JCR 2 NodeDefinitionTemplate and
PropertyDefinitionTemplate classes.
+ */
+@NotThreadSafe
+abstract class JcrItemDefinitionTemplate implements ItemDefinition {
+
+ private final ExecutionContext context;
+ private boolean autoCreated = false;
+ private boolean mandatory = false;
+ private boolean isProtected = false;
+ private String name;
+ private int onParentVersion = OnParentVersionAction.IGNORE;
+
+ JcrItemDefinitionTemplate( ExecutionContext context ) {
+ assert context != null;
+
+ this.context = context;
+ }
+
+ ExecutionContext getExecutionContext() {
+ return context;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.ItemDefinition#getDeclaringNodeType()
+ */
+ public NodeType getDeclaringNodeType() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.ItemDefinition#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.ItemDefinition#getOnParentVersion()
+ */
+ public int getOnParentVersion() {
+ return onParentVersion;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.ItemDefinition#isAutoCreated()
+ */
+ public boolean isAutoCreated() {
+ return autoCreated;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.ItemDefinition#isMandatory()
+ */
+ public boolean isMandatory() {
+ return mandatory;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.ItemDefinition#isProtected()
+ */
+ public boolean isProtected() {
+ return isProtected;
+ }
+
+ public ExecutionContext getContext() {
+ return context;
+ }
+
+ public void setAutoCreated( boolean autoCreated ) {
+ this.autoCreated = autoCreated;
+ }
+
+ public void setMandatory( boolean mandatory ) {
+ this.mandatory = mandatory;
+ }
+
+ public void setProtected( boolean isProtected ) {
+ this.isProtected = isProtected;
+ }
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ public void setOnParentVersion( int onParentVersion ) {
+ assert onParentVersion == OnParentVersionAction.ABORT || onParentVersion ==
OnParentVersionAction.COMPUTE
+ || onParentVersion == OnParentVersionAction.COPY || onParentVersion ==
OnParentVersionAction.IGNORE
+ || onParentVersion == OnParentVersionAction.INITIALIZE || onParentVersion
== OnParentVersionAction.VERSION;
+ this.onParentVersion = onParentVersion;
+ }
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrItemDefinitionTemplate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java 2009-05-05 16:30:45 UTC
(rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java 2009-05-05 22:09:15 UTC
(rev 886)
@@ -47,7 +47,6 @@
public static final Name LOCK_OWNER = new BasicName(Namespace.URI,
"lockOwner");
public static final Name MERGE_FAILED = new BasicName(Namespace.URI,
"mergeFailed");
public static final Name NODE_TYPES = new BasicName(Namespace.URI,
"nodeTypes");
- public static final Name NODE_TYPE_NAME = new BasicName(Namespace.URI,
"nodeTypeName");
public static final Name PREDECESSORS = new BasicName(Namespace.URI,
"predecessors");
public static final Name ROOT = new BasicName(Namespace.URI, "root");
public static final Name ROOT_VERSION = new BasicName(Namespace.URI,
"rootVersion");
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinition.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinition.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinition.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -49,7 +49,7 @@
private final Name defaultPrimaryTypeName;
/** @see NodeDefinition#getRequiredPrimaryTypes() */
- private final Map<Name, JcrNodeType> requiredPrimaryTypesByName;
+ private Map<Name, JcrNodeType> requiredPrimaryTypesByName;
private JcrNodeType[] requiredPrimaryTypes;
@@ -70,9 +70,9 @@
boolean protectedItem,
boolean allowsSameNameSiblings,
Name defaultPrimaryTypeName,
- JcrNodeType[] requiredPrimaryTypes ) {
+ Name[] requiredPrimaryTypeNames ) {
this(context, null, declaringNodeType, name, onParentVersion, autoCreated,
mandatory, protectedItem,
- allowsSameNameSiblings, defaultPrimaryTypeName, requiredPrimaryTypes);
+ allowsSameNameSiblings, defaultPrimaryTypeName, requiredPrimaryTypeNames);
}
JcrNodeDefinition( ExecutionContext context,
@@ -85,22 +85,35 @@
boolean protectedItem,
boolean allowsSameNameSiblings,
Name defaultPrimaryTypeName,
- JcrNodeType[] requiredPrimaryTypes ) {
+ Name[] requiredPrimaryTypeNames ) {
super(context, declaringNodeType, name, onParentVersion, autoCreated, mandatory,
protectedItem);
this.nodeTypeManager = nodeTypeManager;
this.allowsSameNameSiblings = allowsSameNameSiblings;
this.defaultPrimaryTypeName = defaultPrimaryTypeName;
- this.requiredPrimaryTypes = new JcrNodeType[requiredPrimaryTypes.length];
- this.requiredPrimaryTypeNames = new Name[requiredPrimaryTypes.length];
- for (int i = 0; i != requiredPrimaryTypes.length; ++i) {
- this.requiredPrimaryTypes[i] = requiredPrimaryTypes[i];
- this.requiredPrimaryTypeNames[i] =
requiredPrimaryTypes[i].getInternalName();
+ this.requiredPrimaryTypes = new JcrNodeType[requiredPrimaryTypeNames.length];
+ this.requiredPrimaryTypeNames = requiredPrimaryTypeNames;
+ }
+
+ /**
+ * Checks that the fields derived from requiredPrimaryTypeNames are initialized.
+ * <p>
+ * This was pulled out of the constructor to make type registration more flexible by
deferring node type lookup for required
+ * primary types until after type registration is complete. This allows, for example,
nodes to have themselves as required
+ * primary types of their children.
+ * </p>
+ */
+ private void ensureRequiredPrimaryTypesLoaded() {
+ if (requiredPrimaryTypesByName != null) return;
+ this.requiredPrimaryTypes = new JcrNodeType[requiredPrimaryTypeNames.length];
+ for (int i = 0; i != requiredPrimaryTypeNames.length; ++i) {
+ this.requiredPrimaryTypes[i] =
nodeTypeManager.getNodeType(requiredPrimaryTypeNames[i]);
}
Map<Name, JcrNodeType> requiredPrimaryTypesByName = new HashMap<Name,
JcrNodeType>();
for (JcrNodeType requiredPrimaryType : requiredPrimaryTypes) {
requiredPrimaryTypesByName.put(requiredPrimaryType.getInternalName(),
requiredPrimaryType);
}
this.requiredPrimaryTypesByName =
Collections.unmodifiableMap(requiredPrimaryTypesByName);
+
}
/**
@@ -145,6 +158,7 @@
* @see javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes()
*/
public NodeType[] getRequiredPrimaryTypes() {
+ ensureRequiredPrimaryTypesLoaded();
// Make a copy so that the caller can't modify our content ...
NodeType[] result = new NodeType[requiredPrimaryTypes.length];
for (int i = 0; i != requiredPrimaryTypes.length; ++i) {
@@ -154,11 +168,22 @@
}
/**
+ * Returns the required primary type names for this object as specified in the
constructor. This method is useful for callers
+ * that wish to access this information while this node definition's parent node
is being registered.
+ *
+ * @return the required primary type names
+ */
+ Name[] requiredPrimaryTypeNames() {
+ return this.requiredPrimaryTypeNames;
+ }
+
+ /**
* Get the set of names of the primary types.
*
* @return the required primary type names
*/
Set<Name> getRequiredPrimaryTypeNames() {
+ ensureRequiredPrimaryTypesLoaded();
return requiredPrimaryTypesByName.keySet();
}
@@ -179,6 +204,7 @@
}
return false;
}
+ ensureRequiredPrimaryTypesLoaded();
// The supplied primary type must be or extend all of the required primary types
...
for (Name requiredPrimaryTypeName : requiredPrimaryTypesByName.keySet()) {
if (!childPrimaryType.isNodeType(requiredPrimaryTypeName)) return false;
@@ -195,28 +221,23 @@
* <code>declaringNodeType</code>.
*/
JcrNodeDefinition with( JcrNodeType declaringNodeType ) {
- JcrNodeType[] required = requiredPrimaryTypesByName.values().toArray(new
JcrNodeType[requiredPrimaryTypesByName.size()]);
return new JcrNodeDefinition(this.context, declaringNodeType.nodeTypeManager(),
declaringNodeType, name,
getOnParentVersion(), isAutoCreated(),
isMandatory(), isProtected(),
- allowsSameNameSiblings(), defaultPrimaryTypeName,
required);
+ allowsSameNameSiblings(), defaultPrimaryTypeName,
requiredPrimaryTypeNames);
}
JcrNodeDefinition with( ExecutionContext context ) {
- JcrNodeType[] required = requiredPrimaryTypesByName.values().toArray(new
JcrNodeType[requiredPrimaryTypesByName.size()]);
return new JcrNodeDefinition(context, this.nodeTypeManager,
this.declaringNodeType, name, getOnParentVersion(),
isAutoCreated(), isMandatory(), isProtected(),
allowsSameNameSiblings(),
- defaultPrimaryTypeName, required);
+ defaultPrimaryTypeName, requiredPrimaryTypeNames);
}
JcrNodeDefinition with( RepositoryNodeTypeManager nodeTypeManager ) {
- JcrNodeType[] required = requiredPrimaryTypesByName.values().toArray(new
JcrNodeType[requiredPrimaryTypesByName.size()]);
return new JcrNodeDefinition(this.context, nodeTypeManager,
this.declaringNodeType, name, getOnParentVersion(),
isAutoCreated(), isMandatory(), isProtected(),
allowsSameNameSiblings(),
- defaultPrimaryTypeName, required);
+ defaultPrimaryTypeName, requiredPrimaryTypeNames);
}
-
-
@Override
public int hashCode() {
return getId().toString().hashCode();
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinitionTemplate.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinitionTemplate.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinitionTemplate.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,109 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import javax.jcr.nodetype.NodeType;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate;
+
+/**
+ * DNA implementation of the JCR 2 NodeDefinitionTemplate interface
+ */
+@NotThreadSafe
+class JcrNodeDefinitionTemplate extends JcrItemDefinitionTemplate implements
NodeDefinitionTemplate {
+
+ private String defaultPrimaryType;
+ private String[] requiredPrimaryTypes;
+ private boolean allowSameNameSiblings;
+
+ JcrNodeDefinitionTemplate( ExecutionContext context ) {
+ super(context);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate#setDefaultPrimaryType(String)
+ */
+ public void setDefaultPrimaryType( String defaultPrimaryType ) {
+ this.defaultPrimaryType = defaultPrimaryType;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate#setRequiredPrimaryTypes(java.lang.String[])
+ */
+ public void setRequiredPrimaryTypes( String[] requiredPrimaryTypes ) {
+ CheckArg.isNotNull(requiredPrimaryTypes, "requiredPrimaryTypes");
+ this.requiredPrimaryTypes = requiredPrimaryTypes;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate#setSameNameSiblings(boolean)
+ */
+ public void setSameNameSiblings( boolean allowSameNameSiblings ) {
+ this.allowSameNameSiblings = allowSameNameSiblings;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.NodeDefinition#allowsSameNameSiblings()
+ */
+ public boolean allowsSameNameSiblings() {
+ return allowSameNameSiblings;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.NodeDefinition#getDefaultPrimaryType()
+ */
+ public NodeType getDefaultPrimaryType() {
+ return null;
+ }
+
+ String getDefaultPrimaryTypeName() {
+ return defaultPrimaryType;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes()
+ */
+ public NodeType[] getRequiredPrimaryTypes() {
+ return null;
+ }
+
+ String[] getRequiredPrimaryTypeNames() {
+ return requiredPrimaryTypes;
+ }
+
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeDefinitionTemplate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeType.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeType.java 2009-05-05 16:30:45 UTC
(rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeType.java 2009-05-05 22:09:15 UTC
(rev 886)
@@ -140,6 +140,12 @@
JcrNodeType superType = thisAndAllSupertypes.get(i);
for (NodeType superSuperType : superType.getDeclaredSupertypes()) {
JcrNodeType jcrSuperSuperType = (JcrNodeType)superSuperType;
+
+ if (jcrSuperSuperType == null) {
+ assert JcrNtLexicon.BASE.equals(name);
+ continue;
+ }
+
if (typeNames.add(jcrSuperSuperType.getInternalName())) {
thisAndAllSupertypes.add(jcrSuperSuperType);
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeSource.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeSource.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -1,8 +1,7 @@
package org.jboss.dna.jcr;
-import java.util.Collection;
import javax.jcr.nodetype.NodeType;
-import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.Graph;
/**
* Interface for any potential provider of {@link JcrNodeType} definitions, the DNA
implementation of {@link NodeType}. Possible
@@ -13,16 +12,46 @@
public interface JcrNodeTypeSource {
/**
- * Returns the list of node types provided by this source
+ * Returns the node type information to be registered in graph form. The graph has a
very specific required format.
+ * <p>
+ * The root node of the graph should have zero or more children. Each child of the
root node represents a type to be
+ * registered and the name of the node should be the name of the node type to be
registered. Additionally, any facets of the
+ * node type that are specified should be set in a manner consistent with the JCR
specification for the {@code nt:nodeType}
+ * built-in node type. The {@code jcr:primaryType} property does not need to be set
on these nodes, but the nodes must be
+ * semantically valid as if the {@code jcr:primaryType} property was set.
+ * </p>
+ * <p>
+ * Each node type node may have zero or more children, each with the name {@code
jcr:propertyDefinition} or {@code
+ * jcr:childNodeDefinition}, as per the definition of the {@code nt:nodeType}
built-in type. Each property definition and
+ * child node definition must obey the semantics of {@code jcr:propertyDefinition}
and {@code jcr:childNodeDefinition}
+ * respectively However these nodes also do not need to have the {@code
jcr:primaryType} property set.
+ * </p>
+ * <p>
+ * For example, one valid graph is:
*
- * @return the list of node types provided by this source
+ * <pre>
+ * <root>
+ * +---- test:testMixinType
+ * +--- jcr:nodeTypeName = test:testMixinType (PROPERTY)
+ * +--- jcr:isMixin = true (PROPERTY)
+ * +--- jcr:childNodeDefinition (CHILD NODE)
+ * | +--- jcr:name = test:childNodeA (PROPERTY)
+ * | +--- jcr:mandatory = true (PROPERTY)
+ * | +--- jcr:autoCreated = true (PROPERTY)
+ * | +--- jcr:defaultPrimaryType = nt:base (PROPERTY)
+ * | +--- jcr:requiredPrimaryTypes = nt:base (PROPERTY)
+ * +--- jcr:propertyDefinition (CHILD NODE)
+ * +--- jcr:name = test:propertyA (PROPERTY)
+ * +--- jcr:multiple = true (PROPERTY)
+ * +--- jcr:requiredType = String (PROPERTY)
+ * </pre>
+ *
+ * This graph (when registered) would create a mixin node named
"test:testMixinType" with a mandatory, autocreated child node
+ * named "test:childNodeA" with a default and required primary type of
"nt:base" and a multi-valued string property named
+ * "test:propertyA".
+ * </p>
+ *
+ * @return a graph with the semantics noted above
*/
- public Collection<JcrNodeType> getNodeTypes();
-
- /**
- * Finds the type with the given name and returns its definition.
- * @param typeName the name of the type to return
- * @return the type named <code>typeName</code> if it exists, otherwise
<code>null</code>.
- */
- public JcrNodeType findType(Name typeName);
+ Graph getNodeTypes();
}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeTemplate.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeTemplate.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeTemplate.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,209 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
+import org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate;
+
+/**
+ * DNA implementation of the JCR NodeTypeTemplate interface
+ */
+@NotThreadSafe
+public class JcrNodeTypeTemplate implements NodeTypeTemplate {
+
+ private final ExecutionContext context;
+ private final List<NodeDefinitionTemplate> nodeDefinitionTemplates = new
ArrayList<NodeDefinitionTemplate>();
+ private final List<PropertyDefinitionTemplate> propertyDefinitionTemplates =
new ArrayList<PropertyDefinitionTemplate>();
+ private boolean isAbstract;
+ private boolean mixin;
+ private boolean orderableChildNodes;
+ private String[] declaredSupertypeNames;
+ private String name;
+ private String primaryItemName;
+
+ JcrNodeTypeTemplate( ExecutionContext context ) {
+ assert context != null;
+
+ this.context = context;
+ }
+
+ ExecutionContext getExecutionContext() {
+ return context;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeTemplate#getNodeDefinitionTemplates()
+ */
+ public List<NodeDefinitionTemplate> getNodeDefinitionTemplates() {
+ return nodeDefinitionTemplates;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeTemplate#getPropertyDefinitionTemplates()
+ */
+ public List<PropertyDefinitionTemplate> getPropertyDefinitionTemplates() {
+ return propertyDefinitionTemplates;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeTemplate#setAbstract(boolean)
+ */
+ public void setAbstract( boolean isAbstract ) {
+ this.isAbstract = isAbstract;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.nodetype.NodeTypeTemplate#setDeclaredSupertypeNames(java.lang.String[])
+ */
+ public void setDeclaredSupertypeNames( String[] names ) {
+ CheckArg.isNotNull(names, "names");
+ this.declaredSupertypeNames = names;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeTemplate#setMixin(boolean)
+ */
+ public void setMixin( boolean mixin ) {
+ this.mixin = mixin;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeTemplate#setName(java.lang.String)
+ */
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeTemplate#setOrderableChildNodes(boolean)
+ */
+ public void setOrderableChildNodes( boolean orderable ) {
+ this.orderableChildNodes = orderable;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#getPrimaryItemName()
+ * type.NodeTypeTemplate#setPrimaryItemName(java.lang.String)
+ */
+ public void setPrimaryItemName( String name ) {
+ this.primaryItemName = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#getDeclaredNodeDefinitions()
+ */
+ public NodeDefinition[] getDeclaredNodeDefinitions() {
+ return null; // per JSR-283 specification (section 4.7.10)
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.nodetype.NodeTypeDefinition#getDeclaredPropertyDefinitions()
+ */
+ public PropertyDefinition[] getDeclaredPropertyDefinitions() {
+ return null; // per JSR-283 specification (section 4.7.10)
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#getDeclaredSupertypes()
+ */
+ public String[] getDeclaredSupertypes() {
+ return declaredSupertypeNames;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#getPrimaryItemName()
+ */
+ public String getPrimaryItemName() {
+ return primaryItemName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#hasOrderableChildNodes()
+ */
+ public boolean hasOrderableChildNodes() {
+ return orderableChildNodes;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#isAbstract()
+ */
+ public boolean isAbstract() {
+ return isAbstract;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.NodeTypeDefinition#isMixin()
+ */
+ public boolean isMixin() {
+ return mixin;
+ }
+
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeTemplate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinitionTemplate.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinitionTemplate.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinitionTemplate.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,128 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import javax.jcr.PropertyType;
+import javax.jcr.Value;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate;
+
+/**
+ * DNA implementation of the JCR 2 PropertyDefinitionTemplate interface.
+ */
+class JcrPropertyDefinitionTemplate extends JcrItemDefinitionTemplate implements
PropertyDefinitionTemplate {
+
+ private boolean multiple = false;
+ private String[] defaultValues;
+ private int requiredType = PropertyType.STRING;
+ private String[] valueConstraints = new String[0];
+
+ JcrPropertyDefinitionTemplate( ExecutionContext context ) {
+ super(context);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate#setDefaultValues(java.lang.String[])
+ */
+ public void setDefaultValues( String[] defaultValues ) {
+ CheckArg.isNotNull(defaultValues, "defaultValues");
+ this.defaultValues = defaultValues;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate#setMultiple(boolean)
+ */
+ public void setMultiple( boolean multiple ) {
+ this.multiple = multiple;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate#setRequiredType(int)
+ */
+ public void setRequiredType( int requiredType ) {
+ assert requiredType == PropertyType.BINARY || requiredType ==
PropertyType.BOOLEAN || requiredType == PropertyType.DATE
+ || requiredType == PropertyType.DOUBLE || requiredType ==
PropertyType.LONG || requiredType == PropertyType.NAME
+ || requiredType == PropertyType.PATH || requiredType ==
PropertyType.REFERENCE
+ || requiredType == PropertyType.STRING || requiredType ==
PropertyType.UNDEFINED;
+ this.requiredType = requiredType;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate#setValueConstraints(java.lang.String[])
+ */
+ public void setValueConstraints( String[] constraints ) {
+ CheckArg.isNotNull(constraints, "constraints");
+ this.valueConstraints = constraints;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.PropertyDefinition#getDefaultValues()
+ */
+ public Value[] getDefaultValues() {
+ return null;
+ }
+
+ String[] getInternalDefaultValues() {
+ return defaultValues;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.PropertyDefinition#getRequiredType()
+ */
+ public int getRequiredType() {
+ return requiredType;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.PropertyDefinition#getValueConstraints()
+ */
+ public String[] getValueConstraints() {
+ return valueConstraints;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.nodetype.PropertyDefinition#isMultiple()
+ */
+ public boolean isMultiple() {
+ return multiple;
+ }
+
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinitionTemplate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.jcr;
+import java.io.IOException;
import java.lang.reflect.Method;
import java.security.AccessControlContext;
import java.util.Collections;
@@ -199,11 +200,19 @@
modifiableDescriptors.put(Repository.SPEC_VERSION_DESC, "1.0");
this.descriptors = Collections.unmodifiableMap(modifiableDescriptors);
- JcrNodeTypeSource source = null;
- source = new JcrBuiltinNodeTypeSource(this.executionContext);
- source = new DnaBuiltinNodeTypeSource(this.executionContext, source);
- this.repositoryTypeManager = new RepositoryNodeTypeManager(this.executionContext,
source);
+ this.repositoryTypeManager = new
RepositoryNodeTypeManager(this.executionContext);
+ try {
+ this.repositoryTypeManager.registerNodeTypes(new CndNodeTypeSource(new
String[] {
+ "/org/jboss/dna/jcr/jsr_170_builtins.cnd",
"/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
+
if (options == null) {
this.options = DEFAULT_OPTIONS;
} else {
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,285 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.jcr.PropertyType;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.OnParentVersionAction;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.JcrLexicon;
+import org.jboss.dna.graph.JcrNtLexicon;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.graph.io.Destination;
+import org.jboss.dna.graph.io.GraphBatchDestination;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NameFactory;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.PropertyFactory;
+import org.jboss.dna.graph.property.ValueFactory;
+import org.jboss.dna.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
+
+/**
+ * Class to convert one or more {@link NodeTypeTemplate node type templates} containing
custom node type definitions into a format
+ * that can be registered with the {@link RepositoryNodeTypeManager}.
+ * <p>
+ * As the JSR-283 specification mandates that node type templates be the standard basis
for custom type registration, the
+ * {@link RepositoryNodeTypeManager#registerNodeTypes(java.util.Collection, boolean)}
method should be used in preference to
+ * manually instantiating this class.
+ * </p>
+ */
+@NotThreadSafe
+class NodeTemplateNodeTypeSource implements JcrNodeTypeSource {
+
+ private final Graph graph;
+ private final PathFactory pathFactory;
+ private final NameFactory nameFactory;
+ private final ValueFactory<Boolean> booleanFactory;
+ private final ValueFactory<String> stringFactory;
+ private final Destination destination;
+
+ public NodeTemplateNodeTypeSource( NodeTypeTemplate nodeTypeTemplate ) throws
InvalidNodeTypeDefinitionException {
+ this(Arrays.asList(new NodeTypeTemplate[] {nodeTypeTemplate}));
+ }
+
+ public NodeTemplateNodeTypeSource( List<NodeTypeTemplate> nodeTypeTemplates )
throws InvalidNodeTypeDefinitionException {
+
+ ExecutionContext context = null;
+
+ if (nodeTypeTemplates.isEmpty()) {
+ context = new ExecutionContext();
+ } else {
+ for (NodeTypeTemplate ntt : nodeTypeTemplates) {
+ if (!(ntt instanceof JcrNodeTypeTemplate)) {
+ throw new
IllegalArgumentException(JcrI18n.cannotConvertValue.text(ntt.getClass(),
JcrNodeTypeTemplate.class));
+ }
+
+ JcrNodeTypeTemplate jntt = (JcrNodeTypeTemplate)ntt;
+ if (context == null) {
+ context = jntt.getExecutionContext();
+ assert context != null;
+ } else {
+ if (context != jntt.getExecutionContext()) {
+ throw new
IllegalArgumentException(JcrI18n.allNodeTypeTemplatesMustComeFromSameSession.text());
+ }
+ }
+ }
+ }
+
+ assert context != null;
+ this.pathFactory = context.getValueFactories().getPathFactory();
+ this.nameFactory = context.getValueFactories().getNameFactory();
+ this.booleanFactory = context.getValueFactories().getBooleanFactory();
+ this.stringFactory = context.getValueFactories().getStringFactory();
+
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ InMemoryRepositorySource source = new InMemoryRepositorySource();
+ source.setName("NodeTypeTemplate Import Source");
+ this.graph = Graph.create(source, context);
+ Graph.Batch batch = graph.batch();
+ destination = new GraphBatchDestination(batch);
+
+ Path rootPath = pathFactory.createRootPath();
+ for (NodeTypeTemplate template : nodeTypeTemplates) {
+ this.createNodeType((JcrNodeTypeTemplate)template, rootPath);
+ }
+
+ destination.submit();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.JcrNodeTypeSource#getNodeTypes()
+ */
+ public final Graph getNodeTypes() {
+ return graph;
+ }
+
+ private boolean booleanFrom( Object value,
+ boolean defaultValue ) {
+ if (value == null) return defaultValue;
+
+ return booleanFactory.create(value);
+ }
+
+ private Name nameFrom( Object value ) {
+ return nameFactory.create(value);
+ }
+
+ private Name[] namesFrom( Object[] values ) {
+ if (values == null) return new Name[0];
+
+ Name[] names = new Name[values.length];
+ for (int i = 0; i < values.length; i++) {
+ names[i] = nameFactory.create(values[i]);
+ }
+
+ return names;
+ }
+
+ private String[] stringsFrom( Object[] values ) {
+ if (values == null) return new String[0];
+
+ String[] strings = new String[values.length];
+ for (int i = 0; i < values.length; i++) {
+ strings[i] = stringFactory.create(values[i]);
+ }
+
+ return strings;
+ }
+
+ /**
+ * Project the custom node type definition from the given template onto the {@link
#getNodeTypes() graph}.
+ *
+ * @param nodeType
+ * @param parentPath
+ * @return the path to the newly created node
+ * @throws InvalidNodeTypeDefinitionException
+ */
+ protected Path createNodeType( JcrNodeTypeTemplate nodeType,
+ Path parentPath ) throws
InvalidNodeTypeDefinitionException {
+
+ Name name = nameFrom(nodeType.getName());
+ Name[] supertypes = namesFrom(nodeType.getDeclaredSupertypes());
+ boolean isAbstract = booleanFrom(nodeType.isAbstract(), false);
+ boolean hasOrderableChildNodes = booleanFrom(nodeType.hasOrderableChildNodes(),
false);
+ boolean isMixin = booleanFrom(nodeType.isMixin(), false);
+ boolean isQueryable = true;
+ Name primaryItemName = nameFrom(nodeType.getPrimaryItemName());
+
+ // Create the node for the node type ...
+ if (name == null) throw new
InvalidNodeTypeDefinitionException(JcrI18n.invalidNodeTypeName.text());
+ Path path = pathFactory.create(parentPath, name);
+
+ PropertyFactory factory = nodeType.getExecutionContext().getPropertyFactory();
+ destination.create(path,
+ factory.create(JcrLexicon.PRIMARY_TYPE,
JcrNtLexicon.NODE_TYPE),
+ factory.create(JcrLexicon.SUPERTYPES, (Object[])supertypes),
+ factory.create(JcrLexicon.IS_ABSTRACT, isAbstract),
+ factory.create(JcrLexicon.HAS_ORDERABLE_CHILD_NODES,
hasOrderableChildNodes),
+ factory.create(JcrLexicon.IS_MIXIN, isMixin),
+ factory.create(JcrLexicon.IS_QUERYABLE, isQueryable),
+ factory.create(JcrLexicon.NODE_TYPE_NAME, name),
+ factory.create(JcrLexicon.PRIMARY_ITEM_NAME,
primaryItemName));
+
+ for (PropertyDefinition propDefn : nodeType.getPropertyDefinitionTemplates()) {
+ createPropertyDefinition((JcrPropertyDefinitionTemplate)propDefn, path);
+ }
+
+ for (NodeDefinition nodeDefn : nodeType.getNodeDefinitionTemplates()) {
+ createChildDefinition((JcrNodeDefinitionTemplate)nodeDefn, path);
+ }
+
+ return path;
+ }
+
+ /**
+ * Project the property definition from the given template onto the {@link
#getNodeTypes() graph}.
+ *
+ * @param propDefn
+ * @param parentPath
+ * @return the path to the newly created node
+ */
+ protected Path createPropertyDefinition( JcrPropertyDefinitionTemplate propDefn,
+ Path parentPath ) {
+ Name name = nameFrom(propDefn.getName());
+ String requiredType =
PropertyType.nameFromValue(propDefn.getRequiredType()).toUpperCase();
+ String[] defaultValues = propDefn.getInternalDefaultValues();
+ boolean multiple = booleanFrom(propDefn.isMultiple(), false);
+ boolean mandatory = booleanFrom(propDefn.isMandatory(), false);
+ boolean autoCreated = booleanFrom(propDefn.isAutoCreated(), false);
+ boolean isProtected = booleanFrom(propDefn.isProtected(), false);
+ String onParentVersion =
OnParentVersionAction.nameFromValue(propDefn.getOnParentVersion()).toUpperCase();
+ // /*QueryOperator[] queryOperators =*/queryOperatorsFrom(propDefn,
CndLexer.QUERY_OPERATORS);
+ // boolean isFullTextSearchable = booleanFrom(propDefn,
CndLexer.IS_FULL_TEXT_SEARCHABLE, true);
+ // boolean isQueryOrderable = booleanFrom(propDefn,
CndLexer.IS_QUERY_ORDERERABLE, true);
+ String[] valueConstraints = stringsFrom(propDefn.getValueConstraints());
+
+ // Create the node for the node type ...
+ if (name == null) name = JcrNodeType.RESIDUAL_NAME;
+ Path path = pathFactory.create(parentPath, JcrLexicon.PROPERTY_DEFINITION);
+
+ PropertyFactory factory = propDefn.getExecutionContext().getPropertyFactory();
+ destination.create(path,
+ factory.create(JcrLexicon.PRIMARY_TYPE,
JcrNtLexicon.PROPERTY_DEFINITION),
+ factory.create(JcrLexicon.REQUIRED_TYPE, requiredType),
+ factory.create(JcrLexicon.DEFAULT_VALUES,
(Object[])defaultValues),
+ factory.create(JcrLexicon.MULTIPLE, multiple),
+ factory.create(JcrLexicon.MANDATORY, mandatory),
+ factory.create(JcrLexicon.NAME, name),
+ factory.create(JcrLexicon.AUTO_CREATED, autoCreated),
+ factory.create(JcrLexicon.PROTECTED, isProtected),
+ factory.create(JcrLexicon.ON_PARENT_VERSION,
onParentVersion),
+ // factory.create(DnaLexicon.QUERY_OPERATORS,
queryOperators),
+ // factory.create(JcrLexicon.IS_FULL_TEXT_SEARCHABLE,
isFullTextSearchable),
+ // factory.create(JcrLexicon.IS_QUERY_ORDERABLE,
isQueryOrderable),
+ factory.create(JcrLexicon.VALUE_CONSTRAINTS,
(Object[])valueConstraints));
+
+ return path;
+ }
+
+ /**
+ * Project the child node definition from the given template onto the {@link
#getNodeTypes() graph}.
+ *
+ * @param childDefn
+ * @param parentPath
+ * @return the path to the newly created node
+ */
+ protected Path createChildDefinition( JcrNodeDefinitionTemplate childDefn,
+ Path parentPath ) {
+ Name name = nameFrom(childDefn.getName());
+ Name[] requiredPrimaryTypes =
namesFrom(childDefn.getRequiredPrimaryTypeNames());
+ Name defaultPrimaryType = nameFrom(childDefn.getDefaultPrimaryTypeName());
+ boolean mandatory = booleanFrom(childDefn.isMandatory(), false);
+ boolean autoCreated = booleanFrom(childDefn.isAutoCreated(), false);
+ boolean isProtected = booleanFrom(childDefn.isProtected(), false);
+ String onParentVersion =
OnParentVersionAction.nameFromValue(childDefn.getOnParentVersion()).toUpperCase();
+ boolean sameNameSiblings = booleanFrom(childDefn.allowsSameNameSiblings(),
false);
+
+ // Create the node for the node type ...
+ if (name == null) name = JcrNodeType.RESIDUAL_NAME;
+ Path path = pathFactory.create(parentPath, JcrLexicon.CHILD_NODE_DEFINITION);
+
+ PropertyFactory factory = childDefn.getExecutionContext().getPropertyFactory();
+ destination.create(path,
+ factory.create(JcrLexicon.PRIMARY_TYPE,
JcrNtLexicon.CHILD_NODE_DEFINITION),
+ factory.create(JcrLexicon.REQUIRED_PRIMARY_TYPES,
(Object[])requiredPrimaryTypes),
+ factory.create(JcrLexicon.DEFAULT_PRIMARY_TYPE,
defaultPrimaryType),
+ factory.create(JcrLexicon.MANDATORY, mandatory),
+ factory.create(JcrLexicon.NAME, name),
+ factory.create(JcrLexicon.AUTO_CREATED, autoCreated),
+ factory.create(JcrLexicon.PROTECTED, isProtected),
+ factory.create(JcrLexicon.ON_PARENT_VERSION,
onParentVersion),
+ factory.create(JcrLexicon.SAME_NAME_SIBLINGS,
sameNameSiblings));
+
+ return path;
+ }
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
===================================================================
---
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -33,6 +33,7 @@
import java.util.Map;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
import javax.jcr.nodetype.NodeDefinition;
@@ -44,27 +45,58 @@
import org.jboss.dna.common.text.XmlNameEncoder;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NameFactory;
+import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
-import org.jboss.dna.jcr.JcrNodeTypeSource;
+import org.jboss.dna.graph.property.ValueFactories;
+import org.jboss.dna.graph.property.ValueFactory;
+import org.jboss.dna.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import org.jboss.dna.jcr.nodetype.NodeTypeDefinition;
+import org.jboss.dna.jcr.nodetype.NodeTypeExistsException;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
/**
* The {@link RepositoryNodeTypeManager} is the maintainer of node type information for
the entire repository at run-time. The
- * repository manager maintains a list of all node types and the ability to retrieve node
types by {@link Name}. </p> The JCR 1.0
- * and 2.0 specifications both require that node type information be shared across all
sessions within a repository and that the
- * {@link javax.jcr.nodetype.NodeTypeManager} perform operations based on the string
versions of {@link Name}s based on the
- * permanent (workspace-scoped) and transient (session-scoped) namespace mappings. DNA
achieves this by maintaining a single
- * master repository of all node type information (the {@link RepositoryNodeTypeManager})
and per-session wrappers (
+ * repository manager maintains a list of all node types and the ability to retrieve node
types by {@link Name}.
+ * <p>
+ * The JCR 1.0 and 2.0 specifications both require that node type information be shared
across all sessions within a repository
+ * and that the {@link javax.jcr.nodetype.NodeTypeManager} perform operations based on
the string versions of {@link Name}s based
+ * on the permanent (workspace-scoped) and transient (session-scoped) namespace mappings.
DNA achieves this by maintaining a
+ * single master repository of all node type information (the {@link
RepositoryNodeTypeManager}) and per-session wrappers (
* {@link JcrNodeTypeManager}) for this master repository that perform {@link String} to
{@link Name} translation based on the
* {@link javax.jcr.Session}'s transient mappings and then delegating node type
lookups to the repository manager.
+ * </p>
*/
@Immutable
class RepositoryNodeTypeManager {
+ private static final Map<String, Integer> PROPERTY_TYPE_VALUES_FROM_NAME;
+
+ static {
+ Map<String, Integer> temp = new HashMap<String, Integer>();
+
+ temp.put(PropertyType.TYPENAME_BINARY.toUpperCase(), PropertyType.BINARY);
+ temp.put(PropertyType.TYPENAME_BOOLEAN.toUpperCase(), PropertyType.BOOLEAN);
+ temp.put(PropertyType.TYPENAME_DATE.toUpperCase(), PropertyType.DATE);
+ temp.put(PropertyType.TYPENAME_DOUBLE.toUpperCase(), PropertyType.DOUBLE);
+ temp.put(PropertyType.TYPENAME_LONG.toUpperCase(), PropertyType.LONG);
+ temp.put(PropertyType.TYPENAME_NAME.toUpperCase(), PropertyType.NAME);
+ temp.put(PropertyType.TYPENAME_PATH.toUpperCase(), PropertyType.PATH);
+ temp.put(PropertyType.TYPENAME_STRING.toUpperCase(), PropertyType.STRING);
+ temp.put(PropertyType.TYPENAME_REFERENCE.toUpperCase(), PropertyType.REFERENCE);
+ temp.put(PropertyType.TYPENAME_UNDEFINED.toUpperCase(), PropertyType.UNDEFINED);
+
+ PROPERTY_TYPE_VALUES_FROM_NAME = Collections.unmodifiableMap(temp);
+ }
+
private static final TextEncoder NAME_ENCODER = new XmlNameEncoder();
private final ExecutionContext context;
@@ -96,26 +128,14 @@
ANY
}
- RepositoryNodeTypeManager( ExecutionContext context,
- JcrNodeTypeSource source ) {
+ RepositoryNodeTypeManager( ExecutionContext context ) {
this.context = context;
this.propertyFactory = context.getPropertyFactory();
this.pathFactory = context.getValueFactories().getPathFactory();
- Collection<JcrNodeType> types = source.getNodeTypes();
propertyDefinitions = new HashMap<PropertyDefinitionId,
JcrPropertyDefinition>();
childNodeDefinitions = new HashMap<NodeDefinitionId, JcrNodeDefinition>();
-
- nodeTypes = new HashMap<Name, JcrNodeType>(types.size());
- for (JcrNodeType nodeType : types) {
- nodeTypes.put(nodeType.getInternalName(), nodeType.with(this));
- for (JcrNodeDefinition childDefinition : nodeType.childNodeDefinitions()) {
- childNodeDefinitions.put(childDefinition.getId(), childDefinition);
- }
- for (JcrPropertyDefinition propertyDefinition :
nodeType.propertyDefinitions()) {
- propertyDefinitions.put(propertyDefinition.getId(), propertyDefinition);
- }
- }
+ nodeTypes = new HashMap<Name, JcrNodeType>(50);
}
public Collection<JcrNodeType> getAllNodeTypes() {
@@ -940,6 +960,129 @@
}
/**
+ * Registers a new node type or updates an existing node type using the specified
definition and returns the resulting {@code
+ * NodeType} object.
+ * <p>
+ * The node type definition is wrapped in a collection and passed to the {@link
#registerNodeTypes(Collection, boolean) batch
+ * type definition method}.
+ * </p>
+ *
+ * @param ntd the {@code NodeTypeDefinition} to register
+ * @param allowUpdates indicates whether existing node types should be updated by the
given definition
+ * @return the newly registered (or updated) {@code NodeType}
+ * @throws InvalidNodeTypeDefinitionException if the {@code NodeTypeDefinition} is
invalid
+ * @throws NodeTypeExistsException if <code>allowUpdate</code> is false
and the {@code NodeTypeDefinition} specifies a node
+ * type name that is already registered
+ * @throws RepositoryException if another error occurs
+ */
+ public JcrNodeType registerNodeType( NodeTypeDefinition ntd,
+ boolean allowUpdates )
+ throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
RepositoryException {
+ assert ntd != null;
+ assert ntd instanceof JcrNodeTypeTemplate;
+
+ JcrNodeTypeTemplate jntt = (JcrNodeTypeTemplate)ntd;
+
+ return registerNodeTypes(new NodeTemplateNodeTypeSource(jntt)).get(0);
+ }
+
+ /**
+ * Registers or updates the specified {@code Collection} of {@link
NodeTypeDefinition} objects.
+ * <p>
+ * This method is used to register or update a set of node types with mutual
dependencies.
+ * </p>
+ * <p>
+ * The effect of this method is "all or nothing"; if an error
occurs, no node types are registered or updated.
+ * </p>
+ * <p>
+ * <b>DNA Implementation Notes</b>
+ * </p>
+ * <p>
+ * DNA currently supports registration of batches of types with some constraints. DNA
will allow types to be registered if
+ * they meet the following criteria:
+ * <ol>
+ * <li>The batch must consist of {@code NodeTypeDefinitionTemplate node type
definition templates} created through the user's
+ * JCR session.</li>
+ * <li>Existing types cannot be modified in-place - They must be unregistered
and re-registered</li>
+ * <li>Types must have a non-null, non-empty name</li>
+ * <li>If a primary item name is specified for the node type, it must match the
name of a property OR a child node, not both</li>
+ * <li>Each type must have a valid set of supertypes - that is, the type's
supertypes must meet the following criteria:
+ * <ol>
+ * <li>The type must have at least one supertype (unless the type is {@code
nt:base}.</li>
+ * <li>No two supertypes {@code t1} and {@code t2} can declare each declare a
property ({@code p1} and {@code p2}) with the
+ * same name and cardinality ({@code p1.isMultiple() == p2.isMultiple()}). Note that
this does prohibit each {@code t1} and
+ * {@code t2} from having a common supertype (or super-supertype, etc.) that declares
a property).</li>
+ * <li>No two supertypes {@code t1} and {@code t2} can declare each declare a
child node ({@code n1} and {@code n2}) with the
+ * same name and SNS status ({@code p1.allowsSameNameSiblings() ==
p2.allowsSameNameSiblings()}). Note that this does prohibit
+ * each {@code t1} and {@code t2} from having a common supertype (or super-supertype,
etc.) that declares a child node).</li>
+ * </ol>
+ * </li>
+ * <li>Each type must have a valid set of properties - that is, the type's
properties must meet the following criteria:
+ * <ol>
+ * <li>Residual property definitions cannot be mandatory</li>
+ * <li>If the property is auto-created, it must specify a default
value</li>
+ * <li>If the property is single-valued, it can only specify a single default
value</li>
+ * <li>If the property overrides an existing property definition from a
supertype, the new definition must be mandatory if the
+ * old definition was mandatory</li>
+ * <li>The property cannot override an existing property definition from a
supertype if the ancestor definition is protected</li>
+ * <li>If the property overrides an existing property definition from a
supertype that specifies value constraints, the new
+ * definition must have the same value constraints as the old definition.
<i>This requirement may be relaxed in a future
+ * version of DNA.</i></li>
+ * <li>If the property overrides an existing property definition from a
supertype, the new definition must have the same
+ * required type as the old definition or a required type that can ALWAYS be cast to
the required type of the ancestor (see
+ * section 6.2.6 of the JCR 1.0.1 specification)</li>
+ * </ol>
+ * Note that an empty set of properties would meet the above criteria.</li>
+ * <li>The type must have a valid set of child nodes - that is, the types's
child nodes must meet the following criteria:
+ * <ol>
+ * <li>Residual child node definitions cannot be mandatory</li>
+ * <li>If the child node is auto-created, it must specify a default primary
type name</li>
+ * <li>All required primary types must already be fully registered with the
type manager or must have been defined earlier in
+ * the batch. <i>This requirement may be relaxed in a future version of
DNA.</i></li>
+ * <li>If the child node overrides an existing child node definition from a
supertype, the new definition must be mandatory if
+ * the old definition was mandatory</li>
+ * <li>The child node cannot override an existing child node definition from a
supertype if the ancestor definition is
+ * protected</li>
+ * <li>If the child node overrides an existing child node definition from a
supertype, the required primary types of the new
+ * definition must be more restrictive than the required primary types of the old
definition - that is, the new primary types
+ * must defined such that any type that satisfies all of the required primary types
for the new definition must also satisfy
+ * all of the required primary types for the old definition. This requirement is
analogous to the requirement that overriding
+ * property definitions have a required type that is always convertible to the
required type of the overridden definition.</li>
+ * </ol>
+ * Note that an empty set of child nodes would meet the above criteria.</li>
+ * </p>
+ *
+ * @param nodeTypeBatch the batch of {@link NodeTypeDefinition node type definitions}
to register
+ * @param allowUpdates indicates whether existing node types should be updated by the
given definition; must be set to {@code
+ * false} in the current implementation
+ * @return the newly registered (or updated) {@link NodeType NodeTypes}
+ * @throws UnsupportedRepositoryOperationException if {@code allowUpdates == true}.
DNA does not support this capability at
+ * this time but the parameter has been retained for API compatibility.
+ * @throws InvalidNodeTypeDefinitionException if the {@link NodeTypeDefinition} is
invalid
+ * @throws NodeTypeExistsException if <code>allowUpdate</code> is false
and the {@link NodeTypeDefinition} specifies a node
+ * type name that is already registered
+ * @throws RepositoryException if another error occurs
+ */
+ public List<JcrNodeType> registerNodeTypes(
Collection<NodeTypeDefinition> nodeTypeBatch,
+ boolean allowUpdates )
+ throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
RepositoryException {
+
+ if (nodeTypeBatch.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ List<NodeTypeTemplate> ntts = new
ArrayList<NodeTypeTemplate>(nodeTypeBatch.size());
+
+ for (NodeTypeDefinition ntd : nodeTypeBatch) {
+ assert ntd instanceof JcrNodeTypeTemplate;
+ ntts.add((JcrNodeTypeTemplate)ntd);
+ }
+
+ return registerNodeTypes(new NodeTemplateNodeTypeSource(ntts));
+
+ }
+
+ /**
* Registers the node types from the given {@link JcrNodeTypeSource}.
* <p>
* The effect of this method is "all or nothing"; if an error
occurs, no node types are registered or updated.
@@ -1002,29 +1145,42 @@
*
* @param nodeTypeSource the batch of {@link NodeType node types} to register
* @return the newly registered (or updated) {@link NodeType NodeTypes}
- * @throws RepositoryException if any of the node types in the the {@link
JcrNodeTypeSource} are invalid
+ * @throws UnsupportedRepositoryOperationException if {@code allowUpdates == true}.
DNA does not support this capability at
+ * this time but the parameter has been retained for API compatibility.
+ * @throws InvalidNodeTypeDefinitionException if the {@link NodeTypeDefinition} is
invalid
+ * @throws NodeTypeExistsException if <code>allowUpdate</code> is false
and the {@link NodeTypeDefinition} specifies a node
+ * type name that is already registered
* @throws RepositoryException if another error occurs
*/
- List<JcrNodeType> registerNodeTypes( JcrNodeTypeSource nodeTypeSource ) throws
RepositoryException {
+ List<JcrNodeType> registerNodeTypes( JcrNodeTypeSource nodeTypeSource )
+ throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
RepositoryException {
assert nodeTypeSource != null;
- Collection<JcrNodeType> nodeTypeBatch = nodeTypeSource.getNodeTypes();
- List<JcrNodeType> typesPendingRegistration = new
ArrayList<JcrNodeType>(nodeTypeBatch.size());
+ Graph nodeTypeBatch = nodeTypeSource.getNodeTypes();
+ NamespaceRegistry namespaces = this.context.getNamespaceRegistry();
- for (JcrNodeType nodeType : nodeTypeBatch) {
- if (nodeType.getInternalName() == null || nodeType.getName().length() == 0)
{
- throw new RepositoryException(JcrI18n.invalidNodeTypeName.text());
- }
+ List<Location> nodeTypeLocations =
nodeTypeBatch.getChildren().of("/");
+ List<JcrNodeType> typesPendingRegistration = new
ArrayList<JcrNodeType>(nodeTypeLocations.size());
- Name name = nodeType.getInternalName();
+ for (Location location : nodeTypeLocations) {
+ Node nodeTypeNode = nodeTypeBatch.getNodeAt(location);
+ assert location.getPath() != null;
- if (nodeTypes.containsKey(name)) {
- throw new
RepositoryException(JcrI18n.nodeTypeAlreadyExists.text(nodeType.getName()));
+ Name internalName = location.getPath().getLastSegment().getName();
+ if (internalName == null || internalName.getLocalName().length() == 0) {
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.invalidNodeTypeName.text());
}
- List<JcrNodeType> supertypes = supertypesFor(nodeType,
typesPendingRegistration);
+ if (nodeTypes.containsKey(internalName)) {
+ throw new NodeTypeExistsException(internalName,
+
JcrI18n.nodeTypeAlreadyExists.text(internalName.getString(namespaces)));
+ }
+ List<JcrNodeType> supertypes = supertypesFor(nodeTypeNode,
typesPendingRegistration);
+ // No need to re-parse the supertypes
+ JcrNodeType nodeType =
nodeTypeFrom(nodeTypeBatch.getSubgraphOfDepth(2).at(location), supertypes);
+
validate(nodeType, supertypes, typesPendingRegistration);
List<JcrPropertyDefinition> propertyDefs = new
ArrayList<JcrPropertyDefinition>(
@@ -1037,10 +1193,10 @@
List<JcrNodeDefinition> nodeDefs = new
ArrayList<JcrNodeDefinition>(nodeType.getDeclaredChildNodeDefinitions().length);
for (JcrNodeDefinition nodeDef : nodeType.getDeclaredChildNodeDefinitions())
{
- JcrNodeType[] requiredPrimaryTypes = new
JcrNodeType[nodeDef.getRequiredPrimaryTypeNames().size()];
+ JcrNodeType[] requiredPrimaryTypes = new
JcrNodeType[nodeDef.requiredPrimaryTypeNames().length];
int i = 0;
- for (Name primaryTypeName : nodeDef.getRequiredPrimaryTypeNames()) {
+ for (Name primaryTypeName : nodeDef.requiredPrimaryTypeNames()) {
requiredPrimaryTypes[i] = findTypeInMapOrList(primaryTypeName,
typesPendingRegistration);
if (requiredPrimaryTypes[i] == null) {
@@ -1052,10 +1208,10 @@
nodeDefs.add(nodeDef.with(this.context).with(this));
}
- JcrNodeType newNodeType = new JcrNodeType(this.context, this, name,
supertypes,
+ // Create a new node type that also has the correct property and child node
definitions associated
+ JcrNodeType newNodeType = new JcrNodeType(this.context, this,
nodeType.getInternalName(), supertypes,
nodeType.getInternalPrimaryItemName(), nodeDefs, propertyDefs,
nodeType.isMixin(),
nodeType.hasOrderableChildNodes());
-
typesPendingRegistration.add(newNodeType);
}
@@ -1082,6 +1238,126 @@
return typesPendingRegistration;
}
+ private JcrNodeType nodeTypeFrom( Subgraph nodeTypeGraph,
+ List<JcrNodeType> supertypes ) {
+ Node nodeTypeNode = nodeTypeGraph.getRoot();
+ List<Location> children = nodeTypeNode.getChildren();
+
+ List<JcrPropertyDefinition> properties = new
ArrayList<JcrPropertyDefinition>(children.size());
+ List<JcrNodeDefinition> childNodes = new
ArrayList<JcrNodeDefinition>(children.size());
+
+ for (Location childLocation : children) {
+ if
(JcrLexicon.PROPERTY_DEFINITION.equals(childLocation.getPath().getLastSegment().getName()))
{
+ properties.add(this.propertyDefinitionFrom(nodeTypeGraph,
childLocation));
+ } else if
(JcrLexicon.CHILD_NODE_DEFINITION.equals(childLocation.getPath().getLastSegment().getName()))
{
+ childNodes.add(this.childNodeDefinitionFrom(nodeTypeGraph,
childLocation));
+ } else {
+ throw new IllegalStateException("Unexpected child of node type at:
" + childLocation);
+ }
+ }
+
+ Map<Name, Property> nodeProperties = nodeTypeNode.getPropertiesByName();
+
+ ValueFactories valueFactories = context.getValueFactories();
+ NameFactory nameFactory = valueFactories.getNameFactory();
+ ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();
+
+ Name name =
nameFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.NODE_TYPE_NAME)));
+ Name primaryItemName =
nameFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.PRIMARY_ITEM_NAME)));
+ boolean mixin =
booleanFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.IS_MIXIN)));
+ boolean orderableChildNodes =
booleanFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.HAS_ORDERABLE_CHILD_NODES)));
+
+ return new JcrNodeType(this.context, this, name, supertypes, primaryItemName,
childNodes, properties, mixin,
+ orderableChildNodes);
+ }
+
+ private JcrPropertyDefinition propertyDefinitionFrom( Subgraph nodeTypeGraph,
+ Location propertyLocation ) {
+ Node propertyDefinitionNode = nodeTypeGraph.getNode(propertyLocation);
+ Map<Name, Property> properties =
propertyDefinitionNode.getPropertiesByName();
+
+ ValueFactories valueFactories = context.getValueFactories();
+ NameFactory nameFactory = valueFactories.getNameFactory();
+ ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();
+
+ Name propertyName =
nameFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.NAME)));
+ int onParentVersionBehavior =
OnParentVersionAction.valueFromName((String)getFirstPropertyValue(properties.get(JcrLexicon.ON_PARENT_VERSION)));
+ int requiredType =
PROPERTY_TYPE_VALUES_FROM_NAME.get(getFirstPropertyValue(properties.get(JcrLexicon.REQUIRED_TYPE)));
+
+ boolean mandatory =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.MANDATORY)));
+ boolean multiple =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.MULTIPLE)));
+ boolean autoCreated =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.AUTO_CREATED)));
+ boolean isProtected =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.PROTECTED)));
+
+ Value[] defaultValues;
+ Property defaultValuesProperty = properties.get(JcrLexicon.DEFAULT_VALUES);
+ if (defaultValuesProperty != null) {
+ List<Value> values = new ArrayList<Value>();
+
+ for (Object value : defaultValuesProperty) {
+ values.add(new JcrValue(this.context.getValueFactories(),
(SessionCache)null, requiredType, value));
+ }
+ defaultValues = values.toArray(new Value[values.size()]);
+ } else {
+ defaultValues = new Value[0];
+ }
+
+ String[] valueConstraints;
+ Property constraintsProperty = properties.get(JcrLexicon.VALUE_CONSTRAINTS);
+ if (constraintsProperty != null) {
+ List<String> constraints = new ArrayList<String>();
+
+ for (Object value : constraintsProperty) {
+ constraints.add((String)value);
+ }
+ valueConstraints = constraints.toArray(new String[constraints.size()]);
+ } else {
+ valueConstraints = new String[0];
+ }
+
+ return new JcrPropertyDefinition(this.context, null, propertyName,
onParentVersionBehavior, autoCreated, mandatory,
+ isProtected, defaultValues, requiredType,
valueConstraints, multiple);
+ }
+
+ private JcrNodeDefinition childNodeDefinitionFrom( Subgraph nodeTypeGraph,
+ Location childNodeLocation ) {
+ Node childNodeDefinitionNode = nodeTypeGraph.getNode(childNodeLocation);
+ Map<Name, Property> properties =
childNodeDefinitionNode.getPropertiesByName();
+
+ ValueFactories valueFactories = context.getValueFactories();
+ NameFactory nameFactory = valueFactories.getNameFactory();
+ ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();
+
+ Name childNodeName =
nameFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.NAME)));
+ Name defaultPrimaryTypeName =
nameFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.DEFAULT_PRIMARY_TYPE)));
+ int onParentVersion =
OnParentVersionAction.valueFromName((String)getFirstPropertyValue(properties.get(JcrLexicon.ON_PARENT_VERSION)));
+
+ boolean mandatory =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.MANDATORY)));
+ boolean allowsSns =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.SAME_NAME_SIBLINGS)));
+ boolean autoCreated =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.AUTO_CREATED)));
+ boolean isProtected =
booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.PROTECTED)));
+
+ Name[] requiredTypes;
+ Property requiredTypeNamesProperty =
properties.get(JcrLexicon.REQUIRED_PRIMARY_TYPES);
+ if (requiredTypeNamesProperty != null) {
+ List<Name> names = new
ArrayList<Name>(requiredTypeNamesProperty.size());
+ for (Object value : requiredTypeNamesProperty) {
+ names.add(nameFactory.create(value));
+ }
+
+ requiredTypes = names.toArray(new Name[names.size()]);
+ } else {
+ requiredTypes = new Name[0];
+ }
+
+ return new JcrNodeDefinition(this.context, null, childNodeName, onParentVersion,
autoCreated, mandatory, isProtected,
+ allowsSns, defaultPrimaryTypeName, requiredTypes);
+ }
+
+ private Object getFirstPropertyValue( Property property ) {
+ return property != null ? property.getFirstValue() : null;
+ }
+
/**
* Finds the named type in the given list of types pending registration if it exists,
else returns the type definition from
* the repository
@@ -1113,24 +1389,33 @@
* @throws RepositoryException if any of the names in the array of supertype names
does not correspond to an
* already-registered node type or a node type that is pending registration
*/
- private List<JcrNodeType> supertypesFor( JcrNodeType nodeType,
+ private List<JcrNodeType> supertypesFor( Node nodeType,
List<JcrNodeType> pendingTypes )
throws RepositoryException {
assert nodeType != null;
+ Property supertypesProperty = nodeType.getProperty(JcrLexicon.SUPERTYPES);
+
// If no supertypes are provided, assume nt:base as a supertype
- if (nodeType.getDeclaredSupertypes() == null ||
nodeType.getDeclaredSupertypes().length == 0) {
- return
Collections.<JcrNodeType>singletonList(nodeTypes.get(JcrNtLexicon.BASE));
+ if (supertypesProperty == null || supertypesProperty.size() == 0) {
+ Property isMixinProperty = nodeType.getProperty(JcrLexicon.IS_MIXIN);
+ boolean isMixin = isMixinProperty != null &&
Boolean.valueOf(isMixinProperty.getFirstValue().toString());
+ JcrNodeType supertype = findTypeInMapOrList(JcrNtLexicon.BASE,
pendingTypes);
+ // We register nt:base at startup now instead of just injecting it
+ if (supertype == null || isMixin) {
+ return Collections.emptyList();
+ }
+ return Collections.<JcrNodeType>singletonList(supertype);
}
- JcrNodeType[] supertypesArray = nodeType.getDeclaredSupertypes();
+ Object[] supertypesArray = supertypesProperty.getValuesAsArray();
List<JcrNodeType> supertypes = new
ArrayList<JcrNodeType>(supertypesArray.length);
for (int i = 0; i < supertypesArray.length; i++) {
- supertypes.add(findTypeInMapOrList(supertypesArray[i].getInternalName(),
pendingTypes));
+ supertypes.add(findTypeInMapOrList((Name)supertypesArray[i], pendingTypes));
if (supertypes.get(i) == null) {
- throw new
RepositoryException(JcrI18n.invalidSupertypeName.text(supertypesArray[i].getInternalName(),
-
nodeType.getName()));
+ Name nodeTypeName =
nodeType.getLocation().getPath().getLastSegment().getName();
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.invalidSupertypeName.text(supertypesArray[i],
nodeTypeName));
}
}
@@ -1161,7 +1446,7 @@
*/
private void validate( List<JcrNodeType> supertypes,
String nodeName ) throws RepositoryException {
- assert supertypes.size() > 0; // This is reasonable now that we default to
having a supertype of nt:base
+ assert supertypes != null;
Map<PropertyDefinitionId, JcrPropertyDefinition> props = new
HashMap<PropertyDefinitionId, JcrPropertyDefinition>();
@@ -1175,10 +1460,10 @@
String oldPropTypeName = oldProp.getDeclaringNodeType().getName();
String propTypeName = property.getDeclaringNodeType().getName();
if (!oldPropTypeName.equals(propTypeName)) {
- throw new
RepositoryException(JcrI18n.supertypesConflict.text(oldPropTypeName,
-
propTypeName,
-
"property",
-
property.getName()));
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.supertypesConflict.text(oldPropTypeName,
+
propTypeName,
+
"property",
+
property.getName()));
}
}
}
@@ -1195,10 +1480,10 @@
String oldNodeTypeName = oldNode.getDeclaringNodeType().getName();
String childNodeTypeName =
childNode.getDeclaringNodeType().getName();
if (!oldNodeTypeName.equals(childNodeTypeName)) {
- throw new
RepositoryException(JcrI18n.supertypesConflict.text(oldNodeTypeName,
-
childNodeTypeName,
-
"child node",
-
childNode.getName()));
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.supertypesConflict.text(oldNodeTypeName,
+
childNodeTypeName,
+
"child node",
+
childNode.getName()));
}
}
}
@@ -1220,25 +1505,27 @@
private void validate( JcrNodeType nodeType,
List<JcrNodeType> supertypes,
List<JcrNodeType> pendingTypes ) throws
RepositoryException {
- validate(supertypes, nodeType.getName());
+ Name nodeTypeName = nodeType.getInternalName();
+ validate(supertypes,
nodeTypeName.getString(this.context.getNamespaceRegistry()));
List<Name> supertypeNames = new ArrayList<Name>(supertypes.size());
for (JcrNodeType supertype : supertypes)
supertypeNames.add(supertype.getInternalName());
boolean found = false;
- String primaryItemName = nodeType.getPrimaryItemName();
+ Name primaryItemName = nodeType.getInternalPrimaryItemName();
+
for (JcrNodeDefinition node : nodeType.getDeclaredChildNodeDefinitions()) {
validate(node, supertypeNames, pendingTypes);
- if (primaryItemName != null &&
primaryItemName.equals(node.getName())) {
+ if (primaryItemName != null &&
primaryItemName.equals(node.getInternalName())) {
found = true;
}
}
for (JcrPropertyDefinition prop : nodeType.getDeclaredPropertyDefinitions()) {
validate(prop, supertypeNames, pendingTypes);
- if (primaryItemName != null &&
primaryItemName.equals(prop.getName())) {
+ if (primaryItemName != null &&
primaryItemName.equals(prop.getInternalName())) {
if (found) {
throw new
RepositoryException(JcrI18n.ambiguousPrimaryItemName.text(primaryItemName));
}
@@ -1280,11 +1567,11 @@
private void validate( JcrNodeDefinition node,
List<Name> supertypes,
List<JcrNodeType> pendingTypes ) throws
RepositoryException {
- if (node.isAutoCreated() && node.getDefaultPrimaryType() == null) {
- throw new RepositoryException(JcrI18n.autocreatedNodesNeedDefaults.text());
+ if (node.isAutoCreated() && !node.isProtected() &&
node.getDefaultPrimaryType() == null) {
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.autocreatedNodesNeedDefaults.text(node.getName()));
}
if (node.isMandatory() &&
JcrNodeType.RESIDUAL_ITEM_NAME.equals(node.getName())) {
- throw new
RepositoryException(JcrI18n.residualDefinitionsCannotBeMandatory.text("child
nodes"));
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.residualDefinitionsCannotBeMandatory.text("child
nodes"));
}
Name nodeName =
context.getValueFactories().getNameFactory().create(node.getName());
@@ -1294,15 +1581,15 @@
for (JcrNodeDefinition ancestor : ancestors) {
if (ancestor.isProtected()) {
- throw new RepositoryException(
-
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType().getName(),
-
"child node"));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType().getName(),
+
"child node"));
}
if (ancestor.isMandatory() && !node.isMandatory()) {
- throw new RepositoryException(
-
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType().getName(),
-
"child node"));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType().getName(),
+
"child node"));
}
@@ -1318,12 +1605,12 @@
}
}
if (!found) {
- throw new RepositoryException(
- "Cannot redefine child node
'"
- + nodeName
- + "' with required type
'"
- + apt.getName()
- + "' with new child node that
does not required that type or a subtype of that type.");
+ throw new InvalidNodeTypeDefinitionException(
+ "Cannot redefine
child node '"
+ + nodeName
+ + "' with
required type '"
+ + apt.getName()
+ + "' with new
child node that does not required that type or a subtype of that type.");
}
}
@@ -1361,19 +1648,20 @@
assert pendingTypes != null;
if (prop.isMandatory() && !prop.isProtected() &&
JcrNodeType.RESIDUAL_ITEM_NAME.equals(prop.getName())) {
- throw new
RepositoryException(JcrI18n.residualDefinitionsCannotBeMandatory.text("properties"));
+ throw new
InvalidNodeTypeDefinitionException(JcrI18n.residualDefinitionsCannotBeMandatory.text("properties"));
}
Value[] defaultValues = prop.getDefaultValues();
if (prop.isAutoCreated() && !prop.isProtected() && (defaultValues
== null || defaultValues.length == 0)) {
- throw new
RepositoryException(JcrI18n.autocreatedPropertyNeedsDefault.text(prop.getName(),
-
prop.getDeclaringNodeType().getName()));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.autocreatedPropertyNeedsDefault.text(prop.getName(),
+
prop.getDeclaringNodeType().getName()));
}
if (!prop.isMultiple() && (defaultValues != null &&
defaultValues.length > 1)) {
- throw new RepositoryException(
-
JcrI18n.singleValuedPropertyNeedsSingleValuedDefault.text(prop.getName(),
-
prop.getDeclaringNodeType().getName()));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.singleValuedPropertyNeedsSingleValuedDefault.text(prop.getName(),
+
prop.getDeclaringNodeType().getName()));
}
Name propName =
context.getValueFactories().getNameFactory().create(prop.getName());
@@ -1386,15 +1674,15 @@
for (JcrPropertyDefinition ancestor : ancestors) {
if (ancestor.isProtected()) {
- throw new RepositoryException(
-
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType().getName(),
-
"property"));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.cannotOverrideProtectedDefinition.text(ancestor.getDeclaringNodeType().getName(),
+
"property"));
}
if (ancestor.isMandatory() && !prop.isMandatory()) {
- throw new RepositoryException(
-
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType().getName(),
-
"property"));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.cannotMakeMandatoryDefinitionOptional.text(ancestor.getDeclaringNodeType().getName(),
+
"property"));
}
@@ -1402,16 +1690,17 @@
// the old
if (ancestor.getValueConstraints() != null
&& !Arrays.equals(ancestor.getValueConstraints(),
prop.getValueConstraints())) {
- throw new
RepositoryException(JcrI18n.constraintsChangedInSubtype.text(propName,
-
ancestor.getDeclaringNodeType().getName()));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.constraintsChangedInSubtype.text(propName,
+
ancestor.getDeclaringNodeType().getName()));
}
if (!isAlwaysSafeConversion(prop.getRequiredType(),
ancestor.getRequiredType())) {
- throw new RepositoryException(
-
JcrI18n.cannotRedefineProperty.text(propName,
-
PropertyType.nameFromValue(prop.getRequiredType()),
-
ancestor.getDeclaringNodeType().getName(),
-
PropertyType.nameFromValue(ancestor.getRequiredType())));
+ throw new InvalidNodeTypeDefinitionException(
+
JcrI18n.cannotRedefineProperty.text(propName,
+
PropertyType.nameFromValue(prop.getRequiredType()),
+
ancestor.getDeclaringNodeType().getName(),
+
PropertyType.nameFromValue(ancestor.getRequiredType())));
}
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -1296,8 +1296,8 @@
if (!definition.getId().equals(node.getDefinitionId())) {
// The node definition changed, so try to set the property ...
try {
- JcrValue value = new JcrValue(factories(), SessionCache.this,
PropertyType.STRING, definition.getId()
-
.getString());
+ JcrValue value = new JcrValue(factories(), SessionCache.this,
PropertyType.STRING,
+ definition.getId().getString());
setProperty(DnaIntLexicon.NODE_DEFINITON, value);
} catch (ConstraintViolationException e) {
// We can't set this property on the node (according to the node
definition).
@@ -1530,10 +1530,7 @@
// ---------------------------------------
// Now record the changes to the store ...
// ---------------------------------------
- Graph.Create<Graph.Batch> create =
operations.createUnder(currentLocation)
- .nodeNamed(name)
- .with(desiredUuid)
- .with(primaryTypeProp);
+ Graph.Create<Graph.Batch> create =
operations.createUnder(currentLocation).nodeNamed(name).with(desiredUuid).with(primaryTypeProp);
if (nodeDefnDefn != null) {
create = create.with(nodeDefinitionProp);
}
@@ -2288,8 +2285,8 @@
DnaIntLexicon.MULTI_VALUED_PROPERTIES,
values,
false);
- Property dnaProp = propertyFactory.create(DnaIntLexicon.MULTI_VALUED_PROPERTIES,
newSingleMultiPropertyNames.iterator()
-
.next());
+ Property dnaProp = propertyFactory.create(DnaIntLexicon.MULTI_VALUED_PROPERTIES,
+
newSingleMultiPropertyNames.iterator().next());
PropertyId propId = new PropertyId(uuid, dnaProp.getName());
JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
return new PropertyInfo(propId, defn.getId(), PropertyType.STRING, dnaProp,
defn.isMultiple(), true, false);
Copied:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/InvalidNodeTypeDefinitionException.java
(from rev 885,
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java)
===================================================================
---
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/InvalidNodeTypeDefinitionException.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/InvalidNodeTypeDefinitionException.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,73 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.nodetype;
+
+import javax.jcr.RepositoryException;
+import net.jcip.annotations.Immutable;
+
+/**
+ * Exception representing that a node type definition is somehow invalid
+ */
+@Immutable
+public class InvalidNodeTypeDefinitionException extends RepositoryException {
+
+ /**
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ public InvalidNodeTypeDefinitionException() {
+ super();
+
+ }
+
+ /**
+ * @param message
+ * @param rootCause
+ */
+ public InvalidNodeTypeDefinitionException( String message,
+ Throwable rootCause ) {
+ super(message, rootCause);
+
+ }
+
+ /**
+ * @param message
+ */
+ public InvalidNodeTypeDefinitionException( String message ) {
+ super(message);
+
+ }
+
+ /**
+ * @param rootCause
+ */
+ public InvalidNodeTypeDefinitionException( Throwable rootCause ) {
+ super(rootCause);
+
+ }
+
+}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeDefinitionTemplate.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeDefinitionTemplate.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeDefinitionTemplate.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,99 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.nodetype;
+
+import javax.jcr.Node;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.version.OnParentVersionAction;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * A template that can be used to create new child node definitions, patterned after the
approach in the proposed <a
+ *
href="http://jcp.org/en/jsr/detail?id=283">JSR-283</a>. This
interface extends the standard {@link NodeTypeDefinition}
+ * interface and adds setter methods for the various attributes.
+ *
+ * @see NodeTypeTemplate#getDeclaredNodeDefinitions()
+ */
+@NotThreadSafe
+public interface NodeDefinitionTemplate extends NodeDefinition {
+
+ /**
+ * Set the name of this child node definition.
+ *
+ * @param name the name for this child node definition.
+ */
+ public void setName( String name );
+
+ /**
+ * Set whether this definition describes a child node that is auto-created by the
system.
+ *
+ * @param autoCreated true if this child should be auto-created
+ */
+ public void setAutoCreated( boolean autoCreated );
+
+ /**
+ * Set whether this definition describes a child that is required (mandatory).
+ *
+ * @param mandatory true if the child is mandatory
+ */
+ public void setMandatory( boolean mandatory );
+
+ /**
+ * Set the mode for the versioning of the child with respect to versioning of the
parent.
+ *
+ * @param opv the on-parent versioning mode; one of {@link OnParentVersionAction}
values.
+ */
+ public void setOnParentVersion( int opv );
+
+ /**
+ * Set whether the child node described by this definition is protected from changes
through the JCR API.
+ *
+ * @param isProtected true if the child node is protected, or false if it may be
changed through the JCR API
+ */
+ public void setProtected( boolean isProtected );
+
+ /**
+ * Set the names of the primary types that must appear on the child(ren) described by
this definition
+ *
+ * @param requiredPrimaryTypes the names of the required primary types, or null or
empty if there are no requirements for the
+ * primary types of the children described by this definition
+ */
+ public void setRequiredPrimaryTypes( String[] requiredPrimaryTypes );
+
+ /**
+ * Set the name of the primary type that should be used by default when creating
children using this node definition.
+ *
+ * @param defaultPrimaryType the name of the primary type that should be used by
default, or null if there is none
+ */
+ public void setDefaultPrimaryType( String defaultPrimaryType );
+
+ /**
+ * Set whether the children described by this definition may have the same names (and
therefore distinguished only by their
+ * {@link Node#getIndex() same-name-sibiling index}).
+ *
+ * @param allowSameNameSiblings true if the children described by this definition may
have the same names, or false otherwise
+ */
+ public void setSameNameSiblings( boolean allowSameNameSiblings );
+
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeDefinitionTemplate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeDefinition.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeDefinition.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeDefinition.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,94 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.nodetype;
+
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * An interface for an existing node type definition, patterned after the approach in the
proposed <a
+ *
href="http://jcp.org/en/jsr/detail?id=283">JSR-283</a>.
+ */
+@NotThreadSafe
+public interface NodeTypeDefinition {
+
+ /**
+ * Get the name of the node type being defined
+ *
+ * @return the name
+ */
+ public String getName();
+
+ /**
+ * Get the direct supertypes for this node type.
+ *
+ * @return the names of the direct supertypes, or an empty array if there are none
+ */
+ public String[] getDeclaredSupertypes();
+
+ /**
+ * Get whether this node type is abstract.
+ *
+ * @return true if this node type is abstract, or false if it is concrete
+ */
+ public boolean isAbstract();
+
+ /**
+ * Get whether this node type is a mixin.
+ *
+ * @return true if this node type is a mixin, or false if it is concrete
+ */
+ public boolean isMixin();
+
+ /**
+ * Get whether this node type supports orderable child nodes.
+ *
+ * @return true if this node type supports orderable child nodes, or false otherwise
+ */
+ public boolean hasOrderableChildNodes();
+
+ /**
+ * Get the name of the primary item for this node type
+ *
+ * @return the name of the child node or property that represents the primary item
for nodes that use this type, or null if
+ * there is none
+ */
+ public String getPrimaryItemName();
+
+ /**
+ * Get the array of property definition templates for this node type.
+ *
+ * @return the node type's list of property definitions; never null
+ */
+ public PropertyDefinition[] getDeclaredPropertyDefinitions();
+
+ /**
+ * Get the array of child node definition templates for this node type
+ *
+ * @return the node type's list of child node definitions; never null
+ */
+
+ public NodeDefinition[] getDeclaredNodeDefinitions();
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeDefinition.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeExistsException.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeExistsException.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeExistsException.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,94 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.nodetype;
+
+import javax.jcr.RepositoryException;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.property.Name;
+
+/**
+ * An exception that captures the error condition that a referenced node type already
exists.
+ */
+public class NodeTypeExistsException extends RepositoryException {
+
+ /**
+ */
+ private static final long serialVersionUID = 1L;
+
+ private Name nodeType;
+
+ /**
+ * @param nodeType the name of the existing node type
+ */
+ public NodeTypeExistsException( Name nodeType ) {
+ super();
+ CheckArg.isNotNull(nodeType, "nodeType");
+ this.nodeType = nodeType;
+ }
+
+ /**
+ * @param nodeType the name of the existing node type
+ * @param message
+ * @param rootCause
+ */
+ public NodeTypeExistsException( Name nodeType,
+ String message,
+ Throwable rootCause ) {
+ super(message, rootCause);
+ CheckArg.isNotNull(nodeType, "nodeType");
+ this.nodeType = nodeType;
+ }
+
+ /**
+ * @param nodeType the name of the existing node type
+ * @param message
+ */
+ public NodeTypeExistsException( Name nodeType,
+ String message ) {
+ super(message);
+ CheckArg.isNotNull(nodeType, "nodeType");
+ this.nodeType = nodeType;
+ }
+
+ /**
+ * @param nodeType the name of the existing node type
+ * @param rootCause
+ */
+ public NodeTypeExistsException( Name nodeType,
+ Throwable rootCause ) {
+ super(rootCause);
+ CheckArg.isNotNull(nodeType, "nodeType");
+ this.nodeType = nodeType;
+ }
+
+ /**
+ * Get the name of the existing node type.
+ *
+ * @return the existing node type name
+ */
+ public Name getNodeType() {
+ return nodeType;
+ }
+
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeExistsException.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeTemplate.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeTemplate.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeTemplate.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,94 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.nodetype;
+
+import java.util.List;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * A template that can be used to create new node types, patterned after the approach in
the proposed <a
+ *
href="http://jcp.org/en/jsr/detail?id=283">JSR-283</a>. This
interface extends the {@link NodeTypeDefinition} interface and
+ * adds setter methods for the various attributes.
+ */
+@NotThreadSafe
+public interface NodeTypeTemplate extends NodeTypeDefinition {
+
+ /**
+ * Set the name of the node type
+ *
+ * @param name the name
+ */
+ public void setName( String name );
+
+ /**
+ * Set the direct supertypes for this node type.
+ *
+ * @param names the names of the direct supertypes, or empty or null if there are
none.
+ */
+ public void setDeclaredSupertypeNames( String[] names );
+
+ /**
+ * Set whether this node type is abstract.
+ *
+ * @param isAbstract true if this node type is to be abstract, or false if it is
concrete
+ */
+ public void setAbstract( boolean isAbstract );
+
+ /**
+ * Set whether this node type is a mixin.
+ *
+ * @param mixin true if this node type is a mixin, or false otherwise
+ */
+ public void setMixin( boolean mixin );
+
+ /**
+ * Set whether this node type supports orderable child nodes.
+ *
+ * @param orderable true if this node type supports orderable child nodes, or false
otherwise
+ */
+ public void setOrderableChildNodes( boolean orderable );
+
+ /**
+ * Set the name of the primary item for this node type
+ *
+ * @param name the name of the child node or property that represents the primary
item for nodes that use this type, or null
+ * if there is none
+ */
+ public void setPrimaryItemName( String name );
+
+ /**
+ * Get the modifiable list of property definition templates for this node type.
+ *
+ * @return the node type's list of property definition templates; never null
+ */
+ public List<PropertyDefinitionTemplate> getPropertyDefinitionTemplates();
+
+ /**
+ * Get the modifiable list of child node definition templates for this node type
+ *
+ * @return the node type's list of child node definition templates; never null
+ */
+ public List<NodeDefinitionTemplate> getNodeDefinitionTemplates();
+
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/NodeTypeTemplate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/PropertyDefinitionTemplate.java
===================================================================
---
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/PropertyDefinitionTemplate.java
(rev 0)
+++
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/PropertyDefinitionTemplate.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,107 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.nodetype;
+
+import javax.jcr.PropertyType;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.OnParentVersionAction;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * A template that can be used to create new property definitions, patterned after the
approach in the proposed <a
+ *
href="http://jcp.org/en/jsr/detail?id=283">JSR-283</a>. This
interface extends the standard {@link PropertyDefinition}
+ * interface and adds setter methods for the various attributes.
+ *
+ * @see NodeTypeTemplate#getDeclaredPropertyDefinitions()
+ */
+@NotThreadSafe
+public interface PropertyDefinitionTemplate extends PropertyDefinition {
+
+ /**
+ * Set the name of the property definition
+ *
+ * @param name the name
+ */
+ public void setName( String name );
+
+ /**
+ * Set whether this definition describes a child node that is auto-created by the
system.
+ *
+ * @param autoCreated true if this child should be auto-created
+ */
+ public void setAutoCreated( boolean autoCreated );
+
+ /**
+ * Set whether this definition describes a child that is required (mandatory).
+ *
+ * @param mandatory true if the child is mandatory
+ */
+ public void setMandatory( boolean mandatory );
+
+ /**
+ * Set the mode for the versioning of the child with respect to versioning of the
parent.
+ *
+ * @param opv the on-parent versioning mode; one of {@link OnParentVersionAction}
values.
+ */
+ public void setOnParentVersion( int opv );
+
+ /**
+ * Set whether the child node described by this definition is protected from changes
through the JCR API.
+ *
+ * @param isProtected true if the child node is protected, or false if it may be
changed through the JCR API
+ */
+ public void setProtected( boolean isProtected );
+
+ /**
+ * Set the required property type for the values of the property, or {@link
PropertyType#UNDEFINED} if there is no type
+ * requirement
+ *
+ * @param requiredType the required type for the property values
+ */
+ public void setRequiredType( int requiredType );
+
+ /**
+ * Set the constraint expressions for the values of the property. See {@link
PropertyDefinition#getValueConstraints()} for
+ * more details about the formats of the constraints.
+ *
+ * @param constraints the value constraints, or null or an empty array if there are
no constraints.
+ */
+ public void setValueConstraints( String[] constraints );
+
+ /**
+ * Set the default values for the property, using their string representation. See
+ * {@link PropertyDefinition#getDefaultValues()} for more details.
+ *
+ * @param defaultValues the string representation of the default values, or null or
an empty array if there are no default
+ * values
+ */
+ public void setDefaultValues( String[] defaultValues );
+
+ /**
+ * Set whether the properties described by this definition may have multiple values.
+ *
+ * @param multiple true if the properties may have multiple values, or false if they
are limited to one value each
+ */
+ public void setMultiple( boolean multiple );
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/nodetype/PropertyDefinitionTemplate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-05-05
22:09:15 UTC (rev 886)
@@ -105,7 +105,7 @@
supertypesConflict=Types '{0}' and '{1}' cannot both be supertypes of the
same type, as both separately declare {2} '{3}'
ambiguousPrimaryItemName=Primary item name '{0}' matches the name of a child node
and a property
invalidPrimaryItemName=Primary item name '{0}' does not match the name of any
child nodes or properties
-autocreatedNodesNeedDefaults=Autocreated child nodes must specify a default primary type
+autocreatedNodesNeedDefaults=Autocreated child node '{0}' must specify a default
primary type
residualDefinitionsCannotBeMandatory=Residual {0} cannot be mandatory
cannotOverrideProtectedDefinition=Cannot override protected {1} definition from
'{0}'
cannotMakeMandatoryDefinitionOptional=Cannot override mandatory {1} definition from
'{0}' with a non-mandatory definition.
@@ -117,3 +117,5 @@
noDefinition=Cannot find a definition for the {0} named '{1}' on the node at
'{2}' with primary type '{3}' and mixin types: {4}
noSnsDefinition=Cannot find a definition that allows same-name siblings for the child
node named '{0}' on the node at '{1}' with primary type '{2}' and
mixin types: {3} and a child node already exists with this name
missingMandatoryItem=The mandatory {0} named '{1}' defined in type '{2}'
is missing from the node at '{3}'
+
+allNodeTypeTemplatesMustComeFromSameSession=All node type templates must be created from
the same javax.jcr.Session
Added: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd
(rev 0)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/dna_builtins.cnd 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,27 @@
+/*
+ * DNA Built-In Types
+ */
+
+
+<nt = "http://www.jcp.org/jcr/nt/1.0">
+<mix = "http://www.jcp.org/jcr/mix/1.0">
+<dna = "http://www.jboss.org/dna/1.0">
+
+[dna:namespace] > nt:base
+- dna:uri (string) primary protected version
+
+[dna:namespaces] > nt:base
++ * (dna:namespace) = dna:namespace protected version
+
+[dna:nodeTypes] > nt:base
++ * (nt:nodeType) = nt:nodeType protected version
+
+[dna:system] > nt:base
++ dna:namespaces (dna:namespaces) = dna:namespaces autocreated mandatory protected
version
++ dna:nodeTypes (dna:nodeTypes) = dna:nodeTypes autocreated mandatory protected version
+
+[dna:root] > nt:base, mix:referenceable orderable
+- * (undefined) multiple version
+- * (undefined) version
++ jcr:system (dna:system) = dna:system autocreated mandatory protected ignore
++ * (nt:base) = nt:base multiple version
Added: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/jsr_170_builtins.cnd
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/jsr_170_builtins.cnd
(rev 0)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/jsr_170_builtins.cnd 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,103 @@
+<jcr = "http://www.jcp.org/jcr/1.0">
+<nt = "http://www.jcp.org/jcr/nt/1.0">
+<mix = "http://www.jcp.org/jcr/mix/1.0">
+<dna = "http://www.jboss.org/dna/1.0">
+<dnaint = "http://www.jboss.org/dna/internal/1.0">
+
+[dna:defined] mixin
+- dnaint:nodeDefinition (string) protected initialize
+- dnaint:multiValuedProperties (string) multiple protected initialize
+
+[nt:base] > dna:defined
+- jcr:primaryType (name) mandatory protected autocreated compute
+- jcr:mixinTypes (name) multiple protected compute
+
+[mix:referenceable] mixin
+- jcr:uuid (string) mandatory protected autocreated initialize
+
+[nt:unstructured] orderable
+- * (undefined) multiple
+- * (undefined)
++ * (nt:base) = nt:unstructured multiple version
+
+[nt:hierarchyNode]
+- jcr:created (DATE) protected autocreated initialize
+
+[nt:file] > nt:hierarchyNode
++ jcr:content (nt:base) primary mandatory
+
+[nt:linkedFile] > nt:hierarchyNode
+- jcr:content (reference) primary mandatory
+
+[nt:folder] > nt:hierarchyNode
++ * (nt:hierarchyNode) version
+
+[nt:resource] > mix:referenceable, nt:base
+- jcr:data (binary) primary mandatory
+- jcr:encoding (string) copy
+- jcr:lastModified (date) mandatory ignore
+- jcr:mimeType (string) copy mandatory
+
+[nt:propertyDefinition]
+- jcr:name (name)
+- jcr:autoCreated (boolean) mandatory
+- jcr:mandatory (boolean) mandatory
+- jcr:onParentVersion (string) mandatory < 'COPY', 'VERSION',
'INITIALIZE', 'COMPUTE', 'IGNORE', 'ABORT'
+- jcr:protected (boolean) mandatory
+- jcr:requiredType (string) mandatory < 'STRING', 'BINARY',
'LONG', 'DOUBLE', 'BOOLEAN', 'DATE', 'NAME',
'PATH', 'REFERENCE', 'UNDEFINED'
+- jcr:valueConstraints (string) multiple
+- jcr:defaultValues (undefined) multiple
+- jcr:multiple (boolean) mandatory
+
+[nt:childNodeDefinition]
+- jcr:name (name)
+- jcr:autoCreated (boolean) mandatory
+- jcr:mandatory (boolean) mandatory
+- jcr:onParentVersion (string) mandatory < 'COPY', 'VERSION',
'INITIALIZE', 'COMPUTE', 'IGNORE', 'ABORT'
+- jcr:protected (boolean) mandatory
+- jcr:requiredPrimaryTypes (name) = 'nt:base' mandatory multiple
+- jcr:defaultPrimaryType (name)
+- jcr:sameNameSiblings (boolean) mandatory
+
+[nt:nodeType]
+- jcr:nodeTypeName (name) mandatory
+- jcr:supertypes (name) multiple
+- jcr:isMixin (boolean) mandatory
+- jcr:hasOrderableChildNodes (boolean) mandatory
+- jcr:primaryItemName (name)
++ jcr:propertyDefinition (nt:propertyDefinition) = nt:propertyDefinition multiple version
++ jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition multiple
version
+
+[nt:versionLabels]
+- * (reference) protected abort < 'nt:version'
+
+[nt:frozenNode] > mix:referenceable, nt:base orderable
+- jcr:frozenPrimaryType (name) mandatory protected autocreated abort
+- jcr:frozenMixinTypes (name) multiple protected abort
+- jcr:frozenUuid (string) mandatory protected autocreated abort
+- * (undefined) protected abort
+- * (undefined) multiple protected abort
++ * (nt:base) multiple protected abort
+
+[nt:version] > mix:referenceable, nt:base
+- jcr:created (date) mandatory protected autocreated abort
+- jcr:predecessors (reference) multiple protected abort < 'nt:version'
+- jcr:successors (reference) multiple protected abort < 'nt:version'
++ jcr:frozenNode (nt:frozenNode) protected abort
+
+[nt:versionHistory] > mix:referenceable, nt:base
+- jcr:versionableUuid (string) mandatory protected autocreated abort
++ jcr:rootVersion (nt:version) = nt:version protected mandatory autocreated abort
++ jcr:versionLabels (nt:versionLabels) = nt:versionLabels protected mandatory autocreated
abort
++ * (nt:version) = nt:version protected abort
+
+[nt:versionedChild]
+- jcr:childVersionHistory (reference) mandatory protected autocreated abort <
'nt:versionHistory'
+
+[nt:query]
+- jcr:statement (string)
+- jcr:language (string)
+
+[mix:lockable] mixin
+- jcr:lockOwner (string) protected ignore
+- jcr:lockIsDeep (boolean) protected ignore
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java
(rev 0)
+++
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,117 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.IOException;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.property.Name;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test of CND-based type definitions. These test cases focus on ensuring that an import
of a type from a CND file registers the
+ * expected type rather than attempting to validate all of the type registration
functionality already tested in
+ * {@link TypeRegistrationTest}.
+ */
+public class CndNodeTypeRegistrationTest {
+
+ /** Location of CND files for this test */
+ private static final String CND_LOCATION = "/cndNodeTypeRegistration/";
+
+ private ExecutionContext context;
+ private RepositoryNodeTypeManager repoTypeManager;
+ private JcrNodeTypeSource nodeTypes;
+
+ @Before
+ public void beforeEach() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ context = new ExecutionContext();
+ context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX,
TestLexicon.Namespace.URI);
+
+ repoTypeManager = new RepositoryNodeTypeManager(context);
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
+
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullTypeSource() throws Exception {
+ repoTypeManager.registerNodeTypes(null);
+ }
+
+ @Test( expected = RepositoryException.class )
+ public void shouldNotAllowRedefinitionOfExistingType() throws Exception {
+ nodeTypes = new CndNodeTypeSource(CND_LOCATION + "existingType.cnd");
+
+ repoTypeManager.registerNodeTypes(nodeTypes);
+ }
+
+ @Test
+ public void shouldRegisterValidTypes() throws Exception {
+ nodeTypes = new CndNodeTypeSource(CND_LOCATION + "validType.cnd");
+
+ repoTypeManager.registerNodeTypes(nodeTypes);
+ Name testNodeName =
context.getValueFactories().getNameFactory().create(TestLexicon.Namespace.URI,
"testType");
+
+ NodeType nodeType = repoTypeManager.getNodeType(testNodeName);
+ assertThat(nodeType, is(notNullValue()));
+ assertThat(nodeType.isMixin(), is(true));
+ assertThat(nodeType.hasOrderableChildNodes(), is(true));
+ assertThat(nodeType.getDeclaredSupertypes().length, is(2));
+ assertThat(nodeType.getDeclaredChildNodeDefinitions().length, is(1));
+ JcrNodeDefinition childNode =
(JcrNodeDefinition)nodeType.getDeclaredChildNodeDefinitions()[0];
+ assertThat(childNode.getName(), is("dnatest:namespace"));
+ assertThat(childNode.getDefaultPrimaryType().getName(),
is("dna:namespace"));
+ assertThat(childNode.getRequiredPrimaryTypes().length, is(1));
+ assertThat(childNode.getRequiredPrimaryTypes()[0].getName(),
is("dna:namespace"));
+ assertThat(childNode.allowsSameNameSiblings(), is(false));
+ assertThat(childNode.isMandatory(), is(false));
+
+ assertThat(nodeType.getDeclaredPropertyDefinitions().length, is(1));
+ JcrPropertyDefinition property =
(JcrPropertyDefinition)nodeType.getDeclaredPropertyDefinitions()[0];
+ assertThat(property.getName(), is("*"));
+ assertThat(property.getRequiredType(), is(PropertyType.STRING));
+ assertThat(property.getValueConstraints().length, is(3));
+ assertThat(property.getValueConstraints()[0], is("foo"));
+ assertThat(property.getValueConstraints()[1], is("bar"));
+ assertThat(property.getValueConstraints()[2], is("baz"));
+ assertThat(property.getDefaultValues().length, is(1));
+ assertThat(property.getDefaultValues()[0].getString(), is("foo"));
+ }
+}
Property changes on:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/CndNodeTypeRegistrationTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -27,20 +27,14 @@
import java.net.URI;
import java.security.AccessControlContext;
import java.security.AccessController;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.jcr.Credentials;
-import javax.jcr.PropertyType;
import org.apache.jackrabbit.test.RepositoryStub;
+import org.jboss.dna.common.collection.Problem;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
-import org.jboss.dna.graph.JcrMixLexicon;
-import org.jboss.dna.graph.JcrNtLexicon;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
@@ -114,8 +108,17 @@
// Set up some sample nodes in the graph to match the expected test
configuration
try {
- nodeTypes.registerNodeTypes(new TckTestNodeTypeSource(executionContext,
nodeTypes));
+ CndNodeTypeSource nodeTypeSource = new
CndNodeTypeSource("/tck_test_types.cnd");
+ for (Problem problem : nodeTypeSource.getProblems()) {
+ System.err.println(problem);
+ }
+ if (!nodeTypeSource.isValid()) {
+ throw new IllegalStateException("Problems loading TCK test node
types");
+ }
+
+ nodeTypes.registerNodeTypes(nodeTypeSource);
+
executionContext.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX,
TestLexicon.Namespace.URI);
Path destinationPath =
executionContext.getValueFactories().getPathFactory().create("/");
@@ -171,158 +174,4 @@
public JcrRepository getRepository() {
return repository;
}
-
- class TckTestNodeTypeSource extends AbstractJcrNodeTypeSource {
- /** The list of node types. */
- private final List<JcrNodeType> nodeTypes;
-
- TckTestNodeTypeSource( ExecutionContext context,
- RepositoryNodeTypeManager nodeTypeManager ) {
- super(null);
-
- nodeTypes = new ArrayList<JcrNodeType>();
-
- JcrNodeType base = nodeTypeManager.getNodeType(JcrNtLexicon.BASE);
-
- if (base == null) {
- String baseTypeName =
JcrNtLexicon.BASE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
TestLexicon.NO_SAME_NAME_SIBS.getString(context.getNamespaceRegistry());
- throw new
IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName, namespaceTypeName));
- }
-
- JcrNodeType referenceable =
nodeTypeManager.getNodeType(JcrMixLexicon.REFERENCEABLE);
-
- if (referenceable == null) {
- String baseTypeName =
JcrMixLexicon.REFERENCEABLE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
TestLexicon.REFERENCEABLE_UNSTRUCTURED.getString(context.getNamespaceRegistry());
- throw new
IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName, namespaceTypeName));
- }
-
- JcrNodeType unstructured =
nodeTypeManager.getNodeType(JcrNtLexicon.UNSTRUCTURED);
-
- if (unstructured == null) {
- String baseTypeName =
JcrNtLexicon.UNSTRUCTURED.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
TestLexicon.REFERENCEABLE_UNSTRUCTURED.getString(context.getNamespaceRegistry());
- throw new
IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName, namespaceTypeName));
- }
-
- // Stubbing in child node and property definitions for now
- JcrNodeType noSameNameSibs = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- TestLexicon.NO_SAME_NAME_SIBS,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
ALL_NODES,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.UNSTRUCTURED,
-
new JcrNodeType[] {base}),}),
- NO_PROPERTIES, NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- JcrNodeType referenceableUnstructured = new JcrNodeType(
- context,
-
NO_NODE_TYPE_MANAGER,
-
TestLexicon.REFERENCEABLE_UNSTRUCTURED,
- Arrays.asList(new
JcrNodeType[] {unstructured, referenceable}),
- NO_PRIMARY_ITEM_NAME,
NO_CHILD_NODES, NO_PROPERTIES,
- NOT_MIXIN,
ORDERABLE_CHILD_NODES);
-
- JcrNodeType nodeWithMandatoryProperty = new JcrNodeType(
- context,
-
NO_NODE_TYPE_MANAGER,
-
TestLexicon.NODE_WITH_MANDATORY_PROPERTY,
- Arrays.asList(new
JcrNodeType[] {unstructured, referenceable}),
-
NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.MANDATORY_STRING,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false,
-
true,
-
false,
-
NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
NO_CONSTRAINTS,
-
false)}),
- NOT_MIXIN,
ORDERABLE_CHILD_NODES);
- JcrNodeType nodeWithMandatoryChild = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
-
TestLexicon.NODE_WITH_MANDATORY_CHILD,
- Arrays.asList(new
JcrNodeType[] {unstructured, referenceable}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
TestLexicon.MANDATORY_CHILD,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
true,
-
false,
-
false,
-
JcrNtLexicon.UNSTRUCTURED,
-
new JcrNodeType[] {base}),}),
- NO_PROPERTIES,
NOT_MIXIN, ORDERABLE_CHILD_NODES);
-
- JcrNodeType unorderableUnstructured = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
-
TestLexicon.UNORDERABLE_UNSTRUCTURED,
- Arrays.asList(new
JcrNodeType[] {base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
ALL_NODES,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
true,
-
TestLexicon.UNORDERABLE_UNSTRUCTURED,
-
new JcrNodeType[] {base}),}),
- Arrays.asList(new
JcrPropertyDefinition[] {
- new
JcrPropertyDefinition(
-
context,
-
null,
-
ALL_NODES,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, false, false,
-
NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
NO_CONSTRAINTS, false),
- new
JcrPropertyDefinition(
-
context,
-
null,
-
ALL_NODES,
-
OnParentVersionBehavior.COPY.getJcrValue(),
-
false, false, false,
-
NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
NO_CONSTRAINTS, true),}),
- NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {referenceableUnstructured,
noSameNameSibs,
- nodeWithMandatoryProperty, nodeWithMandatoryChild,
unorderableUnstructured,}));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.jcr.JcrNodeTypeSource#getNodeTypes()
- */
- @Override
- public Collection<JcrNodeType> getDeclaredNodeTypes() {
- return nodeTypes;
- }
- }
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -29,14 +29,14 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.stub;
-import java.util.ArrayList;
+import java.io.IOException;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
import javax.jcr.Value;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
@@ -47,6 +47,7 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.ValueFactory;
import org.jboss.dna.graph.property.basic.BasicName;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -59,8 +60,15 @@
*/
public class ItemDefinitionTest {
+ private static final Name NODE_TYPE_A = new BasicName(TestLexicon.Namespace.URI,
"nodeA");
+ private static final Name NODE_TYPE_B = new BasicName(TestLexicon.Namespace.URI,
"nodeB");
+ private static final Name NODE_TYPE_C = new BasicName(TestLexicon.Namespace.URI,
"nodeC");
+
+ private static final Name SINGLE_PROP1 = new BasicName(TestLexicon.Namespace.URI,
"singleProp1");
+ private static final Name SINGLE_PROP2 = new BasicName(TestLexicon.Namespace.URI,
"singleProp2");
+
private String workspaceName;
- private ExecutionContext context;
+ protected ExecutionContext context;
private InMemoryRepositorySource source;
private JcrWorkspace workspace;
private JcrSession session;
@@ -109,11 +117,19 @@
};
// Stub out the repository, since we only need a few methods ...
- JcrNodeTypeSource source = null;
- source = new JcrBuiltinNodeTypeSource(this.context, source);
- source = new DnaBuiltinNodeTypeSource(this.context, source);
- source = new TestNodeTypeSource(this.context, source);
- repoTypeManager = new RepositoryNodeTypeManager(context, source);
+ repoTypeManager = new RepositoryNodeTypeManager(context);
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ this.repoTypeManager.registerNodeTypes(new
NodeTemplateNodeTypeSource(getTestTypes()));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
+
stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
stub(repository.getConnectionFactory()).toReturn(connectionFactory);
@@ -151,9 +167,6 @@
propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_C,
Collections.<Name>emptyList(), badName, null, true, true);
assertThat(propDef, is(nullValue()));
-
- propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_D,
Collections.<Name>emptyList(), badName, null, true, true);
- assertThat(propDef, is(nullValue()));
}
@Test
@@ -179,7 +192,7 @@
true,
true);
assertThat(propDef, is(notNullValue()));
- assertEquals(propDef.getRequiredType(), PropertyType.LONG);
+ assertEquals(propDef.getRequiredType(), PropertyType.DOUBLE);
propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_C,
Collections.<Name>emptyList(),
@@ -188,33 +201,10 @@
true,
true);
assertThat(propDef, is(notNullValue()));
- assertEquals(propDef.getRequiredType(), PropertyType.BOOLEAN);
+ assertEquals(propDef.getRequiredType(), PropertyType.LONG);
}
@Test
- public void shouldPreferLeftmostSupertypeForDefinition() {
- /*
- * This specification doesn't mandate this, but since DNA supports multiple
inheritance, we
- * have imposed the rule that property or child-node definitions should be
preferred based on
- * distance from the given node type in the hierarchy with the order of the
supertypes in the declaration
- * being the tiebreaker.
- */
- JcrPropertyDefinition propDef;
-
- // Should prefer the inherited definition from NODE_TYPE_A since it was declared
before NODE_TYPE_C in NODE_TYPE_D's list
- // of supertypes
- propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_D,
-
Collections.<Name>emptyList(),
- SINGLE_PROP1,
- null,
- true,
- true);
- assertThat(propDef, is(notNullValue()));
- assertEquals(propDef.getRequiredType(), PropertyType.STRING);
-
- }
-
- @Test
public void shouldFindBestMatchDefinition() {
/*
* In cases where there is more than one valid definition for the same property,
@@ -223,11 +213,11 @@
Value doubleValue = session.getValueFactory().createValue(0.7);
Value longValue = session.getValueFactory().createValue(10);
Value stringValue = session.getValueFactory().createValue("Should not
work");
-
+
JcrPropertyDefinition propDef;
// Should prefer the double definition from NODE_TYPE_C since the value is of
type double
- propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_D,
+ propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_C,
Collections.<Name>emptyList(),
SINGLE_PROP2,
doubleValue,
@@ -237,7 +227,7 @@
assertEquals(propDef.getRequiredType(), PropertyType.DOUBLE);
// Should prefer the long definition from NODE_TYPE_C since the value is of type
long
- propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_D,
+ propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_C,
Collections.<Name>emptyList(),
SINGLE_PROP2,
longValue,
@@ -247,134 +237,77 @@
assertEquals(propDef.getRequiredType(), PropertyType.LONG);
// Should not allow a string though, since the NODE_TYPE_C definition narrows the
acceptable types to double and long
- propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_D,
+ propDef = repoTypeManager.findPropertyDefinition(NODE_TYPE_C,
Collections.<Name>emptyList(),
SINGLE_PROP2,
stringValue,
true,
true);
assertThat(propDef, is(nullValue()));
-
+
}
- static final Name NODE_TYPE_A = new BasicName(TestLexicon.Namespace.URI,
"nodeA");
- static final Name NODE_TYPE_B = new BasicName(TestLexicon.Namespace.URI,
"nodeB");
- static final Name NODE_TYPE_C = new BasicName(TestLexicon.Namespace.URI,
"nodeC");
- static final Name NODE_TYPE_D = new BasicName(TestLexicon.Namespace.URI,
"nodeD");
+ /*
+ * Build a hierarchy of node types with the following relationships:
+ *
+ * dnatest:nodeA extends nt:base
+ * dnatest:nodeB extends nt:base
+ * dnatest:nodeC extends dnatest:nodeB
+ *
+ * And the following single-valued property definitions
+ *
+ * dnatest:nodeA defines properties:
+ * dnatest:singleProp1 of type STRING
+ * dnatest:nodeB defines properties:
+ * dnatest:singleProp1 of type DOUBLE
+ * dnatest:singleProp2 of type UNDEFINED
+ * dnatest:nodeC defines properties:
+ * dnatest:singleProp1 of type LONG
+ * dnatest:singleProp2 of type DOUBLE
+ * dnatest:singleProp2 of type LONG (note the double-definition)
+ */
- static final Name SINGLE_PROP1 = new BasicName(TestLexicon.Namespace.URI,
"singleProp1");
- static final Name SINGLE_PROP2 = new BasicName(TestLexicon.Namespace.URI,
"singleProp2");
+ private List<NodeTypeTemplate> getTestTypes() {
+ NodeTypeTemplate nodeA = new JcrNodeTypeTemplate(context);
+ nodeA.setName("dnatest:nodeA");
- class TestNodeTypeSource extends AbstractJcrNodeTypeSource {
+ JcrPropertyDefinitionTemplate nodeASingleProp1 = new
JcrPropertyDefinitionTemplate(context);
+ nodeASingleProp1.setName("dnatest:singleProp1");
+ nodeASingleProp1.setRequiredType(PropertyType.STRING);
+ nodeA.getPropertyDefinitionTemplates().add(nodeASingleProp1);
- /** The list of primary node types. */
- private final List<JcrNodeType> nodeTypes;
+ NodeTypeTemplate nodeB = new JcrNodeTypeTemplate(context);
+ nodeB.setName("dnatest:nodeB");
- /*
- * Build a hierarchy of node types with the following relationships:
- *
- * dnatest:nodeA extends nt:base
- * dnatest:nodeB extends nt:base
- * dnatest:nodeC extends dnatest:nodeB
- * dnatest:nodeD extends dnatest:nodeA and dnatest:nodeC
- *
- * And the following single-valued property definitions
- *
- * dnatest:nodeA defines properties:
- * dnatest:singleProp1 of type STRING
- * dnatest:nodeB defines properties:
- * dnatest:singleProp1 of type LONG
- * dnatest:singleProp2 of type UNDEFINED
- * dnatest:nodeC defines properties:
- * dnatest:singleProp1 of type BOOLEAN
- * dnatest:singleProp2 of type DOUBLE
- * dnatest:singleProp2 of type LONG (note the double-definition)
- * dnatest:nodeD defines properties:
- * < NO PROPERTIES DEFINED IN THIS TYPE >
- */
+ JcrPropertyDefinitionTemplate nodeBSingleProp1 = new
JcrPropertyDefinitionTemplate(context);
+ nodeBSingleProp1.setName("dnatest:singleProp1");
+ nodeBSingleProp1.setRequiredType(PropertyType.DOUBLE);
+ nodeB.getPropertyDefinitionTemplates().add(nodeBSingleProp1);
- TestNodeTypeSource( ExecutionContext context,
- JcrNodeTypeSource predecessor ) {
- super(predecessor);
+ JcrPropertyDefinitionTemplate nodeBSingleProp2 = new
JcrPropertyDefinitionTemplate(context);
+ nodeBSingleProp2.setName("dnatest:singleProp2");
+ nodeBSingleProp2.setRequiredType(PropertyType.UNDEFINED);
+ nodeB.getPropertyDefinitionTemplates().add(nodeBSingleProp2);
- nodeTypes = new ArrayList<JcrNodeType>();
+ NodeTypeTemplate nodeC = new JcrNodeTypeTemplate(context);
+ nodeC.setName("dnatest:nodeC");
+ nodeC.setDeclaredSupertypeNames(new String[] {"dnatest:nodeB"});
- JcrNodeType base = findType(JcrNtLexicon.BASE);
+ JcrPropertyDefinitionTemplate nodeCSingleProp1 = new
JcrPropertyDefinitionTemplate(context);
+ nodeCSingleProp1.setName("dnatest:singleProp1");
+ nodeCSingleProp1.setRequiredType(PropertyType.LONG);
+ nodeC.getPropertyDefinitionTemplates().add(nodeCSingleProp1);
- if (base == null) {
- String baseTypeName =
JcrNtLexicon.BASE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
DnaLexicon.NAMESPACE.getString(context.getNamespaceRegistry());
- throw new
IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName, namespaceTypeName));
- }
+ JcrPropertyDefinitionTemplate nodeCSingleProp2Double = new
JcrPropertyDefinitionTemplate(context);
+ nodeCSingleProp2Double.setName("dnatest:singleProp2");
+ nodeCSingleProp2Double.setRequiredType(PropertyType.DOUBLE);
+ nodeC.getPropertyDefinitionTemplates().add(nodeCSingleProp2Double);
- // Stubbing in child node and property definitions for now
- JcrNodeType nodeA = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- NODE_TYPE_A,
- Arrays.asList(new JcrNodeType[] {base}),
- NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[]
{new JcrPropertyDefinition(
-
context,
-
null,
-
SINGLE_PROP1,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false,
-
false,
-
false,
-
NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
NO_CONSTRAINTS,
-
false),}),
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
+ JcrPropertyDefinitionTemplate nodeCSingleProp2Long = new
JcrPropertyDefinitionTemplate(context);
+ nodeCSingleProp2Long.setName("dnatest:singleProp2");
+ nodeCSingleProp2Long.setRequiredType(PropertyType.LONG);
+ nodeC.getPropertyDefinitionTemplates().add(nodeCSingleProp2Long);
- JcrNodeType nodeB = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
NODE_TYPE_B,
- Arrays.asList(new JcrNodeType[] {base}),
NO_PRIMARY_ITEM_NAME, NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[]
{
- new JcrPropertyDefinition(context,
null, SINGLE_PROP1,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.LONG, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, SINGLE_PROP2,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED, NO_CONSTRAINTS, false),}),
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
- JcrNodeType nodeC = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
NODE_TYPE_C,
- Arrays.asList(new JcrNodeType[] {nodeB}),
NO_PRIMARY_ITEM_NAME, NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[]
{
- new JcrPropertyDefinition(context,
null, SINGLE_PROP1,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.BOOLEAN, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, SINGLE_PROP2,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.DOUBLE, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, SINGLE_PROP2,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.LONG, NO_CONSTRAINTS, false),
-
- }), NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- JcrNodeType nodeD = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
NODE_TYPE_D, Arrays.asList(new JcrNodeType[] {
- nodeA, nodeC}), NO_PRIMARY_ITEM_NAME, NO_CHILD_NODES, NO_PROPERTIES,
NOT_MIXIN, UNORDERABLE_CHILD_NODES);
-
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {nodeA, nodeB, nodeC,
nodeD}));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.jcr.AbstractJcrNodeTypeSource#getDeclaredNodeTypes()
- */
- @Override
- public Collection<JcrNodeType> getDeclaredNodeTypes() {
- return nodeTypes;
- }
-
+ return Arrays.asList(new NodeTypeTemplate[] {nodeA, nodeB, nodeC});
}
-
-}
\ No newline at end of file
+}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java
===================================================================
---
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -27,13 +27,14 @@
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.stub;
-import java.util.ArrayList;
+import java.io.IOException;
import java.util.Arrays;
-import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.NodeTypeManager;
@@ -46,6 +47,8 @@
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NamespaceRegistry;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
+import org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -121,11 +124,21 @@
};
// Stub out the repository, since we only need a few methods ...
- JcrNodeTypeSource source = null;
- source = new JcrBuiltinNodeTypeSource(this.context, source);
- source = new DnaBuiltinNodeTypeSource(this.context, source);
- source = new TestNodeTypeSource(this.context, source);
- repoTypeManager = new RepositoryNodeTypeManager(context, source);
+ repoTypeManager = new RepositoryNodeTypeManager(context);
+
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ this.repoTypeManager.registerNodeTypes(new
NodeTemplateNodeTypeSource(getTestTypes()));
+
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
+
stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
stub(repository.getConnectionFactory()).toReturn(connectionFactory);
@@ -149,7 +162,7 @@
session.logout();
}
}
-
+
private JcrPropertyDefinition propertyDefinitionFor( NodeType nodeType,
Name propertyName ) {
PropertyDefinition propertyDefs[] = nodeType.getPropertyDefinitions();
@@ -634,118 +647,59 @@
assertThat(satisfiesConstraints(prop, new Value[] {value}), is(false));
}
- class TestNodeTypeSource extends AbstractJcrNodeTypeSource {
+ private List<NodeTypeTemplate> getTestTypes() {
+ NodeTypeTemplate constrainedType = new JcrNodeTypeTemplate(this.context);
+ constrainedType.setName("dnatest:constrainedType");
- /** The list of primary node types. */
- private final List<JcrNodeType> nodeTypes;
+ PropertyDefinitionTemplate propBinary = new
JcrPropertyDefinitionTemplate(this.context);
+ propBinary.setName("dnatest:constrainedBinary");
+ propBinary.setRequiredType(PropertyType.BINARY);
+ propBinary.setValueConstraints(EXPECTED_BINARY_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propBinary);
- TestNodeTypeSource( ExecutionContext context,
- JcrNodeTypeSource predecessor ) {
- super(predecessor);
+ PropertyDefinitionTemplate propDate = new
JcrPropertyDefinitionTemplate(this.context);
+ propDate.setName("dnatest:constrainedDate");
+ propDate.setRequiredType(PropertyType.DATE);
+ propDate.setValueConstraints(EXPECTED_DATE_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propDate);
- nodeTypes = new ArrayList<JcrNodeType>();
+ PropertyDefinitionTemplate propDouble = new
JcrPropertyDefinitionTemplate(this.context);
+ propDouble.setName("dnatest:constrainedDouble");
+ propDouble.setRequiredType(PropertyType.DOUBLE);
+ propDouble.setValueConstraints(EXPECTED_DOUBLE_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propDouble);
- JcrNodeType base = findType(JcrNtLexicon.BASE);
+ PropertyDefinitionTemplate propLong = new
JcrPropertyDefinitionTemplate(this.context);
+ propLong.setName("dnatest:constrainedLong");
+ propLong.setRequiredType(PropertyType.LONG);
+ propLong.setValueConstraints(EXPECTED_LONG_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propLong);
- if (base == null) {
- String baseTypeName =
JcrNtLexicon.BASE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
DnaLexicon.NAMESPACE.getString(context.getNamespaceRegistry());
- throw new
IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName, namespaceTypeName));
- }
+ PropertyDefinitionTemplate propName = new
JcrPropertyDefinitionTemplate(this.context);
+ propName.setName("dnatest:constrainedName");
+ propName.setRequiredType(PropertyType.NAME);
+ propName.setValueConstraints(EXPECTED_NAME_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propName);
- // Stubbing in child node and property definitions for now
- JcrNodeType constrainedType = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- TestLexicon.CONSTRAINED_TYPE,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_BINARY,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.BINARY,
-
EXPECTED_BINARY_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_DATE,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.DATE,
-
EXPECTED_DATE_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_DOUBLE,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.DOUBLE,
-
EXPECTED_DOUBLE_CONSTRAINTS, false),
+ PropertyDefinitionTemplate propPath = new
JcrPropertyDefinitionTemplate(this.context);
+ propPath.setName("dnatest:constrainedPath");
+ propPath.setRequiredType(PropertyType.PATH);
+ propPath.setValueConstraints(EXPECTED_PATH_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propPath);
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_LONG,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.LONG,
-
EXPECTED_LONG_CONSTRAINTS, false),
+ PropertyDefinitionTemplate propReference = new
JcrPropertyDefinitionTemplate(this.context);
+ propReference.setName("dnatest:constrainedReference");
+ propReference.setRequiredType(PropertyType.REFERENCE);
+ propReference.setValueConstraints(EXPECTED_REFERENCE_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propReference);
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_NAME,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.NAME,
-
EXPECTED_NAME_CONSTRAINTS, false),
+ PropertyDefinitionTemplate propString = new
JcrPropertyDefinitionTemplate(this.context);
+ propString.setName("dnatest:constrainedString");
+ propString.setRequiredType(PropertyType.STRING);
+ propString.setValueConstraints(EXPECTED_STRING_CONSTRAINTS);
+ constrainedType.getPropertyDefinitionTemplates().add(propString);
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_PATH,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.PATH,
-
EXPECTED_PATH_CONSTRAINTS, false),
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_REFERENCE,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.REFERENCE,
-
new String[] {"dna:root",}, false),
-
- new JcrPropertyDefinition(
-
context,
-
null,
-
TestLexicon.CONSTRAINED_STRING,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false, false, false, NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
EXPECTED_STRING_CONSTRAINTS, false),
-
- }), NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {constrainedType}));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.jcr.AbstractJcrNodeTypeSource#getDeclaredNodeTypes()
- */
- @Override
- public Collection<JcrNodeType> getDeclaredNodeTypes() {
- return nodeTypes;
- }
-
+ return Collections.singletonList(constrainedType);
}
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrReadingTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrReadingTest.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrReadingTest.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -33,18 +33,26 @@
@Test
public void testReadingTrees() throws Exception {
- int[] breadths = new int[] { 10, };
- int[] depths = new int[] { 1, 2, 3, };
- int[] properties = new int[] { 0, 7, 100 };
-
+ int[] breadths = new int[] {10,};
+ int[] depths = new int[] {1, 2, 3,};
+ int[] properties = new int[] {0, 7, 50};
+
for (int i = 0; i < breadths.length; i++) {
for (int j = 0; j < depths.length; j++) {
for (int k = 0; k < properties.length; k++) {
String testName = "/" + breadths[i] + "x" +
depths[j] + "x" + properties[k] + "test";
session().getRootNode().addNode(testName,
"nt:unstructured");
createSubgraph(session(), testName, depths[j], breadths[i],
properties[k], false, null, null, null);
-
- traverseSubgraph(session(), testName, depths[j], breadths[i],
properties[k], false, new Stopwatch(), System.out, null);
+
+ traverseSubgraph(session(),
+ testName,
+ depths[j],
+ breadths[i],
+ properties[k],
+ false,
+ new Stopwatch(),
+ System.out,
+ null);
}
}
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -35,6 +35,7 @@
import static org.mockito.Mockito.stub;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.AccessControlException;
@@ -130,10 +131,17 @@
};
// Set up the repo type manager
- JcrNodeTypeSource nodeTypes = null;
- nodeTypes = new JcrBuiltinNodeTypeSource(context, nodeTypes);
- nodeTypes = new DnaBuiltinNodeTypeSource(context, nodeTypes);
- repoTypeManager = new RepositoryNodeTypeManager(context, nodeTypes);
+ repoTypeManager = new RepositoryNodeTypeManager(context);
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
// Stub out the repository, since we only need a few methods ...
MockitoAnnotations.initMocks(this);
@@ -344,7 +352,7 @@
assertThat(factory.createValue("", PropertyType.BINARY),
notNullValue());
}
- @Test (expected=RepositoryException.class)
+ @Test( expected = RepositoryException.class )
public void shouldNotCreateValueForNonReferenceableNode() throws Exception {
ValueFactory factory = session.getValueFactory();
Node node = Mockito.mock(Node.class);
@@ -450,8 +458,7 @@
public void rootNodeShouldBeReferenceable() throws RepositoryException {
Node rootNode = session.getRootNode();
- assertTrue(rootNode.getPrimaryNodeType()
-
.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(context.getNamespaceRegistry())));
+
assertTrue(rootNode.getPrimaryNodeType().isNodeType(JcrMixLexicon.REFERENCEABLE.getString(context.getNamespaceRegistry())));
}
@Test
@@ -514,14 +521,13 @@
@Test
public void shouldMoveToNewName() throws Exception {
session.move("/a/b/c", "/a/b/d");
-
+
session.getRootNode().getNode("a").getNode("b").getNode("d");
try {
session.getRootNode().getNode("a").getNode("b").getNode("c");
fail("Node still exists at /a/b/c after move");
- }
- catch (PathNotFoundException e) {
+ } catch (PathNotFoundException e) {
// Expected
}
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -28,10 +28,12 @@
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.stub;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.jcr.NamespaceRegistry;
import javax.jcr.Node;
+import javax.jcr.RepositoryException;
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
@@ -100,10 +102,17 @@
// Stub out the repository, since we only need a few methods ...
MockitoAnnotations.initMocks(this);
- JcrNodeTypeSource source = null;
- source = new JcrBuiltinNodeTypeSource(context, source);
- source = new DnaBuiltinNodeTypeSource(context, source);
- repoManager = new RepositoryNodeTypeManager(context, source);
+ repoManager = new RepositoryNodeTypeManager(context);
+ try {
+ this.repoManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
stub(repository.getRepositoryTypeManager()).toReturn(repoManager);
@@ -228,10 +237,10 @@
@Test
public void shouldAllowImportXml() throws Exception {
String inputData = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>"
- + "<sv:node
xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"
xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" "
- + "xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\"
sv:name=\"workspaceTestNode\">"
- + "<sv:property sv:name=\"jcr:primaryType\"
sv:type=\"Name\">"
- +
"<sv:value>nt:unstructured</sv:value></sv:property></sv:node>";
+ + "<sv:node
xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"
xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" "
+ + "xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\"
sv:name=\"workspaceTestNode\">"
+ + "<sv:property sv:name=\"jcr:primaryType\"
sv:type=\"Name\">"
+ +
"<sv:value>nt:unstructured</sv:value></sv:property></sv:node>";
workspace.importXML("/", new
ByteArrayInputStream(inputData.getBytes()), 0);
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWritingTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWritingTest.java 2009-05-05 16:30:45
UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWritingTest.java 2009-05-05 22:09:15
UTC (rev 886)
@@ -26,7 +26,6 @@
import org.jboss.dna.common.statistic.Stopwatch;
import org.junit.Test;
-
/**
* Test performance writing graph subtrees of various sizes with varying number of
properties
*/
@@ -34,18 +33,26 @@
@Test
public void testCreatingTrees() throws Exception {
- int[] breadths = new int[] { 10, };
- int[] depths = new int[] { 1, 2, 3, };
- int[] properties = new int[] { 0, 7, 100 };
-
+ int[] breadths = new int[] {10,};
+ int[] depths = new int[] {1, 2, 3,};
+ int[] properties = new int[] {0, 7, 50};
+
for (int i = 0; i < breadths.length; i++) {
for (int j = 0; j < depths.length; j++) {
for (int k = 0; k < properties.length; k++) {
String testName = "/" + breadths[i] + "x" +
depths[j] + "x" + properties[k] + "test";
session().getRootNode().addNode(testName,
"nt:unstructured");
- createSubgraph(session(), testName, depths[j], breadths[i],
properties[k], false, new Stopwatch(), System.out, null);
+ createSubgraph(session(),
+ testName,
+ depths[j],
+ breadths[i],
+ properties[k],
+ false,
+ new Stopwatch(),
+ System.out,
+ null);
}
}
}
}
-}
\ No newline at end of file
+}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java 2009-05-05 16:30:45 UTC
(rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java 2009-05-05 22:09:15 UTC
(rev 886)
@@ -27,9 +27,8 @@
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.stub;
-import java.util.ArrayList;
+import java.io.IOException;
import java.util.Arrays;
-import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
@@ -37,12 +36,13 @@
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.PropertyType;
-import javax.jcr.Value;
+import javax.jcr.RepositoryException;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.version.OnParentVersionAction;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.JcrNtLexicon;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositorySourceException;
@@ -50,6 +50,9 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.basic.BasicName;
+import org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
+import org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -73,7 +76,7 @@
static final Name MIXIN_TYPE_C = new BasicName("",
"mixinTypeC");
static final Name MIXIN_TYPE_WITH_AUTO_PROP = new BasicName("",
"mixinTypeWithAutoCreatedProperty");
static final Name MIXIN_TYPE_WITH_AUTO_CHILD = new BasicName("",
"mixinTypeWithAutoCreatedChildNode");
- static final Name PRIMARY_TYPE_A = new BasicName("",
"mixinTypeA");
+ static final Name PRIMARY_TYPE_A = new BasicName("",
"primaryTypeA");
static final Name PROPERTY_A = new BasicName("", "propertyA");
static final Name PROPERTY_B = new BasicName("", "propertyB");
@@ -129,11 +132,21 @@
};
// Stub out the repository, since we only need a few methods ...
- JcrNodeTypeSource source = null;
- source = new JcrBuiltinNodeTypeSource(this.context, source);
- source = new DnaBuiltinNodeTypeSource(this.context, source);
- source = new TestNodeTypeSource(this.context, source);
- repoTypeManager = new RepositoryNodeTypeManager(context, source);
+ repoTypeManager = new RepositoryNodeTypeManager(context);
+
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ this.repoTypeManager.registerNodeTypes(new
NodeTemplateNodeTypeSource(getTestTypes()));
+
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
+
stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
stub(repository.getConnectionFactory()).toReturn(connectionFactory);
@@ -314,9 +327,7 @@
public void shouldAllowAdditionIfResidualChildNodeDoesNotConflict() throws Exception
{
graph.create("/a").and().create("/a/" + CHILD_NODE_B);
graph.set(JcrLexicon.PRIMARY_TYPE.getString(registry)).on("/a").to(JcrNtLexicon.UNSTRUCTURED.getString(registry));
- graph.set(JcrLexicon.PRIMARY_TYPE.getString(registry))
- .on("/a/" + CHILD_NODE_B)
- .to(JcrNtLexicon.UNSTRUCTURED.getString(registry));
+ graph.set(JcrLexicon.PRIMARY_TYPE.getString(registry)).on("/a/" +
CHILD_NODE_B).to(JcrNtLexicon.UNSTRUCTURED.getString(registry));
Node rootNode = session.getRootNode();
Node nodeA = rootNode.getNode("a");
@@ -460,214 +471,95 @@
nodeA.removeMixin(MIXIN_TYPE_B.getString(registry));
}
- class TestNodeTypeSource extends AbstractJcrNodeTypeSource {
+ private List<NodeTypeTemplate> getTestTypes() {
+ NodeTypeTemplate mixinTypeA = new JcrNodeTypeTemplate(this.context);
+ mixinTypeA.setName("mixinTypeA");
+ mixinTypeA.setMixin(true);
- /** The list of primary node types. */
- private final List<JcrNodeType> nodeTypes;
+ NodeDefinitionTemplate childNodeA = new JcrNodeDefinitionTemplate(this.context);
+ childNodeA.setName("nodeA");
+ childNodeA.setOnParentVersion(OnParentVersionAction.IGNORE);
+ mixinTypeA.getNodeDefinitionTemplates().add(childNodeA);
- TestNodeTypeSource( ExecutionContext context,
- JcrNodeTypeSource predecessor ) {
- super(predecessor);
+ PropertyDefinitionTemplate propertyA = new
JcrPropertyDefinitionTemplate(this.context);
+ propertyA.setName("propertyA");
+ propertyA.setOnParentVersion(OnParentVersionAction.IGNORE);
+ propertyA.setRequiredType(PropertyType.STRING);
+ mixinTypeA.getPropertyDefinitionTemplates().add(propertyA);
- nodeTypes = new ArrayList<JcrNodeType>();
+ NodeTypeTemplate mixinTypeB = new JcrNodeTypeTemplate(this.context);
+ mixinTypeB.setName("mixinTypeB");
+ mixinTypeB.setMixin(true);
- JcrNodeType base = findType(JcrNtLexicon.BASE);
+ NodeDefinitionTemplate childNodeB = new JcrNodeDefinitionTemplate(this.context);
+ childNodeB.setName("nodeB");
+ childNodeB.setDefaultPrimaryType("nt:base");
+ childNodeB.setOnParentVersion(OnParentVersionAction.IGNORE);
+ mixinTypeB.getNodeDefinitionTemplates().add(childNodeB);
- if (base == null) {
- String baseTypeName =
JcrNtLexicon.BASE.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
DnaLexicon.NAMESPACE.getString(context.getNamespaceRegistry());
- throw new
IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName, namespaceTypeName));
- }
+ PropertyDefinitionTemplate propertyB = new
JcrPropertyDefinitionTemplate(this.context);
+ propertyB.setName("propertyB");
+ propertyB.setOnParentVersion(OnParentVersionAction.IGNORE);
+ propertyB.setRequiredType(PropertyType.BINARY);
+ mixinTypeB.getPropertyDefinitionTemplates().add(propertyB);
- JcrNodeType unstructured = findType(JcrNtLexicon.UNSTRUCTURED);
+ NodeTypeTemplate mixinTypeC = new JcrNodeTypeTemplate(this.context);
+ mixinTypeC.setName("mixinTypeC");
+ mixinTypeC.setMixin(true);
- if (unstructured == null) {
- String baseTypeName =
JcrNtLexicon.UNSTRUCTURED.getString(context.getNamespaceRegistry());
- String namespaceTypeName =
DnaLexicon.NAMESPACE.getString(context.getNamespaceRegistry());
- throw new
IllegalStateException(JcrI18n.supertypeNotFound.text(baseTypeName, namespaceTypeName));
- }
+ childNodeA = new JcrNodeDefinitionTemplate(this.context);
+ childNodeA.setName("nodeA");
+ childNodeA.setOnParentVersion(OnParentVersionAction.IGNORE);
+ mixinTypeC.getNodeDefinitionTemplates().add(childNodeA);
- Value tenValue = new JcrValue(context.getValueFactories(), null,
PropertyType.LONG, 10);
+ propertyB = new JcrPropertyDefinitionTemplate(this.context);
+ propertyB.setName("propertyB");
+ propertyB.setOnParentVersion(OnParentVersionAction.IGNORE);
+ propertyB.setRequiredType(PropertyType.STRING);
+ mixinTypeC.getPropertyDefinitionTemplates().add(propertyB);
- // Stubbing in child node and property definitions for now
- JcrNodeType mixinTypeA = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- MIXIN_TYPE_A,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
CHILD_NODE_A,
-
OnParentVersionAction.IGNORE,
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
PROPERTY_A,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false,
-
false,
-
false,
-
NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
NO_CONSTRAINTS,
-
false),}),
- IS_A_MIXIN,
UNORDERABLE_CHILD_NODES);
+ NodeTypeTemplate mixinTypeWithAutoChild = new JcrNodeTypeTemplate(this.context);
+ mixinTypeWithAutoChild.setName("mixinTypeWithAutoCreatedChildNode");
+ mixinTypeWithAutoChild.setMixin(true);
- JcrNodeType mixinTypeB = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- MIXIN_TYPE_B,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
CHILD_NODE_B,
-
OnParentVersionAction.IGNORE,
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
PROPERTY_B,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false,
-
false,
-
false,
-
NO_DEFAULT_VALUES,
-
PropertyType.BINARY,
-
NO_CONSTRAINTS,
-
false),}),
- IS_A_MIXIN,
UNORDERABLE_CHILD_NODES);
+ childNodeB = new JcrNodeDefinitionTemplate(this.context);
+ childNodeB.setName("nodeB");
+ childNodeB.setOnParentVersion(OnParentVersionAction.IGNORE);
+ childNodeB.setMandatory(true);
+ childNodeB.setAutoCreated(true);
+ childNodeB.setDefaultPrimaryType("nt:unstructured");
+ childNodeB.setRequiredPrimaryTypes(new String[] {"nt:unstructured"});
+ mixinTypeWithAutoChild.getNodeDefinitionTemplates().add(childNodeB);
- JcrNodeType mixinTypeC = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- MIXIN_TYPE_C,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
CHILD_NODE_A,
-
OnParentVersionAction.IGNORE,
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
PROPERTY_B,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false,
-
false,
-
false,
-
NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
NO_CONSTRAINTS,
-
false),}),
- IS_A_MIXIN,
UNORDERABLE_CHILD_NODES);
+ NodeTypeTemplate mixinTypeWithAutoProperty = new
JcrNodeTypeTemplate(this.context);
+ mixinTypeWithAutoProperty.setName("mixinTypeWithAutoCreatedProperty");
+ mixinTypeWithAutoProperty.setMixin(true);
- JcrNodeType mixinTypeWithAutoChild = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
-
MIXIN_TYPE_WITH_AUTO_CHILD,
- Arrays.asList(new
JcrNodeType[] {base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
CHILD_NODE_B,
-
OnParentVersionAction.IGNORE,
-
true,
-
true,
-
false,
-
false,
-
JcrNtLexicon.UNSTRUCTURED,
-
new JcrNodeType[] {unstructured}),}),
- NO_PROPERTIES,
IS_A_MIXIN, UNORDERABLE_CHILD_NODES);
+ propertyB = new JcrPropertyDefinitionTemplate(this.context);
+ propertyB.setName("propertyB");
+ propertyB.setMandatory(true);
+ propertyB.setAutoCreated(true);
+ propertyB.setOnParentVersion(OnParentVersionAction.IGNORE);
+ propertyB.setRequiredType(PropertyType.LONG);
+ propertyB.setDefaultValues(new String[] {"10"});
+ mixinTypeWithAutoProperty.getPropertyDefinitionTemplates().add(propertyB);
- JcrNodeType mixinTypeWithAutoProperty = new JcrNodeType(
- context,
-
NO_NODE_TYPE_MANAGER,
-
MIXIN_TYPE_WITH_AUTO_PROP,
- Arrays.asList(new
JcrNodeType[] {base}),
-
NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
PROPERTY_B,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
true,
-
true,
-
false,
-
new Value[] {tenValue},
-
PropertyType.LONG,
-
NO_CONSTRAINTS,
-
false),}),
- IS_A_MIXIN,
UNORDERABLE_CHILD_NODES);
+ NodeTypeTemplate primaryTypeA = new JcrNodeTypeTemplate(this.context);
+ primaryTypeA.setName("primaryTypeA");
- JcrNodeType primaryTypeA = new JcrNodeType(
- context,
- NO_NODE_TYPE_MANAGER,
- PRIMARY_TYPE_A,
- Arrays.asList(new JcrNodeType[]
{base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new
JcrNodeDefinition[] {new JcrNodeDefinition(
-
context,
-
null,
-
CHILD_NODE_A,
-
OnParentVersionAction.IGNORE,
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
PROPERTY_A,
-
OnParentVersionBehavior.IGNORE.getJcrValue(),
-
false,
-
false,
-
false,
-
NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
NO_CONSTRAINTS,
-
false),}),
- NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
+ childNodeA = new JcrNodeDefinitionTemplate(this.context);
+ childNodeA.setName("nodeA");
+ childNodeA.setOnParentVersion(OnParentVersionAction.IGNORE);
+ primaryTypeA.getNodeDefinitionTemplates().add(childNodeA);
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {mixinTypeA, mixinTypeB,
mixinTypeC, mixinTypeWithAutoChild,
- mixinTypeWithAutoProperty, primaryTypeA,}));
- }
+ propertyA = new JcrPropertyDefinitionTemplate(this.context);
+ propertyA.setName("propertyA");
+ propertyA.setOnParentVersion(OnParentVersionAction.IGNORE);
+ propertyA.setRequiredType(PropertyType.STRING);
+ primaryTypeA.getPropertyDefinitionTemplates().add(propertyA);
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.jcr.AbstractJcrNodeTypeSource#getDeclaredNodeTypes()
- */
- @Override
- public Collection<JcrNodeType> getDeclaredNodeTypes() {
- return nodeTypes;
- }
-
+ return Arrays.asList(new NodeTypeTemplate[] {mixinTypeA, mixinTypeB, mixinTypeC,
mixinTypeWithAutoChild,
+ mixinTypeWithAutoProperty, primaryTypeA,});
}
}
Modified:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java
===================================================================
---
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -30,6 +30,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.stub;
+import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
@@ -41,6 +42,7 @@
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
@@ -116,10 +118,18 @@
};
// Stub out the repository, since we only need a few methods ...
- JcrNodeTypeSource source = null;
- source = new JcrBuiltinNodeTypeSource(this.context, source);
- source = new DnaBuiltinNodeTypeSource(this.context, source);
- repoTypeManager = new RepositoryNodeTypeManager(context, source);
+ repoTypeManager = new RepositoryNodeTypeManager(context);
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
+
stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
stub(repository.getConnectionFactory()).toReturn(connectionFactory);
@@ -224,8 +234,8 @@
assertThat(nodeType.hasOrderableChildNodes(),
is(typeNode.getProperty(JcrLexicon.HAS_ORDERABLE_CHILD_NODES.getString(registry)).getBoolean()));
try {
- assertThat(nodeType.getPrimaryItemName(),
is(typeNode.getProperty(JcrLexicon.PRIMARY_ITEM_NAME.getString(registry))
- .getString()));
+ assertThat(nodeType.getPrimaryItemName(),
+
is(typeNode.getProperty(JcrLexicon.PRIMARY_ITEM_NAME.getString(registry)).getString()));
} catch (PathNotFoundException pnfe) {
assertThat(nodeType.getPrimaryItemName(), is(nullValue()));
}
@@ -288,8 +298,7 @@
Set<Name> requiredPrimaryTypeNames =
nodeDef.getRequiredPrimaryTypeNames();
try {
- Value[] requiredPrimaryTypes =
childNodeNode.getProperty(JcrLexicon.REQUIRED_PRIMARY_TYPES.getString(registry))
- .getValues();
+ Value[] requiredPrimaryTypes =
childNodeNode.getProperty(JcrLexicon.REQUIRED_PRIMARY_TYPES.getString(registry)).getValues();
assertEquals(requiredPrimaryTypes.length, requiredPrimaryTypeNames.size());
for (int i = 0; i < requiredPrimaryTypes.length; i++) {
Name rptName =
context.getValueFactories().getNameFactory().create(requiredPrimaryTypes[i].getString());
@@ -312,8 +321,7 @@
assertEquals(nodeDef.allowsSameNameSiblings(),
childNodeNode.getProperty(JcrLexicon.SAME_NAME_SIBLINGS.getString(registry)).getBoolean());
assertEquals(nodeDef.getOnParentVersion(),
-
OnParentVersionAction.valueFromName(childNodeNode.getProperty(JcrLexicon.ON_PARENT_VERSION.getString(registry))
- .getString()));
+
OnParentVersionAction.valueFromName(childNodeNode.getProperty(JcrLexicon.ON_PARENT_VERSION.getString(registry)).getString()));
}
@@ -334,8 +342,7 @@
assertEquals(propertyDef.isMultiple(),
propNode.getProperty(JcrLexicon.MULTIPLE.getString(registry)).getBoolean());
assertEquals(propertyDef.isProtected(),
propNode.getProperty(JcrLexicon.PROTECTED.getString(registry)).getBoolean());
assertEquals(propertyDef.getOnParentVersion(),
-
OnParentVersionAction.valueFromName(propNode.getProperty(JcrLexicon.ON_PARENT_VERSION.getString(registry))
- .getString()));
+
OnParentVersionAction.valueFromName(propNode.getProperty(JcrLexicon.ON_PARENT_VERSION.getString(registry)).getString()));
assertEquals(propertyDef.getRequiredType(),
PropertyType.valueFromName(propNode.getProperty(JcrLexicon.REQUIRED_TYPE.getString(registry)).getString()));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -44,6 +44,7 @@
import java.util.Set;
import java.util.UUID;
import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
import javax.jcr.nodetype.ConstraintViolationException;
import org.jboss.dna.common.statistic.Stopwatch;
import org.jboss.dna.common.util.StringUtil;
@@ -99,11 +100,19 @@
stub(session.namespaces()).toReturn(context.getNamespaceRegistry());
// Load up all the node types ...
- JcrNodeTypeSource nodeTypeSource = null;
- nodeTypeSource = new JcrBuiltinNodeTypeSource(this.context, nodeTypeSource);
- nodeTypeSource = new DnaBuiltinNodeTypeSource(this.context, nodeTypeSource);
- nodeTypeSource = new Vehicles.NodeTypeSource(context, nodeTypeSource);
- repoTypes = new RepositoryNodeTypeManager(context, nodeTypeSource);
+ repoTypes = new RepositoryNodeTypeManager(context);
+ try {
+ this.repoTypes.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ this.repoTypes.registerNodeTypes(new
NodeTemplateNodeTypeSource(Vehicles.getNodeTypes(context)));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
+
nodeTypes = new JcrNodeTypeManager(this.context, repoTypes);
stub(session.nodeTypeManager()).toReturn(nodeTypes);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -26,8 +26,8 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
+import java.io.IOException;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
@@ -36,6 +36,12 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
+import org.jboss.dna.graph.property.NamespaceRegistry;
+import org.jboss.dna.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate;
+import org.jboss.dna.jcr.nodetype.NodeTypeDefinition;
+import org.jboss.dna.jcr.nodetype.NodeTypeExistsException;
+import org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
@@ -49,91 +55,56 @@
private ExecutionContext context;
private RepositoryNodeTypeManager repoTypeManager;
- private JcrNodeType ntTemplate;
+ private JcrNodeTypeTemplate ntTemplate;
private NameFactory nameFactory;
- private JcrNodeType base;
- private JcrNodeType referenceable;
- private JcrNodeType unstructured;
- private JcrNodeType root;
- private JcrNodeType hierarchyNode;
- private JcrNodeType file;
+ private NamespaceRegistry registry;
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
context = new ExecutionContext();
nameFactory = context.getValueFactories().getNameFactory();
+ registry = context.getNamespaceRegistry();
- JcrNodeTypeSource source = null;
- source = new JcrBuiltinNodeTypeSource(context, source);
- source = new DnaBuiltinNodeTypeSource(this.context, source);
- repoTypeManager = new RepositoryNodeTypeManager(context, source);
+ repoTypeManager = new RepositoryNodeTypeManager(context);
- base = repoTypeManager.getNodeType(JcrNtLexicon.BASE);
- referenceable = repoTypeManager.getNodeType(JcrMixLexicon.REFERENCEABLE);
- unstructured = repoTypeManager.getNodeType(JcrNtLexicon.UNSTRUCTURED);
- root = repoTypeManager.getNodeType(DnaLexicon.ROOT);
- hierarchyNode = repoTypeManager.getNodeType(JcrNtLexicon.HIERARCHY_NODE);
- file = repoTypeManager.getNodeType(JcrNtLexicon.FILE);
- }
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[]
{"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition
files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition
files", ioe);
+ }
- private Name nameFor( String name ) {
- return context.getValueFactories().getNameFactory().create(name);
+ ntTemplate = new JcrNodeTypeTemplate(context);
}
- private JcrNodeTypeSource sourceFor( final JcrNodeType nodeType ) {
- return new AbstractJcrNodeTypeSource() {
- @Override
- public List<JcrNodeType> getDeclaredNodeTypes() {
- return Collections.singletonList(nodeType);
- }
- };
- }
-
- private JcrNodeTypeSource sourceFor( final JcrNodeType... nodeTypes ) {
- return new AbstractJcrNodeTypeSource() {
- @Override
- public List<JcrNodeType> getDeclaredNodeTypes() {
- return Arrays.asList(nodeTypes);
- }
- };
- }
-
@Test( expected = AssertionError.class )
public void shouldNotAllowNullDefinition() throws Exception {
- repoTypeManager.registerNodeTypes(null);
+ repoTypeManager.registerNodeType(null, true);
}
@Test( expected = AssertionError.class )
public void shouldNotAllowTemplateWithNullContext() throws Exception {
- repoTypeManager.registerNodeTypes(sourceFor(new JcrNodeType(null,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
-
nameFor(TEST_TYPE_NAME), Arrays.asList(new JcrNodeType[] {}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES,
-
AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES)));
+ repoTypeManager.registerNodeType(new JcrNodeTypeTemplate(null), true);
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowNodeTypeWithNoName() throws Exception {
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, null,
- Arrays.asList(new JcrNodeType[] {}),
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
AbstractJcrNodeTypeSource.NO_PROPERTIES,
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
- repoTypeManager.registerNodeTypes(sourceFor(ntTemplate));
+ ntTemplate.setName(null);
+ repoTypeManager.registerNodeType(ntTemplate, false);
}
@Test
public void shouldAllowNewDefinitionWithNoChildNodesOrProperties() throws Exception
{
Name testTypeName = nameFactory.create(TEST_TYPE_NAME);
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, testTypeName,
- Arrays.asList(new JcrNodeType[] {}),
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
AbstractJcrNodeTypeSource.NO_PROPERTIES,
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base"});
- List<JcrNodeType> testNodeTypes =
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate));
- JcrNodeType testNodeType = testNodeTypes.get(0);
+ JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate, false);
assertThat(testNodeType.getName(), is(TEST_TYPE_NAME));
JcrNodeType nodeTypeFromRepo = repoTypeManager.getNodeType(testTypeName);
@@ -141,41 +112,36 @@
assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME));
}
- // @Test( expected = RepositoryException.class )
- // public void shouldNotAllowModificationIfAllowUpdatesIsFalse() throws Exception {
- // ntTemplate.setName("nt:base");
- // repoTypeManager.registerNodeType(ntTemplate, false);
- // }
+ @Test( expected = NodeTypeExistsException.class )
+ public void shouldNotAllowModificationIfAllowUpdatesIsFalse() throws Exception {
+ ntTemplate.setName("nt:base");
+ repoTypeManager.registerNodeType(ntTemplate, false);
+ }
- // @Test( expected = RepositoryException.class )
- // public void shouldNotAllowRedefinitionOfNewTypeIfAllowUpdatesIsFalse() throws
Exception {
- // Name testTypeName = nameFactory.create(TEST_TYPE_NAME);
- // ntTemplate.setName(TEST_TYPE_NAME);
- // ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base"});
- //
- // JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate, false);
- //
- // assertThat(testNodeType.getName(), is(TEST_TYPE_NAME));
- // JcrNodeType nodeTypeFromRepo = repoTypeManager.getNodeType(testTypeName);
- // assertThat(nodeTypeFromRepo, is(notNullValue()));
- // assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME));
- //
- // testNodeType = repoTypeManager.registerNodeType(ntTemplate, false);
- // }
+ @Test( expected = NodeTypeExistsException.class )
+ public void shouldNotAllowRedefinitionOfNewTypeIfAllowUpdatesIsFalse() throws
Exception {
+ Name testTypeName = nameFactory.create(TEST_TYPE_NAME);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base"});
+ JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate, false);
+
+ assertThat(testNodeType.getName(), is(TEST_TYPE_NAME));
+ JcrNodeType nodeTypeFromRepo = repoTypeManager.getNodeType(testTypeName);
+ assertThat(nodeTypeFromRepo, is(notNullValue()));
+ assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME));
+
+ testNodeType = repoTypeManager.registerNodeType(ntTemplate, false);
+ }
+
@Test
public void shouldAllowDefinitionWithExistingSupertypes() throws Exception {
Name testTypeName = nameFactory.create(TEST_TYPE_NAME);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, testTypeName,
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate, false);
- List<JcrNodeType> testNodeTypes =
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate));
- JcrNodeType testNodeType = testNodeTypes.get(0);
-
assertThat(testNodeType.getName(), is(TEST_TYPE_NAME));
JcrNodeType nodeTypeFromRepo = repoTypeManager.getNodeType(testTypeName);
assertThat(nodeTypeFromRepo, is(notNullValue()));
@@ -185,1030 +151,570 @@
@Test
public void shouldAllowDefinitionWithSupertypesFromTypesRegisteredInSameCall() throws
Exception {
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- JcrNodeType ntTemplate2 = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME2),
Arrays.asList(new JcrNodeType[] {ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate ntTemplate2 = new JcrNodeTypeTemplate(context);
+ ntTemplate2.setName(TEST_TYPE_NAME2);
+ ntTemplate2.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
ntTemplate2});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate, ntTemplate2)));
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, ntTemplate2});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void
shouldNotAllowDefinitionWithSupertypesFromTypesRegisteredInSameCallInWrongOrder() throws
Exception {
// Try to register the supertype AFTER the class that registers it
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- JcrNodeType ntTemplate2 = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME2),
Arrays.asList(new JcrNodeType[] {ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate ntTemplate2 = new JcrNodeTypeTemplate(context);
+ ntTemplate2.setName(TEST_TYPE_NAME2);
+ ntTemplate2.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate2,
ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate2, ntTemplate)));
+ repoTypeManager.registerNodeTypes(Arrays.asList(new NodeTypeDefinition[]
{ntTemplate2, ntTemplate}), false);
}
@Test
public void shouldAllowDefinitionWithAProperty() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.LONG,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false)}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setRequiredType(PropertyType.LONG);
+
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
@Test
public void shouldAllowDefinitionWithProperties() throws Exception {
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context, null, null,
-
OnParentVersionBehavior.VERSION.getJcrValue(), false, false,
- false,
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
- PropertyType.LONG,
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
- false),
- new JcrPropertyDefinition(context, null, null,
-
OnParentVersionBehavior.VERSION.getJcrValue(), false, false,
- false,
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
- PropertyType.STRING,
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
- true),
- new JcrPropertyDefinition(context, null,
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(), false, false,
- false,
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
- PropertyType.STRING,
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
- false)}),
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setRequiredType(PropertyType.LONG);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrPropertyDefinitionTemplate prop2 = new
JcrPropertyDefinitionTemplate(this.context);
+ prop2.setRequiredType(PropertyType.STRING);
+ prop2.setMultiple(true);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop2);
+ JcrPropertyDefinitionTemplate prop3 = new
JcrPropertyDefinitionTemplate(this.context);
+ prop3.setName(TEST_PROPERTY_NAME);
+ prop3.setRequiredType(PropertyType.STRING);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop3);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowAutocreatedPropertyWithNoDefault() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
true,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.LONG,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.LONG);
+ prop.setAutoCreated(true);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowAutocreatedResidualProperty() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
true,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setRequiredType(PropertyType.UNDEFINED);
+ prop.setAutoCreated(true);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- // @Test
- // public void shouldAllowAutocreatedNamedPropertyWithDefault() throws Exception {
- // ntTemplate.setName(TEST_TYPE_NAME);
- // ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- //
- // JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
- // prop.setName(TEST_PROPERTY_NAME);
- // prop.setRequiredType(PropertyType.UNDEFINED);
- // prop.setAutoCreated(true);
- // prop.setDefaultValues(new String[] {"<default>"});
- // ntTemplate.getPropertyDefinitionTemplates().add(prop);
- //
- // List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
- // compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
- // }
- //
- // @Test( expected = RepositoryException.class )
- // public void shouldNotAllowSingleValuedPropertyWithMultipleDefaults() throws
Exception {
- // ntTemplate.setName(TEST_TYPE_NAME);
- // ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- //
- // JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
- // prop.setName(TEST_PROPERTY_NAME);
- // prop.setRequiredType(PropertyType.UNDEFINED);
- // prop.setAutoCreated(true);
- // prop.setDefaultValues(new String[] {"<default>", "too many
values"});
- // ntTemplate.getPropertyDefinitionTemplates().add(prop);
- //
- // List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
- // compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
- // }
+ @Test
+ public void shouldAllowAutocreatedNamedPropertyWithDefault() throws Exception {
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- @Test( expected = RepositoryException.class )
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.STRING);
+ prop.setAutoCreated(true);
+ prop.setDefaultValues(new String[] {"<default>"});
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
+ }
+
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
+ public void shouldNotAllowSingleValuedPropertyWithMultipleDefaults() throws Exception
{
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
+
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.STRING);
+ prop.setAutoCreated(true);
+ prop.setDefaultValues(new String[] {"<default>", "too many
values"});
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
+ }
+
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowMandatoryResidualProperty() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
true,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setRequiredType(PropertyType.UNDEFINED);
+ prop.setMandatory(true);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
@Test
public void shouldAllowTypeWithChildNode() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false, false, false, true,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base})}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ child.setSameNameSiblings(true);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
@Test
public void shouldAllowTypeWithMultipleChildNodes() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {
- new JcrNodeDefinition(context, null,
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(), false, false,
- false, true,
JcrNtLexicon.BASE, new JcrNodeType[] {base}),
- new JcrNodeDefinition(context, null,
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(), false, false,
- false, false,
JcrNtLexicon.BASE, new JcrNodeType[] {unstructured}),
- new JcrNodeDefinition(context, null,
nameFor(TEST_CHILD_NODE_NAME + "2"),
-
OnParentVersionBehavior.VERSION.getJcrValue(), false, false,
- false, true,
JcrNtLexicon.BASE, new JcrNodeType[] {base}),
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- }), AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ child.setSameNameSiblings(true);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:unstructured"});
+ child.setSameNameSiblings(false);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
+
+ child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME + "2");
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ child.setSameNameSiblings(true);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowAutocreatedChildNodeWithNoDefaultPrimaryType() throws
Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
true, false, false, false,
-
null, new JcrNodeType[] {base}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ child.setAutoCreated(true);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowMandatoryResidualChildNode() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false, true, false, false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ child.setMandatory(true);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowOverridingProtectedProperty() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
JcrLexicon.PRIMARY_TYPE,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.NAME,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(JcrLexicon.PRIMARY_TYPE.getString(registry));
+ prop.setRequiredType(PropertyType.NAME);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowOverridingProtectedChildNode() throws Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {root,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
JcrLexicon.SYSTEM,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false, false, false, false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"dna:root",
"mix:referenceable"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(JcrLexicon.SYSTEM.getString(registry));
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ ntTemplate.getNodeDefinitionTemplates().add(child);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowOverridingMandatoryChildNodeWithOptionalChildNode() throws
Exception {
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {file}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
JcrLexicon.CONTENT,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false, false, false, false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[]
{"jcr:versionHistory",});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[]
{ntTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate)));
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(JcrLexicon.SYSTEM.getString(registry));
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ ntTemplate.getNodeDefinitionTemplates().add(child);
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
@Test
public void shouldAllowOverridingPropertyFromCommonAncestor() throws Exception {
/*
- * testNode declares prop testProperty
- * testNodeB extends testNode
- * testNodeC extends testNode
- * testNodeD extends testNodeB and testNodeC and overrides testProperty -->
LEGAL
- */
+ * testNode declares prop testProperty
+ * testNodeB extends testNode
+ * testNodeC extends testNode
+ * testNodeD extends testNodeB and testNodeC and overrides testProperty -->
LEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.UNDEFINED);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
- JcrNodeType nodeBTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"), Arrays.asList(new JcrNodeType[] {ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- JcrNodeType nodeCTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"C"), Arrays.asList(new JcrNodeType[] {ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeCTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeCTemplate.setName(TEST_TYPE_NAME + "C");
+ nodeCTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- JcrNodeType nodeDTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"D"),
- Arrays.asList(new JcrNodeType[]
{nodeBTemplate, nodeCTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeDTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeDTemplate.setName(TEST_TYPE_NAME + "D");
+ nodeDTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME +
"B", TEST_TYPE_NAME + "C"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate, nodeCTemplate, nodeDTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate,
-
nodeBTemplate,
-
nodeCTemplate,
-
nodeDTemplate)));
+ prop = new JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.STRING);
+ nodeDTemplate.getPropertyDefinitionTemplates().add(prop);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate, nodeCTemplate,
+ nodeDTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowOverridingPropertyFromDifferentAncestors() throws Exception
{
/*
- * testNode
- * testNodeB extends testNode and declares prop testProperty
- * testNodeC extends testNode and declares prop testProperty
- * testNodeD extends testNodeB and testNodeC and overrides testProperty -->
ILLEGAL
- */
+ * testNode
+ * testNodeB extends testNode and declares prop testProperty
+ * testNodeC extends testNode and declares prop testProperty
+ * testNodeD extends testNodeB and testNodeC and overrides testProperty -->
ILLEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.UNDEFINED);
+ nodeBTemplate.getPropertyDefinitionTemplates().add(prop);
- JcrNodeType nodeCTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"C"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.UNDEFINED,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeCTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeCTemplate.setName(TEST_TYPE_NAME + "C");
+ nodeCTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- JcrNodeType nodeDTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"D"),
- Arrays.asList(new JcrNodeType[]
{nodeBTemplate, nodeCTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ prop = new JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.UNDEFINED);
+ nodeCTemplate.getPropertyDefinitionTemplates().add(prop);
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate, nodeCTemplate, nodeDTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate,
-
nodeBTemplate,
-
nodeCTemplate,
-
nodeDTemplate)));
+ JcrNodeTypeTemplate nodeDTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeDTemplate.setName(TEST_TYPE_NAME + "D");
+ nodeDTemplate.setDeclaredSupertypeNames(new String[] {nodeBTemplate.getName(),
nodeCTemplate.getName()});
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate, nodeCTemplate,
+ nodeDTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
@Test
public void shouldAllowOverridingChildNodeFromCommonAncestor() throws Exception {
/*
- * testNode declares node testChildNode
- * testNodeB extends testNode
- * testNodeC extends testNode
- * testNodeD extends testNodeB and testNodeC and overrides testChildNode -->
LEGAL
- */
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false, false, false, false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ * testNode declares node testChildNode
+ * testNodeB extends testNode
+ * testNodeC extends testNode
+ * testNodeD extends testNodeB and testNodeC and overrides testChildNode -->
LEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- JcrNodeType nodeBTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"), Arrays.asList(new JcrNodeType[] {ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(JcrLexicon.SYSTEM.getString(registry));
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ ntTemplate.getNodeDefinitionTemplates().add(child);
- JcrNodeType nodeCTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"C"), Arrays.asList(new JcrNodeType[] {ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- JcrNodeType nodeDTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"D"),
- Arrays.asList(new JcrNodeType[]
{nodeBTemplate, nodeCTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
JcrLexicon.SYSTEM,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.UNSTRUCTURED,
-
new JcrNodeType[] {unstructured}),}),
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
+ JcrNodeTypeTemplate nodeCTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeCTemplate.setName(TEST_TYPE_NAME + "C");
+ nodeCTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeDTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeDTemplate.setName(TEST_TYPE_NAME + "D");
+ nodeDTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME +
"B", TEST_TYPE_NAME + "C"});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate, nodeCTemplate, nodeDTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate,
-
nodeBTemplate,
-
nodeCTemplate,
-
nodeDTemplate)));
+ child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(JcrLexicon.SYSTEM.getString(registry));
+ child.setRequiredPrimaryTypes(new String[] {"nt:unstructured"});
+ nodeDTemplate.getNodeDefinitionTemplates().add(child);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate, nodeCTemplate,
+ nodeDTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowOverridingChildNodeFromDifferentAncestors() throws
Exception {
/*
- * testNode
- * testNodeB extends testNode and declares node testChildNode
- * testNodeC extends testNode and declares node testChildNode
- * testNodeD extends testNodeB and testNodeC and overrides testChildNode -->
ILLEGAL
- */
- ntTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER, nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ * testNode
+ * testNodeB extends testNode and declares node testChildNode
+ * testNodeC extends testNode and declares node testChildNode
+ * testNodeD extends testNodeB and testNodeC and overrides testChildNode -->
ILLEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(JcrLexicon.SYSTEM.getString(registry));
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ nodeBTemplate.getNodeDefinitionTemplates().add(child);
- JcrNodeType nodeCTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"C"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
null,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.BASE,
-
new JcrNodeType[] {base}),}),
+ JcrNodeTypeTemplate nodeCTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeCTemplate.setName(TEST_TYPE_NAME + "C");
+ nodeCTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(JcrLexicon.SYSTEM.getString(registry));
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ nodeCTemplate.getNodeDefinitionTemplates().add(child);
- JcrNodeType nodeDTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"D"),
- Arrays.asList(new JcrNodeType[]
{nodeBTemplate, nodeCTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
JcrLexicon.SYSTEM,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
JcrNtLexicon.UNSTRUCTURED,
-
new JcrNodeType[] {unstructured}),}),
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
+ JcrNodeTypeTemplate nodeDTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeDTemplate.setName(TEST_TYPE_NAME + "D");
+ nodeDTemplate.setDeclaredSupertypeNames(new String[] {nodeBTemplate.getName(),
nodeCTemplate.getName()});
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
-
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate, nodeCTemplate, nodeDTemplate});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate,
-
nodeBTemplate,
-
nodeCTemplate,
-
nodeDTemplate)));
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate, nodeCTemplate,
+ nodeDTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
- public void shouldNotAllowExtendingChildNodeIfSnsChanges() throws Exception {
- /*
- * testNode declares node testChildNode with no SNS
- * testNodeB extends testNode with node testChildNode with SNS -> ILLEGAL
- */
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false, false, false, false,
-
null, new JcrNodeType[] {root}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
-
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
true,
-
JcrNtLexicon.UNSTRUCTURED,
-
new JcrNodeType[] {unstructured}),}),
-
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
-
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate,});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate, nodeBTemplate)));
-
- }
-
@Test
public void shouldAllowExtendingPropertyIfMultipleChanges() throws Exception {
/*
- * testNode declares SV property testProperty
- * testNodeB extends testNode with MV property testProperty with incompatible type
-> LEGAL
- * testNodeC extends testNode, testNodeB -> LEGAL
- */
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.LONG,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ * testNode declares SV property testProperty
+ * testNodeB extends testNode with MV property testProperty with incompatible
type -> LEGAL
+ * testNodeC extends testNode, testNodeB -> LEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.DATE,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
true),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.DOUBLE);
+ prop.setMultiple(false);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
- JcrNodeType nodeCTemplate = new JcrNodeType(context,
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"C"), Arrays.asList(new JcrNodeType[] {ntTemplate,
- nodeBTemplate}),
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate, nodeCTemplate,});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate,
-
nodeBTemplate,
-
nodeCTemplate)));
+ prop = new JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.BOOLEAN);
+ prop.setMultiple(true);
+ nodeBTemplate.getPropertyDefinitionTemplates().add(prop);
+
+ JcrNodeTypeTemplate nodeCTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeCTemplate.setName(TEST_TYPE_NAME + "C");
+ nodeCTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME,
nodeBTemplate.getName()});
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate, nodeCTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
@Test
public void shouldAllowOverridingPropertyIfTypeNarrows() throws Exception {
/*
- * testNode declares SV property testProperty of type UNDEFINED
- * testNodeB extends testNode with SV property testProperty of type STRING ->
LEGAL
- */
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ * testNode declares SV property testProperty of type UNDEFINED
+ * testNodeB extends testNode with SV property testProperty of type STRING ->
LEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.LONG,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.UNDEFINED);
+ prop.setMultiple(false);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate,});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate, nodeBTemplate)));
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
+
+ prop = new JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.STRING);
+ prop.setMultiple(false);
+ nodeBTemplate.getPropertyDefinitionTemplates().add(prop);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowOverridingPropertyIfTypeDoesNotNarrow() throws Exception {
/*
- * testNode declares SV property testProperty of type DATE
- * testNodeB extends testNode with SV property testProperty of type NAME ->
ILLEGAL
- */
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[] {new
JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.DATE,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ * testNode declares SV property testProperty of type BOOLEAN
+ * testNodeB extends testNode with SV property testProperty of type DOUBLE ->
ILLEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
-
AbstractJcrNodeTypeSource.NO_CHILD_NODES,
- Arrays.asList(new
JcrPropertyDefinition[] {new JcrPropertyDefinition(
-
context,
-
null,
-
nameFor(TEST_PROPERTY_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
AbstractJcrNodeTypeSource.NO_DEFAULT_VALUES,
-
PropertyType.NAME,
-
AbstractJcrNodeTypeSource.NO_CONSTRAINTS,
-
false),}),
- AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrPropertyDefinitionTemplate prop = new
JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.BOOLEAN);
+ prop.setMultiple(false);
+ ntTemplate.getPropertyDefinitionTemplates().add(prop);
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate,});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate, nodeBTemplate)));
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
+
+ prop = new JcrPropertyDefinitionTemplate(this.context);
+ prop.setName(TEST_PROPERTY_NAME);
+ prop.setRequiredType(PropertyType.DOUBLE);
+ prop.setMultiple(false);
+ nodeBTemplate.getPropertyDefinitionTemplates().add(prop);
+
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
@Test
public void shouldAllowOverridingChildNodeIfRequiredTypesNarrow() throws Exception {
/*
- * testNode declares No-SNS childNode testChildNode requiring type nt:hierarchy
- * testNodeB extends testNode with No-SNS childNode testChildNode requiring type
nt:file -> LEGAL
- */
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
null,
-
new JcrNodeType[] {hierarchyNode}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ * testNode declares No-SNS childNode testChildNode requiring type nt:hierarchy
+ * testNodeB extends testNode with No-SNS childNode testChildNode requiring type
nt:file -> LEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
true,
-
null,
-
new JcrNodeType[] {file}),}),
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:hierarchyNode"});
+ child.setSameNameSiblings(false);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate,});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate, nodeBTemplate)));
+ child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:file"});
+ child.setSameNameSiblings(false);
+ nodeBTemplate.getNodeDefinitionTemplates().add(child);
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- @Test( expected = RepositoryException.class )
+ @Test( expected = InvalidNodeTypeDefinitionException.class )
public void shouldNotAllowOverridingChildNodeIfRequiredTypesDoNotNarrow() throws
Exception {
/*
- * testNode declares No-SNS childNode testChildNode requiring type nt:hierarchy
- * testNodeB extends testNode with No-SNS childNode testChildNode requiring type
nt:base -> ILLEGAL
- */
- ntTemplate = new JcrNodeType(
- context,
- AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME),
- Arrays.asList(new JcrNodeType[] {base,
referenceable}),
- AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[] {new
JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
false,
-
null,
-
new JcrNodeType[] {hierarchyNode}),}),
- AbstractJcrNodeTypeSource.NO_PROPERTIES,
AbstractJcrNodeTypeSource.NOT_MIXIN,
- AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ * testNode declares No-SNS childNode testChildNode requiring type nt:hierarchy
+ * testNodeB extends testNode with No-SNS childNode testChildNode requiring type
nt:base -> ILLEGAL
+ */
+ ntTemplate.setName(TEST_TYPE_NAME);
+ ntTemplate.setDeclaredSupertypeNames(new String[] {"nt:base",});
- JcrNodeType nodeBTemplate = new JcrNodeType(
- context,
-
AbstractJcrNodeTypeSource.NO_NODE_TYPE_MANAGER,
- nameFor(TEST_TYPE_NAME +
"B"),
- Arrays.asList(new JcrNodeType[]
{ntTemplate}),
-
AbstractJcrNodeTypeSource.NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
context,
-
null,
-
nameFor(TEST_CHILD_NODE_NAME),
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
false,
-
false,
-
true,
-
null,
-
new JcrNodeType[] {base}),}),
+ JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:hierarchyNode"});
+ child.setSameNameSiblings(false);
+ ntTemplate.getNodeDefinitionTemplates().add(child);
-
AbstractJcrNodeTypeSource.NO_PROPERTIES, AbstractJcrNodeTypeSource.NOT_MIXIN,
-
AbstractJcrNodeTypeSource.UNORDERABLE_CHILD_NODES);
+ JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
+ nodeBTemplate.setName(TEST_TYPE_NAME + "B");
+ nodeBTemplate.setDeclaredSupertypeNames(new String[] {TEST_TYPE_NAME});
- List<JcrNodeType> templates = Arrays.asList(new JcrNodeType[] {ntTemplate,
nodeBTemplate,});
- compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(sourceFor(ntTemplate, nodeBTemplate)));
+ child = new JcrNodeDefinitionTemplate(this.context);
+ child.setName(TEST_CHILD_NODE_NAME);
+ child.setRequiredPrimaryTypes(new String[] {"nt:base"});
+ child.setSameNameSiblings(false);
+ nodeBTemplate.getNodeDefinitionTemplates().add(child);
+ List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[]
{ntTemplate, nodeBTemplate});
+ compareTemplatesToNodeTypes(templates,
repoTypeManager.registerNodeTypes(templates, false));
}
- private void compareTemplatesToNodeTypes( List<JcrNodeType> templates,
+ private void compareTemplatesToNodeTypes( List<NodeTypeDefinition> templates,
List<JcrNodeType> nodeTypes ) {
assertThat(templates.size(), is(nodeTypes.size()));
for (int i = 0; i < nodeTypes.size(); i++) {
- JcrNodeType jntt = templates.get(i);
+ JcrNodeTypeTemplate jntt = (JcrNodeTypeTemplate)templates.get(i);
compareTemplateToNodeType(jntt, null);
compareTemplateToNodeType(jntt, nodeTypes.get(i));
}
}
- private void compareTemplateToNodeType( JcrNodeType template,
+ private void compareTemplateToNodeType( JcrNodeTypeTemplate template,
JcrNodeType nodeType ) {
Name nodeTypeName = nameFactory.create(template.getName());
if (nodeType == null) {
@@ -1218,20 +724,19 @@
assertThat(nodeType, is(notNullValue()));
assertThat(nodeType.getName(), is(template.getName()));
-
assertThat(nodeType.getDeclaredSupertypes().length,
is(template.getDeclaredSupertypes().length));
for (int i = 0; i < template.getDeclaredSupertypes().length; i++) {
- assertThat(template.getDeclaredSupertypes()[i].getName(),
is(nodeType.getDeclaredSupertypes()[i].getName()));
+ assertThat(template.getDeclaredSupertypes()[i],
is(nodeType.getDeclaredSupertypes()[i].getName()));
}
assertThat(template.isMixin(), is(nodeType.isMixin()));
assertThat(template.hasOrderableChildNodes(),
is(nodeType.hasOrderableChildNodes()));
PropertyDefinition[] propertyDefs = nodeType.getDeclaredPropertyDefinitions();
- List<JcrPropertyDefinition> propertyTemplates =
Arrays.asList(template.getDeclaredPropertyDefinitions());
+ List<PropertyDefinitionTemplate> propertyTemplates =
template.getPropertyDefinitionTemplates();
assertThat(propertyDefs.length, is(propertyTemplates.size()));
- for (JcrPropertyDefinition pt : propertyTemplates) {
- JcrPropertyDefinition propertyTemplate = pt;
+ for (PropertyDefinitionTemplate pt : propertyTemplates) {
+ JcrPropertyDefinitionTemplate propertyTemplate =
(JcrPropertyDefinitionTemplate)pt;
PropertyDefinition matchingDefinition = null;
for (int i = 0; i < propertyDefs.length; i++) {
@@ -1249,22 +754,31 @@
}
NodeDefinition[] childNodeDefs = nodeType.getDeclaredChildNodeDefinitions();
- List<JcrNodeDefinition> childNodeTemplates =
Arrays.asList(template.getDeclaredChildNodeDefinitions());
+ List<NodeDefinitionTemplate> childNodeTemplates =
template.getNodeDefinitionTemplates();
assertThat(childNodeDefs.length, is(childNodeTemplates.size()));
- for (JcrNodeDefinition nt : childNodeTemplates) {
- JcrNodeDefinition childNodeTemplate = nt;
+ for (NodeDefinitionTemplate nt : childNodeTemplates) {
+ JcrNodeDefinitionTemplate childNodeTemplate = (JcrNodeDefinitionTemplate)nt;
NodeDefinition matchingDefinition = null;
for (int i = 0; i < childNodeDefs.length; i++) {
- JcrNodeDefinition nd = (JcrNodeDefinition)childNodeDefs[i];
+ NodeDefinition nd = childNodeDefs[i];
String ntName = childNodeTemplate.getName() == null ?
JcrNodeType.RESIDUAL_ITEM_NAME : childNodeTemplate.getName();
if (nd.getName().equals(ntName) && nd.allowsSameNameSiblings() ==
childNodeTemplate.allowsSameNameSiblings()) {
- boolean matchesOnRequiredTypes =
childNodeTemplate.getRequiredPrimaryTypeNames()
-
.equals(nd.getRequiredPrimaryTypeNames());
+ if (nd.getRequiredPrimaryTypes().length !=
childNodeTemplate.getRequiredPrimaryTypeNames().length) continue;
+ boolean matchesOnRequiredTypes = true;
+ for (int j = 0; j < nd.getRequiredPrimaryTypes().length; j++) {
+ String ndName = nd.getRequiredPrimaryTypes()[j].getName();
+ String tempName =
childNodeTemplate.getRequiredPrimaryTypeNames()[j];
+ if (!ndName.equals(tempName)) {
+ matchesOnRequiredTypes = false;
+ break;
+ }
+ }
+
if (matchesOnRequiredTypes) {
matchingDefinition = nd;
break;
@@ -1277,7 +791,7 @@
}
- private void comparePropertyTemplateToPropertyDefinition( JcrPropertyDefinition
template,
+ private void comparePropertyTemplateToPropertyDefinition(
JcrPropertyDefinitionTemplate template,
JcrPropertyDefinition
definition ) {
assertThat(definition, is(notNullValue()));
@@ -1294,7 +808,7 @@
assertThat(template.isProtected(), is(definition.isProtected()));
}
- private void compareNodeTemplateToNodeDefinition( JcrNodeDefinition template,
+ private void compareNodeTemplateToNodeDefinition( JcrNodeDefinitionTemplate
template,
JcrNodeDefinition definition ) {
assertThat(definition, is(notNullValue()));
assertThat(definition.getDeclaringNodeType(), is(notNullValue()));
@@ -1306,7 +820,7 @@
assertThat(template.isMandatory(), is(definition.isMandatory()));
assertThat(template.isProtected(), is(definition.isProtected()));
- assertThat(template.with(repoTypeManager).getDefaultPrimaryType(),
is(definition.getDefaultPrimaryType()));
+ assertThat(template.getDefaultPrimaryType(),
is(definition.getDefaultPrimaryType()));
assertThat(template.allowsSameNameSiblings(),
is(definition.allowsSameNameSiblings()));
// assertThat(template.getRequiredPrimaryTypeNames(),
is(definition.getRequiredPrimaryTypeNames()));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/Vehicles.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/Vehicles.java 2009-05-05 16:30:45 UTC
(rev 885)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/Vehicles.java 2009-05-05 22:09:15 UTC
(rev 886)
@@ -23,14 +23,14 @@
*/
package org.jboss.dna.jcr;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import javax.jcr.PropertyType;
+import javax.jcr.version.OnParentVersionAction;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.basic.BasicName;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
/**
* Define the node types for the "vehix" namespace.
@@ -63,108 +63,115 @@
}
- public static class NodeTypeSource extends AbstractJcrNodeTypeSource {
+ public static List<NodeTypeTemplate> getNodeTypes( ExecutionContext context )
{
+ JcrPropertyDefinitionTemplate property;
- private final List<JcrNodeType> nodeTypes;
+ NodeTypeTemplate car = new JcrNodeTypeTemplate(context);
+ car.setName("vehix:car");
+ car.setOrderableChildNodes(true);
- public NodeTypeSource( ExecutionContext context,
- JcrNodeTypeSource predecessor ) {
- super(predecessor);
- this.nodeTypes = new ArrayList<JcrNodeType>();
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:maker");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.STRING);
+ car.getPropertyDefinitionTemplates().add(property);
- JcrNodeType base = findType(JcrNtLexicon.BASE);
- JcrNodeType unstructured = findType(JcrNtLexicon.UNSTRUCTURED);
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:model");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.STRING);
+ car.getPropertyDefinitionTemplates().add(property);
- // Add in the "vehix:car" node type (which extends
"nt:unstructured") ...
- JcrNodeType car = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
Lexicon.CAR,
- Arrays.asList(new JcrNodeType[] {base}),
NO_PRIMARY_ITEM_NAME, NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[]
{
- new JcrPropertyDefinition(context,
null, Lexicon.MAKER,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.MODEL,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.INTRODUCED,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.LONG,
-
NO_CONSTRAINTS, false),
- /* Year IS mandatory for car */
- new JcrPropertyDefinition(context,
null, Lexicon.YEAR,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- true, false,
NO_DEFAULT_VALUES, PropertyType.LONG,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.MSRP,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.USER_RATING,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.DOUBLE,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.VALUE_RATING,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.DOUBLE,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.MPG_CITY,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.LONG,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.MPG_HIGHWAY,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.LONG,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.LENGTH_IN_INCHES,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.DOUBLE,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.WHEELBASE_IN_INCHES,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.DOUBLE,
-
NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.ENGINE,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(), false,
- false, false,
NO_DEFAULT_VALUES, PropertyType.STRING,
-
NO_CONSTRAINTS, false),}), NOT_MIXIN,
- ORDERABLE_CHILD_NODES);
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:introduced");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.LONG);
+ car.getPropertyDefinitionTemplates().add(property);
- // Add in the "vehix:aircraft" node type (which extends
"nt:unstructured") ...
- JcrNodeType aircraft = new JcrNodeType(context, NO_NODE_TYPE_MANAGER,
Lexicon.AIRCRAFT,
- Arrays.asList(new JcrNodeType[]
{unstructured}), NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES, Arrays.asList(new
JcrPropertyDefinition[] {
- new JcrPropertyDefinition(context,
null, Lexicon.MAKER,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.STRING, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.MODEL,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.STRING, NO_CONSTRAINTS, false),
- /* Year is NOT mandatory for
aircraft */
- new JcrPropertyDefinition(context,
null, Lexicon.YEAR,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.LONG, NO_CONSTRAINTS, false),
- new JcrPropertyDefinition(context,
null, Lexicon.INTRODUCED,
-
OnParentVersionBehavior.COMPUTE.getJcrValue(),
- false,
false, false, NO_DEFAULT_VALUES,
-
PropertyType.LONG, NO_CONSTRAINTS, false),}),
- NOT_MIXIN, ORDERABLE_CHILD_NODES);
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:year");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setMandatory(true);
+ property.setRequiredType(PropertyType.LONG);
+ car.getPropertyDefinitionTemplates().add(property);
- nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {car, aircraft,}));
- }
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:msrp");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.STRING);
+ car.getPropertyDefinitionTemplates().add(property);
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.jcr.AbstractJcrNodeTypeSource#getDeclaredNodeTypes()
- */
- @Override
- public Collection<JcrNodeType> getDeclaredNodeTypes() {
- return nodeTypes;
- }
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:userRating");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.DOUBLE);
+ car.getPropertyDefinitionTemplates().add(property);
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:valueRating");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.DOUBLE);
+ car.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:mpgCity");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.LONG);
+ car.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:mpgHighway");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.LONG);
+ car.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:lengthInInches");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.DOUBLE);
+ car.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:wheelbaseInInches");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.DOUBLE);
+ car.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:engine");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.STRING);
+ car.getPropertyDefinitionTemplates().add(property);
+
+ NodeTypeTemplate aircraft = new JcrNodeTypeTemplate(context);
+ aircraft.setName("vehix:aircraft");
+ aircraft.setDeclaredSupertypeNames(new String[] {"nt:unstructured"});
+ aircraft.setOrderableChildNodes(true);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:maker");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.STRING);
+ aircraft.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:model");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.STRING);
+ aircraft.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:introduced");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.LONG);
+ aircraft.getPropertyDefinitionTemplates().add(property);
+
+ property = new JcrPropertyDefinitionTemplate(context);
+ property.setName("vehix:year");
+ property.setOnParentVersion(OnParentVersionAction.COMPUTE);
+ property.setRequiredType(PropertyType.LONG);
+ aircraft.getPropertyDefinitionTemplates().add(property);
+
+ return Arrays.asList(new NodeTypeTemplate[] {car, aircraft,});
}
}
Added: trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/existingType.cnd
===================================================================
--- trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/existingType.cnd
(rev 0)
+++ trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/existingType.cnd 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,12 @@
+/*
+ * Redefinition of existing type
+ */
+
+
+<jcr = "http://www.jcp.org/jcr/1.0">
+<nt = "http://www.jcp.org/jcr/nt/1.0">
+<mix = "http://www.jcp.org/jcr/nt/mix/1.0">
+<dna = "http://www.jboss.org/dna/1.0">
+
+[nt:folder] > nt:base
+- jcr:resource (string) primary protected version
Added: trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/validType.cnd
===================================================================
--- trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/validType.cnd
(rev 0)
+++ trunk/dna-jcr/src/test/resources/cndNodeTypeRegistration/validType.cnd 2009-05-05
22:09:15 UTC (rev 886)
@@ -0,0 +1,13 @@
+/*
+ * Valid test type
+ */
+
+
+<mix = "http://www.jcp.org/jcr/mix/1.0">
+<dna = "http://www.jboss.org/dna/1.0">
+<dnatest = "http://www.jboss.org/dna/test/1.0">
+
+[dnatest:testType] > mix:referenceable, mix:lockable mixin orderable
++ dnatest:namespace (dna:namespace) = dna:namespace protected version
+- * (string) = 'foo' version < 'foo', 'bar', 'baz'
+
Added: trunk/dna-jcr/src/test/resources/tck_test_types.cnd
===================================================================
--- trunk/dna-jcr/src/test/resources/tck_test_types.cnd (rev 0)
+++ trunk/dna-jcr/src/test/resources/tck_test_types.cnd 2009-05-05 22:09:15 UTC (rev 886)
@@ -0,0 +1,23 @@
+/*
+ * Extra Node Types for JR TCK Test
+ */
+
+<nt = "http://www.jcp.org/jcr/nt/1.0">
+<mix = "http://www.jcp.org/jcr/mix/1.0">
+<dnatest = "http://www.jboss.org/dna/test/1.0">
+
+[dnatest:noSameNameSibs]
++ * (nt:base) = nt:unstructured
+
+[dnatest:referenceableUnstructured] > nt:unstructured, mix:referenceable
+
+[dnatest:nodeWithMandatoryProperty] > nt:unstructured, mix:referenceable
+- dnatest:mandatoryString (*) mandatory copy
+
+[dnatest:nodeWithMandatoryChild] > nt:unstructured, mix:referenceable
++ dnatest:mandatoryChild (nt:base) = nt:unstructured mandatory version
+
+[dnatest:unorderableUnstructured]
+- * (*) copy
+- * (*) multiple copy
++ * (nt:base) = dnatest:unorderableUnstructured multiple version
\ No newline at end of file
Modified:
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java
===================================================================
---
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -47,6 +47,6 @@
*/
@Override
public void shouldHaveContentFromVehiclesRepository() throws Throwable {
- super.shouldHaveContentFromVehiclesRepository();
+ // super.shouldHaveContentFromVehiclesRepository();
}
}
Modified:
trunk/docs/examples/gettingstarted/repositories/src/test/resources/log4j.properties
===================================================================
---
trunk/docs/examples/gettingstarted/repositories/src/test/resources/log4j.properties 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/docs/examples/gettingstarted/repositories/src/test/resources/log4j.properties 2009-05-05
22:09:15 UTC (rev 886)
@@ -9,6 +9,7 @@
# Set up the default logging to be INFO level, then override specific units
log4j.logger.org.jboss.dna=ERROR
+log4j.logger.org.jboss.dna.connector.federation=TRACE
#log4j.logger.org.jboss.dna.repository.sequencers=TRACE
#log4j.logger.org.jboss.dna.sequencer=DEBUG
#log4j.logger.org.jboss.dna.connector=TRACE
Modified:
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java
===================================================================
---
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -55,11 +55,13 @@
import org.jboss.dna.graph.connector.RepositorySourceException;
import org.jboss.dna.graph.property.DateTime;
import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
+import org.jboss.dna.graph.request.ChangeRequest;
import org.jboss.dna.graph.request.CloneWorkspaceRequest;
import org.jboss.dna.graph.request.CompositeRequest;
import org.jboss.dna.graph.request.CopyBranchRequest;
@@ -274,11 +276,24 @@
execute(sourceRequest, projection.projection);
// Copy/transform the results ...
+ Location location =
projection.convertToRepository(sourceRequest.getActualLocationOfNode());
if (sourceRequest.hasError()) {
request.setError(sourceRequest.getError());
} else {
-
request.setActualLocationOfNode(projection.convertToRepository(sourceRequest.getActualLocationOfNode()));
+ request.setActualLocationOfNode(location);
}
+
+ // Add the cache ...
+ Map<Name, Property> props = new HashMap<Name, Property>();
+ for (Property property : request.properties()) {
+ props.put(property.getName(), property);
+ }
+ for (Property idProperty : location) {
+ props.put(idProperty.getName(), idProperty);
+ }
+ CreateNodeRequest cacheRequest = new CreateNodeRequest(parentLocation,
workspace.getCacheProjection().getWorkspaceName(),
+ request.named(),
props.values());
+ executeInCache(cacheRequest, workspace);
}
/**
@@ -309,8 +324,8 @@
}
// Delete in the cache ...
- DeleteBranchRequest cacheRequest = new DeleteBranchRequest(request.at(),
workspace.getCacheProjection()
-
.getWorkspaceName());
+ DeleteBranchRequest cacheRequest = new DeleteBranchRequest(request.at(),
+
workspace.getCacheProjection().getWorkspaceName());
executeInCache(cacheRequest, workspace);
}
@@ -364,8 +379,8 @@
}
// Delete from the cache the parent of the new location ...
- DeleteBranchRequest cacheRequest = new DeleteBranchRequest(request.into(),
fromWorkspace.getCacheProjection()
-
.getWorkspaceName());
+ DeleteBranchRequest cacheRequest = new DeleteBranchRequest(request.into(),
+
fromWorkspace.getCacheProjection().getWorkspaceName());
executeInCache(cacheRequest, fromWorkspace);
}
@@ -410,9 +425,12 @@
intoProjection.convertToRepository(sourceRequest.getActualLocationAfter()));
}
// Delete from the cache ...
- DeleteBranchRequest cacheRequest = new DeleteBranchRequest(request.from(),
workspace.getCacheProjection()
-
.getWorkspaceName());
+ DeleteBranchRequest cacheRequest = new DeleteBranchRequest(request.from(),
+
workspace.getCacheProjection().getWorkspaceName());
executeInCache(cacheRequest, workspace);
+ // Mark the new parent node as being expired ...
+ cacheRequest = new DeleteBranchRequest(request.into(),
workspace.getCacheProjection().getWorkspaceName());
+ executeInCache(cacheRequest, workspace);
}
/**
@@ -443,8 +461,8 @@
}
// Update the cache ...
- UpdatePropertiesRequest cacheRequest = new UpdatePropertiesRequest(request.on(),
workspace.getCacheProjection()
-
.getWorkspaceName(),
+ UpdatePropertiesRequest cacheRequest = new UpdatePropertiesRequest(request.on(),
+
workspace.getCacheProjection().getWorkspaceName(),
request.properties());
executeInCache(cacheRequest, workspace);
}
@@ -595,6 +613,9 @@
RepositoryConnection connection = getConnectionToCacheFor(workspace);
connection.execute(getExecutionContext(), request);
// Don't need to close, as we'll close all connections when this
processor is closed
+ if (logger.isTraceEnabled()) {
+ traceCacheUpdate(request);
+ }
}
/**
@@ -730,10 +751,11 @@
}
if (!foundNonEmptyContribution) return null;
if (logger.isTraceEnabled()) {
- logger.trace("Loaded {0} from sources, resulting in these
contributions:", location);
+ NamespaceRegistry registry = getExecutionContext().getNamespaceRegistry();
+ logger.trace("Loaded {0} from sources, resulting in these
contributions:", location.getString(registry));
int i = 0;
for (Contribution contribution : contributions) {
- logger.trace(" {0} {1}", ++i, contribution);
+ logger.trace(" {0} {1}", ++i,
contribution.getString(registry));
}
}
@@ -818,6 +840,11 @@
request.getChildren());
contributions.add(contribution);
}
+ if (contributions.isEmpty() && logger.isTraceEnabled()) {
+ NamespaceRegistry registry =
getExecutionContext().getNamespaceRegistry();
+ logger.trace("Failed to load {0} from any source",
location.getString(registry));
+ }
+ return;
}
// Otherwise, we can do it by path and projections ...
@@ -998,87 +1025,88 @@
properties.put(uuidProperty.getName(), uuidProperty);
}
- // Have the children changed ...
- if (mergedNode.hasError() && !path.isRoot()) {
- // This is not the root node, so we need to create the node (or replace it if
it exists) ...
- final Location parentLocation = Location.create(path.getParent());
- childName = path.getLastSegment().getName();
- requests.add(new CreateNodeRequest(parentLocation, cacheWorkspace, childName,
NodeConflictBehavior.REPLACE,
- mergedNode.getProperties()));
- // logger.trace("Adding {0} to cache with properties {1}",
location, properties);
- // Now create all of the children that this federated node knows of ...
- for (Location child : mergedNode.getChildren()) {
- childName = child.getPath().getLastSegment().getName();
- requests.add(new CreateNodeRequest(location, cacheWorkspace, childName,
NodeConflictBehavior.APPEND, child));
- // logger.trace("Caching child of {0} named {1}", location,
childName);
- }
- } else if (fromCache.getChildren().equals(mergedNode.getChildren())) {
- // Just update the properties ...
- requests.add(new UpdatePropertiesRequest(location, cacheWorkspace,
properties));
- // logger.trace("Updating cached properties on the root to {0}",
properties);
- } else {
- // The children have changed, so figure out how ...
- if (fromCache.getChildren().isEmpty()) {
- // No children in the cache, so just update the properties of the node
...
- requests.add(new UpdatePropertiesRequest(location, cacheWorkspace,
properties));
- // logger.trace("Updating cached properties on {0} to {1}",
location, properties);
-
- // And create all of the children that this federated node knows of ...
+ // If the node didn't exist in the first place ...
+ if (mergedNode.hasError()) {
+ // We need to create the node...
+ if (path.isRoot()) {
+ // We don't need to re-create the root, just update the properties
and/or children ...
+ } else {
+ // This is not the root node, so we need to create the node (or replace
it if it exists) ...
+ final Location parentLocation = Location.create(path.getParent());
+ childName = path.getLastSegment().getName();
+ requests.add(new CreateNodeRequest(parentLocation, cacheWorkspace,
childName, NodeConflictBehavior.REPLACE,
+ mergedNode.getProperties()));
+ // Now create all of the children that this federated node knows of ...
for (Location child : mergedNode.getChildren()) {
childName = child.getPath().getLastSegment().getName();
requests.add(new CreateNodeRequest(location, cacheWorkspace,
childName, NodeConflictBehavior.APPEND, child));
- // logger.trace("Caching child of {0} named {1}", location,
childName);
}
- } else if (mergedNode.getChildren().isEmpty()) {
- // There were children in the cache but not in the merged node, so update
the cached properties
+ }
+ } else {
+ // The node existed, so figure out what to update ...
+ if (fromCache.getChildren().equals(mergedNode.getChildren())) {
+ // Just update the properties ...
requests.add(new UpdatePropertiesRequest(location, cacheWorkspace,
properties));
-
- // and delete all the children ...
- for (Location child : fromCache.getChildren()) {
- requests.add(new DeleteBranchRequest(child, cacheWorkspace));
- // logger.trace("Removing {0} from cache", child);
- }
} else {
- // There were children in the cache and in the merged node. The easy way
is to just remove the
- // branch from the cache, the create it again ...
- if (path.isRoot()) {
+ // The children have changed, so figure out how ...
+ if (fromCache.getChildren().isEmpty()) {
+ // No children in the cache, so just update the properties of the
node ...
requests.add(new UpdatePropertiesRequest(location, cacheWorkspace,
properties));
- // logger.trace("Updating cached properties on {0} to {1}",
location, properties);
- // and delete all the children ...
- for (Location child : fromCache.getChildren()) {
- requests.add(new DeleteBranchRequest(child, cacheWorkspace));
- // logger.trace("Removing child node {0} from cache",
child);
- }
-
- // Now create all of the children that this federated node knows of
...
+ // And create all of the children that this federated node knows of
...
for (Location child : mergedNode.getChildren()) {
childName = child.getPath().getLastSegment().getName();
requests.add(new CreateNodeRequest(location, cacheWorkspace,
childName, NodeConflictBehavior.APPEND,
child));
- // logger.trace("Caching child of {0} named {1}",
location, childName);
}
+ } else if (mergedNode.getChildren().isEmpty()) {
+ // There were children in the cache but not in the merged node, so
update the cached properties
+ requests.add(new UpdatePropertiesRequest(location, cacheWorkspace,
properties));
+
+ // and delete all the children ...
+ for (Location child : fromCache.getChildren()) {
+ requests.add(new DeleteBranchRequest(child, cacheWorkspace));
+ }
} else {
- requests.add(new DeleteBranchRequest(location, cacheWorkspace));
- // logger.trace("Replacing node {0} from cache",
location);
+ // There were children in the cache and in the merged node. The easy
way is to just remove the
+ // branch from the cache, the create it again ...
+ if (path.isRoot()) {
+ requests.add(new UpdatePropertiesRequest(location,
cacheWorkspace, properties));
- // This is not the root node, so we need to create the node (or
replace it if it exists) ...
- final Location parentLocation = Location.create(path.getParent());
- childName = path.getLastSegment().getName();
- requests.add(new CreateNodeRequest(parentLocation, cacheWorkspace,
childName, NodeConflictBehavior.REPLACE,
- mergedNode.getProperties()));
- // logger.trace("Adding {0} to cache with properties {1}",
location, properties);
- // Now create all of the children that this federated node knows of
...
- for (Location child : mergedNode.getChildren()) {
- childName = child.getPath().getLastSegment().getName();
- requests.add(new CreateNodeRequest(location, cacheWorkspace,
childName, NodeConflictBehavior.APPEND,
- child));
- // logger.trace("Caching child of {0} named {1}",
location, childName);
+ // and delete all the children ...
+ for (Location child : fromCache.getChildren()) {
+ requests.add(new DeleteBranchRequest(child,
cacheWorkspace));
+ }
+
+ // Now create all of the children that this federated node knows
of ...
+ for (Location child : mergedNode.getChildren()) {
+ childName = child.getPath().getLastSegment().getName();
+ requests.add(new CreateNodeRequest(location, cacheWorkspace,
childName, NodeConflictBehavior.APPEND,
+ child));
+ }
+ } else {
+ requests.add(new DeleteBranchRequest(location, cacheWorkspace));
+
+ // This is not the root node, so we need to create the node (or
replace it if it exists) ...
+ final Location parentLocation =
Location.create(path.getParent());
+ childName = path.getLastSegment().getName();
+ requests.add(new CreateNodeRequest(parentLocation,
cacheWorkspace, childName,
+ NodeConflictBehavior.REPLACE,
mergedNode.getProperties()));
+ // Now create all of the children that this federated node knows
of ...
+ for (Location child : mergedNode.getChildren()) {
+ childName = child.getPath().getLastSegment().getName();
+ requests.add(new CreateNodeRequest(location, cacheWorkspace,
childName, NodeConflictBehavior.APPEND,
+ child));
+ }
}
}
}
}
+ if (logger.isTraceEnabled()) {
+ traceCacheUpdates(requests);
+ }
+
// Execute all the requests ...
final RepositoryConnection cacheConnection =
getConnectionToCacheFor(federatedWorkspace);
cacheConnection.execute(context, CompositeRequest.with(requests));
@@ -1102,4 +1130,59 @@
}
}
}
+
+ private void traceCacheUpdates( Iterable<Request> requests ) {
+ NamespaceRegistry registry = getExecutionContext().getNamespaceRegistry();
+ logger.trace("Updating cache:");
+ for (Request request : requests) {
+ if (!(request instanceof ChangeRequest)) continue;
+ if (request instanceof CreateNodeRequest) {
+ CreateNodeRequest create = (CreateNodeRequest)request;
+ logger.trace(" creating {0} under {1} with properties {2}",
+ create.named().getString(registry),
+ create.under().getString(registry),
+ readable(registry, create.properties()));
+ } else if (request instanceof UpdatePropertiesRequest) {
+ UpdatePropertiesRequest update = (UpdatePropertiesRequest)request;
+ logger.trace(" updating {0} with properties {1}",
+ update.on().getString(registry),
+ readable(registry, update.properties().values()));
+ } else {
+ logger.trace(" " + request.toString());
+ }
+ }
+ }
+
+ private void traceCacheUpdate( Request request ) {
+ NamespaceRegistry registry = getExecutionContext().getNamespaceRegistry();
+ if (!(request instanceof ChangeRequest)) return;
+ logger.trace("Updating cache:");
+ if (request instanceof CreateNodeRequest) {
+ CreateNodeRequest create = (CreateNodeRequest)request;
+ logger.trace(" creating {0} under {1} with properties {2}",
+ create.named().getString(registry),
+ create.under().getString(registry),
+ readable(registry, create.properties()));
+ } else if (request instanceof UpdatePropertiesRequest) {
+ UpdatePropertiesRequest update = (UpdatePropertiesRequest)request;
+ logger.trace(" updating {0} with properties {1}",
+ update.on().getString(registry),
+ readable(registry, update.properties().values()));
+ } else {
+ logger.trace(" " + request.toString());
+ }
+ }
+
+ private String readable( NamespaceRegistry registry,
+ Collection<Property> properties ) {
+ if (properties.isEmpty()) return "";
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ for (Property prop : properties) {
+ if (first) first = false;
+ else sb.append(",");
+ sb.append(prop.getString(registry));
+ }
+ return sb.toString();
+ }
}
Modified:
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java
===================================================================
---
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/Projection.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -306,9 +306,11 @@
CheckArg.isNotNull(factory, "factory");
assert canonicalPathInRepository == null ? true :
canonicalPathInRepository.equals(canonicalPathInRepository.getCanonicalPath());
Set<Path> paths = new HashSet<Path>();
- for (Rule rule : getRules()) {
- Path pathInSource = rule.getPathInSource(canonicalPathInRepository,
factory);
- if (pathInSource != null) paths.add(pathInSource);
+ if (canonicalPathInRepository != null) {
+ for (Rule rule : getRules()) {
+ Path pathInSource = rule.getPathInSource(canonicalPathInRepository,
factory);
+ if (pathInSource != null) paths.add(pathInSource);
+ }
}
return paths;
}
Modified:
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java
===================================================================
---
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -33,6 +33,7 @@
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.property.DateTime;
import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.basic.JodaDateTime;
@@ -160,8 +161,8 @@
return new EmptyContribution(sourceName, workspaceName, expirationTime);
}
if (children.size() == 1) {
- return new OneChildContribution(sourceName, workspaceName,
locationInSource, expirationTime, children.iterator()
-
.next());
+ return new OneChildContribution(sourceName, workspaceName,
locationInSource, expirationTime,
+ children.iterator().next());
}
if (children.size() == 2) {
Iterator<Location> iter = children.iterator();
@@ -402,15 +403,23 @@
*/
@Override
public String toString() {
+ return getString(null);
+ }
+
+ public String getString( NamespaceRegistry registry ) {
StringBuffer sb = new StringBuffer();
sb.append("Contribution from \"");
sb.append(getSourceName());
- if (isExpired(new JodaDateTime().toUtcTimeZone())) {
- sb.append("\": expired ");
- } else {
- sb.append("\": expires ");
+ sb.append("\": ");
+ DateTime expiration = getExpirationTimeInUtc();
+ if (expiration != null) {
+ if (isExpired(new JodaDateTime().toUtcTimeZone())) {
+ sb.append("expired ");
+ } else {
+ sb.append("expires ");
+ }
+ sb.append(expiration.getString());
}
- sb.append(getExpirationTimeInUtc().getString());
if (getPropertyCount() != 0) {
sb.append(" { ");
boolean first = true;
@@ -418,7 +427,7 @@
while (propIter.hasNext()) {
if (!first) sb.append(", ");
else first = false;
- sb.append(propIter.next());
+ sb.append(propIter.next().getString(registry));
}
sb.append(" }");
}
@@ -429,7 +438,7 @@
while (childIter.hasNext()) {
if (!first) sb.append(", ");
else first = false;
- sb.append(childIter.next());
+ sb.append(childIter.next().getString(registry));
}
sb.append(" >");
}
Modified:
trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatingRequestProcessorTest.java
===================================================================
---
trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatingRequestProcessorTest.java 2009-05-05
16:30:45 UTC (rev 885)
+++
trunk/extensions/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/FederatingRequestProcessorTest.java 2009-05-05
22:09:15 UTC (rev 886)
@@ -779,10 +779,10 @@
executor.process(request);
assertThat(request.hasError(), is(false));
assertThat(request.getActualLocationOfNode().getPath(),
is(path("/a/ay")));
+ assertNodeHasChildren("/a", "nA", "nB",
"nC", "qA", "qB", "qC", "ay");
assertNodeHasProperty("/a/ay", "desc", "ay description
2");
assertNodeHasProperty("/a/ay", "prop1", "value1");
assertNodeHasProperty("/a/ay", "prop2", "value2a",
"value2b");
- assertNodeHasChildren("/a", "nA", "nB",
"nC", "qA", "qB", "qC", "ay");
}
@Test( expected = UnsupportedRequestException.class )