jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1540047 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/spi/commit/DefaultMoveValidator.java test/java/org/apache/jackrabbit/oak/spi/state/MoveDetectorTest.java
Date Fri, 08 Nov 2013 14:23:29 GMT
Author: mduerig
Date: Fri Nov  8 14:23:28 2013
New Revision: 1540047

URL: http://svn.apache.org/r1540047
Log:
OAK-783: Reflect Move and Rename upon Root#commit
Introduce and use DefaultMoveValidator

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/DefaultMoveValidator.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/MoveDetectorTest.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/DefaultMoveValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/DefaultMoveValidator.java?rev=1540047&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/DefaultMoveValidator.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/DefaultMoveValidator.java
Fri Nov  8 14:23:28 2013
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.spi.commit;
+
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.spi.state.MoveValidator;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * {@code MoveValidator} that does nothing by default and doesn't recurse into subtrees.
+ * Useful as a sentinel or as a base class for more complex validators.
+ *
+ * @see DefaultValidator
+ */
+public class DefaultMoveValidator extends DefaultValidator implements MoveValidator {
+    @Override
+    public void move(String sourcePath, String destPath, NodeState moved) throws CommitFailedException
{
+        // do nothing
+    }
+
+    @Override
+    public MoveValidator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
+        // do nothing
+        return null;
+    }
+
+    @Override
+    public MoveValidator childNodeChanged(String name, NodeState before, NodeState after)
throws CommitFailedException {
+        // do nothing
+        return null;
+    }
+
+    @Override
+    public MoveValidator childNodeDeleted(String name, NodeState before) throws CommitFailedException
{
+        // do nothing
+        return null;
+    }
+}

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/MoveDetectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/MoveDetectorTest.java?rev=1540047&r1=1540046&r2=1540047&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/MoveDetectorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/MoveDetectorTest.java
Fri Nov  8 14:23:28 2013
@@ -23,9 +23,9 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertTrue;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
+import org.apache.jackrabbit.oak.spi.commit.DefaultMoveValidator;
 import org.apache.jackrabbit.oak.spi.commit.EditorDiff;
 import org.junit.Before;
 import org.junit.Test;
@@ -149,7 +149,7 @@ public class MoveDetectorTest {
         return builder;
     }
 
-    private static class FindSingleMove implements MoveValidator {
+    private static class FindSingleMove extends DefaultMoveValidator {
         private final String sourcePath;
         private final String destPath;
 
@@ -172,85 +172,25 @@ public class MoveDetectorTest {
         }
 
         @Override
-        public void enter(NodeState before, NodeState after) throws CommitFailedException
{
-        }
-
-        @Override
-        public void leave(NodeState before, NodeState after) throws CommitFailedException
{
-        }
-
-        @Override
-        public void propertyAdded(PropertyState after) {
-        }
-
-        @Override
-        public void propertyChanged(PropertyState before, PropertyState after) {
-        }
-
-        @Override
-        public void propertyDeleted(PropertyState before) {
-        }
-
-        @Override
-        public MoveValidator childNodeAdded(String name, NodeState after) {
-            return null;
-        }
-
-        @Override
         public MoveValidator childNodeChanged(String name, NodeState before, NodeState after)
{
             return this;
         }
 
-        @Override
-        public MoveValidator childNodeDeleted(String name, NodeState before) {
-            return null;
-        }
-
         public boolean found() {
             return found;
         }
     }
 
-    private static class AssertNoMove implements MoveValidator {
+    private static class AssertNoMove extends DefaultMoveValidator {
         @Override
         public void move(String sourcePath, String destPath, NodeState moved) throws CommitFailedException
{
             throw new CommitFailedException("Test", 0, "There should be no move operation");
         }
 
         @Override
-        public void enter(NodeState before, NodeState after) throws CommitFailedException
{
-        }
-
-        @Override
-        public void leave(NodeState before, NodeState after) throws CommitFailedException
{
-        }
-
-        @Override
-        public void propertyAdded(PropertyState after) {
-        }
-
-        @Override
-        public void propertyChanged(PropertyState before, PropertyState after) {
-        }
-
-        @Override
-        public void propertyDeleted(PropertyState before) {
-        }
-
-        @Override
-        public MoveValidator childNodeAdded(String name, NodeState after) {
-            return null;
-        }
-
-        @Override
         public MoveValidator childNodeChanged(String name, NodeState before, NodeState after)
{
             return this;
         }
-
-        @Override
-        public MoveValidator childNodeDeleted(String name, NodeState before) {
-            return null;
-        }
     }
 
 }



Mime
View raw message