You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/05/13 14:43:20 UTC

svn commit: r774294 [1/2] - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/j...

Author: angela
Date: Wed May 13 12:43:19 2009
New Revision: 774294

URL: http://svn.apache.org/viewvc?rev=774294&view=rev
Log:
JCR-2105: JSR 283 NodeType Management (work in progress)
JCR-1483: Move common node type functionality to jackrabbit-spi-commons

NOTE: intermediate checkin to avoid additional conflicts with stefans work

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ItemDefinitionImpl.java   (contents, props changed)
      - copied, changed from r773904, jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java
Removed:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/InvalidNodeTypeDefException.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java Wed May 13 12:43:19 2009
@@ -509,46 +509,6 @@
 
     //--------------------------------------------------< new JSR 283 methods >
     /**
-     * Registers a new node type or updates an existing node type using the
-     * specified definition and returns the resulting <code>NodeType</code>
-     * object.
-     * <p/>
-     * Typically, the object passed to this method will be a
-     * <code>NodeTypeTemplate</code> (a subclass of
-     * <code>NodeTypeDefinition</code>) acquired from
-     * <code>NodeTypeManager.createNodeTypeTemplate</code> and then filled-in
-     * with definition information.
-     * <p/>
-     * Throws an <code>InvalidNodeTypeDefinitionException</code> if the
-     * <code>NodeTypeDefinition</code> is invalid.
-     * <p/>
-     * Throws a <code>NodeTypeExistsException</code> if <code>allowUpdate</code>
-     * is <code>false</code> and the <code>NodeTypeDefinition</code> specifies a
-     * node type name that is already registered.
-     * <p/>
-     * Throws an <code>UnsupportedRepositoryOperationException</code> if this
-     * implementation does not support node type registration.
-     *
-     * @param ntd an <code>NodeTypeDefinition</code>.
-     * @param allowUpdate a boolean
-     * @return the registered node type
-     * @throws InvalidNodeTypeDefinitionException if the
-     *  <code>NodeTypeDefinition</code> is invalid.
-     * @throws NodeTypeExistsException if <code>allowUpdate</code> is
-     *  <code>false</code> and the <code>NodeTypeDefinition</code> specifies a
-     *  node type name that is already registered.
-     * @throws UnsupportedRepositoryOperationException if this implementation
-     *  does not support node type registration.
-     * @throws RepositoryException if another error occurs.
-     * @since JCR 2.0
-     */
-    public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
-            throws RepositoryException {
-        NodeTypeDefinition[] ntds = new NodeTypeDefinition[] { ntd };
-        return registerNodeTypes(ntds, allowUpdate).nextNodeType();
-    }
-
-    /**
      * Registers or updates the specified <code>Collection</code> of
      * <code>NodeTypeDefinition</code> objects. This method is used to register
      * or update a set of node types with mutual dependencies. Returns an
@@ -629,26 +589,6 @@
     }
 
     /**
-     * Unregisters the specified node type.
-     * <p/>
-     * Throws a <code>NoSuchNodeTypeException</code> if no registered node type
-     * exists with the specified name.
-     *
-     * @param name a <code>String</code>.
-     * @throws UnsupportedRepositoryOperationException if this implementation
-     *  does not support node type registration.
-     * @throws NoSuchNodeTypeException if no registered node type exists with
-     *  the specified name.
-     * @throws RepositoryException if another error occurs.
-     * @since JCR 2.0
-     */
-    public void unregisterNodeType(String name)
-            throws UnsupportedRepositoryOperationException,
-            NoSuchNodeTypeException, RepositoryException {
-        unregisterNodeTypes(new String[] {name});
-    }
-
-    /**
      * Unregisters the specified set of node types. Used to unregister a set of node types with mutual dependencies.
      * <p/>
      * Throws a <code>NoSuchNodeTypeException</code> if one of the names listed is not a registered node type.

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java Wed May 13 12:43:19 2009
@@ -41,57 +41,57 @@
     private final int onParentVersion;
 
     ItemDefinitionImpl(ItemDefinition definition) {
-	if (definition == null) {
+        if (definition == null) {
             throw new IllegalArgumentException("PropDef argument can not be null");
         }
         name = definition.getName();
-	declaringNodeType = definition.getDeclaringNodeType();
-	isAutoCreated = definition.isAutoCreated();
-	isMandatory = definition.isMandatory();
-	isProtected = definition.isProtected();
-	onParentVersion = definition.getOnParentVersion();
+        declaringNodeType = definition.getDeclaringNodeType();
+        isAutoCreated = definition.isAutoCreated();
+        isMandatory = definition.isMandatory();
+        isProtected = definition.isProtected();
+        onParentVersion = definition.getOnParentVersion();
     }
 
     /**
      * @see ItemDefinition#getDeclaringNodeType()
      */
     public NodeType getDeclaringNodeType() {
-	return declaringNodeType;
+        return declaringNodeType;
     }
 
     /**
      * @see ItemDefinition#getName()
      */
     public String getName() {
-	return name;
+        return name;
     }
 
     /**
      * @see ItemDefinition#isAutoCreated()
      */
     public boolean isAutoCreated() {
-	return isAutoCreated;
+        return isAutoCreated;
     }
 
     /**
      * @see ItemDefinition#isMandatory()
      */
     public boolean isMandatory() {
-	return isMandatory;
+        return isMandatory;
     }
 
     /**
      * @see ItemDefinition#getOnParentVersion()
      */
     public int getOnParentVersion() {
-	return onParentVersion;
+        return onParentVersion;
     }
 
     /**
      * @see ItemDefinition#isProtected()
      */
     public boolean isProtected() {
-	return isProtected;
+        return isProtected;
     }
 
     //------------------------------------------< XmlSerializable interface >---

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java Wed May 13 12:43:19 2009
@@ -37,34 +37,34 @@
     private final boolean allowsSameNameSiblings;
 
     private NodeDefinitionImpl(NodeDefinition definition) {
-	super(definition);
+        super(definition);
 
-	requiredPrimaryTypes = definition.getRequiredPrimaryTypes();
-	defaultPrimaryType = definition.getDefaultPrimaryType();
-	allowsSameNameSiblings = definition.allowsSameNameSiblings();
+        requiredPrimaryTypes = definition.getRequiredPrimaryTypes();
+        defaultPrimaryType = definition.getDefaultPrimaryType();
+        allowsSameNameSiblings = definition.allowsSameNameSiblings();
     }
 
     public static NodeDefinitionImpl create(NodeDefinition definition) {
-	if (definition instanceof NodeDefinitionImpl) {
-	    return (NodeDefinitionImpl) definition;
-	} else {
-	    return new NodeDefinitionImpl(definition);
-	}
+        if (definition instanceof NodeDefinitionImpl) {
+            return (NodeDefinitionImpl) definition;
+        } else {
+            return new NodeDefinitionImpl(definition);
+        }
     }
 
-    //--------------------------------------------------< NodeDef interface >---
+    //-----------------------------------------------------< NodeDefinition >---
     /**
      * @see javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes()
      */
     public NodeType[] getRequiredPrimaryTypes() {
-	return requiredPrimaryTypes;
+        return requiredPrimaryTypes;
     }
 
     /**
      * @see javax.jcr.nodetype.NodeDefinition#getDefaultPrimaryType()
      */
     public NodeType getDefaultPrimaryType() {
-	return defaultPrimaryType;
+        return defaultPrimaryType;
     }
 
     /**
@@ -74,12 +74,22 @@
         return allowsSameNameSiblings;
     }
 
+    /**
+     * @see javax.jcr.nodetype.NodeDefinition#getDefaultPrimaryTypeName()
+     */
     public String getDefaultPrimaryTypeName() {
-        throw new UnsupportedOperationException("JCR-1591");
+        return defaultPrimaryType.getName();
     }
 
