jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1547034 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-core/src/main/...
Date Mon, 02 Dec 2013 14:45:42 GMT
Author: angela
Date: Mon Dec  2 14:45:42 2013
New Revision: 1547034

URL: http://svn.apache.org/r1547034
Log:
OAK-372 : Integrate PropertyBuilder with NodeBuilder

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
  (contents, props changed)
      - copied, changed from r1545683, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilder.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/PropertyBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyUtil.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilderTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/ItemImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Mon Dec  2 14:45:42 2013
@@ -18,22 +18,8 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.indexOf;
-import static org.apache.jackrabbit.oak.api.Tree.Status.EXISTING;
-import static org.apache.jackrabbit.oak.api.Tree.Status.MODIFIED;
-import static org.apache.jackrabbit.oak.api.Tree.Status.NEW;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
-import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
-
 import java.util.Collections;
 import java.util.Set;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
@@ -44,11 +30,23 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.core.AbstractRoot.Move;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.indexOf;
+import static org.apache.jackrabbit.oak.api.Tree.Status.EXISTING;
+import static org.apache.jackrabbit.oak.api.Tree.Status.MODIFIED;
+import static org.apache.jackrabbit.oak.api.Tree.Status.NEW;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
+import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
 
 public class MutableTree extends AbstractTree {
 
@@ -197,7 +195,7 @@ public class MutableTree extends Abstrac
             if (parent.hasOrderableChildren()) {
                 // FIXME (OAK-842) child order not updated when parent is not accessible
                 parent.nodeBuilder.setProperty(
-                        MemoryPropertyBuilder.copy(STRING, parent.nodeBuilder.getProperty(OAK_CHILD_ORDER))
+                        PropertyBuilder.copy(STRING, parent.nodeBuilder.getProperty(OAK_CHILD_ORDER))
                                 .removeValue(name)
                                 .getPropertyState()
                 );
@@ -216,7 +214,7 @@ public class MutableTree extends Abstrac
             nodeBuilder.setChildNode(name);
             if (hasOrderableChildren()) {
                 nodeBuilder.setProperty(
-                        MemoryPropertyBuilder.copy(STRING, nodeBuilder.getProperty(OAK_CHILD_ORDER))
+                        PropertyBuilder.copy(STRING, nodeBuilder.getProperty(OAK_CHILD_ORDER))
                                 .addValue(name)
                                 .getPropertyState());
             }
@@ -386,8 +384,7 @@ public class MutableTree extends Abstrac
         for (String name : nodeBuilder.getChildNodeNames()) {
             names.add(name);
         }
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.array(
-                STRING, OAK_CHILD_ORDER);
+        PropertyBuilder builder = PropertyBuilder.array(STRING, OAK_CHILD_ORDER);
         builder.setValues(names);
         nodeBuilder.setProperty(builder.getPropertyState());
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java
Mon Dec  2 14:45:42 2013
@@ -22,10 +22,9 @@ import com.google.common.collect.Sets;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.core.AbstractTree;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
 
 /**
  * This conflict handler instance takes care of properly merging conflicts
@@ -77,8 +76,7 @@ public class ChildOrderConflictHandler e
 
     private static void merge(NodeBuilder parent, PropertyState ours, PropertyState theirs)
{
         Set<String> theirOrder = Sets.newHashSet(theirs.getValue(Type.STRINGS));
-        PropertyBuilder<String> merged = MemoryPropertyBuilder.array(Type.STRING)
-                .assignFrom(theirs);
+        PropertyBuilder<String> merged = PropertyBuilder.array(Type.STRING).assignFrom(theirs);
 
         // Append child node names from ours that are not in theirs
         for (String ourChild : ours.getValue(Type.STRINGS)) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
Mon Dec  2 14:45:42 2013
@@ -16,24 +16,12 @@
  */
 package org.apache.jackrabbit.oak.plugins.commit;
 
-import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.CONFLICT;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.ADD_EXISTING_NODE;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.ADD_EXISTING_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.CHANGE_CHANGED_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.CHANGE_DELETED_NODE;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.CHANGE_DELETED_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_CHANGED_NODE;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_CHANGED_PROPERTY;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_DELETED_NODE;
-import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_DELETED_PROPERTY;
-
 import java.util.Map;
 
 import com.google.common.collect.ImmutableMap;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.core.AbstractTree;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler.Resolution;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
@@ -41,10 +29,21 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff.CONFLICT;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.ADD_EXISTING_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.ADD_EXISTING_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.CHANGE_CHANGED_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.CHANGE_DELETED_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.CHANGE_DELETED_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_CHANGED_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_CHANGED_PROPERTY;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_DELETED_NODE;
+import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_DELETED_PROPERTY;
+
 /**
  * MergingNodeStateDiff... TODO
  */
@@ -238,7 +237,7 @@ public final class MergingNodeStateDiff 
         target.setChildNode(name, state);
         PropertyState childOrder = target.getProperty(AbstractTree.OAK_CHILD_ORDER);
         if (childOrder != null) {
-            PropertyBuilder<String> builder = MemoryPropertyBuilder.copy(Type.STRING,
childOrder);
+            PropertyBuilder builder = PropertyBuilder.copy(Type.STRING, childOrder);
             builder.addValue(name);
             target.setProperty(builder.getPropertyState());
         }
@@ -248,7 +247,7 @@ public final class MergingNodeStateDiff 
         target.getChildNode(name).remove();
         PropertyState childOrder = target.getProperty(AbstractTree.OAK_CHILD_ORDER);
         if (childOrder != null) {
-            PropertyBuilder<String> builder = MemoryPropertyBuilder.copy(Type.STRING,
childOrder);
+            PropertyBuilder builder = PropertyBuilder.copy(Type.STRING, childOrder);
             builder.removeValue(name);
             target.setProperty(builder.getPropertyState());
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
Mon Dec  2 14:45:42 2013
@@ -34,7 +34,7 @@ import static com.google.common.base.Pre
  * providing default implementation which correspond to a property
  * without any value.
  */
-abstract class EmptyPropertyState extends AbstractPropertyState {
+public abstract class EmptyPropertyState extends AbstractPropertyState {
 
     private final String name;
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImpl.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImpl.java
Mon Dec  2 14:45:42 2013
@@ -80,9 +80,8 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits;
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider;
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConfiguration;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
 import org.apache.jackrabbit.oak.util.NodeUtil;
-import org.apache.jackrabbit.oak.util.PropertyUtil;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.util.Text;
@@ -506,7 +505,7 @@ public class AccessControlManagerImpl im
             if (mixins == null) {
                 tree.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton(mixinName),
Type.NAMES);
             } else {
-                PropertyBuilder pb = PropertyUtil.getPropertyBuilder(Type.NAME, mixins);
+                PropertyBuilder pb = PropertyBuilder.copy(Type.NAME, mixins);
                 pb.addValue(mixinName);
                 tree.setProperty(pb.getPropertyState());
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
Mon Dec  2 14:45:42 2013
@@ -27,8 +27,7 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
-import org.apache.jackrabbit.oak.util.PropertyUtil;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
 import org.apache.jackrabbit.util.Text;
 
 /**
@@ -66,9 +65,9 @@ class JcrAllCommitHook implements PostVa
 
                 PropertyBuilder<String> propertyBuilder;
                 if (aggregates == null) {
-                    propertyBuilder = PropertyUtil.getPropertyBuilder(Type.NAME, REP_AGGREGATES,
true);
+                    propertyBuilder = PropertyBuilder.create(Type.NAME, REP_AGGREGATES, true);
                 } else {
-                    propertyBuilder = PropertyUtil.getPropertyBuilder(Type.NAME, aggregates);
+                    propertyBuilder = PropertyBuilder.copy(Type.NAME, aggregates);
                 }
                 if (!propertyBuilder.hasValue(name)) {
                     propertyBuilder.addValue(name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
Mon Dec  2 14:45:42 2013
@@ -19,10 +19,10 @@ package org.apache.jackrabbit.oak.securi
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
-
 import javax.annotation.Nonnull;
 import javax.jcr.RepositoryException;
 
+import com.google.common.collect.Iterators;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -35,8 +35,6 @@ import org.apache.jackrabbit.oak.util.Ab
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Iterators;
-
 /**
  * {@code MembershipProvider} implementation storing group membership information
  * with the {@code Tree} associated with a given {@link org.apache.jackrabbit.api.security.user.Group}.
@@ -115,7 +113,6 @@ class MembershipProvider extends Authori
      */
     MembershipProvider(Root root, ConfigurationParameters config) {
         super(root, config);
-
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
Mon Dec  2 14:45:42 2013
@@ -27,8 +27,7 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
-import org.apache.jackrabbit.oak.util.PropertyUtil;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
 
 import com.google.common.collect.Iterators;
 
@@ -110,9 +109,9 @@ public class MembershipWriter {
                 }
                 bestTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, UserConstants.NT_REP_MEMBER_REFERENCES,
NAME);
             }
-            propertyBuilder = PropertyUtil.getPropertyBuilder(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS,
true);
+            propertyBuilder = PropertyBuilder.create(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS,
true);
         } else {
-            propertyBuilder = PropertyUtil.getPropertyBuilder(Type.WEAKREFERENCE, bestProperty);
+            propertyBuilder = PropertyBuilder.copy(Type.WEAKREFERENCE, bestProperty);
         }
         propertyBuilder.addValue(memberContentId);
         bestTree.setProperty(propertyBuilder.getPropertyState());
@@ -136,7 +135,7 @@ public class MembershipWriter {
             Tree t = trees.next();
             PropertyState refs = t.getProperty(UserConstants.REP_MEMBERS);
             if (refs != null) {
-                PropertyBuilder<String> prop = PropertyUtil.getPropertyBuilder(Type.WEAKREFERENCE,
refs);
+                PropertyBuilder<String> prop = PropertyBuilder.copy(Type.WEAKREFERENCE,
refs);
                 if (prop.hasValue(memberContentId)) {
                     prop.removeValue(memberContentId);
                     if (prop.isEmpty()) {
@@ -175,7 +174,7 @@ public class MembershipWriter {
         int numNodes = 0;
         for (String ref: members) {
             if (prop == null) {
-                prop = PropertyUtil.getPropertyBuilder(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS,
true);
+                prop = PropertyBuilder.create(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS,
true);
             }
             prop.addValue(ref);
             count++;

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
(from r1545683, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilder.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilder.java&r1=1545683&r2=1547034&rev=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
Mon Dec  2 14:45:42 2013
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.plugins.memory;
+package org.apache.jackrabbit.oak.util;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -26,7 +26,21 @@ import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
+import org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.BooleanPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.DecimalPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.DoublePropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.EmptyPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.GenericPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.LongPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.MultiBinaryPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.MultiBooleanPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.MultiDecimalPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.MultiDoublePropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.MultiGenericPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.MultiLongPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.StringPropertyState;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
@@ -35,7 +49,7 @@ import static com.google.common.base.Pre
  * {@code PropertyBuilder} for building in memory {@code PropertyState} instances.
  * @param <T>
  */
-public class MemoryPropertyBuilder<T> implements PropertyBuilder<T> {
+public class PropertyBuilder<T> {
     private final Type<T> type;
 
     private String name;
@@ -48,7 +62,7 @@ public class MemoryPropertyBuilder<T> im
      * @param type  type of the {@code PropertyState} instances to be built.
      * @throws IllegalArgumentException if {@code type.isArray()} is {@code true}.
      */
-    public MemoryPropertyBuilder(Type<T> type) {
+    public PropertyBuilder(Type<T> type) {
         checkArgument(!type.isArray(), "type must not be array");
         this.type = type;
     }
@@ -59,8 +73,8 @@ public class MemoryPropertyBuilder<T> im
      * @param type  type of the {@code PropertyState} instances to be built.
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder<T> scalar(Type<T> type) {
-        return new MemoryPropertyBuilder<T>(type);
+    public static <T> PropertyBuilder scalar(Type<T> type) {
+        return new PropertyBuilder<T>(type);
     }
 
     /**
@@ -69,8 +83,8 @@ public class MemoryPropertyBuilder<T> im
      * @param type  type of the {@code PropertyState} instances to be built.
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder<T> array(Type<T> type) {
-        return new MemoryPropertyBuilder<T>(type).setArray();
+    public static <T> PropertyBuilder array(Type<T> type) {
+        return new PropertyBuilder<T>(type).setArray();
     }
 
     /**
@@ -85,7 +99,7 @@ public class MemoryPropertyBuilder<T> im
      * @param name  initial name
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder<T> scalar(Type<T> type, String name)
{
+    public static <T> PropertyBuilder scalar(Type<T> type, String name) {
         return scalar(type).setName(name);
     }
 
@@ -101,7 +115,7 @@ public class MemoryPropertyBuilder<T> im
      * @param name  initial name
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder<T> array(Type<T> type, String name)
{
+    public static <T> PropertyBuilder array(Type<T> type, String name) {
         return scalar(type).setName(name).setArray();
     }
 
@@ -111,60 +125,73 @@ public class MemoryPropertyBuilder<T> im
      * the values of {@code property}.
      * Equivalent to
      * <pre>
-     *     MemoryPropertyBuilder.create(type).assignFrom(property);
+     *     PropertyBuilder.scalar(type).assignFrom(property);
      * </pre>
+     *
      * @param type  type of the {@code PropertyState} instances to be built.
      * @param property  initial name and values
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder<T> copy(Type<T> type, PropertyState
property) {
+    public static <T> PropertyBuilder copy(Type<T> type, PropertyState property)
{
         return scalar(type).assignFrom(property);
     }
 
-    @Override
+    /**
+     * Create a new {@code PropertyBuilder} from the specified parameters. Depending
+     * on the {@code isArray} flag this corresponds to
+     * <pre>{@link #array(org.apache.jackrabbit.oak.api.Type, String)}</pre>
or
+     * <pre>{@link #scalar(org.apache.jackrabbit.oak.api.Type, String)}</pre>.
+     *
+     *
+     *
+     * @param type type of the {@code PropertyState} instances to be built.
+     * @param name the name of the state to be built.
+     * @param isArray
+     * @return {@code PropertyBuilder} for {@code type}.
+     */
+    public static <T> PropertyBuilder create(@Nonnull Type<T> type, @Nonnull
String name, boolean isArray) {
+        if (isArray) {
+            return array(type, name);
+        } else {
+            return scalar(type, name);
+        }
+    }
+
     public String getName() {
         return name;
     }
 
-    @Override
     public T getValue() {
         return values.isEmpty() ? null : values.get(0);
     }
 
     @Nonnull
-    @Override
     public List<T> getValues() {
         return Lists.newArrayList(values);
     }
 
-    @Override
     public T getValue(int index) {
         return values.get(index);
     }
 
-    @Override
     public boolean hasValue(Object value) {
         return values.contains(value);
     }
 
-    @Override
     public int count() {
         return values.size();
     }
 
-    @Override
     public boolean isArray() {
         return isArray;
     }
 
-    @Override
     public boolean isEmpty() {
         return count() == 0;
     }
 
     @SuppressWarnings("unchecked")
     @Nonnull
-    @Override
     public PropertyState getPropertyState() {
         checkState(name != null, "Property has no name");
         checkState(isArray() || values.size() == 1, "Property has multiple values");
@@ -211,8 +238,7 @@ public class MemoryPropertyBuilder<T> im
 
     @SuppressWarnings("unchecked")
     @Nonnull
-    @Override
-    public PropertyBuilder<T> assignFrom(PropertyState property) {
+    public PropertyBuilder assignFrom(PropertyState property) {
         if (property != null) {
             setName(property.getName());
             if (property.isArray()) {
@@ -227,65 +253,56 @@ public class MemoryPropertyBuilder<T> im
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> setName(String name) {
+    public PropertyBuilder setName(String name) {
         this.name = name;
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> setArray() {
+    public PropertyBuilder setArray() {
         isArray = true;
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> setScalar() {
+    public PropertyBuilder setScalar() {
         isArray = false;
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> setValue(T value) {
+    public PropertyBuilder setValue(T value) {
         values.clear();
         values.add(value);
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> addValue(T value) {
+    public PropertyBuilder addValue(T value) {
         values.add(value);
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> setValue(T value, int index) {
+    public PropertyBuilder setValue(T value, int index) {
         values.set(index, value);
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> setValues(Iterable<T> values) {
+    public PropertyBuilder setValues(Iterable<T> values) {
         this.values = Lists.newArrayList(values);
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> removeValue(int index) {
+    public PropertyBuilder removeValue(int index) {
         values.remove(index);
         return this;
     }
 
     @Nonnull
-    @Override
-    public PropertyBuilder<T> removeValue(Object value) {
+    public PropertyBuilder removeValue(Object value) {
         values.remove(value);
         return this;
     }

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilderTest.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilderTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilderTest.java
Mon Dec  2 14:45:42 2013
@@ -20,7 +20,7 @@ import java.util.Arrays;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -29,7 +29,7 @@ public class MemoryPropertyBuilderTest {
 
     @Test
     public void testStringProperty() {
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.STRING);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.STRING);
         builder.setName("foo").setValue("bar");
         assertEquals(StringPropertyState.stringProperty("foo", "bar"),
                 builder.getPropertyState());
@@ -41,7 +41,7 @@ public class MemoryPropertyBuilderTest {
 
     @Test
     public void testLongProperty() {
-        PropertyBuilder<Long> builder = MemoryPropertyBuilder.scalar(Type.LONG);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.LONG);
         builder.setName("foo").setValue(42L);
         assertEquals(LongPropertyState.createLongProperty("foo", 42L),
                 builder.getPropertyState());
@@ -53,7 +53,7 @@ public class MemoryPropertyBuilderTest {
 
     @Test
     public void testStringsProperty() {
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.array(Type.STRING);
+        PropertyBuilder builder = PropertyBuilder.array(Type.STRING);
         builder.setName("foo")
                 .addValue("one")
                 .addValue("two");
@@ -74,7 +74,7 @@ public class MemoryPropertyBuilderTest {
 
     @Test
     public void testDateProperty() {
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.array(Type.DATE);
+        PropertyBuilder builder = PropertyBuilder.array(Type.DATE);
         String date1 = "1970-01-01T00:00:00.000Z";
         String date2 = "1971-01-01T00:00:00.000Z";
         builder.setName("foo")
@@ -98,7 +98,7 @@ public class MemoryPropertyBuilderTest {
     @Test
     public void testAssignFromLong() {
         PropertyState source = LongPropertyState.createLongProperty("foo", 42L);
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.STRING);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.STRING);
         builder.assignFrom(source);
         assertEquals(StringPropertyState.stringProperty("foo", "42"),
                 builder.getPropertyState());
@@ -107,7 +107,7 @@ public class MemoryPropertyBuilderTest {
     @Test
     public void testAssignFromString() {
         PropertyState source = StringPropertyState.stringProperty("foo", "42");
-        PropertyBuilder<Long> builder = MemoryPropertyBuilder.scalar(Type.LONG);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.LONG);
         builder.assignFrom(source);
         assertEquals(LongPropertyState.createLongProperty("foo", 42L),
                 builder.getPropertyState());
@@ -117,7 +117,7 @@ public class MemoryPropertyBuilderTest {
     public void testAssignFromDate() {
         String date = "1970-01-01T00:00:00.000Z";
         PropertyState source = GenericPropertyState.dateProperty("foo", date);
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.DATE);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.DATE);
         builder.assignFrom(source);
         assertEquals(source, builder.getPropertyState());
     }
@@ -125,14 +125,14 @@ public class MemoryPropertyBuilderTest {
     @Test(expected = NumberFormatException.class)
     public void testAssignFromStringNumberFormatException() {
         PropertyState source = StringPropertyState.stringProperty("foo", "bar");
-        PropertyBuilder<Long> builder = MemoryPropertyBuilder.scalar(Type.LONG);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.LONG);
         builder.assignFrom(source);
     }
 
     @Test
     public void testAssignFromLongs() {
         PropertyState source = MultiLongPropertyState.createLongProperty("foo", Arrays.asList(1L,
2L, 3L));
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.STRING);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.STRING);
         builder.assignFrom(source);
         assertEquals(MultiStringPropertyState.stringProperty("foo", Arrays.asList("1", "2",
"3")),
                 builder.getPropertyState());
@@ -141,7 +141,7 @@ public class MemoryPropertyBuilderTest {
     @Test
     public void testAssignFromStrings() {
         PropertyState source = MultiStringPropertyState.stringProperty("foo", Arrays.asList("1",
"2", "3"));
-        PropertyBuilder<Long> builder = MemoryPropertyBuilder.scalar(Type.LONG);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.LONG);
         builder.assignFrom(source);
         assertEquals(MultiLongPropertyState.createLongProperty("foo", Arrays.asList(1L, 2L,
3L)),
                 builder.getPropertyState());
@@ -152,7 +152,7 @@ public class MemoryPropertyBuilderTest {
         String date1 = "1970-01-01T00:00:00.000Z";
         String date2 = "1971-01-01T00:00:00.000Z";
         PropertyState source = MultiGenericPropertyState.dateProperty("foo", Arrays.asList(date1,
date2));
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.DATE);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.DATE);
         builder.assignFrom(source);
         assertEquals(source, builder.getPropertyState());
     }
@@ -160,7 +160,7 @@ public class MemoryPropertyBuilderTest {
     @Test
     public void testAssignInvariant() {
         PropertyState source = MultiStringPropertyState.stringProperty("source", Arrays.asList("1",
"2", "3"));
-        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.STRING);
+        PropertyBuilder builder = PropertyBuilder.scalar(Type.STRING);
         builder.assignFrom(source);
         assertEquals(source, builder.getPropertyState());
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/ItemImpl.java?rev=1547034&r1=1547033&r2=1547034&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/ItemImpl.java
Mon Dec  2 14:45:42 2013
@@ -41,7 +41,7 @@ import org.apache.jackrabbit.oak.jcr.del
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.session.operation.ItemOperation;
 import org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
+import org.apache.jackrabbit.oak.util.PropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.ReadWriteNodeTypeManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -378,7 +378,7 @@ abstract class ItemImpl<T extends ItemDe
             if (base == UNDEFINED) {
                 base = STRING;
             }
-            return MemoryPropertyBuilder.array(base)
+            return PropertyBuilder.array(base)
                     .setName(oakName).getPropertyState();
         }
         if (type == UNDEFINEDS) {



Mime
View raw message