jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1440936 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Thu, 31 Jan 2013 12:49:34 GMT
Author: mduerig
Date: Thu Jan 31 12:49:34 2013
New Revision: 1440936

URL: http://svn.apache.org/viewvc?rev=1440936&view=rev
Log:
OAK-599: PropertyDelegate uses TreeImpl.PropertyLocation

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/NullLocation.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java?rev=1440936&r1=1440935&r2=1440936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
Thu Jan 31 12:49:34 2013
@@ -97,4 +97,12 @@ public interface TreeLocation {
      */
     boolean remove();
 
+    /**
+     * Set the underlying property of this {@code TreeLocation}. If the underlying item is
+     * not a property, this method return {@code false}.
+     * @param property The property to set
+     * @return {@code true} if the property state was set, {@code false} otherwise.
+     */
+    boolean set(PropertyState property);
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java?rev=1440936&r1=1440935&r2=1440936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractNodeLocation.java
Thu Jan 31 12:49:34 2013
@@ -54,4 +54,9 @@ abstract class AbstractNodeLocation<T ex
     public Tree.Status getStatus() {
         return tree.getStatus();
     }
+
+    @Override
+    public boolean set(PropertyState property) {
+        return false;
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/NullLocation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/NullLocation.java?rev=1440936&r1=1440935&r2=1440936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/NullLocation.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/NullLocation.java
Thu Jan 31 12:49:34 2013
@@ -97,4 +97,11 @@ final class NullLocation implements Tree
         return null;
     }
 
+    /**
+     * @return {@code false}
+     */
+    @Override
+    public boolean set(PropertyState property) {
+        return false;
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java?rev=1440936&r1=1440935&r2=1440936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
Thu Jan 31 12:49:34 2013
@@ -321,5 +321,10 @@ public class ReadOnlyTree implements Tre
         public Status getStatus() {
             return Status.EXISTING;
         }
+
+        @Override
+        public boolean set(PropertyState property) {
+            return false;
+        }
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1440936&r1=1440935&r2=1440936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Thu Jan 31 12:49:34 2013
@@ -636,8 +636,7 @@ public class TreeImpl implements Tree {
         }
     }
 
-    // TODO: OAK-599 (accessed by PropertyDelegate)
-    public final class PropertyLocation extends AbstractPropertyLocation<TreeImpl, NodeLocation>
{
+    private final class PropertyLocation extends AbstractPropertyLocation<TreeImpl, NodeLocation>
{
 
         private PropertyLocation(NodeLocation parentLocation, String name) {
             super(parentLocation, name);
@@ -656,13 +655,10 @@ public class TreeImpl implements Tree {
             return parentLocation.tree.getPropertyStatus(name);
         }
 
-        /**
-         * Set the underlying property
-         *
-         * @param property The property to set
-         */
-        public void set(PropertyState property) {
+        @Override
+        public boolean set(PropertyState property) {
             parentLocation.tree.setProperty(property);
+            return true;
         }
 
         /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1440936&r1=1440935&r2=1440936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Thu Jan 31 12:49:34 2013
@@ -25,7 +25,6 @@ import javax.jcr.Value;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.TreeLocation;
-import org.apache.jackrabbit.oak.core.TreeImpl.PropertyLocation;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 
@@ -78,7 +77,9 @@ public class PropertyDelegate extends It
      * @param value
      */
     public void setValue(Value value) throws RepositoryException {
-        getPropertyLocation().set(PropertyStates.createProperty(getName(), value));
+        if (!getLocation().set(PropertyStates.createProperty(getName(), value))) {
+            throw new InvalidItemStateException();
+        }
     }
 
     /**
@@ -87,7 +88,9 @@ public class PropertyDelegate extends It
      * @param values
      */
     public void setValues(Iterable<Value> values) throws RepositoryException {
-        getPropertyLocation().set(PropertyStates.createProperty(getName(), values));
+        if (!getLocation().set(PropertyStates.createProperty(getName(), values))) {
+            throw new InvalidItemStateException();
+        }
     }
 
     /**
@@ -108,14 +111,4 @@ public class PropertyDelegate extends It
         return property;
     }
 
-    // TODO: OAK-599
-    @Nonnull
-    private PropertyLocation getPropertyLocation() throws InvalidItemStateException {
-        TreeLocation location = getLocation();
-        if (!(location instanceof PropertyLocation)) {
-            throw new InvalidItemStateException();
-        }
-        return (PropertyLocation) location;
-    }
-
 }



Mime
View raw message