+    /**
+     * @see javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypeNames()
+     */
     public String[] getRequiredPrimaryTypeNames() {
-        throw new UnsupportedOperationException("JCR-1591");
+        String[] names = new String[requiredPrimaryTypes.length];
+        for (int i = 0; i < requiredPrimaryTypes.length; i++) {
+            names[i] = requiredPrimaryTypes[i].getName();
+        }
+        return names;
     }
 
     //-------------------------------------< implementation specific method >---
@@ -100,12 +110,12 @@
         // reqPrimaryTypes: minimal set is nt:base.
         NodeType[] nts = getRequiredPrimaryTypes();
         Element reqPrimaryTypes = document.createElement(REQUIREDPRIMARYTYPES_ELEMENT);
-	for (int i = 0; i < nts.length; i++) {
+        for (int i = 0; i < nts.length; i++) {
             Element rptElem = document.createElement(REQUIREDPRIMARYTYPE_ELEMENT);
             DomUtil.setText(rptElem, nts[i].getName());
-	    reqPrimaryTypes.appendChild(rptElem);
+            reqPrimaryTypes.appendChild(rptElem);
 
-	}
+        }
         elem.appendChild(reqPrimaryTypes);
         return elem;
     }
@@ -116,7 +126,7 @@
      * @return always returns {@link #CHILDNODEDEFINITION_ELEMENT}.
      */
     String getElementName() {
-	return CHILDNODEDEFINITION_ELEMENT;
+        return CHILDNODEDEFINITION_ELEMENT;
     }
 
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java Wed May 13 12:43:19 2009
@@ -112,6 +112,30 @@
     /** Name of the <code>sameNameSiblings</code> attribute. */
     String SAMENAMESIBLINGS_ATTRIBUTE = "sameNameSiblings";
 
+    /**
+     * Name of the availableQueryOperators element.
+     * @since JCR 2.0
+     */
+    String AVAILABLE_QUERY_OPERATORS_ELEMENT = "availableQueryOperators";
+
+    /**
+     * Name of the availableQueryOperator element.
+     * @since JCR 2.0
+     */
+    String AVAILABLE_QUERY_OPERATOR_ELEMENT = "availableQueryOperator";
+
+    /**
+     * Name of the fullTextSearchable attribute.
+     * @since JCR 2.0
+     */
+    String FULL_TEXT_SEARCHABLE_ATTRIBUTE = "fullTextSearchable";
+
+    /**
+     * Name of the queryOrderable attribute.
+     * @since JCR 2.0
+     */
+    String QUERY_ORDERABLE_ATTRIBUTE = "queryOrderable";
+
     //----------< attr. not defined by copied from o.a.j.core.n.x.Constants >---
     /**
      * Name of the declaring nodetype. This value is not needed during

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/PropertyDefinitionImpl.java Wed May 13 12:43:19 2009
@@ -38,22 +38,28 @@
     private final String[] valueConstraints;
     private final Value[] defaultValues;
     private final boolean isMultiple;
+    private final String[] availableQueryOperators;
+    private final boolean isFullTextSearchable;
+    private final boolean isQueryOrderable;
 
     private PropertyDefinitionImpl(PropertyDefinition definition) {
-	super(definition);
+        super(definition);
 
-	type = definition.getRequiredType();
-	valueConstraints = definition.getValueConstraints();
-	defaultValues = definition.getDefaultValues();
-	isMultiple = definition.isMultiple();
+        type = definition.getRequiredType();
+        valueConstraints = definition.getValueConstraints();
+        defaultValues = definition.getDefaultValues();
+        isMultiple = definition.isMultiple();
+        availableQueryOperators = definition.getAvailableQueryOperators();
+        isFullTextSearchable = definition.isFullTextSearchable();
+        isQueryOrderable = definition.isQueryOrderable();
     }
 
     public static PropertyDefinitionImpl create(PropertyDefinition definition) {
-	if (definition instanceof PropertyDefinitionImpl) {
-	    return (PropertyDefinitionImpl)definition;
-	} else {
-	    return new PropertyDefinitionImpl(definition);
-	}
+        if (definition instanceof PropertyDefinitionImpl) {
+            return (PropertyDefinitionImpl)definition;
+        } else {
+            return new PropertyDefinitionImpl(definition);
+        }
     }
 
     //----------------------------------------< PropertyDefintion interface >---
@@ -61,40 +67,49 @@
      * @see PropertyDefinition#getRequiredType()
      */
     public int getRequiredType() {
-	return type;
+        return type;
     }
 
     /**
      * @see PropertyDefinition#getValueConstraints()
      */
     public String[] getValueConstraints() {
-	return valueConstraints;
+        return valueConstraints;
     }
 
     /**
      * @see PropertyDefinition#getDefaultValues()
      */
     public Value[] getDefaultValues() {
-	return defaultValues;
+        return defaultValues;
     }
 
     /**
      * @see PropertyDefinition#isMultiple()
      */
     public boolean isMultiple() {
-	return isMultiple;
+        return isMultiple;
     }
 
+    /**
+     * @see PropertyDefinition#getAvailableQueryOperators()
+     */
     public String[] getAvailableQueryOperators() {
-        throw new UnsupportedOperationException("JCR-2091");
+        return availableQueryOperators;
     }
 
+    /**
+     * @see PropertyDefinition#isFullTextSearchable()
+     */
     public boolean isFullTextSearchable() {
-        throw new UnsupportedOperationException("JCR-2091");
+        return isFullTextSearchable;
     }
 
+    /**
+     * @see PropertyDefinition#isQueryOrderable()
+     */
     public boolean isQueryOrderable() {
-        throw new UnsupportedOperationException("JCR-2091");
+        return isQueryOrderable;
     }
 
     //-------------------------------------< implementation specific method >---
@@ -105,11 +120,15 @@
      * @param document
      */
     public Element toXml(Document document) {
-	Element elem = super.toXml(document);
+        Element elem = super.toXml(document);
 
         elem.setAttribute(MULTIPLE_ATTRIBUTE, Boolean.toString(isMultiple()));
         elem.setAttribute(REQUIREDTYPE_ATTRIBUTE, PropertyType.nameFromValue(getRequiredType()));
 
+        // JCR 2.0 extensions
+        elem.setAttribute(FULL_TEXT_SEARCHABLE_ATTRIBUTE, Boolean.toString(isFullTextSearchable()));
+        elem.setAttribute(QUERY_ORDERABLE_ATTRIBUTE, Boolean.toString(isQueryOrderable()));
+
         // default values may be 'null'
         Value[] values = getDefaultValues();
         if (values != null) {
@@ -136,6 +155,15 @@
         }
         elem.appendChild(constrElem);
 
+        // JCR 2.0 extension
+        Element qopElem = document.createElement(AVAILABLE_QUERY_OPERATORS_ELEMENT);
+        String[] qops = getAvailableQueryOperators();
+        for (int i = 0; i < qops.length; i++) {
+            Element opElem = document.createElement(AVAILABLE_QUERY_OPERATOR_ELEMENT);
+            DomUtil.setText(opElem, qops[i]);
+            qopElem.appendChild(opElem);
+        }
+
         return elem;
     }
 
@@ -145,7 +173,6 @@
      * @return always returns {@link #PROPERTYDEFINITION_ELEMENT}
      */
     String getElementName() {
-	return PROPERTYDEFINITION_ELEMENT;
+        return PROPERTYDEFINITION_ELEMENT;
     }
-
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Wed May 13 12:43:19 2009
@@ -441,14 +441,11 @@
             public Iterator getDefinitions(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException {
                 return service.getQNodeTypeDefinitions(sessionInfo, nodeTypeNames);
             }
-            public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs) throws NoSuchNodeTypeException, RepositoryException {
-                throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
-            }
-            public void reregisterNodeTypes(QNodeTypeDefinition[] nodeTypeDefs) throws NoSuchNodeTypeException, RepositoryException {
-                throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
+            public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate) throws RepositoryException {
+                service.registerNodeTypes(sessionInfo, nodeTypeDefs, allowUpdate);
             }
             public void unregisterNodeTypes(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException {
-                throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
+                service.unregisterNodeTypes(sessionInfo, nodeTypeNames);
             }
         };
         NodeTypeCache ntCache = NodeTypeCache.getInstance(service, sessionInfo.getUserID());

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java Wed May 13 12:43:19 2009
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.commons.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.spi.commons.nodetype.ValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
@@ -33,6 +32,7 @@
 import javax.jcr.PropertyType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
 
 import java.util.Stack;
 import java.util.Map;
@@ -63,11 +63,11 @@
      * @param ntDefs
      * @param validatedDefs
      * @return Map mapping the definition to the resulting effective nodetype
-     * @throws InvalidNodeTypeDefException
+     * @throws InvalidNodeTypeDefinitionException
      * @throws RepositoryException
      */
     public Map validateNodeTypeDefs(Collection ntDefs, Map validatedDefs)
-        throws InvalidNodeTypeDefException, RepositoryException {
+        throws InvalidNodeTypeDefinitionException, RepositoryException {
         // tmp. map containing names/defs of validated nodetypes
         Map tmpMap = new HashMap(validatedDefs);
         for (Iterator it = ntDefs.iterator(); it.hasNext();) {
@@ -110,7 +110,7 @@
                 msg.append(" ");
             }
             log.error(msg.toString());
-            throw new InvalidNodeTypeDefException(msg.toString());
+            throw new InvalidNodeTypeDefinitionException(msg.toString());
         }
         return ntMap;
     }
@@ -122,11 +122,11 @@
      * that are known to be valid or are already registered. This map is used to
      * validated dependencies and check for circular inheritance
      * @return
-     * @throws InvalidNodeTypeDefException
+     * @throws InvalidNodeTypeDefinitionException
      * @throws RepositoryException
      */
     public EffectiveNodeType validateNodeTypeDef(QNodeTypeDefinition ntDef, Map validatedDefs)
-            throws InvalidNodeTypeDefException, RepositoryException {
+            throws InvalidNodeTypeDefinitionException, RepositoryException {
         /**
          * the effective (i.e. merged and resolved) node type resulting from
          * the specified node type definition;
@@ -141,7 +141,7 @@
         if (name == null) {
             String msg = "no name specified";
             log.debug(msg);
-            throw new InvalidNodeTypeDefException(msg);
+            throw new InvalidNodeTypeDefinitionException(msg);
         }
         checkNamespace(name);
 
@@ -158,13 +158,13 @@
                     String msg = "[" + name + "] invalid supertype: "
                             + supertypes[i] + " (infinite recursion))";
                     log.debug(msg);
-                    throw new InvalidNodeTypeDefException(msg);
+                    throw new InvalidNodeTypeDefinitionException(msg);
                 }
                 /* compare to given nt-name set and not to registered nodetypes */
                 if (!validatedDefs.containsKey(supertypes[i])) {
                     String msg = "[" + name + "] invalid supertype: " + supertypes[i];
                     log.debug(msg);
-                    throw new InvalidNodeTypeDefException(msg);
+                    throw new InvalidNodeTypeDefinitionException(msg);
                 }
             }
 
@@ -197,16 +197,16 @@
                     String msg = "[" + name + "] all primary node types except"
                         + " nt:base itself must be (directly or indirectly) derived from nt:base";
                     log.debug(msg);
-                    throw new InvalidNodeTypeDefException(msg);
+                    throw new InvalidNodeTypeDefinitionException(msg);
                 }
             } catch (ConstraintViolationException e) {
                 String msg = "[" + name + "] failed to validate supertypes";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg, e);
+                throw new InvalidNodeTypeDefinitionException(msg, e);
             } catch (NoSuchNodeTypeException e) {
                 String msg = "[" + name + "] failed to validate supertypes";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg, e);
