jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1484694 - in /jackrabbit/oak/trunk: oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/
Date Tue, 21 May 2013 08:27:51 GMT
Author: jukka
Date: Tue May 21 08:27:51 2013
New Revision: 1484694

URL: http://svn.apache.org/r1484694
Log:
Revert failing commit 1484689 (OAK-829)

Modified:
    jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java

Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java?rev=1484694&r1=1484693&r2=1484694&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
Tue May 21 08:27:51 2013
@@ -18,9 +18,6 @@ package org.apache.jackrabbit.oak.common
 
 import java.util.Iterator;
 import java.util.NoSuchElementException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import javax.annotation.Nonnull;
 
 /**
@@ -33,9 +30,6 @@ import javax.annotation.Nonnull;
  */
 public final class PathUtils {
 
-    private static final Pattern SNS_PATTERN =
-            Pattern.compile("(.+)\\[[1-9][0-9]*\\]$");
-
     private PathUtils() {
         // utility class
     }
@@ -159,23 +153,6 @@ public final class PathUtils {
     }
 
     /**
-     * Returns the given name without the possible SNS index suffix. If the
-     * name does not contain an SNS index, then it is returned as-is.
-     *
-     * @param name name with a possible SNS index suffix
-     * @return name without the SNS index suffix
-     */
-    @Nonnull
-    public static String dropIndexFromName(@Nonnull String name) {
-        Matcher matcher = SNS_PATTERN.matcher(name);
-        if (matcher.matches()) {
-            return matcher.group(1);
-        } else {
-            return name;
-        }
-    }
-
-    /**
      * Calculate the number of elements in the path. The root path has zero
      * elements.
      *

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java?rev=1484694&r1=1484693&r2=1484694&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java
Tue May 21 08:27:51 2013
@@ -28,12 +28,10 @@ import static org.apache.jackrabbit.JcrC
 import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
 import static org.apache.jackrabbit.JcrConstants.JCR_NODETYPENAME;
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
-import static org.apache.jackrabbit.JcrConstants.JCR_SAMENAMESIBLINGS;
 import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
 import static org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT;
 import static org.apache.jackrabbit.oak.api.Type.UNDEFINED;
 import static org.apache.jackrabbit.oak.api.Type.UNDEFINEDS;
-import static org.apache.jackrabbit.oak.commons.PathUtils.dropIndexFromName;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_IS_ABSTRACT;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.OAK_MANDATORY_CHILD_NODES;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.OAK_MANDATORY_PROPERTIES;
@@ -189,20 +187,18 @@ class EffectiveType {
      *         {@code false} otherwise
      */
     boolean isValidChildNode(String nameWithIndex, EffectiveType effective) {
-        String name = dropIndexFromName(nameWithIndex);
-        boolean sns = !name.equals(nameWithIndex);
+        String nodeName = getNameWithoutIndex(nameWithIndex);
         Set<String> typeNames = effective.getTypeNames();
 
         // Find matching named child node definition
         for (NodeState type : types) {
             NodeState definitions = type
                     .getChildNode(OAK_NAMED_CHILD_NODE_DEFINITIONS)
-                    .getChildNode(name);
+                    .getChildNode(nodeName);
 
             for (String typeName : typeNames) {
                 NodeState definition = definitions.getChildNode(typeName);
-                if (definition.exists()
-                        && sns == definition.getBoolean(JCR_SAMENAMESIBLINGS)) {
+                if (definition.exists()) {
                     return true;
                 }
             }
@@ -227,8 +223,7 @@ class EffectiveType {
                     type.getChildNode(OAK_RESIDUAL_CHILD_NODE_DEFINITIONS);
             for (String typeName : typeNames) {
                 NodeState definition = residual.getChildNode(typeName);
-                if (definition.exists()
-                        && sns == definition.getBoolean(JCR_SAMENAMESIBLINGS)) {
+                if (definition.exists()) {
                     return true;
                 }
             }
@@ -245,8 +240,7 @@ class EffectiveType {
      */
     @CheckForNull
     String getDefaultType(String nameWithIndex) {
-        String name = dropIndexFromName(nameWithIndex);
-        boolean sns = !name.equals(nameWithIndex);
+        String name = getNameWithoutIndex(nameWithIndex);
 
         for (NodeState type : types) {
             NodeState named = type
@@ -260,8 +254,7 @@ class EffectiveType {
                     residual.getChildNodeEntries())) {
                 NodeState definition = entry.getNodeState();
                 String defaultType = definition.getName(JCR_DEFAULTPRIMARYTYPE);
-                if (defaultType != null
-                        && sns == definition.getBoolean(JCR_SAMENAMESIBLINGS)) {
+                if (defaultType != null) {
                     return defaultType;
                 }
             }
@@ -348,6 +341,22 @@ class EffectiveType {
         return names.toString();
     }
 
+    //-----------------------------------------------------------< private >--
+
+    private static String getNameWithoutIndex(String name) {
+        int n = name.length();
+        if (n > 3 && name.charAt(n - 1) == ']') {
+            int i = n - 2;
+            while (i > 1 && Character.isDigit(name.charAt(i))) {
+                i--;
+            }
+            if (name.charAt(i) == '[') {
+                return name.substring(0, i);
+            }
+        }
+        return name;
+    }
+
     private boolean nameSetContains(String set, String name) {
         for (NodeState type : types) {
             if (contains(type.getNames(set), name)) {

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=1484694&r1=1484693&r2=1484694&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
Tue May 21 08:27:51 2013
@@ -21,7 +21,6 @@ import static com.google.common.collect.
 import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.commons.PathUtils.dropIndexFromName;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.NODE_TYPES_PATH;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.OAK_SUPERTYPES;
 
@@ -391,7 +390,7 @@ public abstract class ReadOnlyNodeTypeMa
         checkNotNull(parent);
         checkNotNull(targetNode);
 
-        String name = dropIndexFromName(targetNode.getName());
+        String name = targetNode.getName();
         EffectiveNodeType eff = getEffectiveNodeType(parent);
         return eff.getNodeDefinition(name, getEffectiveNodeType(targetNode));
     }



Mime
View raw message