jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1304530 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state: ChangeTree.java TransientNodeState.java
Date Fri, 23 Mar 2012 18:05:01 GMT
Author: mduerig
Date: Fri Mar 23 18:05:01 2012
New Revision: 1304530

URL: http://svn.apache.org/viewvc?rev=1304530&view=rev
Log:
OAK-15: Clean up oak-jcr
Use Scalar instead of JsonValue (WIP)

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java?rev=1304530&r1=1304529&r2=1304530&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
Fri Mar 23 18:05:01 2012
@@ -23,7 +23,6 @@ import org.apache.commons.collections.ma
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.ScalarImpl;
 import org.apache.jackrabbit.mk.model.PropertyState;
-import org.apache.jackrabbit.oak.api.Scalar;
 import org.apache.jackrabbit.oak.jcr.util.Iterators;
 import org.apache.jackrabbit.oak.jcr.util.Path;
 import org.apache.jackrabbit.oak.jcr.util.Predicate;
@@ -34,7 +33,6 @@ import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 import static org.apache.jackrabbit.oak.jcr.util.Unchecked.cast;
@@ -333,40 +331,30 @@ public class ChangeTree {
         }
 
         /**
-         * Set the property with the given {@code name} to {@code value} or remove the
-         * property if {@code value} is {@code null}.
-         * @param name
-         * @param value
+         * Set the given property {@code state}
+         * @param state
          */
-        public void setValue(String name, Scalar value) {
-            if (value == null) {
-                value = ScalarImpl.nullScalar();
-            }
-
-            if (value.equals(ScalarImpl.nullScalar()) && properties.containsKey(name)
&&
-                    !properties.get(name).equals(ScalarImpl.nullScalar())) {
-
-                properties.remove(name);
-                notifyRemoveProperty(this, name);
-            }
-            else {
-                KernelPropertyState state = new KernelPropertyState(name, value);
-                properties.put(name, state);
-                touch();
-                notifySetProperty(this, state);
-            }
+        public void setProperty(PropertyState state) {
+            properties.put(state.getName(), state);
+            touch();
+            notifySetProperty(this, state);
         }
 
         /**
-         * Set the property with the given {@code name} to {@code values}.
+         * Remove the property with the given {@code name}
          * @param name
-         * @param values
          */
-        public void setValue(String name, List<Scalar> values) {
-            KernelPropertyState state = new KernelPropertyState(name, values);
-            properties.put(name, state);
-            touch();
-            notifySetProperty(this, state);
+        public void removeProperty(String name)  {
+            KernelPropertyState state = (KernelPropertyState) properties.get(name);  // fixme
don't cast
+            if (state != null && !state.isMultiValued() && !state.getValue().equals(ScalarImpl.nullScalar()))
{
+                // remove transiently added property
+                properties.remove(name);
+            }
+            else {
+                // mark property as removed
+                properties.put(name, new KernelPropertyState(name, ScalarImpl.nullScalar()));
+                notifyRemoveProperty(this, name);
+            }
         }
 
         //------------------------------------------< internal >---
@@ -617,7 +605,12 @@ public class ChangeTree {
         }
 
         @Override
-        public void setValue(String name, Scalar value) {
+        public void removeProperty(String name) {
+            throw new IllegalStateException("Removed");
+        }
+
+        @Override
+        public void setProperty(PropertyState state) {
             throw new IllegalStateException("Removed");
         }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java?rev=1304530&r1=1304529&r2=1304530&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java
Fri Mar 23 18:05:01 2012
@@ -142,7 +142,7 @@ public class TransientNodeState {
      *               to remove the property.
      */
     public void setProperty(String name, Scalar value) {
-        getNodeDelta().setValue(name, value);
+        getNodeDelta().setProperty(new KernelPropertyState(name, value));
     }
 
     /**
@@ -151,7 +151,7 @@ public class TransientNodeState {
      * @param values  Values of the property.
      */
     public void setProperty(String name, List<Scalar> values) {
-        getNodeDelta().setValue(name, values);
+        getNodeDelta().setProperty(new KernelPropertyState(name, values));
     }
 
     /**
@@ -159,7 +159,7 @@ public class TransientNodeState {
      * @param name  name of the property to remove.
      */
     public void removeProperty(String name) {
-        getNodeDelta().setValue(name, (Scalar) null);
+        getNodeDelta().removeProperty(name);
     }
 
     /**
@@ -270,7 +270,7 @@ public class TransientNodeState {
         }
 
         if (state.isMultiValued()) {
-            return true;
+            return getPersistedPropertyState(name) == null;
         }
         else {
             Scalar value = state.getValue();



Mime
View raw message