+                throw new InvalidNodeTypeDefinitionException(msg, e);
             }
         } else {
             // no supertypes specified: has to be either a mixin type or nt:base
@@ -214,7 +214,7 @@
                 String msg = "[" + name
                         + "] all primary node types except nt:base itself must be (directly or indirectly) derived from nt:base";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg);
+                throw new InvalidNodeTypeDefinitionException(msg);
             }
         }
 
@@ -231,20 +231,20 @@
             if (!name.equals(pd.getDeclaringNodeType())) {
                 String msg = "[" + name + "#" + pd.getName() + "] invalid declaring node type specified";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg);
+                throw new InvalidNodeTypeDefinitionException(msg);
             }
             checkNamespace(pd.getName());
             // check that auto-created properties specify a name
             if (pd.definesResidual() && pd.isAutoCreated()) {
                 String msg = "[" + name + "#" + pd.getName() + "] auto-created properties must specify a name";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg);
+                throw new InvalidNodeTypeDefinitionException(msg);
             }
             // check that auto-created properties specify a type
             if (pd.getRequiredType() == PropertyType.UNDEFINED && pd.isAutoCreated()) {
                 String msg = "[" + name + "#" + pd.getName() + "] auto-created properties must specify a type";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg);
+                throw new InvalidNodeTypeDefinitionException(msg);
             }
             /* check default values:
              * make sure type of value is consistent with required property type
@@ -276,7 +276,7 @@
                                     + "] invalid REFERENCE value constraint '"
                                     + ntName + "' (unknown node type)";
                             log.debug(msg);
-                            throw new InvalidNodeTypeDefException(msg);
+                            throw new InvalidNodeTypeDefinitionException(msg);
                         }
                     }
                 }
@@ -292,7 +292,7 @@
                 String msg = "[" + name + "#" + cnd.getName()
                         + "] invalid declaring node type specified";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg);
+                throw new InvalidNodeTypeDefinitionException(msg);
             }
             checkNamespace(cnd.getName());
             // check that auto-created child-nodes specify a name
@@ -300,7 +300,7 @@
                 String msg = "[" + name + "#" + cnd.getName()
                         + "] auto-created child-nodes must specify a name";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg);
+                throw new InvalidNodeTypeDefinitionException(msg);
             }
             // check that auto-created child-nodes specify a default primary type
             if (cnd.getDefaultPrimaryType() == null
@@ -308,7 +308,7 @@
                 String msg = "[" + name + "#" + cnd.getName()
                         + "] auto-created child-nodes must specify a default primary type";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg);
+                throw new InvalidNodeTypeDefinitionException(msg);
             }
             // check default primary type
             Name dpt = cnd.getDefaultPrimaryType();
@@ -328,7 +328,7 @@
                     String msg = "[" + name + "#" + cnd.getName()
                             + "] invalid default primary type '" + dpt + "'";
                     log.debug(msg);
-                    throw new InvalidNodeTypeDefException(msg);
+                    throw new InvalidNodeTypeDefinitionException(msg);
                 }
                 /**
                  * build effective (i.e. merged and resolved) node type from
@@ -360,12 +360,12 @@
                     String msg = "[" + name + "#" + cnd.getName()
                             + "] failed to validate default primary type";
                     log.debug(msg);
-                    throw new InvalidNodeTypeDefException(msg, e);
+                    throw new InvalidNodeTypeDefinitionException(msg, e);
                 } catch (NoSuchNodeTypeException e) {
                     String msg = "[" + name + "#" + cnd.getName()
                             + "] failed to validate default primary type";
                     log.debug(msg);
-                    throw new InvalidNodeTypeDefException(msg, e);
+                    throw new InvalidNodeTypeDefinitionException(msg, e);
                 }
             }
 
@@ -391,7 +391,7 @@
                         String msg = "[" + name + "#" + cnd.getName()
                                 + "] invalid required primary type: " + rpt;
                         log.debug(msg);
-                        throw new InvalidNodeTypeDefException(msg);
+                        throw new InvalidNodeTypeDefinitionException(msg);
                     }
                     /**
                      * check if default primary type satisfies the required
@@ -402,7 +402,7 @@
                                 + "] default primary type does not satisfy required primary type constraint "
                                 + rpt;
                         log.debug(msg);
-                        throw new InvalidNodeTypeDefException(msg);
+                        throw new InvalidNodeTypeDefinitionException(msg);
                     }
                     /**
                      * build effective (i.e. merged and resolved) node type from
@@ -425,12 +425,12 @@
                         String msg = "[" + name + "#" + cnd.getName()
                                 + "] failed to validate required primary type constraint";
                         log.debug(msg);
-                        throw new InvalidNodeTypeDefException(msg, e);
+                        throw new InvalidNodeTypeDefinitionException(msg, e);
                     } catch (NoSuchNodeTypeException e) {
                         String msg = "[" + name + "#" + cnd.getName()
                                 + "] failed to validate required primary type constraint";
                         log.debug(msg);
-                        throw new InvalidNodeTypeDefException(msg, e);
+                        throw new InvalidNodeTypeDefinitionException(msg, e);
                     }
                 }
             }
@@ -447,11 +447,11 @@
             } catch (ConstraintViolationException e) {
                 String msg = "[" + name + "] failed to resolve node type definition";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg, e);
+                throw new InvalidNodeTypeDefinitionException(msg, e);
             } catch (NoSuchNodeTypeException e) {
                 String msg = "[" + name + "] failed to resolve node type definition";
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg, e);
+                throw new InvalidNodeTypeDefinitionException(msg, e);
             }
         }
         return ent;
@@ -462,11 +462,11 @@
      * @param supertypes
      * @param inheritanceChain
      * @param ntdMap
-     * @throws InvalidNodeTypeDefException
+     * @throws InvalidNodeTypeDefinitionException
      * @throws RepositoryException
      */
     private void checkForCircularInheritance(Name[] supertypes, Stack inheritanceChain, Map ntdMap)
