jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1384010 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/ oak-jcr/
Date Wed, 12 Sep 2012 16:10:53 GMT
Author: mduerig
Date: Wed Sep 12 16:10:53 2012
New Revision: 1384010

URL: http://svn.apache.org/viewvc?rev=1384010&view=rev
Log:
OAK-66: JCR Node Type Management
property type validation for path and name

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java?rev=1384010&r1=1384009&r2=1384010&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/AbstractNodeTypeManager.java
Wed Sep 12 16:10:53 2012
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.commons.ite
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryValueFactory;
 import org.apache.jackrabbit.oak.util.NodeUtil;
@@ -89,6 +90,11 @@ public abstract class AbstractNodeTypeMa
     }
 
     @Nonnull
+    protected NamePathMapper getNamePathMapper() {
+        return NamePathMapper.DEFAULT;
+    }
+
+    @Nonnull
     protected CoreValueFactory getCoreValueFactory() {
         return MemoryValueFactory.INSTANCE;
     }
@@ -112,7 +118,7 @@ public abstract class AbstractNodeTypeMa
         if (types != null) {
             Tree type = types.getChild(getOakName(name));
             if (type != null) {
-                return new NodeTypeImpl(this, getValueFactory(),
+                return new NodeTypeImpl(this, getValueFactory(), getNamePathMapper(),
                         new NodeUtil(type, getCoreValueFactory(), getNameMapper()));
             }
         }
@@ -125,7 +131,7 @@ public abstract class AbstractNodeTypeMa
         Tree types = getTypes();
         if (types != null) {
             for (Tree type : types.getChildren()) {
-                list.add(new NodeTypeImpl(this, getValueFactory(),
+                list.add(new NodeTypeImpl(this, getValueFactory(), getNamePathMapper(),
                         new NodeUtil(type, getCoreValueFactory(), getNameMapper())));
 
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java?rev=1384010&r1=1384009&r2=1384010&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeImpl.java
Wed Sep 12 16:10:53 2012
@@ -42,6 +42,7 @@ import javax.jcr.nodetype.PropertyDefini
 import javax.security.auth.Subject;
 
 import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
 import org.apache.jackrabbit.oak.plugins.type.constraint.Constraints;
 import org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal;
@@ -80,13 +81,16 @@ class NodeTypeImpl implements NodeType {
 
     private final NodeTypeManager manager;
 
+    private final NamePathMapper mapper;
+
     private final ValueFactory factory;
 
     private final NodeUtil node;
 
     public NodeTypeImpl(
-            NodeTypeManager manager, ValueFactory factory, NodeUtil node) {
+            NodeTypeManager manager, ValueFactory factory, NamePathMapper mapper, NodeUtil
node) {
         this.manager = manager;
+        this.mapper = mapper;
         this.factory = factory;
         this.node = node;
     }
@@ -306,7 +310,7 @@ class NodeTypeImpl implements NodeType {
         return false;
     }
 
-    private static boolean meetsTypeConstraints(Value value, int requiredType) {
+    private boolean meetsTypeConstraints(Value value, int requiredType) {
         try {
             switch (requiredType) {
                 case PropertyType.STRING:
@@ -328,13 +332,13 @@ class NodeTypeImpl implements NodeType {
                     value.getBoolean();
                     return true;
                 case PropertyType.NAME:
-                    // TODO check type constraint for name
-                    value.getString();
-                    return true;
+                    return mapper.getOakName(value.getString()) != null;
                 case PropertyType.PATH:
-                    // TODO check type constraint for path
-                    value.getString();
-                    return true;
+                    int type = value.getType();
+                    return type != PropertyType.DOUBLE &&
+                           type != PropertyType.LONG &&
+                           type != PropertyType.BOOLEAN &&
+                           mapper.getOakPath(value.getString()) != null;
                 case PropertyType.REFERENCE:
                 case PropertyType.WEAKREFERENCE:
                     return IdentifierManager.isValidUUID(value.getString());
@@ -359,7 +363,7 @@ class NodeTypeImpl implements NodeType {
         }
     }
 
-    private static boolean meetsTypeConstraints(Value[] values, int requiredType) {
+    private boolean meetsTypeConstraints(Value[] values, int requiredType) {
         // Constraints must be met by all values
         for (Value value : values) {
             if (!meetsTypeConstraints(value, requiredType)) {

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=1384010&r1=1384009&r2=1384010&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
Wed Sep 12 16:10:53 2012
@@ -22,6 +22,7 @@ import java.security.PrivilegedAction;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.Nonnull;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
@@ -49,6 +50,7 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal;
 import org.apache.jackrabbit.oak.util.NodeUtil;
@@ -90,11 +92,11 @@ public class NodeTypeManagerImpl extends
 
     private final ContentSession session;
 
-    private final NameMapper mapper;
+    private final NamePathMapper mapper;
 
     private final ValueFactory factory;
 
-    public NodeTypeManagerImpl(ContentSession session, NameMapper mapper, ValueFactory factory)
{
+    public NodeTypeManagerImpl(ContentSession session, NamePathMapper mapper, ValueFactory
factory) {
         this.session = session;
         this.mapper = mapper;
         this.factory = factory;
@@ -176,6 +178,12 @@ public class NodeTypeManagerImpl extends
         return factory;
     }
 
+    @Nonnull
+    @Override
+    protected NamePathMapper getNamePathMapper() {
+        return mapper;
+    }
+
     @Override
     protected CoreValueFactory getCoreValueFactory() {
         return session.getCoreValueFactory();
@@ -267,7 +275,7 @@ public class NodeTypeManagerImpl extends
             internalRegisterNodeDefinition(def, nd);
         }
 
-        return new NodeTypeImpl(this, this.factory, node);
+        return new NodeTypeImpl(this, this.factory, this.mapper, node);
     }
 
     private static void internalRegisterItemDefinition(

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1384010&r1=1384009&r2=1384010&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Wed Sep 12 16:10:53 2012
@@ -69,7 +69,6 @@ org.apache.jackrabbit.test.api.HasPermis
 org.apache.jackrabbit.test.api.lock.LockManagerTest#testAddInvalidLockToken
 org.apache.jackrabbit.test.api.lock.LockManagerTest#testLockNonLockable
 org.apache.jackrabbit.test.api.nodetype.PropertyDefTest#testIsMandatory
-org.apache.jackrabbit.test.api.nodetype.CanSetPropertyPathTest#testConversions
 org.apache.jackrabbit.test.api.LifecycleTest
 org.apache.jackrabbit.test.api.query.ElementTest#testElementTestNameTestSomeNTWithSNS<!--
OAK-203 -->
 org.apache.jackrabbit.test.api.query.GetPropertyNamesTest#testGetPropertyNames



Mime
View raw message