jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1371213 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Date Thu, 09 Aug 2012 13:49:17 GMT
Author: angela
Date: Thu Aug  9 13:49:17 2012
New Revision: 1371213

URL: http://svn.apache.org/viewvc?rev=1371213&view=rev
Log:
OAK-66 : JCR Node Type Management 

- simplify Node#isNodeType preventing duplicate conversion to from jcr-name to oak-name and
back

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.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/type/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java?rev=1371213&r1=1371212&r2=1371213&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
Thu Aug  9 13:49:17 2012
@@ -21,6 +21,7 @@ import java.io.InputStreamReader;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.Nonnull;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
@@ -116,8 +117,21 @@ public class NodeTypeManagerImpl impleme
         }
     }
 
+    /**
+     * Returns the internal name for the specified JCR name.
+     *
+     * @param jcrName JCR node type name.
+     * @return the internal representation of the given JCR name.
+     * @throws RepositoryException If there is no valid internal representation
+     * of the specified JCR name.
+     */
+    @Nonnull
     protected String getOakName(String jcrName) throws RepositoryException {
-        return mapper.getOakName(jcrName);
+        String oakName = mapper.getOakName(jcrName);
+        if (oakName == null) {
+            throw new RepositoryException("Invalid JCR name " + jcrName);
+        }
+        return oakName;
     }
 
     /**
@@ -131,7 +145,7 @@ public class NodeTypeManagerImpl impleme
     protected void refresh() throws RepositoryException {
     }
 
-    //---------------------------------------------------< NodeTypeManager >--
+    //----------------------------------------------------< NodeTypeManager >---
 
     @Override
     public boolean hasNodeType(String name) throws RepositoryException {
@@ -160,7 +174,7 @@ public class NodeTypeManagerImpl impleme
             for (Tree type : types.getChildren()) {
                 list.add(new NodeTypeImpl(this, factory, new NodeUtil(
                         session.getCoreValueFactory(), mapper, type)));
-                
+
             }
         }
         return new NodeTypeIteratorAdapter(list);

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=1371213&r1=1371212&r2=1371213&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
Thu Aug  9 13:49:17 2012
@@ -67,7 +67,6 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
 import org.apache.jackrabbit.oak.jcr.value.ValueConverter;
-import org.apache.jackrabbit.oak.namepath.NameMapper;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -874,37 +873,24 @@ public class NodeImpl extends ItemImpl<N
     public boolean isNodeType(final String nodeTypeName) throws RepositoryException {
         checkStatus();
 
-        return sessionDelegate.perform(new SessionOperation<Boolean>() {
-            @Override
-            public Boolean perform() throws RepositoryException {
-                // TODO: might be expanded, need a better way for this
-                NameMapper mapper = sessionDelegate.getNamePathMapper();
-                String oakName = mapper.getOakName(nodeTypeName);
-                if (oakName == null) {
-                    return false; // An unknown name can't belong to a valid type
-                }
-                String jcrName = mapper.getJcrName(oakName);
-
-                // TODO: figure out the right place for this check
-                NodeTypeManager ntm = sessionDelegate.getNodeTypeManager();
-                NodeType ntToCheck = ntm.getNodeType(jcrName); // throws on not found
-                String nameToCheck = ntToCheck.getName();
-
-                NodeType currentPrimaryType = getPrimaryNodeType();
-                if (currentPrimaryType.isNodeType(nameToCheck)) {
-                    return true;
-                }
+        // TODO: figure out the right place for this check
+        NodeTypeManager ntm = sessionDelegate.getNodeTypeManager();
+        NodeType ntToCheck = ntm.getNodeType(nodeTypeName); // throws on not found
+        String nameToCheck = ntToCheck.getName();
 
-                for (NodeType mixin : getMixinNodeTypes()) {
-                    if (mixin.isNodeType(nameToCheck)) {
-                        return true;
-                    }
-                }
-                // TODO: END
+        NodeType currentPrimaryType = getPrimaryNodeType();
+        if (currentPrimaryType.isNodeType(nameToCheck)) {
+            return true;
+        }
 
-                return false;
+        for (NodeType mixin : getMixinNodeTypes()) {
+            if (mixin.isNodeType(nameToCheck)) {
+                return true;
             }
-        });
+        }
+        // TODO: END
+
+        return false;
     }
 
     @Override



Mime
View raw message