-        throws InvalidNodeTypeDefException, RepositoryException {
+        throws InvalidNodeTypeDefinitionException, RepositoryException {
         for (int i = 0; i < supertypes.length; i++) {
             Name stName = supertypes[i];
             int pos = inheritanceChain.lastIndexOf(stName);
@@ -481,7 +481,7 @@
                 }
                 buf.append("--> ");
                 buf.append(stName);
-                throw new InvalidNodeTypeDefException("circular inheritance detected: " + buf.toString());
+                throw new InvalidNodeTypeDefinitionException("circular inheritance detected: " + buf.toString());
             }
 
             if (ntdMap.containsKey(stName)) {
@@ -493,7 +493,7 @@
                     inheritanceChain.pop();
                 }
             } else {
-                throw new InvalidNodeTypeDefException("Unknown supertype: " + stName);
+                throw new InvalidNodeTypeDefinitionException("Unknown supertype: " + stName);
             }
         }
     }
@@ -503,11 +503,11 @@
      * @param childNodeENT
      * @param definingParentNTs
      * @param ntdMap
-     * @throws InvalidNodeTypeDefException
+     * @throws InvalidNodeTypeDefinitionException
      */
     private void checkForCircularNodeAutoCreation(EffectiveNodeType childNodeENT,
                                                   Stack definingParentNTs, Map ntdMap)
-        throws InvalidNodeTypeDefException {
+        throws InvalidNodeTypeDefinitionException {
         // check for circularity through default node types of auto-created child nodes
         // (node type 'a' defines auto-created child node with default node type 'a')
         Name[] childNodeNTs = childNodeENT.getAllNodeTypes();
@@ -527,7 +527,7 @@
                 buf.append("--> ");
                 buf.append("node type ");
                 buf.append(nt);
-                throw new InvalidNodeTypeDefException("circular node auto-creation detected: "
+                throw new InvalidNodeTypeDefinitionException("circular node auto-creation detected: "
                     + buf.toString());
             }
         }
@@ -547,11 +547,11 @@
             } catch (NoSuchNodeTypeException e) {
                 String msg = definingNT + " defines invalid default node type for child node " + nodeDefs[i].getName();
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg, e);
+                throw new InvalidNodeTypeDefinitionException(msg, e);
             } catch (ConstraintViolationException e) {
                 String msg = definingNT + " defines invalid default node type for child node " + nodeDefs[i].getName();
                 log.debug(msg);
-                throw new InvalidNodeTypeDefException(msg, e);
+                throw new InvalidNodeTypeDefinitionException(msg, e);
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java Wed May 13 12:43:19 2009
@@ -143,21 +143,16 @@
     }
 
     public void registerNodeTypes(NodeTypeStorage storage,
-                                  QNodeTypeDefinition[] nodeTypeDefs)
-            throws NoSuchNodeTypeException, RepositoryException {
-        throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
-    }
-
-    public void reregisterNodeTypes(NodeTypeStorage storage,
-                                    QNodeTypeDefinition[] nodeTypeDefs)
-            throws NoSuchNodeTypeException, RepositoryException {
-        throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
+                                  QNodeTypeDefinition[] nodeTypeDefs,
+                                  boolean allowUpdate)
+            throws RepositoryException {
+        storage.registerNodeTypes(nodeTypeDefs, allowUpdate);
     }
 
     public void unregisterNodeTypes(NodeTypeStorage storage,
                                     Name[] nodeTypeNames)
             throws NoSuchNodeTypeException, RepositoryException {
-        throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI");
+        storage.unregisterNodeTypes(nodeTypeNames);
     }
 
     /**
@@ -177,13 +172,9 @@
                     throws NoSuchNodeTypeException, RepositoryException {
                 return NodeTypeCache.this.getDefinitions(storage, nodeTypeNames);
             }
-            public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs)
-                    throws NoSuchNodeTypeException, RepositoryException {
-                NodeTypeCache.this.registerNodeTypes(storage, nodeTypeDefs);
-            }
-            public void reregisterNodeTypes(QNodeTypeDefinition[] nodeTypeDefs)
-                    throws NoSuchNodeTypeException, RepositoryException {
-                NodeTypeCache.this.reregisterNodeTypes(storage, nodeTypeDefs);
+            public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate)
+                    throws RepositoryException {
+                NodeTypeCache.this.registerNodeTypes(storage, nodeTypeDefs, allowUpdate);
             }
             public void unregisterNodeTypes(Name[] nodeTypeNames)
                     throws NoSuchNodeTypeException, RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java Wed May 13 12:43:19 2009
@@ -22,6 +22,9 @@
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
@@ -33,7 +36,6 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.PropertyType;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.NamespaceException;
@@ -45,10 +47,13 @@
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeTypeExistsException;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.HashSet;
+import java.util.List;
 import java.io.PrintStream;
 
 /**
@@ -358,37 +363,38 @@
     }
 
     /**
-     * @see NodeTypeManager#registerNodeType(javax.jcr.nodetype.NodeTypeDefinition, boolean)
-     */
-    public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
-            throws RepositoryException {
-        // TODO
-        throw new UnsupportedRepositoryOperationException("JCR-1591");
-    }
-
-    /**
      * @see NodeTypeManager#registerNodeTypes(javax.jcr.nodetype.NodeTypeDefinition[], boolean)
      */
     public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
             throws RepositoryException {
-        // TODO
-        throw new UnsupportedRepositoryOperationException("JCR-1591");
-    }
+        List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>(ntds.length);
+        for (NodeTypeDefinition definition : ntds) {
+            QNodeTypeDefinition qdef = new QNodeTypeDefinitionImpl(definition, resolver(), mgrProvider.getQValueFactory());
+            if (!allowUpdate && hasNodeType(qdef.getName())) {
+                throw new NodeTypeExistsException("NodeType " + definition.getName() + " already exists.");
+            }
+            defs.add(qdef);
+        }
+
+        getNodeTypeRegistry().registerNodeTypes(defs, allowUpdate);
+
+        List<NodeType> nts = new ArrayList<NodeType>();
+        for (Iterator<QNodeTypeDefinition> it = defs.iterator(); it.hasNext();) {
+            nts.add(getNodeType(it.next().getName()));
+        }
+        return new NodeTypeIteratorAdapter(nts);
 
