jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1311712 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-mk/src/main/java/org/apache/jack...
Date Tue, 10 Apr 2012 13:26:11 GMT
Author: angela
Date: Tue Apr 10 13:26:11 2012
New Revision: 1311712

URL: http://svn.apache.org/viewvc?rev=1311712&view=rev
Log:
OAK-55 : Provide reasonable way to set property on NodeStateEditor

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/NodeStateEditor.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java?rev=1311712&r1=1311711&r2=1311712&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
Tue Apr 10 13:26:11 2012
@@ -22,6 +22,9 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.mk.model.NodeState;
 import org.apache.jackrabbit.mk.model.NodeStateEditor;
 import org.apache.jackrabbit.mk.model.PropertyState;
+import org.apache.jackrabbit.mk.model.Scalar;
+
+import java.util.List;
 
 import static org.apache.jackrabbit.mk.util.PathUtils.elements;
 import static org.apache.jackrabbit.mk.util.PathUtils.getName;
@@ -90,10 +93,19 @@ public class KernelNodeStateEditor imple
     }
 
     @Override
-    public void setProperty(PropertyState state) {
-        transientState.setProperty(state);
-        jsop.append("^\"").append(path(state.getName())).append("\":")
-                .append(state.getEncodedValue());
+    public void setProperty(String name, Scalar value) {
+        PropertyState propertyState = new KernelPropertyState(name, value);
+        transientState.setProperty(propertyState);
+        jsop.append("^\"").append(path(propertyState.getName())).append("\":")
+                .append(propertyState.getEncodedValue());
+    }
+
+    @Override
+    public void setProperty(String name, List<Scalar> values) {
+        PropertyState propertyState = new KernelPropertyState(name, values);
+        transientState.setProperty(propertyState);
+        jsop.append("^\"").append(path(propertyState.getName())).append("\":")
+                .append(propertyState.getEncodedValue());
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzTest.java?rev=1311712&r1=1311711&r2=1311712&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzTest.java
Tue Apr 10 13:26:11 2012
@@ -218,11 +218,13 @@ public class KernelNodeStateEditorFuzzTe
 
         static class SetProperty extends Operation {
             private final String parentPath;
-            private KernelPropertyState propertyState;
+            private String propertyName;
+            private Scalar propertyValue;
 
             SetProperty(String parentPath, String name, Scalar value) {
                 this.parentPath = parentPath;
-                this.propertyState = new KernelPropertyState(name, value);
+                this.propertyName = name;
+                this.propertyValue = value;
             }
 
             @Override
@@ -230,13 +232,13 @@ public class KernelNodeStateEditorFuzzTe
                 for (String element : PathUtils.elements(parentPath)) {
                     editor = editor.edit(element);
                 }
-                editor.setProperty(propertyState);
+                editor.setProperty(propertyName, propertyValue);
             }
 
             @Override
             public String toString() {
-                return '^' + PathUtils.concat(parentPath, propertyState.getName()) + ':'
-                        + propertyState.getEncodedValue();
+                return '^' + PathUtils.concat(parentPath, propertyName) + ':'
+                        + propertyValue;
             }
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java?rev=1311712&r1=1311711&r2=1311712&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
Tue Apr 10 13:26:11 2012
@@ -155,7 +155,7 @@ public class KernelNodeStateEditorTest {
 
         assertFalse(transientState.hasProperty("new"));
         Scalar value = ScalarImpl.stringScalar("value");
-        editor.setProperty(new KernelPropertyState("new", value));
+        editor.setProperty("new", value);
         PropertyState property = transientState.getProperty("new");
         assertNotNull(property);
         assertEquals("new", property.getName());
@@ -275,16 +275,16 @@ public class KernelNodeStateEditorTest {
         assertEquals(3, transientState.getPropertyCount());
 
         Scalar value = ScalarImpl.stringScalar("foo");
-        editor.setProperty(new KernelPropertyState("a", value));
+        editor.setProperty("a", value);
         assertEquals(3, transientState.getPropertyCount());
 
         editor.removeProperty("a");
         assertEquals(2, transientState.getPropertyCount());
 
-        editor.setProperty(new KernelPropertyState("x", value));
+        editor.setProperty("x", value);
         assertEquals(3, transientState.getPropertyCount());
 
-        editor.setProperty(new KernelPropertyState("a", value));
+        editor.setProperty("a", value);
         assertEquals(4, transientState.getPropertyCount());
     }
     

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1311712&r1=1311711&r2=1311712&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Tue Apr 10 13:26:11 2012
@@ -224,7 +224,7 @@ public class NodeImpl extends ItemImpl i
     public Property setProperty(String name, Value value, int type) throws RepositoryException
{
         checkStatus();
 
-        editor.setProperty(new KernelPropertyState(name, ValueConverter.toScalar(value)));
+        editor.setProperty(name, ValueConverter.toScalar(value));
         return getProperty(name);
     }
 
@@ -246,7 +246,7 @@ public class NodeImpl extends ItemImpl i
     public Property setProperty(String name, Value[] values, int type) throws RepositoryException
{
         checkStatus();
 
-        editor.setProperty(new KernelPropertyState(name, ValueConverter.toScalar(values)));
+        editor.setProperty(name, ValueConverter.toScalar(values));
         return getProperty(name);
     }
 
@@ -418,8 +418,7 @@ public class NodeImpl extends ItemImpl i
         Property property = getPropertyOrNull(relPath);
         if (property == null) {
             throw new PathNotFoundException(relPath);
-        }
-        else {
+        } else {
             return property;
         }
     }
@@ -595,8 +594,7 @@ public class NodeImpl extends ItemImpl i
     public void setPrimaryType(String nodeTypeName) throws RepositoryException {
         checkStatus();
 
-        editor.setProperty(new KernelPropertyState(
-                JcrConstants.JCR_PRIMARYTYPE, ScalarImpl.stringScalar(nodeTypeName)));
+        editor.setProperty(JcrConstants.JCR_PRIMARYTYPE, ScalarImpl.stringScalar(nodeTypeName));
     }
 
     @Override
@@ -821,6 +819,11 @@ public class NodeImpl extends ItemImpl i
 
     }
 
+    //-----------------------------------------------------< implementation >---
+    public NodeStateEditor getEditor() {
+        return editor;
+    }
+
     //------------------------------------------------------------< private >---
     /**
      * Shortcut to retrieve the version manager from the workspace associated

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1311712&r1=1311711&r2=1311712&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Tue Apr 10 13:26:11 2012
@@ -22,7 +22,6 @@ import org.apache.jackrabbit.mk.util.Pat
 import org.apache.jackrabbit.oak.jcr.util.LogUtil;
 import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStateEditor;
-import org.apache.jackrabbit.oak.kernel.KernelPropertyState;
 import org.apache.jackrabbit.oak.kernel.TransientNodeState;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
@@ -563,10 +562,8 @@ public class PropertyImpl extends ItemIm
 
         if (value == null) {
             remove();
-        }
-        else {
-            parentEditor.setProperty(new KernelPropertyState(
-                    propertyState.getName(), ValueConverter.toScalar(value)));
+        } else {
+            parentEditor.setProperty(propertyState.getName(), ValueConverter.toScalar(value));
         }
     }
 
@@ -584,10 +581,8 @@ public class PropertyImpl extends ItemIm
 
         if (values == null) {
             remove();
-        }
-        else {
-            parentEditor.setProperty(new KernelPropertyState(
-                    propertyState.getName(), ValueConverter.toScalar(values)));
+        } else {
+            parentEditor.setProperty(propertyState.getName(), ValueConverter.toScalar(values));
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/NodeStateEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/NodeStateEditor.java?rev=1311712&r1=1311711&r2=1311712&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/NodeStateEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/NodeStateEditor.java
Tue Apr 10 13:26:11 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.mk.model;
 
+import java.util.List;
+
 /**
  * An editor for modifying existing and creating new
  * {@link NodeState node states}.
@@ -39,10 +41,20 @@ public interface NodeStateEditor {
     void removeNode(String name);
 
     /**
-     * Set a property on this node state
-     * @param state property state to set
+     * Set a single valued property state on this node state.
+     *
+     * @param name The name of this property
+     * @param value The value of this property
+     */
+    void setProperty(String name, Scalar value);
+
+    /**
+     * Set a multivalued valued property state on this node state.
+     *
+     * @param name The name of this property
+     * @param values The value of this property
      */
-    void setProperty(PropertyState state);
+    void setProperty(String name, List<Scalar> values);
 
     /**
      * Remove a property from this node state



Mime
View raw message