jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1394118 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: api/ core/ plugins/commit/ plugins/name/ security/user/ util/
Date Thu, 04 Oct 2012 15:45:52 GMT
Author: mduerig
Date: Thu Oct  4 15:45:52 2012
New Revision: 1394118

URL: http://svn.apache.org/viewvc?rev=1394118&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
- Replace usages of deprecated Tree.setProperty method with new method and remove the former

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.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-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/AnnotatingConflictHandler.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java?rev=1394118&r1=1394117&r2=1394118&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java Thu
Oct  4 15:45:52 2012
@@ -219,17 +219,6 @@ public interface Tree {
     Tree addChild(String name);
 
     /**
-     * Set a single valued property state
-     *
-     * @param name The name of this property
-     * @param value The value of this property
-     * @return the affected property state
-     */
-    @Nonnull
-    @Deprecated
-    PropertyState setProperty(String name, @Nonnull CoreValue value);
-
-    /**
      * Set a multivalued valued property state
      *
      * @param name The name of this property

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java?rev=1394118&r1=1394117&r2=1394118&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java
Thu Oct  4 15:45:52 2012
@@ -69,7 +69,7 @@ class MergingNodeStateDiff implements No
 
         switch (resolution) {
             case OURS:
-                setProperty(target, after);
+                target.setProperty(after);
                 break;
             case THEIRS:
             case MERGED:
@@ -97,7 +97,7 @@ class MergingNodeStateDiff implements No
 
         switch (resolution) {
             case OURS:
-                setProperty(target, after);
+                target.setProperty(after);
                 break;
             case THEIRS:
             case MERGED:
@@ -207,19 +207,11 @@ class MergingNodeStateDiff implements No
     private static void addChild(Tree target, String name, NodeState state) {
         Tree child = target.addChild(name);
         for (PropertyState property : state.getProperties()) {
-            setProperty(child, property);
+            child.setProperty(property);
         }
         for (ChildNodeEntry entry : state.getChildNodeEntries()) {
             addChild(child, entry.getName(), entry.getNodeState());
         }
     }
 
-    private static void setProperty(Tree target, PropertyState property) {
-        if (property.isArray()) {
-            target.setProperty(property.getName(), property.getValues());
-        } else {
-            target.setProperty(property.getName(), property.getValue());
-        }
-    }
-
 }
\ No newline at end of file

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=1394118&r1=1394117&r2=1394118&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 Oct  4 15:45:52 2012
@@ -188,12 +188,6 @@ public class ReadOnlyTree implements Tre
 
     @Override
     @Deprecated
-    public PropertyState setProperty(String name, CoreValue value) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    @Deprecated
     public PropertyState setProperty(String name, List<CoreValue> values) {
         throw new UnsupportedOperationException();
     }

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=1394118&r1=1394117&r2=1394118&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 Oct  4 15:45:52 2012
@@ -264,17 +264,6 @@ public class TreeImpl implements Tree, P
 
     @Override
     @Deprecated
-    public PropertyState setProperty(String name, CoreValue value) {
-        NodeBuilder builder = getNodeBuilder();
-        builder.setProperty(name, value);
-        root.purge();
-        PropertyState property = getProperty(name);
-        assert property != null;
-        return property;
-    }
-
-    @Override
-    @Deprecated
     public PropertyState setProperty(String name, List<CoreValue> values) {
         NodeBuilder builder = getNodeBuilder();
         builder.setProperty(name, values);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/AnnotatingConflictHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/AnnotatingConflictHandler.java?rev=1394118&r1=1394117&r2=1394118&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/AnnotatingConflictHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/AnnotatingConflictHandler.java
Thu Oct  4 15:45:52 2012
@@ -65,35 +65,35 @@ public class AnnotatingConflictHandler i
     @Override
     public Resolution addExistingProperty(Tree parent, PropertyState ours, PropertyState
theirs) {
         Tree marker = addConflictMarker(parent);
-        setProperty(getOrCreateNode(marker, ADD_EXISTING), ours);
+        getOrCreateNode(marker, ADD_EXISTING).setProperty(ours);
         return Resolution.THEIRS;
     }
 
     @Override
     public Resolution changeDeletedProperty(Tree parent, PropertyState ours) {
         Tree marker = addConflictMarker(parent);
-        setProperty(getOrCreateNode(marker, CHANGE_DELETED), ours);
+        getOrCreateNode(marker, CHANGE_DELETED).setProperty(ours);
         return Resolution.THEIRS;
     }
 
     @Override
     public Resolution changeChangedProperty(Tree parent, PropertyState ours, PropertyState
theirs) {
         Tree marker = addConflictMarker(parent);
-        setProperty(getOrCreateNode(marker, CHANGE_CHANGED), ours);
+        getOrCreateNode(marker, CHANGE_CHANGED).setProperty(ours);
         return Resolution.THEIRS;
     }
 
     @Override
     public Resolution deleteChangedProperty(Tree parent, PropertyState theirs) {
         Tree marker = addConflictMarker(parent);
-        setProperty(getOrCreateNode(marker, DELETE_CHANGED), theirs);
+        getOrCreateNode(marker, DELETE_CHANGED).setProperty(theirs);
         return Resolution.THEIRS;
     }
 
     @Override
     public Resolution deleteDeletedProperty(Tree parent, PropertyState ours) {
         Tree marker = addConflictMarker(parent);
-        setProperty(getOrCreateNode(marker, DELETE_DELETED), ours);
+        getOrCreateNode(marker, DELETE_DELETED).setProperty(ours);
         return Resolution.THEIRS;
     }
 
@@ -151,7 +151,7 @@ public class AnnotatingConflictHandler i
     private static void addChild(Tree parent, String name, NodeState state) {
         Tree child = parent.addChild(name);
         for (PropertyState property : state.getProperties()) {
-            setProperty(child, property);
+            child.setProperty(property);
         }
         for (ChildNodeEntry entry : state.getChildNodeEntries()) {
             addChild(child, entry.getName(), entry.getNodeState());
@@ -162,12 +162,4 @@ public class AnnotatingConflictHandler i
         parent.addChild(name);
     }
 
-    private static void setProperty(Tree parent, PropertyState property) {
-        if (property.isArray()) {
-            parent.setProperty(property.getName(), property.getValues());
-        } else {
-            parent.setProperty(property.getName(), property.getValue());
-        }
-    }
-
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java?rev=1394118&r1=1394117&r2=1394118&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
Thu Oct  4 15:45:52 2012
@@ -24,7 +24,6 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.plugins.memory.StringValue;
 
 /**
  * Writable namespace registry. Mainly for use to implement the full JCR API.
@@ -81,7 +80,7 @@ public abstract class ReadWriteNamespace
                     namespaces.removeProperty(p.getName());
                 }
             }
-            namespaces.setProperty(prefix, new StringValue(uri));
+            namespaces.setProperty(prefix, uri);
             root.commit();
             refresh();
         } catch (NamespaceValidatorException e) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java?rev=1394118&r1=1394117&r2=1394118&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
Thu Oct  4 15:45:52 2012
@@ -20,6 +20,7 @@ import java.security.Principal;
 import java.text.ParseException;
 import java.util.Collections;
 import java.util.Iterator;
+
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.query.Query;
@@ -33,6 +34,7 @@ import org.apache.jackrabbit.oak.api.Res
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.memory.SinglePropertyState;
 import org.apache.jackrabbit.oak.spi.security.principal.TreeBasedPrincipal;
 import org.apache.jackrabbit.oak.spi.security.user.Type;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
@@ -261,7 +263,7 @@ class UserProviderImpl extends Authoriza
             authorizableTree.removeProperty(propertyName);
         } else {
             CoreValue cv = valueFactory.createValue(value, propertyType);
-            authorizableTree.setProperty(propertyName, cv);
+            authorizableTree.setProperty(new SinglePropertyState(propertyName, cv));
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java?rev=1394118&r1=1394117&r2=1394118&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
Thu Oct  4 15:45:52 2012
@@ -42,6 +42,10 @@ import org.apache.jackrabbit.util.ISO860
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.jackrabbit.oak.api.Type.DATE;
+import static org.apache.jackrabbit.oak.api.Type.LONG;
+import static org.apache.jackrabbit.oak.api.Type.NAME;
+
 /**
  * Utility class for accessing and writing typed content of a tree.
  */
@@ -125,7 +129,7 @@ public class NodeUtil {
     }
 
     public void setBoolean(String name, boolean value) {
-        tree.setProperty(name, factory.createValue(value));
+        tree.setProperty(name, value);
     }
 
     public String getString(String name, String defaultValue) {
@@ -138,7 +142,7 @@ public class NodeUtil {
     }
 
     public void setString(String name, String value) {
-        tree.setProperty(name, factory.createValue(value));
+        tree.setProperty(name, value);
     }
 
     public String[] getStrings(String name) {
@@ -178,7 +182,7 @@ public class NodeUtil {
 
     public void setName(String name, String value) {
         String oakName = getOakName(value);
-        tree.setProperty(name, factory.createValue(oakName, PropertyType.NAME));
+        tree.setProperty(name, oakName, NAME);
     }
 
     public String[] getNames(String name, String... defaultValues) {
@@ -203,20 +207,20 @@ public class NodeUtil {
     public void setDate(String name, long time) {
         Calendar cal = GregorianCalendar.getInstance();
         cal.setTimeInMillis(time);
-        tree.setProperty(name, factory.createValue(ISO8601.format(cal), PropertyType.DATE));
+        tree.setProperty(name, ISO8601.format(cal), DATE);
     }
 
     public long getLong(String name, long defaultValue) {
         PropertyState property = tree.getProperty(name);
         if (property != null && !property.isArray()) {
-            return property.getValue().getLong();
+            return property.getValue(LONG);
         } else {
             return defaultValue;
         }
     }
 
     public void setLong(String name, long value) {
-        tree.setProperty(name, factory.createValue(value));
+        tree.setProperty(name, value);
     }
 
     public List<NodeUtil> getNodes(String namePrefix) {



Mime
View raw message