-    /**
-     * @see NodeTypeManager#unregisterNodeType(String)
-     */
-    public void unregisterNodeType(String name) throws RepositoryException {
-        // TODO
-        throw new UnsupportedRepositoryOperationException("JCR-1591");
     }
 
     /**
      * @see NodeTypeManager#unregisterNodeTypes(String[])
      */
     public void unregisterNodeTypes(String[] names) throws RepositoryException {
-        // TODO
-        throw new UnsupportedRepositoryOperationException("JCR-1591");
+        HashSet ntNames = new HashSet();
+        for (String name : names) {
+            ntNames.add(resolver().getQName(name));
+        }
+        getNodeTypeRegistry().unregisterNodeTypes(ntNames);
     }
 
     //-----------------------------------------------------------< Dumpable >---

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java Wed May 13 12:43:19 2009
@@ -18,9 +18,10 @@
 
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
-import org.apache.jackrabbit.spi.commons.nodetype.InvalidNodeTypeDefException;
 
 import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
 import javax.jcr.RepositoryException;
 import java.util.Collection;
 
@@ -71,95 +72,27 @@
     public Name[] getRegisteredNodeTypes() throws RepositoryException;
 
     /**
-     * Validates the <code>NodeTypeDef</code> and returns
-     * a registered <code>EffectiveNodeType</code> instance.
-     * <p/>
-     * The validation includes the following checks:
-     * <ul>
-     * <li>Supertypes must exist and be registered</li>
-     * <li>Inheritance graph must not be circular</li>
-     * <li>Aggregation of supertypes must not result in name conflicts,
-     * ambiguities, etc.</li>
-     * <li>Definitions of auto-created properties must specify a name</li>
-     * <li>Default values in property definitions must satisfy value constraints
-     * specified in the same property definition</li>
-     * <li>Definitions of auto-created child-nodes must specify a name</li>
-     * <li>Default node type in child-node definitions must exist and be
-     * registered</li>
-     * <li>The aggregation of the default node types in child-node definitions
-     * must not result in name conflicts, ambiguities, etc.</li>
-     * <li>Definitions of auto-created child-nodes must not specify default
-     * node types which would lead to infinite child node creation
-     * (e.g. node type 'A' defines auto-created child node with default
-     * node type 'A' ...)</li>
-     * <li>Node types specified as constraints in child-node definitions
-     * must exist and be registered</li>
-     * <li>The aggregation of the node types specified as constraints in
-     * child-node definitions must not result in name conflicts, ambiguities,
-     * etc.</li>
-     * <li>Default node types in child-node definitions must satisfy
-     * node type constraints specified in the same child-node definition</li>
-     * </ul>
-     *
-     * @param ntDef the definition of the new node type
-     * @return an <code>EffectiveNodeType</code> instance
-     * @throws InvalidNodeTypeDefException
+     * Registers the specified node type definitions. If <code>allowUpdate</code>
+     * is <code>true</code> existing node types will be updated, otherwise
+     * an <code>NodeTypeExistsException</code> is thrown.
+     *
+     * @param ntDefs
+     * @param allowUpdate
+     * @throws NodeTypeExistsException
+     * @throws InvalidNodeTypeDefinitionException
      * @throws RepositoryException
      */
-    public EffectiveNodeType registerNodeType(QNodeTypeDefinition ntDef)
-            throws InvalidNodeTypeDefException, RepositoryException;
+    public void registerNodeTypes(Collection<QNodeTypeDefinition> ntDefs, boolean allowUpdate) throws NodeTypeExistsException, InvalidNodeTypeDefinitionException, RepositoryException;
 
     /**
-     * Same as <code>{@link #registerNodeType(QNodeTypeDefinition)}</code> except
-     * that a collection of <code>NodeTypeDef</code>s is registered instead of
-     * just one.
-     * <p/>
-     * This method can be used to register a set of node types that have
-     * dependencies on each other.
-     * <p/>
-     * Note that in the case an exception is thrown, some node types might have
-     * been nevertheless successfully registered.
-     *
-     * @param ntDefs a collection of <code>NodeTypeDef<code>s
-     * @throws InvalidNodeTypeDefException
-     * @throws RepositoryException
-     */
-    public void registerNodeTypes(Collection ntDefs)
-            throws InvalidNodeTypeDefException, RepositoryException;
-
-    /**
-     * @param nodeTypeName
-     * @throws NoSuchNodeTypeException
-     * @throws RepositoryException
-     */
-    public void unregisterNodeType(Name nodeTypeName)
-            throws NoSuchNodeTypeException, RepositoryException;
-
-    /**
-     * Same as <code>{@link #unregisterNodeType(Name)}</code> except
-     * that a set of node types is unregistered instead of just one.
-     * <p/>
-     * This method can be used to unregister a set of node types that depend on
-     * each other.
+     * Unregisters a collection of node types.
      *
      * @param nodeTypeNames a collection of <code>Name</code> objects denoting the
      *                node types to be unregistered
      * @throws NoSuchNodeTypeException if any of the specified names does not
      *                                 denote a registered node type.
      * @throws RepositoryException if another error occurs
-     * @see #unregisterNodeType(Name)
      */
-    public void unregisterNodeTypes(Collection nodeTypeNames)
+    public void unregisterNodeTypes(Collection<Name> nodeTypeNames)
         throws NoSuchNodeTypeException, RepositoryException;
