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 md...@apache.org on 2012/05/30 15:54:43 UTC

svn commit: r1344262 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/name/NameValidator.java plugins/type/TypeValidator.java spi/commit/Validator.java

Author: mduerig
Date: Wed May 30 13:54:43 2012
New Revision: 1344262

URL: http://svn.apache.org/viewvc?rev=1344262&view=rev
Log:
OAK-68 - Extension point for commit validation
Validator.childNodeDeleted should have void return type since there is nothing to validated on a deleted node

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/Validator.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java?rev=1344262&r1=1344261&r2=1344262&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java Wed May 30 13:54:43 2012
@@ -98,9 +98,8 @@ class NameValidator implements Validator
     }
 
     @Override
-    public Validator childNodeDeleted(String name, NodeState before) {
+    public void childNodeDeleted(String name, NodeState before) {
         // do nothing
-        return this;
     }
 
 }

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=1344262&r1=1344261&r2=1344262&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 Wed May 30 13:54:43 2012
@@ -91,9 +91,8 @@ class TypeValidator implements Validator
     }
 
     @Override
-    public Validator childNodeDeleted(String name, NodeState before) {
+    public void childNodeDeleted(String name, NodeState before) {
         // TODO: validate removed child node
-        return this;
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/Validator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/Validator.java?rev=1344262&r1=1344261&r2=1344262&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/Validator.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/Validator.java Wed May 30 13:54:43 2012
@@ -46,8 +46,7 @@ public interface Validator {
             String name, NodeState before, NodeState after)
             throws CommitFailedException;
 
-    @Nonnull
-    Validator childNodeDeleted(String name, NodeState before)
+    void childNodeDeleted(String name, NodeState before)
             throws CommitFailedException;
 
 }



Re: svn commit: r1344262 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/name/NameValidator.java plugins/type/TypeValidator.java spi/commit/Validator.java

Posted by Michael Dürig <md...@apache.org>.

On 1.6.12 11:16, Jukka Zitting wrote:
> Actually, contrary to our earlier discussion, I did now remember why
> it's a good idea for the childNodeDeleted() method to return a
> Validator to be used for descending into the removed subtree.
>
> See the NamespaceValidator class that I added in revision 1345006 for
> validating changes to the /jcr:system/jcr:namespaces subtree. It's
> easier to write that code if I can rely on the ValidatingCommitHook
> calling the propertyDeleted() methods on the removed namespace mapping
> properties instead of also interpreting childNodeDeleted() calls on
> /jcr:system or /jcr:system/jcr:namespaces.

Ack, makes sense.

>
> In that revision I adjusted all the relevant code to reflect the
> restored childNodeDeleted() return value. I also did some further
> cleanup on the exception handling in ValidatingCommitHook (using a
> member variable instead of an array reference from the surrounding
> class).

Ok yes this looks better now. I further cleaned it up a bit in revision 
1345233. It seemed odd to me that you had to pass in the validator to 
the constructor of ValidatorDiff and to its validate method. It should 
only be a member of ValidatorDiff.

Michael

>
> BR,
>
> Jukka Zitting


Re: svn commit: r1344262 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/name/NameValidator.java plugins/type/TypeValidator.java spi/commit/Validator.java

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Wed, May 30, 2012 at 3:54 PM,  <md...@apache.org> wrote:
> Validator.childNodeDeleted should have void return type since there is nothing to validated on a deleted node

Actually, contrary to our earlier discussion, I did now remember why
it's a good idea for the childNodeDeleted() method to return a
Validator to be used for descending into the removed subtree.

See the NamespaceValidator class that I added in revision 1345006 for
validating changes to the /jcr:system/jcr:namespaces subtree. It's
easier to write that code if I can rely on the ValidatingCommitHook
calling the propertyDeleted() methods on the removed namespace mapping
properties instead of also interpreting childNodeDeleted() calls on
/jcr:system or /jcr:system/jcr:namespaces.

In that revision I adjusted all the relevant code to reflect the
restored childNodeDeleted() return value. I also did some further
cleanup on the exception handling in ValidatingCommitHook (using a
member variable instead of an array reference from the surrounding
class).

BR,

Jukka Zitting