jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1420676 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Wed, 12 Dec 2012 13:56:45 GMT
Author: angela
Date: Wed Dec 12 13:56:43 2012
New Revision: 1420676

URL: http://svn.apache.org/viewvc?rev=1420676&view=rev
Log:
OAK-494 : Cleanup ReadOnlyNodeTypeManager  (Work in Progress)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeTypeProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeTypeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java?rev=1420676&r1=1420675&r2=1420676&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
Wed Dec 12 13:56:43 2012
@@ -176,7 +176,8 @@ public class IdentifierManager {
      * @param propertyName A name constraint for the reference properties;
      * {@code null} if no constraint should be enforced.
      * @param nodeTypeNames Node type constraints to be enforced when using
-     * for reference properties.
+     * for reference properties; the specified names are expected to be internal
+     * oak names.
      * @return A set of oak paths of those reference properties referring to the
      * specified {@code tree} and matching the constraints.
      */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeTypeProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeTypeProvider.java?rev=1420676&r1=1420675&r2=1420676&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeTypeProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveNodeTypeProvider.java
Wed Dec 12 13:56:43 2012
@@ -33,7 +33,7 @@ public interface EffectiveNodeTypeProvid
      * type of the {@code tree}. Returns {@code false} otherwise.
      *
      * @param tree The tree to be tested.
-     * @param nodeTypeName The name of the node type to be tested.
+     * @param nodeTypeName The internal oak name of the node type to be tested.
      * @return true if the specified node is of the given node type.
      * @throws NoSuchNodeTypeException If the specified node type name doesn't
      * refer to an existing node type.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeTypeImpl.java?rev=1420676&r1=1420675&r2=1420676&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/NodeTypeImpl.java
Wed Dec 12 13:56:43 2012
@@ -226,17 +226,7 @@ class NodeTypeImpl implements NodeType {
     @Override
     public boolean isNodeType(String nodeTypeName) {
         String oakName = node.getNameMapper().getOakName(nodeTypeName);
-        if (getOakName().equals(oakName)) {
-            return true;
-        }
-
-        for (NodeType type : getDeclaredSupertypes()) {
-            if (type.isNodeType(nodeTypeName)) {
-                return true;
-            }
-        }
-
-        return false;
+        return internalIsNodeType(oakName);
     }
 
     @Override
@@ -377,6 +367,18 @@ class NodeTypeImpl implements NodeType {
         return node.getTree().getName();
     }
 
+    boolean internalIsNodeType(String oakName) {
+        if (getOakName().equals(oakName)) {
+            return true;
+        }
+        for (NodeType type : getDeclaredSupertypes()) {
+            if (((NodeTypeImpl) type).internalIsNodeType(oakName)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     Collection<NodeDefinition> internalGetChildDefinitions() {
         // TODO distinguish between additive and overriding node definitions. See 3.7.6.8
Item Definitions in Subtypes
         Collection<NodeDefinition> definitions = new ArrayList<NodeDefinition>();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java?rev=1420676&r1=1420675&r2=1420676&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
Wed Dec 12 13:56:43 2012
@@ -254,24 +254,19 @@ public abstract class ReadOnlyNodeTypeMa
 
     //------------------------------------------< EffectiveNodeTypeProvider >---
     @Override
-    public boolean isNodeType(Tree tree, String nodeTypeName) throws RepositoryException
{
-        if (!hasNodeType(nodeTypeName)) {
-            throw new NoSuchNodeTypeException(nodeTypeName);
-        }
-
-        String oakName = getOakName(nodeTypeName);
+    public boolean isNodeType(Tree tree, String oakNtName) throws RepositoryException {
+        NodeTypeImpl nodeType = internalGetNodeType(oakNtName);
         NodeUtil node = new NodeUtil(tree);
         String ntName = node.getPrimaryNodeTypeName();
         if (ntName == null) {
             return false;
-        } else if (oakName.equals(ntName)
-                || internalGetNodeType(ntName).isNodeType(nodeTypeName)) {
+        } else if (oakNtName.equals(ntName) || internalGetNodeType(ntName).isNodeType(oakNtName))
{
             return true;
         }
         String[] mixinNames = node.getStrings(JcrConstants.JCR_MIXINTYPES);
         if (mixinNames != null) {
             for (String mixinName : mixinNames) {
-                if (oakName.equals(mixinName) || internalGetNodeType(mixinName).isNodeType(nodeTypeName))
{
+                if (oakNtName.equals(mixinName) || internalGetNodeType(mixinName).isNodeType(oakNtName))
{
                     return true;
                 }
             }
@@ -307,7 +302,7 @@ public abstract class ReadOnlyNodeTypeMa
         PropertyState jcrPrimaryType = tree.getProperty(JCR_PRIMARYTYPE);
         if (jcrPrimaryType != null) {
             String ntName = jcrPrimaryType.getValue(STRING);
-            primaryType = getNodeType(ntName);
+            primaryType = internalGetNodeType(ntName);
         } else {
             throw new RepositoryException("Node at "+tree.getPath()+" has no primary type.");
         }
@@ -317,7 +312,7 @@ public abstract class ReadOnlyNodeTypeMa
         PropertyState jcrMixinType = tree.getProperty(JCR_MIXINTYPES);
         if (jcrMixinType != null) {
             for (String ntName : jcrMixinType.getValue(STRINGS)) {
-                mixinTypes.add(getNodeType(ntName));
+                mixinTypes.add(internalGetNodeType(ntName));
             }
         }
         queue.addAll(mixinTypes);
@@ -334,16 +329,20 @@ public abstract class ReadOnlyNodeTypeMa
 
     @Nonnull
     @Override
-    public NodeDefinition getDefinition(@Nonnull Node parent,
-                                        @Nonnull String nodeName)
+    public NodeDefinition getDefinition(@Nonnull Node parent, @Nonnull String nodeName)
             throws RepositoryException {
         checkNotNull(parent);
         checkNotNull(nodeName);
+
         return getNodeDefinition(getEffectiveNodeType(parent), nodeName, null);
     }
 
     @Override
-    public NodeDefinition getDefinition(@Nonnull Node parent, @Nonnull Node targetNode) throws
RepositoryException {
+    public NodeDefinition getDefinition(@Nonnull Node parent, @Nonnull Node targetNode)
+            throws RepositoryException {
+        checkNotNull(parent);
+        checkNotNull(targetNode);
+
         String name = targetNode.getName();
         EffectiveNodeType eff = getEffectiveNodeType(parent);
         return getNodeDefinition(eff, name, getEffectiveNodeType(targetNode));
@@ -401,7 +400,7 @@ public abstract class ReadOnlyNodeTypeMa
     }
 
     //------------------------------------------------------------< private >---
-    private NodeType internalGetNodeType(String oakName) throws NoSuchNodeTypeException {
+    private NodeTypeImpl internalGetNodeType(String oakName) throws NoSuchNodeTypeException
{
         Tree types = getTypes();
         if (types != null) {
             Tree type = types.getChild(oakName);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1420676&r1=1420675&r2=1420676&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Wed Dec 12 13:56:43 2012
@@ -860,7 +860,8 @@ public class NodeImpl extends ItemImpl<N
     public boolean isNodeType(final String nodeTypeName) throws RepositoryException {
         checkStatus();
 
-        return sessionDelegate.getEffectiveNodeTypeProvider().isNodeType(dlg.getTree(), nodeTypeName);
+        String oakName = sessionDelegate.getOakNameOrThrow(nodeTypeName);
+        return sessionDelegate.getEffectiveNodeTypeProvider().isNodeType(dlg.getTree(), oakName);
     }
 
     @Override



Mime
View raw message