-
-    /**
-     * @param ntd
-     * @return
-     * @throws NoSuchNodeTypeException
-     * @throws InvalidNodeTypeDefException
-     * @throws RepositoryException
-     */
-    public EffectiveNodeType reregisterNodeType(QNodeTypeDefinition ntd)
-            throws NoSuchNodeTypeException, InvalidNodeTypeDefException,
-            RepositoryException;
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java Wed May 13 12:43:19 2009
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QItemDefinition;
-import org.apache.jackrabbit.spi.commons.nodetype.InvalidNodeTypeDefException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,6 +33,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NodeTypeExistsException;
 import javax.jcr.version.OnParentVersionAction;
 import java.io.PrintStream;
 import java.util.Collection;
@@ -155,63 +156,47 @@
         return registeredNTDefs.containsKey(nodeTypeName);
     }
 
-   /**
-     * @see NodeTypeRegistry#registerNodeType(QNodeTypeDefinition)
-     */
-    public synchronized EffectiveNodeType registerNodeType(QNodeTypeDefinition ntDef)
-            throws InvalidNodeTypeDefException, RepositoryException {
-        // validate the new nodetype definition
-        EffectiveNodeType ent = validator.validateNodeTypeDef(ntDef, registeredNTDefs);
-
-        // persist new node type definition
-        storage.registerNodeTypes(new QNodeTypeDefinition[] {ntDef});
-
-        // update internal caches
-        internalRegister(ntDef, ent);
-
-        // notify listeners
-        notifyRegistered(ntDef.getName());
-        return ent;
-    }
-
     /**
-     * @see NodeTypeRegistry#registerNodeTypes(Collection)
+     * @see NodeTypeRegistry#registerNodeTypes(Collection, boolean)
      */
