jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1394012 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
Date Thu, 04 Oct 2012 12:35:16 GMT
Author: mreutegg
Date: Thu Oct  4 12:35:15 2012
New Revision: 1394012

URL: http://svn.apache.org/viewvc?rev=1394012&view=rev
Log:
OAK-66: JCR Node Type Management
- Do not prohibit protected properties in general. We rather need to introduce semantic checks.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java?rev=1394012&r1=1394011&r2=1394012&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
Thu Oct  4 12:35:15 2012
@@ -46,6 +46,15 @@ import static org.apache.jackrabbit.JcrC
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
 
+/**
+ * Validator implementation that check JCR node type constraints.
+ *
+ * TODO: check protected properties and the structure they enforce. some of
+ *       those checks may have to go into separate validator classes. This class
+ *       should only perform checks based on node type information. E.g. it
+ *       cannot and should not check whether the value of the protected jcr:uuid
+ *       is unique.
+ */
 class TypeValidator implements Validator {
     private static final Logger log = LoggerFactory.getLogger(TypeValidator.class);
 
@@ -247,6 +256,9 @@ class TypeValidator implements Validator
         }
 
         public void checkSetProperty(PropertyState property) throws ConstraintViolationException
{
+            if (isProtected(property.getName())) {
+                return;
+            }
             if (property.isArray()) {
                 checkSetProperty(property.getName(), property.getValues());
             }
@@ -278,6 +290,9 @@ class TypeValidator implements Validator
         }
 
         public void checkRemoveProperty(PropertyState property) throws ConstraintViolationException
{
+            if (isProtected(property.getName())) {
+                return;
+            }
             final String name = property.getName();
             for (NodeType nodeType : allTypes) {
                 if (nodeType.canRemoveProperty(name)) {
@@ -333,6 +348,17 @@ class TypeValidator implements Validator
             }
         }
 
+        private boolean isProtected(String propertyName) {
+            for (NodeType nodeType : allTypes) {
+                for (PropertyDefinition pd : nodeType.getPropertyDefinitions()) {
+                    if (propertyName.equals(pd.getName()) && pd.isProtected()) {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
         private Value[] jcrValues(List<CoreValue> values) {
             Value[] jcrValues = new  Value[values.size()];
 



Mime
View raw message