Index: modeshape-graph/src/main/java/org/modeshape/graph/property/ValueTypeSystem.java =================================================================== --- modeshape-graph/src/main/java/org/modeshape/graph/property/ValueTypeSystem.java (revision 1866) +++ modeshape-graph/src/main/java/org/modeshape/graph/property/ValueTypeSystem.java (working copy) @@ -49,6 +49,7 @@ public class ValueTypeSystem implements TypeSystem { private final TypeFactory booleanFactory; private final TypeFactory longFactory; private final TypeFactory doubleFactory; + private final TypeFactory decimalFactory; private final TypeFactory dateFactory; private final TypeFactory pathFactory; private final TypeFactory referenceFactory; @@ -89,6 +90,7 @@ public class ValueTypeSystem implements TypeSystem { this.booleanFactory = new Factory(valueFactories.getBooleanFactory()); this.longFactory = new Factory(valueFactories.getLongFactory()); this.doubleFactory = new Factory(valueFactories.getDoubleFactory()); + this.decimalFactory = new Factory(valueFactories.getDecimalFactory()); this.dateFactory = new Factory(valueFactories.getDateFactory()) { /** @@ -222,6 +224,15 @@ public class ValueTypeSystem implements TypeSystem { /** * {@inheritDoc} * + * @see org.modeshape.graph.query.model.TypeSystem#getDecimalFactory() + */ + public TypeFactory getDecimalFactory() { + return decimalFactory; + } + + /** + * {@inheritDoc} + * * @see org.modeshape.graph.query.model.TypeSystem#getLongFactory() */ public TypeFactory getLongFactory() { Index: modeshape-graph/src/main/java/org/modeshape/graph/property/basic/NameValueFactory.java =================================================================== --- modeshape-graph/src/main/java/org/modeshape/graph/property/basic/NameValueFactory.java (revision 1866) +++ modeshape-graph/src/main/java/org/modeshape/graph/property/basic/NameValueFactory.java (working copy) @@ -60,7 +60,7 @@ public class NameValueFactory extends AbstractValueFactory implements Name protected static final Pattern FULLY_QUALIFIED_NAME_PATTERN = Pattern.compile(FULLY_QUALFIED_NAME_PATTERN_STRING); // Original pattern: (([^:/]*):)?([^:]*) - private static final String PREFIXED_NAME_PATTERN_STRING = "(([^:/]*):)?([^:]*)"; + private static final String PREFIXED_NAME_PATTERN_STRING = "(([^:/]+):)?([^:]*)"; private static final Pattern PREFIXED_NAME_PATTERN = Pattern.compile(PREFIXED_NAME_PATTERN_STRING); private static Name BLANK_NAME; Index: modeshape-graph/src/main/java/org/modeshape/graph/query/model/TypeSystem.java =================================================================== --- modeshape-graph/src/main/java/org/modeshape/graph/query/model/TypeSystem.java (revision 1866) +++ modeshape-graph/src/main/java/org/modeshape/graph/query/model/TypeSystem.java (working copy) @@ -23,6 +23,7 @@ */ package org.modeshape.graph.query.model; +import java.math.BigDecimal; import java.util.Comparator; import java.util.Set; import net.jcip.annotations.Immutable; @@ -79,6 +80,13 @@ public interface TypeSystem { TypeFactory getDoubleFactory(); /** + * Get the type factory for decimal types. + * + * @return the decimal factory; never null + */ + TypeFactory getDecimalFactory(); + + /** * Get the type factory for date-time objects. * * @return the date-time factory, or null if this type system doesn't support date-time objects Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrItemDefinitionTemplate.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrItemDefinitionTemplate.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrItemDefinitionTemplate.java (working copy) @@ -23,13 +23,14 @@ */ package org.modeshape.jcr; +import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.nodetype.ItemDefinition; import javax.jcr.nodetype.NodeType; import javax.jcr.version.OnParentVersionAction; import net.jcip.annotations.NotThreadSafe; -import org.modeshape.common.util.CheckArg; import org.modeshape.graph.ExecutionContext; import org.modeshape.graph.property.Name; +import org.modeshape.graph.property.ValueFormatException; /** * ModeShape convenience implementation to support the JCR 2 NodeDefinitionTemplate and PropertyDefinitionTemplate classes. @@ -125,9 +126,15 @@ abstract class JcrItemDefinitionTemplate implements ItemDefinition { this.isProtected = isProtected; } - public void setName( String name ) { - CheckArg.isNotEmpty(name, "name"); - this.name = context.getValueFactories().getNameFactory().create(name); + public void setName( String name ) throws ConstraintViolationException { + if (name == null) { + throw new ConstraintViolationException(); + } + try { + this.name = context.getValueFactories().getNameFactory().create(name); + } catch (ValueFormatException vfe) { + throw new ConstraintViolationException(vfe); + } } public void setOnParentVersion( int onParentVersion ) { Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeDefinitionTemplate.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeDefinitionTemplate.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeDefinitionTemplate.java (working copy) @@ -23,9 +23,14 @@ */ package org.modeshape.jcr; +import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.nodetype.NodeType; import net.jcip.annotations.NotThreadSafe; import org.modeshape.graph.ExecutionContext; +import org.modeshape.graph.property.Name; +import org.modeshape.graph.property.NameFactory; +import org.modeshape.graph.property.NamespaceRegistry; +import org.modeshape.graph.property.ValueFormatException; import org.modeshape.jcr.nodetype.NodeDefinitionTemplate; /** @@ -34,8 +39,8 @@ import org.modeshape.jcr.nodetype.NodeDefinitionTemplate; @NotThreadSafe class JcrNodeDefinitionTemplate extends JcrItemDefinitionTemplate implements NodeDefinitionTemplate { - private String defaultPrimaryType; - private String[] requiredPrimaryTypes; + private Name defaultPrimaryType; + private Name[] requiredPrimaryTypes; private boolean allowSameNameSiblings; JcrNodeDefinitionTemplate( ExecutionContext context ) { @@ -47,7 +52,7 @@ class JcrNodeDefinitionTemplate extends JcrItemDefinitionTemplate implements Nod * * @see org.modeshape.jcr.nodetype.NodeDefinitionTemplate#setDefaultPrimaryType(String) */ - public void setDefaultPrimaryType( String defaultPrimaryType ) { + public void setDefaultPrimaryType( String defaultPrimaryType ) throws ConstraintViolationException { setDefaultPrimaryTypeName(defaultPrimaryType); } @@ -56,8 +61,12 @@ class JcrNodeDefinitionTemplate extends JcrItemDefinitionTemplate implements Nod * * @param defaultPrimaryType the default primary type for this child node */ - public void setDefaultPrimaryTypeName( String defaultPrimaryType ) { - this.defaultPrimaryType = defaultPrimaryType; + public void setDefaultPrimaryTypeName( String defaultPrimaryType ) throws ConstraintViolationException { + try { + this.defaultPrimaryType = getContext().getValueFactories().getNameFactory().create(defaultPrimaryType); + } catch (ValueFormatException vfe) { + throw new ConstraintViolationException(vfe); + } } /** @@ -67,18 +76,31 @@ class JcrNodeDefinitionTemplate extends JcrItemDefinitionTemplate implements Nod * @deprecated Use {@link #setRequiredPrimaryTypeNames(String[])} instead */ @SuppressWarnings( "dep-ann" ) - public void setRequiredPrimaryTypes( String[] requiredPrimaryTypes ) { + public void setRequiredPrimaryTypes( String[] requiredPrimaryTypes ) throws ConstraintViolationException { setRequiredPrimaryTypeNames(requiredPrimaryTypes); } /** - * SSet the names of the primary types that must appear on the child(ren) described by this definition + * {@inheritDoc} * - * @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 + * @see NodeDefinitionTemplate#setRequiredPrimaryTypeNames(String[]) */ - public void setRequiredPrimaryTypeNames( String[] requiredPrimaryTypes ) { - this.requiredPrimaryTypes = requiredPrimaryTypes; + public void setRequiredPrimaryTypeNames( String[] requiredPrimaryTypes ) throws ConstraintViolationException { + if (requiredPrimaryTypes == null) { + throw new ConstraintViolationException(); + } + + NameFactory nameFactory = getContext().getValueFactories().getNameFactory(); + Name[] rpts = new Name[requiredPrimaryTypes.length]; + for (int i = 0; i < requiredPrimaryTypes.length; i++) { + try { + rpts[i] = nameFactory.create(requiredPrimaryTypes[i]); + } catch (ValueFormatException vfe) { + throw new ConstraintViolationException(vfe); + } + } + + this.requiredPrimaryTypes = rpts; } /** @@ -109,7 +131,8 @@ class JcrNodeDefinitionTemplate extends JcrItemDefinitionTemplate implements Nod } public String getDefaultPrimaryTypeName() { - return defaultPrimaryType; + if (defaultPrimaryType == null) return null; + return defaultPrimaryType.getString(getContext().getNamespaceRegistry()); } /** @@ -122,6 +145,13 @@ class JcrNodeDefinitionTemplate extends JcrItemDefinitionTemplate implements Nod } public String[] getRequiredPrimaryTypeNames() { - return requiredPrimaryTypes; + if (requiredPrimaryTypes == null) return null; + + NamespaceRegistry registry = getContext().getNamespaceRegistry(); + String[] rpts = new String[requiredPrimaryTypes.length]; + for (int i = 0; i < requiredPrimaryTypes.length; i++) { + rpts[i] = requiredPrimaryTypes[i].getString(registry); + } + return rpts; } } Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeType.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeType.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeType.java (working copy) @@ -258,7 +258,6 @@ class JcrNodeType implements NodeType { if (primaryNodeTypeName != null) { JcrNodeType childType = this.nodeTypeManager().getNodeType(childPrimaryTypeName); if (childType.isAbstract() || childType.isMixin()) return false; - } return nodeTypeManager().findChildNodeDefinition(this.name, null, childName, childPrimaryTypeName, 0, true) != null; Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeManager.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeManager.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeManager.java (working copy) @@ -655,7 +655,7 @@ public class JcrNodeTypeManager implements NodeTypeManager { * @throws RepositoryException if another error occurs */ public NodeTypeTemplate createNodeTypeTemplate( NodeTypeDefinition ntd ) throws RepositoryException { - NodeTypeTemplate ntt = createNodeTypeTemplate(); + NodeTypeTemplate ntt = new JcrNodeTypeTemplate(context(), true); if (ntd != null) { ntt.setName(ntd.getName()); @@ -667,6 +667,39 @@ public class JcrNodeTypeManager implements NodeTypeManager { ntt.setQueryable(ntd.isQueryable()); // copy child nodes and props + for (NodeDefinition nodeDefinition : ntd.getDeclaredChildNodeDefinitions()) { + JcrNodeDefinitionTemplate ndt = new JcrNodeDefinitionTemplate(context()); + + ndt.setAutoCreated(nodeDefinition.isAutoCreated()); + ndt.setDefaultPrimaryType(ndt.getDefaultPrimaryTypeName()); + ndt.setMandatory(ndt.isMandatory()); + ndt.setName(ndt.getName()); + ndt.setOnParentVersion(ndt.getOnParentVersion()); + ndt.setProtected(ndt.isProtected()); + ndt.setRequiredPrimaryTypeNames(ndt.getRequiredPrimaryTypeNames()); + ndt.setSameNameSiblings(ndt.allowsSameNameSiblings()); + + ntt.getNodeDefinitionTemplates().add(ndt); + } + + for (PropertyDefinition propertyDefinition : ntd.getDeclaredPropertyDefinitions()) { + JcrPropertyDefinitionTemplate pdt = new JcrPropertyDefinitionTemplate(context()); + + pdt.setAutoCreated(propertyDefinition.isAutoCreated()); + pdt.setAvailableQueryOperators(propertyDefinition.getAvailableQueryOperators()); + pdt.setDefaultValues(propertyDefinition.getDefaultValues()); + pdt.setFullTextSearchable(propertyDefinition.isFullTextSearchable()); + pdt.setMandatory(propertyDefinition.isMandatory()); + pdt.setMultiple(propertyDefinition.isMultiple()); + pdt.setName(propertyDefinition.getName()); + pdt.setOnParentVersion(propertyDefinition.getOnParentVersion()); + pdt.setProtected(propertyDefinition.isProtected()); + pdt.setQueryOrderable(propertyDefinition.isQueryOrderable()); + pdt.setRequiredType(propertyDefinition.getRequiredType()); + pdt.setValueConstraints(propertyDefinition.getValueConstraints()); + + ntt.getPropertyDefinitionTemplates().add(pdt); + } } return ntt; Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeTemplate.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeTemplate.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrNodeTypeTemplate.java (working copy) @@ -25,12 +25,14 @@ package org.modeshape.jcr; import java.util.ArrayList; import java.util.List; +import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.nodetype.NodeDefinition; import javax.jcr.nodetype.PropertyDefinition; import net.jcip.annotations.NotThreadSafe; import org.modeshape.common.util.CheckArg; import org.modeshape.graph.ExecutionContext; import org.modeshape.graph.property.Name; +import org.modeshape.graph.property.ValueFormatException; import org.modeshape.jcr.nodetype.NodeDefinitionTemplate; import org.modeshape.jcr.nodetype.NodeTypeDefinition; import org.modeshape.jcr.nodetype.NodeTypeTemplate; @@ -45,6 +47,7 @@ public class JcrNodeTypeTemplate implements NodeTypeDefinition, NodeTypeTemplate private final ExecutionContext context; private final List nodeDefinitionTemplates = new ArrayList(); private final List propertyDefinitionTemplates = new ArrayList(); + private final boolean createdFromExistingDefinition; private boolean isAbstract; private boolean queryable = true; private boolean mixin; @@ -54,9 +57,15 @@ public class JcrNodeTypeTemplate implements NodeTypeDefinition, NodeTypeTemplate private Name primaryItemName; JcrNodeTypeTemplate( ExecutionContext context ) { + this(context, false); + } + + JcrNodeTypeTemplate( ExecutionContext context, + boolean createdFromExistingDefinition ) { assert context != null; this.context = context; + this.createdFromExistingDefinition = createdFromExistingDefinition; } ExecutionContext getExecutionContext() { @@ -68,6 +77,10 @@ public class JcrNodeTypeTemplate implements NodeTypeDefinition, NodeTypeTemplate return name.getString(context.getNamespaceRegistry()); } + Name[] declaredSupertypeNames() { + return this.declaredSupertypeNames; + } + /** * {@inheritDoc} * @@ -96,28 +109,24 @@ public class JcrNodeTypeTemplate implements NodeTypeDefinition, NodeTypeTemplate } /** - * @param names the names of the supertypes - * @see org.modeshape.jcr.nodetype.NodeTypeTemplate#setDeclaredSupertypeNames(java.lang.String[]) - * @deprecated Use {@link #setDeclaredSuperTypeNames(String[])} instead - */ - @SuppressWarnings( "dep-ann" ) - public void setDeclaredSupertypeNames( String[] names ) { - setDeclaredSuperTypeNames(names); - } - - /** * 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 ) { - CheckArg.isNotNull(names, "names"); + public void setDeclaredSuperTypeNames( String[] names ) throws ConstraintViolationException { + if (names == null) { + throw new ConstraintViolationException(); + } Name[] supertypeNames = new Name[names.length]; for (int i = 0; i < names.length; i++) { CheckArg.isNotEmpty(names[i], "names[" + i + ""); - supertypeNames[i] = context.getValueFactories().getNameFactory().create(names[i]); + try { + supertypeNames[i] = context.getValueFactories().getNameFactory().create(names[i]); + } catch (ValueFormatException vfe) { + throw new ConstraintViolationException(vfe); + } } this.declaredSupertypeNames = supertypeNames; } @@ -136,9 +145,13 @@ public class JcrNodeTypeTemplate implements NodeTypeDefinition, NodeTypeTemplate * * @see org.modeshape.jcr.nodetype.NodeTypeTemplate#setName(java.lang.String) */ - public void setName( String name ) { + public void setName( String name ) throws ConstraintViolationException { CheckArg.isNotEmpty(name, "name"); - this.name = context.getValueFactories().getNameFactory().create(name); + try { + this.name = context.getValueFactories().getNameFactory().create(name); + } catch (ValueFormatException vfe) { + throw new ConstraintViolationException(vfe); + } } /** @@ -156,49 +169,34 @@ public class JcrNodeTypeTemplate implements NodeTypeDefinition, NodeTypeTemplate * @see org.modeshape.jcr.nodetype.NodeTypeDefinition#getPrimaryItemName() * type.NodeTypeTemplate#setPrimaryItemName(java.lang.String) */ - public void setPrimaryItemName( String name ) { - this.primaryItemName = context.getValueFactories().getNameFactory().create(name); - } - - /** - * @return the list of node definitions - * @see org.modeshape.jcr.nodetype.NodeTypeDefinition#getDeclaredNodeDefinitions() - * @deprecated use {@link #getDeclaredChildNodeDefinitions()} instead - */ - @SuppressWarnings( "dep-ann" ) - public NodeDefinition[] getDeclaredNodeDefinitions() { - return getDeclaredChildNodeDefinitions(); + public void setPrimaryItemName( String name ) throws ConstraintViolationException { + try { + this.primaryItemName = context.getValueFactories().getNameFactory().create(name); + } catch (ValueFormatException vfe) { + throw new ConstraintViolationException(vfe); + } } /** - * Get the array of child node definition templates for this node type. This method always returns null from a {@code - * JcrNodeTypeTemplate}, as the method is only meaningful for registered types. + * {@inheritDoc} * - * @return null always + * @see NodeTypeDefinition#getDeclaredChildNodeDefinitions() */ public NodeDefinition[] getDeclaredChildNodeDefinitions() { - return null; + if (!createdFromExistingDefinition && nodeDefinitionTemplates.isEmpty()) return null; + + return nodeDefinitionTemplates.toArray(new NodeDefinition[nodeDefinitionTemplates.size()]); } /** - * {@inheritDoc} This method always returns null from a {@code JcrNodeTypeTemplate}, as the method is only meaningful for - * registered types. + * {@inheritDoc} * - * @return null always * @see org.modeshape.jcr.nodetype.NodeTypeDefinition#getDeclaredPropertyDefinitions() */ public PropertyDefinition[] getDeclaredPropertyDefinitions() { - return null; - } + if (!createdFromExistingDefinition && propertyDefinitionTemplates.isEmpty()) return null; - /** - * @return the names of the declared supertypes - * @see org.modeshape.jcr.nodetype.NodeTypeDefinition#getDeclaredSupertypes() - * @deprecated Use {@link #getDeclaredSupertypeNames()} instead - */ - @Deprecated - public String[] getDeclaredSupertypes() { - return getDeclaredSupertypeNames(); + return propertyDefinitionTemplates.toArray(new PropertyDefinition[propertyDefinitionTemplates.size()]); } /** Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrPropertyDefinitionTemplate.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrPropertyDefinitionTemplate.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrPropertyDefinitionTemplate.java (working copy) @@ -89,8 +89,10 @@ class JcrPropertyDefinitionTemplate extends JcrItemDefinitionTemplate implements */ 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.DOUBLE || requiredType == PropertyType.DECIMAL + || requiredType == PropertyType.LONG || requiredType == PropertyType.NAME || requiredType == PropertyType.PATH + || requiredType == PropertyType.REFERENCE || requiredType == PropertyType.WEAKREFERENCE + || requiredType == PropertyType.URI || requiredType == PropertyType.STRING || requiredType == PropertyType.UNDEFINED; this.requiredType = requiredType; } Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java (working copy) @@ -557,7 +557,7 @@ public class JcrRepository implements Repository { // this.repositoryTypeManager = new RepositoryNodeTypeManager(this, includeInheritedProperties); this.repositoryTypeManager = new RepositoryNodeTypeManager(this, includeInheritedProperties); this.repositoryTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] { - "/org/modeshape/jcr/jsr_170_builtins.cnd", "/org/modeshape/jcr/dna_builtins.cnd"})); + "/org/modeshape/jcr/jsr_283_builtins.cnd", "/org/modeshape/jcr/dna_builtins.cnd"})); } catch (RepositoryException re) { re.printStackTrace(); throw new IllegalStateException("Could not load node type definition files", re); Index: modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTemplateNodeTypeSource.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTemplateNodeTypeSource.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTemplateNodeTypeSource.java (working copy) @@ -166,12 +166,11 @@ class NodeTemplateNodeTypeSource implements JcrNodeTypeSource { * @return the path to the newly created node * @throws InvalidNodeTypeDefinitionException */ - @SuppressWarnings( "deprecation" ) protected Path createNodeType( JcrNodeTypeTemplate nodeType, Path parentPath ) throws InvalidNodeTypeDefinitionException { Name name = nameFrom(nodeType.getName()); - Name[] supertypes = namesFrom(nodeType.getDeclaredSupertypes()); + Name[] supertypes = namesFrom(nodeType.declaredSupertypeNames()); boolean isAbstract = booleanFrom(nodeType.isAbstract(), false); boolean hasOrderableChildNodes = booleanFrom(nodeType.hasOrderableChildNodes(), false); boolean isMixin = booleanFrom(nodeType.isMixin(), false); Index: modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTypeSchemata.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTypeSchemata.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTypeSchemata.java (working copy) @@ -102,12 +102,15 @@ class NodeTypeSchemata implements Schemata { types.put(PropertyType.BINARY, typeSystem.getBinaryFactory().getTypeName()); types.put(PropertyType.BOOLEAN, typeSystem.getBooleanFactory().getTypeName()); types.put(PropertyType.DATE, typeSystem.getDateTimeFactory().getTypeName()); + types.put(PropertyType.DECIMAL, typeSystem.getDecimalFactory().getTypeName()); types.put(PropertyType.DOUBLE, typeSystem.getDoubleFactory().getTypeName()); types.put(PropertyType.LONG, typeSystem.getLongFactory().getTypeName()); types.put(PropertyType.PATH, typeSystem.getPathFactory().getTypeName()); types.put(PropertyType.REFERENCE, typeSystem.getReferenceFactory().getTypeName()); + types.put(PropertyType.WEAKREFERENCE, typeSystem.getReferenceFactory().getTypeName()); types.put(PropertyType.STRING, typeSystem.getStringFactory().getTypeName()); types.put(PropertyType.NAME, typeSystem.getStringFactory().getTypeName()); + types.put(PropertyType.URI, typeSystem.getStringFactory().getTypeName()); // Create the "ALLNODES" table, which will contain all possible properties ... IndexRules.Builder indexRulesBuilder = IndexRules.createBuilder(LuceneSearchEngine.DEFAULT_RULES); @@ -163,6 +166,7 @@ class NodeTypeSchemata implements Schemata { boolean canBeReference = false; switch (defn.getRequiredType()) { case PropertyType.REFERENCE: + case PropertyType.WEAKREFERENCE: case PropertyType.UNDEFINED: canBeReference = true; } Index: modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryNodeTypeManager.java (working copy) @@ -100,13 +100,16 @@ class RepositoryNodeTypeManager { 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_DECIMAL.toUpperCase(), PropertyType.DECIMAL); 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_WEAKREFERENCE.toUpperCase(), PropertyType.WEAKREFERENCE); temp.put(PropertyType.TYPENAME_UNDEFINED.toUpperCase(), PropertyType.UNDEFINED); + temp.put(PropertyType.TYPENAME_URI.toUpperCase(), PropertyType.URI); PROPERTY_TYPE_VALUES_FROM_NAME = Collections.unmodifiableMap(temp); } Index: modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeDefinitionTemplate.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeDefinitionTemplate.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeDefinitionTemplate.java (working copy) @@ -23,8 +23,7 @@ */ package org.modeshape.jcr.nodetype; -import javax.jcr.Node; -import javax.jcr.version.OnParentVersionAction; +import javax.jcr.nodetype.ConstraintViolationException; import net.jcip.annotations.NotThreadSafe; /** @@ -38,61 +37,24 @@ import net.jcip.annotations.NotThreadSafe; public interface NodeDefinitionTemplate extends javax.jcr.nodetype.NodeDefinitionTemplate { /** - * 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 + * @throws ConstraintViolationException if any of the requiredPrimaryTypes are not a syntactically valid JCR name + * in either qualified or expanded form. + * @deprecated Use {@link #setRequiredPrimaryTypeNames(String[])} instead */ - public void setRequiredPrimaryTypes( String[] requiredPrimaryTypes ); + public void setRequiredPrimaryTypes( String[] requiredPrimaryTypes ) throws ConstraintViolationException; /** * 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 + * @throws ConstraintViolationException if defaultPrimaryType is not a syntactically valid JCR name in either + * qualified or expanded form. + * @deprecated Use {@link #setDefaultPrimaryTypeName(String)} instead */ - 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 ); + public void setDefaultPrimaryType( String defaultPrimaryType ) throws ConstraintViolationException; } Index: modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeTypeDefinition.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeTypeDefinition.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeTypeDefinition.java (working copy) @@ -23,8 +23,6 @@ */ package org.modeshape.jcr.nodetype; -import javax.jcr.nodetype.NodeDefinition; -import javax.jcr.nodetype.PropertyDefinition; import net.jcip.annotations.NotThreadSafe; /** @@ -32,77 +30,5 @@ import net.jcip.annotations.NotThreadSafe; * href="http://jcp.org/en/jsr/detail?id=283">JSR-283. */ @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 the direct supertypes for this node type. - * - * @return the names of the direct supertypes, or an empty array if there are none - */ - public String[] getDeclaredSupertypeNames(); - - /** - * 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 abstract. - * - * @return true if this node type is abstract, or false if it is concrete - */ - public boolean isQueryable(); - - /** - * 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(); +public interface NodeTypeDefinition extends javax.jcr.nodetype.NodeTypeDefinition { } Index: modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeTypeTemplate.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeTypeTemplate.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/NodeTypeTemplate.java (working copy) @@ -23,7 +23,6 @@ */ package org.modeshape.jcr.nodetype; -import java.util.List; import net.jcip.annotations.NotThreadSafe; /** @@ -34,75 +33,4 @@ import net.jcip.annotations.NotThreadSafe; @NotThreadSafe public interface NodeTypeTemplate extends javax.jcr.nodetype.NodeTypeTemplate { - /** - * 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 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 ); - - /** - * Sets whether this node is queryable - * - * @param queryable true if the node should be included in query results; false otherwise - */ - public void setQueryable( boolean queryable ); - - /** - * 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 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 getNodeDefinitionTemplates(); - } Index: modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/PropertyDefinitionTemplate.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/PropertyDefinitionTemplate.java (revision 1866) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/nodetype/PropertyDefinitionTemplate.java (working copy) @@ -23,10 +23,7 @@ */ package org.modeshape.jcr.nodetype; -import javax.jcr.PropertyType; -import javax.jcr.Value; import javax.jcr.nodetype.PropertyDefinition; -import javax.jcr.version.OnParentVersionAction; import net.jcip.annotations.NotThreadSafe; /** @@ -40,117 +37,13 @@ import net.jcip.annotations.NotThreadSafe; public interface PropertyDefinitionTemplate extends javax.jcr.nodetype.PropertyDefinitionTemplate { /** - * 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 + * @deprecated Use {@link #setDefaultValues(javax.jcr.Value[])} instead */ public void setDefaultValues( String[] defaultValues ); - /** - * Set the default values for the property, using their {link Value} representation. See - * {@link PropertyDefinition#getDefaultValues()} for more details. - * - * @param values the value representation of the default values, or null or an empty array if there are no default values - */ - public void setDefaultValues( Value[] values ); - - /** - * 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 ); - - /** - * @return whether the properties described by this definition should be searchable in a full-text search - */ - public boolean isFullTextSearchable(); - - /** - * Set whether the properties described by this definition should be searchable in a full-text search - * - * @param fullTextSearchable whether the properties described by this definition should be searchable in a full-text search - */ - public void setFullTextSearchable( boolean fullTextSearchable ); - - /** - * @return whether the query results containing properties described by this definition should be able to be ordered by those - * properties. - */ - public boolean isQueryOrderable(); - - /** - * Set whether the query results containing properties described by this definition should be able to be ordered by those - * properties. - * - * @param queryOrderable whether the query results containing properties described by this definition should be able to be - * ordered by those properties. - */ - public void setQueryOrderable( boolean queryOrderable ); - - /** - * @return the available operators for use in property constraints that reference properties described by this definition. - */ - public String[] getAvailableQueryOperators(); - - /** - * Sets the available operators for use in property constraints that reference properties described by this definition. - * - * @param queryOperators the available operators for use in property constraints that reference properties described by this - * definition. - */ - public void setAvailableQueryOperators( String[] queryOperators ); } Index: modeshape-jcr/src/main/resources/org/modeshape/jcr/jsr_283_builtins.cnd =================================================================== --- modeshape-jcr/src/main/resources/org/modeshape/jcr/jsr_283_builtins.cnd (revision 1866) +++ modeshape-jcr/src/main/resources/org/modeshape/jcr/jsr_283_builtins.cnd (working copy) @@ -93,10 +93,9 @@ - jcr:defaultPrimaryType (name) protected - jcr:sameNameSiblings (boolean) mandatory protected -/* Need full support for weakreference type for jcr:copiedFrom property */ [nt:versionHistory] > mix:referenceable - jcr:versionableUuid (string) mandatory autocreated protected abort - - jcr:copiedFrom (reference) protected abort < 'nt:version' + - jcr:copiedFrom (weakreference) protected abort < 'nt:version' + jcr:rootVersion (nt:version) = nt:version mandatory autocreated protected abort + jcr:versionLabels (nt:versionLabels) = nt:versionLabels mandatory autocreated protected abort + * (nt:version) = nt:version protected abort @@ -146,7 +145,6 @@ [nt:configuration] > mix:versionable - jcr:root (reference) mandatory autocreated protected -/* Need full support for weakreference type to use this [nt:address] - jcr:protocol (string) - jcr:host (string) @@ -155,7 +153,6 @@ - jcr:workspace (string) - jcr:path (path) - jcr:id (weakreference) -*/ [nt:naturalText] - jcr:text (string) Index: modeshape-jcr/src/test/java/org/modeshape/jcr/JcrNodeTypeManagerTest.java =================================================================== --- modeshape-jcr/src/test/java/org/modeshape/jcr/JcrNodeTypeManagerTest.java (revision 1866) +++ modeshape-jcr/src/test/java/org/modeshape/jcr/JcrNodeTypeManagerTest.java (working copy) @@ -202,7 +202,7 @@ public final class JcrNodeTypeManagerTest extends TestSuite { testNode.addNode("hierarchyNode", "nt:folder"); // This residual definition comes from mgnl:content - testNode.addNode("baseNode", "nt:base"); + testNode.addNode("baseNode", "nt:unstructured"); session.save(); } Index: modeshape-jcr/src/test/java/org/modeshape/jcr/JcrObservationManagerTest.java =================================================================== --- modeshape-jcr/src/test/java/org/modeshape/jcr/JcrObservationManagerTest.java (revision 1866) +++ modeshape-jcr/src/test/java/org/modeshape/jcr/JcrObservationManagerTest.java (working copy) @@ -60,14 +60,14 @@ import org.apache.jackrabbit.test.api.observation.PropertyAddedTest; import org.apache.jackrabbit.test.api.observation.PropertyChangedTest; import org.apache.jackrabbit.test.api.observation.PropertyRemovedTest; import org.apache.jackrabbit.test.api.observation.WorkspaceOperationTest; -import org.modeshape.graph.connector.inmemory.InMemoryRepositorySource; -import org.modeshape.jcr.JcrRepository.Option; import org.jboss.security.config.IDTrustConfiguration; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import org.modeshape.graph.connector.inmemory.InMemoryRepositorySource; +import org.modeshape.jcr.JcrRepository.Option; /** * The {@link JcrObservationManager} test class. @@ -1432,7 +1432,7 @@ public final class JcrObservationManagerTest extends TestSuite { // trigger events String node3 = "node3"; - Node n3 = n1.addNode(node3, NT_BASE); + Node n3 = n1.addNode(node3, UNSTRUCTURED); n2.addNode(node3, UNSTRUCTURED); save(); Index: modeshape-jcr/src/test/java/org/modeshape/jcr/JcrTckTest.java =================================================================== --- modeshape-jcr/src/test/java/org/modeshape/jcr/JcrTckTest.java (revision 1866) +++ modeshape-jcr/src/test/java/org/modeshape/jcr/JcrTckTest.java (working copy) @@ -99,7 +99,6 @@ import org.apache.jackrabbit.test.api.WorkspaceMoveSameNameSibsTest; import org.apache.jackrabbit.test.api.WorkspaceMoveTest; import org.apache.jackrabbit.test.api.WorkspaceMoveVersionableTest; import org.apache.jackrabbit.test.api.WorkspaceReadMethodsTest; -import org.apache.jackrabbit.test.api.nodetype.CanAddChildNodeCallWithNodeTypeTest; import org.apache.jackrabbit.test.api.nodetype.CanAddChildNodeCallWithoutNodeTypeTest; import org.apache.jackrabbit.test.api.nodetype.CanRemoveItemTest; import org.apache.jackrabbit.test.api.nodetype.CanSetPropertyBinaryTest; @@ -113,8 +112,10 @@ import org.apache.jackrabbit.test.api.nodetype.CanSetPropertyPathTest; import org.apache.jackrabbit.test.api.nodetype.CanSetPropertyStringTest; import org.apache.jackrabbit.test.api.nodetype.CanSetPropertyTest; import org.apache.jackrabbit.test.api.nodetype.NodeDefTest; +import org.apache.jackrabbit.test.api.nodetype.NodeTypeCreationTest; import org.apache.jackrabbit.test.api.nodetype.NodeTypeManagerTest; import org.apache.jackrabbit.test.api.nodetype.NodeTypeTest; +import org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest; import org.apache.jackrabbit.test.api.nodetype.PropertyDefTest; import org.apache.jackrabbit.test.api.observation.AddEventListenerTest; import org.apache.jackrabbit.test.api.observation.EventIteratorTest; @@ -241,7 +242,7 @@ public class JcrTckTest { suite.addTestSuite(NodeTypeTest.class); suite.addTestSuite(PropertyDefTest.class); - // suite.addTestSuite(PredefinedNodeTypeTest.class); + suite.addTestSuite(PredefinedNodeTypeTest.class); suite.addTestSuite(CanSetPropertyBinaryTest.class); suite.addTestSuite(CanSetPropertyBooleanTest.class); @@ -254,14 +255,13 @@ public class JcrTckTest { suite.addTestSuite(CanSetPropertyStringTest.class); suite.addTestSuite(CanSetPropertyTest.class); - suite.addTestSuite(CanAddChildNodeCallWithNodeTypeTest.class); + // suite.addTestSuite(CanAddChildNodeCallWithNodeTypeTest.class); suite.addTestSuite(CanAddChildNodeCallWithoutNodeTypeTest.class); suite.addTestSuite(CanRemoveItemTest.class); // JCR 2.0 - - // suite.addTestSuite(NodeTypeCreationTest.class); + suite.addTestSuite(NodeTypeCreationTest.class); return suite; } Index: modeshape-jcr/src/test/java/org/modeshape/jcr/TypeRegistrationTest.java =================================================================== --- modeshape-jcr/src/test/java/org/modeshape/jcr/TypeRegistrationTest.java (revision 1866) +++ modeshape-jcr/src/test/java/org/modeshape/jcr/TypeRegistrationTest.java (working copy) @@ -837,9 +837,9 @@ public class TypeRegistrationTest extends AbstractSessionTest { 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], is(nodeType.getDeclaredSupertypes()[i].getName())); + assertThat(nodeType.getDeclaredSupertypes().length, is(template.getDeclaredSupertypeNames().length)); + for (int i = 0; i < template.getDeclaredSupertypeNames().length; i++) { + assertThat(template.getDeclaredSupertypeNames()[i], is(nodeType.getDeclaredSupertypes()[i].getName())); } assertThat(template.isMixin(), is(nodeType.isMixin())); assertThat(template.hasOrderableChildNodes(), is(nodeType.hasOrderableChildNodes()));