-    public synchronized void registerNodeTypes(Collection ntDefs)
-            throws InvalidNodeTypeDefException, RepositoryException {
+    public synchronized void registerNodeTypes(Collection<QNodeTypeDefinition> ntDefs, boolean allowUpdate) throws NodeTypeExistsException, InvalidNodeTypeDefinitionException, RepositoryException {
+        List<Name> added = new ArrayList<Name>();
+        List<Name> modified = new ArrayList<Name>();
+        for (QNodeTypeDefinition def : ntDefs) {
+            Name name = def.getName();
+            if (isRegistered(name)) {
+                modified.add(name);
+            } else {
+                added.add(name);
+            }
+        }
 
         // validate new nodetype definitions
         Map defMap = validator.validateNodeTypeDefs(ntDefs, registeredNTDefs);
-        storage.registerNodeTypes((QNodeTypeDefinition[])ntDefs.toArray(new QNodeTypeDefinition[ntDefs.size()]));
+        storage.registerNodeTypes(ntDefs.toArray(new QNodeTypeDefinition[ntDefs.size()]), allowUpdate);
 
-        // update internal cache
+        // update internal cache:
+        // unregister modified node type definition
+        internalUnregister(modified);
+        // register all new and modified definition
         internalRegister(defMap);
 
         // notify listeners
-        for (Iterator iter = ntDefs.iterator(); iter.hasNext();) {
-            Name ntName = ((QNodeTypeDefinition)iter.next()).getName();
+        for (Name ntName : added) {
             notifyRegistered(ntName);
         }
-    }
-
-    /**
-     * @see NodeTypeRegistry#unregisterNodeType(Name)
-     */
-    public void unregisterNodeType(Name nodeTypeName) throws NoSuchNodeTypeException, RepositoryException {
-        HashSet ntNames = new HashSet();
-        ntNames.add(nodeTypeName);
-        unregisterNodeTypes(ntNames);
+        for (Name ntName : modified) {
+            notifyReRegistered(ntName);
+        }
     }
 
     /**
      * @see NodeTypeRegistry#unregisterNodeTypes(Collection)
      */
-    public synchronized void unregisterNodeTypes(Collection nodeTypeNames)
+    public synchronized void unregisterNodeTypes(Collection<Name> nodeTypeNames)
             throws NoSuchNodeTypeException, RepositoryException {
         // do some preliminary checks
-        for (Iterator iter = nodeTypeNames.iterator(); iter.hasNext();) {
-            Name ntName = (Name) iter.next();
-
+        for (Name ntName : nodeTypeNames) {
             // Best effort check for node types other than those to be
             // unregistered that depend on the given node types
             Set dependents = registeredNTDefs.getDependentNodeTypes(ntName);
@@ -229,7 +214,7 @@
 
         // persist removal of node type definitions
         // NOTE: conflict with existing content not asserted on client
-        storage.unregisterNodeTypes((Name[]) nodeTypeNames.toArray(new Name[nodeTypeNames.size()]));
+        storage.unregisterNodeTypes(nodeTypeNames.toArray(new Name[nodeTypeNames.size()]));
 
 
         // all preconditions are met, node types can now safely be unregistered
@@ -243,32 +228,6 @@
     }
 
     /**
-     * @see NodeTypeRegistry#reregisterNodeType(QNodeTypeDefinition)
-     */
-    public synchronized EffectiveNodeType reregisterNodeType(QNodeTypeDefinition ntd)
-            throws NoSuchNodeTypeException, InvalidNodeTypeDefException,
-            RepositoryException {
-        Name name = ntd.getName();
-        if (!registeredNTDefs.containsKey(name)) {
-            throw new NoSuchNodeTypeException(name.toString());
-        }
-        /* validate new node type definition */
-        EffectiveNodeType ent = validator.validateNodeTypeDef(ntd, registeredNTDefs);
-
-        // first call reregistering on storage
-        storage.reregisterNodeTypes(new QNodeTypeDefinition[]{ntd});
-
-        // unregister old node type definition
-        internalUnregister(name);
-        // register new definition
-        internalRegister(ntd, ent);
-
-        // notify listeners
-        notifyReRegistered(name);
-        return ent;
-    }
-
-    /**
      * @see NodeTypeRegistry#getNodeTypeDefinition(Name)
      */
     public QNodeTypeDefinition getNodeTypeDefinition(Name nodeTypeName)
@@ -675,9 +634,8 @@
         }
     }
 
-    private void internalUnregister(Collection ntNames) {
-        for (Iterator iter = ntNames.iterator(); iter.hasNext();) {
-            Name name = (Name) iter.next();
+    private void internalUnregister(Collection<Name> ntNames) {
+        for (Name name : ntNames) {
             internalUnregister(name);
         }
     }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeStorage.java Wed May 13 12:43:19 2009
@@ -48,9 +48,7 @@
      */
     public Iterator getDefinitions(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException;
 
-    public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs) throws NoSuchNodeTypeException, RepositoryException;
-
-    public void reregisterNodeTypes(QNodeTypeDefinition[] nodeTypeDefs) throws NoSuchNodeTypeException, RepositoryException;
-
+    public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate) throws RepositoryException;
+    
     public void unregisterNodeTypes(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException;
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java Wed May 13 12:43:19 2009
@@ -56,6 +56,8 @@
 import javax.jcr.version.VersionException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NodeTypeExistsException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.util.Iterator;
@@ -376,6 +378,20 @@
         throw new UnsupportedRepositoryOperationException();
     }
 
+    /**
+     * @throws UnsupportedRepositoryOperationException always.
+     */
+    public void registerNodeTypes(SessionInfo sessionInfo, QNodeTypeDefinition[] nodeTypeDefinitions, boolean allowUpdate) throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * @throws UnsupportedRepositoryOperationException always.
+     */
+    public void unregisterNodeTypes(SessionInfo sessionInfo, Name[] nodeTypeNames) throws UnsupportedRepositoryOperationException, NoSuchNodeTypeException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
     //-----------------------------< namespaces >-------------------------------
 
     /**

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java Wed May 13 12:43:19 2009
@@ -21,9 +21,19 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 
 import javax.jcr.PropertyType;
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.NodeDefinition;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Collections;
@@ -200,6 +210,27 @@
     }
 
     /**
+     * Createa a new <code>QNodeTypeDefinitionImpl</code> from a JCR
+     * NodeType definition.
+     *
+     * @param def
+     * @param resolver
+     * @param qValueFactory
+     * @throws RepositoryException
+     */
+    public QNodeTypeDefinitionImpl(NodeTypeDefinition def,
+                                   NamePathResolver resolver,
+                                   QValueFactory qValueFactory) throws RepositoryException {
+        this(resolver.getQName(def.getName()),
+                getNames(def.getDeclaredSupertypeNames(), resolver), null, def.isMixin(),
+                def.isAbstract(), def.isQueryable(), def.hasOrderableChildNodes(),
+                resolver.getQName(def.getPrimaryItemName()),
+                createQPropertyDefinitions(def.getDeclaredPropertyDefinitions(), resolver, qValueFactory),
+                createQNodeDefinitions(def.getDeclaredChildNodeDefinitions(), resolver));
+    }
+
+    //------------------------------------------------< QNodeTypeDefinition >---
+    /**
      * {@inheritDoc}
      */
     public Name getName() {
@@ -366,4 +397,52 @@
         }
         return serDefs;
     }
+
+    private static Name[] getNames(String[] jcrNames, NamePathResolver resolver) throws NamespaceException, IllegalNameException {
+        Name[] names = new Name[jcrNames.length];
+        for (int i = 0; i < jcrNames.length; i++) {
+            names[i] = resolver.getQName(jcrNames[i]);
+        }
+        return names;
+    }
+
+    private static QPropertyDefinition[] createQPropertyDefinitions(PropertyDefinition[] pds,
+                                                                    NamePathResolver resolver,
+                                                                    QValueFactory qValueFactory) throws RepositoryException {
+        QPropertyDefinition[] declaredPropDefs = new QPropertyDefinition[pds.length];
+        for (int i = 0; i < pds.length; i++) {
+            PropertyDefinition propDef = pds[i];
+            Name name = resolver.getQName(propDef.getName());
+            Name declName = resolver.getQName(propDef.getDeclaringNodeType().getName());
+            QValue[] defVls = ValueFormat.getQValues(propDef.getDefaultValues(), resolver, qValueFactory);
+
+            declaredPropDefs[i] = new QPropertyDefinitionImpl(
+                    name, declName, propDef.isAutoCreated(), propDef.isMandatory(),
+                    propDef.getOnParentVersion(), propDef.isProtected(),
+                    defVls, propDef.isMultiple(),
+                    propDef.getRequiredType(), propDef.getValueConstraints(),
+                    getNames(propDef.getAvailableQueryOperators(), resolver),
+                    propDef.isFullTextSearchable(),
+                    propDef.isQueryOrderable());
+        }
+        return declaredPropDefs;
+    }
+
+    private static QNodeDefinition[] createQNodeDefinitions(NodeDefinition[] nds, NamePathResolver resolver) throws RepositoryException {
+        QNodeDefinition[] declaredNodeDefs = new QNodeDefinition[nds.length];
+        for (int i = 0; i < nds.length; i++) {
+            NodeDefinition nodeDef = nds[i];
+            Name name = resolver.getQName(nodeDef.getName());
+            Name declName = resolver.getQName(nodeDef.getDeclaringNodeType().getName());
+            Name defaultPrimaryType = resolver.getQName(nodeDef.getDefaultPrimaryTypeName());
+            Name[] requiredPrimaryTypes = getNames(nodeDef.getRequiredPrimaryTypeNames(), resolver);
+
+            declaredNodeDefs[i] = new QNodeDefinitionImpl(
+                    name, declName, nodeDef.isAutoCreated(), nodeDef.isMandatory(),
+                    nodeDef.getOnParentVersion(), nodeDef.isProtected(),
+                    defaultPrimaryType, requiredPrimaryTypes,
+                    nodeDef.allowsSameNameSiblings());
+        }
+        return declaredNodeDefs;
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java Wed May 13 12:43:19 2009
@@ -60,7 +60,7 @@
     /**
      * The 'fullTextSearcheable' flag
      */
-    private final boolean fullTextSearcheable;
+    private final boolean fullTextSearchable;
 
     /**
      * The 'queryOrderable' flag
@@ -79,7 +79,7 @@
                 propDef.getDefaultValues(), propDef.isMultiple(),
                 propDef.getRequiredType(), propDef.getValueConstraints(),
                 propDef.getAvailableQueryOperators(),
-                propDef.isFullTextSearcheable(),
+                propDef.isFullTextSearchable(),
                 propDef.isQueryOrderable());
     }
 
@@ -130,7 +130,7 @@
      * @param valueConstraints  the value constraints for this property. If none
      *                          exist an empty array must be passed.
      * @param availableQueryOperators
-     * @param isFullTextSearcheable
+     * @param isFullTextSearchable
      * @param isQueryOrderable
      * @throws NullPointerException if <code>valueConstraints</code> is
      *                              <code>null</code>.
@@ -142,7 +142,7 @@
                                    QValue[] defaultValues, boolean isMultiple,
                                    int requiredType, String[] valueConstraints,
                                    Name[] availableQueryOperators,
-                                   boolean isFullTextSearcheable,
+                                   boolean isFullTextSearchable,
                                    boolean isQueryOrderable) {
         super(name, declaringNodeType, isAutoCreated, isMandatory,
                 onParentVersion, isProtected);
@@ -154,7 +154,7 @@
         this.requiredType = requiredType;
         this.valueConstraints = valueConstraints;
         this.availableQueryOperators = availableQueryOperators;
-        this.fullTextSearcheable = isFullTextSearcheable;
+        this.fullTextSearchable = isFullTextSearchable;
         this.queryOrderable = isQueryOrderable;
     }
 
@@ -197,8 +197,8 @@
     /**
      * {@inheritDoc}
      */
-    public boolean isFullTextSearcheable() {
-        return fullTextSearcheable;
+    public boolean isFullTextSearchable() {
+        return fullTextSearchable;
     }
 
     /**
@@ -237,7 +237,7 @@
             return super.equals(obj)
                     && requiredType == other.getRequiredType()
                     && multiple == other.isMultiple()
-                    && fullTextSearcheable == other.isFullTextSearcheable()
+                    && fullTextSearchable == other.isFullTextSearchable()
                     && queryOrderable == other.isQueryOrderable()
                     && Arrays.equals(valueConstraints, other.getValueConstraints())
                     && Arrays.equals(defaultValues, other.getDefaultValues())
@@ -268,7 +268,7 @@
             sb.append('/');
             sb.append(multiple ? 1 : 0);
             sb.append('/');
-            sb.append(fullTextSearcheable ? 1 : 0);
+            sb.append(fullTextSearchable ? 1 : 0);
             sb.append('/');
             sb.append(queryOrderable ? 1 : 0);
             sb.append('/');

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java Wed May 13 12:43:19 2009
@@ -23,6 +23,9 @@
 import javax.jcr.Credentials;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 import org.apache.jackrabbit.spi.Batch;
 import org.apache.jackrabbit.spi.EventBundle;
@@ -45,6 +48,7 @@
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 /**
  * Log wrapper for a {@link RepositoryService}.
@@ -657,6 +661,24 @@
         }, "getQNodeTypeDefinitions(SessionInfo, Name[])", new Object[]{unwrap(sessionInfo), nodetypeNames});
     }
 
+    public void registerNodeTypes(final SessionInfo sessionInfo, final QNodeTypeDefinition[] nodeTypeDefinitions, final boolean allowUpdate) throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.registerNodeTypes(unwrap(sessionInfo), nodeTypeDefinitions, allowUpdate);
+                return null;
+            }
+        }, "registerNodeTypes(SessionInfo, QNodeTypeDefinition[], boolean)", new Object[]{unwrap(sessionInfo), nodeTypeDefinitions, allowUpdate});
+    }
+
+    public void unregisterNodeTypes(final SessionInfo sessionInfo, final Name[] nodeTypeNames) throws UnsupportedRepositoryOperationException, NoSuchNodeTypeException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.unregisterNodeTypes(unwrap(sessionInfo), nodeTypeNames);
+                return null;
+            }
+        }, "unregisterNodeTypes(SessionInfo, Name[])", new Object[]{unwrap(sessionInfo), nodeTypeNames});
+    }
+
     public void createWorkspace(final SessionInfo sessionInfo, final String name, final String srcWorkspaceName) throws RepositoryException {
         execute(new Callable() {
             public Object call() throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java Wed May 13 12:43:19 2009
@@ -18,6 +18,7 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeTemplate;
@@ -25,6 +26,7 @@
 import javax.jcr.nodetype.NodeDefinitionTemplate;
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.RepositoryException;
 
@@ -39,6 +41,15 @@
      */
     private static final Logger log = LoggerFactory.getLogger(AbstractNodeTypeManager.class);
 
+    /**
+     * Return the node type with the specified <code>ntName</code>.
+     *
+     * @param ntName Name of the node type to be returned.
+     * @return the node type with the specified <code>ntName</code>.
+     * @throws NoSuchNodeTypeException If no such node type exists.
+     */
+    public abstract NodeType getNodeType(Name ntName) throws NoSuchNodeTypeException;
+
     //----------------------------------------------------< NodeTypeManager >---
     /**
      * @see javax.jcr.nodetype.NodeTypeManager#createNodeTypeTemplate()
@@ -71,4 +82,21 @@
             throws UnsupportedRepositoryOperationException, RepositoryException {
         return new PropertyDefinitionTemplateImpl();
     }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeManager#registerNodeType(NodeTypeDefinition, boolean)
+     */
+    public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
+            throws RepositoryException {
+        NodeTypeDefinition[] ntds = new NodeTypeDefinition[] { ntd };
+        return registerNodeTypes(ntds, allowUpdate).nextNodeType();
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeManager#unregisterNodeType(String)
+     */
+    public void unregisterNodeType(String name)
+            throws UnsupportedRepositoryOperationException, NoSuchNodeTypeException, RepositoryException {
+        unregisterNodeTypes(new String[] {name});
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/InvalidNodeTypeDefException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/InvalidNodeTypeDefException.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/InvalidNodeTypeDefException.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/InvalidNodeTypeDefException.java Wed May 13 12:43:19 2009
@@ -16,12 +16,14 @@
  */
 package org.apache.jackrabbit.spi.commons.nodetype;
 
-import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
 
 /**
- * The <code>NodeTypeConflictException</code> ...
+ * The <code>InvalidNodeTypeDefException</code> ...
+ *
+ * @deprecated As of JCR 2.0. Use {@link javax.jcr.nodetype.InvalidNodeTypeDefinitionException} instead.
  */
-public class InvalidNodeTypeDefException extends RepositoryException {
+public class InvalidNodeTypeDefException extends InvalidNodeTypeDefinitionException {
 
     /**
      * Constructs a new instance of this class with the specified detail

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ItemDefinitionImpl.java (from r773904, jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ItemDefinitionImpl.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ItemDefinitionImpl.java&p1=jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java&r1=773904&r2=774294&rev=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ItemDefinitionImpl.java Wed May 13 12:43:19 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.jcr2spi.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype;
 
 import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
@@ -22,13 +22,13 @@
 import org.slf4j.Logger;
 
 import javax.jcr.nodetype.ItemDefinition;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.NamespaceException;
 
 /**
  * This class implements the <code>ItemDefinition</code> interface.
- * All method calls are delegated to the wrapped {@link QItemDefinition},
+ * All method calls are delegated to the wrapped {@link org.apache.jackrabbit.spi.QItemDefinition},
  * performing the translation from <code>Name</code>s to JCR names
  * (and vice versa) where necessary.
  */
@@ -45,45 +45,61 @@
     protected static final String ANY_NAME = "*";
 
     /**
-     * The node type manager of this session.
-     */
-    protected final NodeTypeManagerImpl ntMgr;
-
-    /**
      * The namespace resolver used to translate qualified names to JCR names.
      */
     protected final NamePathResolver resolver;
 
+        /**
+     * The node type manager of this session.
+     */
+    protected final AbstractNodeTypeManager ntMgr;
+
     /**
      * The wrapped item definition.
      */
     protected final QItemDefinition itemDef;
 
     /**
-     * Package private constructor
+     * Package private constructor to create a definition that is based on
+     * a template.
      *
      * @param itemDef    item definition
-     * @param ntMgr      node type manager
      * @param resolver
      */
-    ItemDefinitionImpl(QItemDefinition itemDef, NodeTypeManagerImpl ntMgr,
-                       NamePathResolver resolver) {
+    ItemDefinitionImpl(QItemDefinition itemDef, NamePathResolver resolver) {
+        this(itemDef, null, resolver);
+    }
+
+    /**
+     * Package private constructor to create a definition that is based on
+     * an existing node type.
+     *
+     * @param itemDef
+     * @param ntMgr
+     * @param resolver
+     */
+    ItemDefinitionImpl(QItemDefinition itemDef, AbstractNodeTypeManager ntMgr, NamePathResolver resolver) {
         this.itemDef = itemDef;
-        this.ntMgr = ntMgr;
         this.resolver = resolver;
+        this.ntMgr = ntMgr;
     }
 
-    //-------------------------------------------------------< ItemDefinition >
+    //-----------------------------------------------------< ItemDefinition >---
     /**
      * {@inheritDoc}
      */
     public NodeType getDeclaringNodeType() {
-        try {
-            return ntMgr.getNodeType(itemDef.getDeclaringNodeType());
-        } catch (NoSuchNodeTypeException e) {
-            // should never get here
-            log.error("declaring node type does not exist", e);
+        if (ntMgr == null) {
+            // only a template
             return null;
+        } else {
+            try {
+                return ntMgr.getNodeType(itemDef.getDeclaringNodeType());
+            } catch (NoSuchNodeTypeException e) {
+                // should never get here
+                log.error("declaring node type does not exist", e);
+                return null;
+            }
         }
     }
 
@@ -152,5 +168,4 @@
     public int hashCode() {
         return itemDef.hashCode();
     }
-}
-
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ItemDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ItemDefinitionImpl.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url