jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r773838 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commo...
Date Tue, 12 May 2009 10:07:53 GMT
Author: angela
Date: Tue May 12 10:07:53 2009
New Revision: 773838

URL: http://svn.apache.org/viewvc?rev=773838&view=rev
Log:
JCR-2105: JSR 283 NodeType Management (work in progress)
- missing implementations in NodeType.java
JCR-1483: Move common node type functionality to jackrabbit-spi-commons
- move jsr 283 nodetype management impl that can be shared between jackrabbit-core and jackrabbit-jcr2spi
to jackrabbit-spi-commons

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?rev=773838&r1=773837&r2=773838&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
Tue May 12 10:07:53 2009
@@ -29,7 +29,6 @@
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeDefinition;
-import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.jackrabbit.core.data.DataStore;
@@ -37,15 +36,15 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeType;
 import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * A <code>NodeTypeImpl</code> ...
  */
-public class NodeTypeImpl implements NodeType, NodeTypeDefinition {
+public class NodeTypeImpl extends AbstractNodeType implements NodeType, NodeTypeDefinition
{
 
     private static Logger log = LoggerFactory.getLogger(NodeTypeImpl.class);
 
@@ -73,6 +72,7 @@
     NodeTypeImpl(EffectiveNodeType ent, NodeTypeDef ntd,
                  NodeTypeManagerImpl ntMgr, NamePathResolver resolver,
                  ValueFactory valueFactory, DataStore store) {
+        super(ntMgr);
         this.ent = ent;
         this.ntMgr = ntMgr;
         this.resolver = resolver;
@@ -228,49 +228,6 @@
         return (NodeType[]) inherited.toArray(new NodeType[inherited.size()]);
     }
 
-    /**
-     * Returns the node types derived from this node type.
-     *
-     * @param directOnly if <code>true</code> only direct subtypes will be considered
-     *
-     * @return an <code>NodeTypeIterator</code>.
-     * @see #getSubtypes
-     * @see #getDeclaredSubtypes
-     */
-    public NodeTypeIterator getSubtypes(boolean directOnly) {
-        NodeTypeIterator iter;
-        try {
-            iter = ntMgr.getAllNodeTypes();
-        } catch (RepositoryException e) {
-            // should never get here
-            log.error("failed to retrieve registered node types", e);
-            return NodeTypeIteratorAdapter.EMPTY;
-        }
-
-        ArrayList<NodeType> result = new ArrayList<NodeType>();
-        String thisName = getName();
-        while (iter.hasNext()) {
-            NodeType nt = iter.nextNodeType();
-            if (!nt.getName().equals(thisName)) {
-                if (directOnly) {
-                    // direct subtypes only
-                    String[] names = nt.getDeclaredSupertypeNames();
-                    for (int i = 0; i < names.length; i++) {
-                        if (names[i].equals(thisName)) {
-                            result.add(nt);
-                            break;
-                        }
-                    }
-                } else {
-                    // direct and indirect subtypes
-                    if (nt.isNodeType(thisName)) {
-                        result.add(nt);
-                    }
-                }
-            }
-        }
-        return new NodeTypeIteratorAdapter(result);
-    }
 
     //---------------------------------------------------< NodeTypeDefinition >
     /**
@@ -700,29 +657,4 @@
         }
         return false;
     }
-
-    /**
-     * Returns the <i>direct</i> subtypes of this node type in the node type
inheritance hierarchy,
-     * that is, those which actually declared this node type in their list of supertypes.
-     *
-     * @see #getSubtypes
-     *
-     * @return an <code>NodeTypeIterator</code>.
-     * @since JCR 2.0
-     */
-    public NodeTypeIterator getDeclaredSubtypes() {
-        return getSubtypes(true);
-    }
-
-    /**
-     * Returns all subtypes of this node type in the node type inheritance hierarchy.
-     *
-     * @see #getDeclaredSubtypes
-     *
-     * @return a <code>NodeTypeIterator</code>.
-     * @since JCR 2.0
-     */
-    public NodeTypeIterator getSubtypes() {
-        return getSubtypes(false);
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java?rev=773838&r1=773837&r2=773838&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
Tue May 12 10:07:53 2009
@@ -27,6 +27,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeType;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
@@ -41,7 +42,6 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.nodetype.NodeTypeDefinition;
 import java.util.ArrayList;
@@ -49,7 +49,7 @@
 /**
  * <code>NodeTypeImpl</code> ...
  */
-public class NodeTypeImpl implements NodeType, NodeTypeDefinition {
+public class NodeTypeImpl extends AbstractNodeType implements NodeTypeDefinition {
 
     private static Logger log = LoggerFactory.getLogger(NodeTypeImpl.class);
 
@@ -72,6 +72,7 @@
      */
     NodeTypeImpl(EffectiveNodeType ent, QNodeTypeDefinition ntd,
                  NodeTypeManagerImpl ntMgr, ManagerProvider mgrProvider) {
+        super(ntMgr);
         this.ent = ent;
         this.ntMgr = ntMgr;
         this.mgrProvider = mgrProvider;
@@ -356,22 +357,6 @@
     }
 
     /**
-     * @see javax.jcr.nodetype.NodeType#getDeclaredSubtypes()
-     */
-    public NodeTypeIterator getDeclaredSubtypes() {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2003: Add support for JCR 2.0. Implementation
missing");
-    }
-
-    /**
-     * @see javax.jcr.nodetype.NodeType#getSubtypes()
-     */
-    public NodeTypeIterator getSubtypes() {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2003: Add support for JCR 2.0. Implementation
missing");
-    }
-
-    /**
      * @see javax.jcr.nodetype.NodeType#canSetProperty(String, Value)
      */
     public boolean canSetProperty(String propertyName, Value value) {

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=773838&r1=773837&r2=773838&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
Tue May 12 10:07:53 2009
@@ -362,6 +362,7 @@
      */
     public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
             throws RepositoryException {
+        // TODO
         throw new UnsupportedRepositoryOperationException("JCR-1591");
     }
 
@@ -370,6 +371,7 @@
      */
     public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
             throws RepositoryException {
+        // TODO
         throw new UnsupportedRepositoryOperationException("JCR-1591");
     }
 
@@ -377,6 +379,7 @@
      * @see NodeTypeManager#unregisterNodeType(String)
      */
     public void unregisterNodeType(String name) throws RepositoryException {
+        // TODO
         throw new UnsupportedRepositoryOperationException("JCR-1591");
     }
 
@@ -384,6 +387,7 @@
      * @see NodeTypeManager#unregisterNodeTypes(String[])
      */
     public void unregisterNodeTypes(String[] names) throws RepositoryException {
+        // TODO
         throw new UnsupportedRepositoryOperationException("JCR-1591");
     }
 

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java?rev=773838&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
Tue May 12 10:07:53 2009
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.commons.nodetype;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.RepositoryException;
+import java.util.ArrayList;
+
+/**
+ * <code>AbstractNodeType</code>...
+ */
+/**
+ * <code>AbstractNodeType</code>...
+ */
+public abstract class AbstractNodeType implements NodeType {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(AbstractNodeType.class);
+
+    private final AbstractNodeTypeManager ntMgr;
+
+    /**
+     * Create a new <code>AbstractNodeType</code>.
+     *
+     * @param ntMgr
+     */
+    public AbstractNodeType(AbstractNodeTypeManager ntMgr) {
+        this.ntMgr = ntMgr;
+    }
+
+    //-----------------------------------------------------------< NodeType >---
+    /**
+     * @see javax.jcr.nodetype.NodeType#getDeclaredSubtypes()
+     */
+    public NodeTypeIterator getDeclaredSubtypes() {
+        return getSubtypes(true);
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeType#getSubtypes()
+     */
+    public NodeTypeIterator getSubtypes() {
+        return getSubtypes(false);
+    }        
+
+    //--------------------------------------------------------------------------
+    /**
+     * Returns the node types derived from this node type.
+     *
+     * @param directOnly if <code>true</code> only direct subtypes will be considered
+     *
+     * @return an <code>NodeTypeIterator</code>.
+     * @see NodeType#getSubtypes
+     * @see NodeType#getDeclaredSubtypes
+     */
+    public NodeTypeIterator getSubtypes(boolean directOnly) {
+        NodeTypeIterator iter;
+        try {
+            iter = ntMgr.getAllNodeTypes();
+        } catch (RepositoryException e) {
+            // should never get here
+            log.error("failed to retrieve registered node types", e);
+            return NodeTypeIteratorAdapter.EMPTY;
+        }
+
+        ArrayList<NodeType> result = new ArrayList<NodeType>();
+        String thisName = getName();
+        while (iter.hasNext()) {
+            NodeType nt = iter.nextNodeType();
+            if (!nt.getName().equals(thisName)) {
+                if (directOnly) {
+                    // direct subtypes only
+                    String[] names = nt.getDeclaredSupertypeNames();
+                    for (int i = 0; i < names.length; i++) {
+                        if (names[i].equals(thisName)) {
+                            result.add(nt);
+                            break;
+                        }
+                    }
+                } else {
+                    // direct and indirect subtypes
+                    if (nt.isNodeType(thisName)) {
+                        result.add(nt);
+                    }
+                }
+            }
+        }
+        return new NodeTypeIteratorAdapter(result);
+    }
+}
\ No newline at end of file



Mime
View raw message