You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2012/10/04 14:35:16 UTC
svn commit: r1394012 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
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()];