jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1394256 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/commit/ plugins/identifier/ plugins/index/property/ plugins/type/ query/ast/ security/user/
Date Thu, 04 Oct 2012 20:48:24 GMT
Author: mduerig
Date: Thu Oct  4 20:48:23 2012
New Revision: 1394256

URL: http://svn.apache.org/viewvc?rev=1394256&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
- Replace CoreValue.getString with PropertyState.getValue(Type)

Modified:
    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/commit/ConflictValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java

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=1394256&r1=1394255&r2=1394256&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 20:48:23 2012
@@ -16,21 +16,18 @@
  */
 package org.apache.jackrabbit.oak.plugins.commit;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import javax.jcr.PropertyType;
-
-import org.apache.jackrabbit.oak.plugins.memory.MultiPropertyState;
-import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
-import org.apache.jackrabbit.oak.api.CoreValue;
+import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
+import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.plugins.type.NodeTypeConstants.ADD_EXISTING;
 import static org.apache.jackrabbit.oak.plugins.type.NodeTypeConstants.CHANGE_CHANGED;
 import static org.apache.jackrabbit.oak.plugins.type.NodeTypeConstants.CHANGE_DELETED;
@@ -126,16 +123,18 @@ public class AnnotatingConflictHandler i
         return Resolution.THEIRS;
     }
 
-    private Tree addConflictMarker(Tree parent) {
+    private static Tree addConflictMarker(Tree parent) {
         PropertyState jcrMixin = parent.getProperty(JCR_MIXINTYPES);
-        List<CoreValue> mixins = new ArrayList<CoreValue>();
-        if (jcrMixin != null) {
-            assert jcrMixin.isArray();
-            mixins.addAll(jcrMixin.getValues());
+        List<String> mixins;
+        if (jcrMixin == null) {
+            mixins = Lists.newArrayList();
+        }
+        else {
+            mixins = Lists.newArrayList(jcrMixin.getValue(NAMES));
         }
         if (!mixins.contains(MIX_REP_MERGE_CONFLICT)) {
-            mixins.add(valueFactory.createValue(MIX_REP_MERGE_CONFLICT, PropertyType.NAME));
-            parent.setProperty(new MultiPropertyState(JCR_MIXINTYPES, mixins));
+            mixins.add(MIX_REP_MERGE_CONFLICT);
+            parent.setProperty(JCR_MIXINTYPES, mixins, NAMES);
         }
 
         return getOrCreateNode(parent, REP_OURS);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ConflictValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ConflictValidator.java?rev=1394256&r1=1394255&r2=1394256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ConflictValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ConflictValidator.java
Thu Oct  4 20:48:23 2012
@@ -20,13 +20,14 @@ import javax.jcr.InvalidItemStateExcepti
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.plugins.type.NodeTypeConstants;
 import org.apache.jackrabbit.oak.spi.commit.DefaultValidator;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
 /**
  * {@link Validator} which checks the presence of conflict markers
  * in the tree in fails the commit if any are found.
@@ -63,8 +64,8 @@ public class ConflictValidator extends D
     private static void failOnMergeConflict(PropertyState property) throws CommitFailedException
{
         if (JcrConstants.JCR_MIXINTYPES.equals(property.getName())) {
             assert property.isArray();
-            for (CoreValue v : property.getValues()) {
-                if (NodeTypeConstants.MIX_REP_MERGE_CONFLICT.equals(v.getString())) {
+            for (String v : property.getValue(STRINGS)) {
+                if (NodeTypeConstants.MIX_REP_MERGE_CONFLICT.equals(v)) {
                     throw new CommitFailedException(new InvalidItemStateException("Item has
unresolved conflicts"));
                 }
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java?rev=1394256&r1=1394255&r2=1394256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
Thu Oct  4 20:48:23 2012
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugin
 import java.io.UnsupportedEncodingException;
 import java.text.ParseException;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
@@ -40,6 +39,7 @@ import org.apache.jackrabbit.oak.api.Res
 import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.memory.StringValue;
@@ -47,6 +47,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 
 /**
  * IdentifierManager...
@@ -237,8 +238,8 @@ public class IdentifierManager {
             @Override
             public boolean apply(PropertyState pState) {
                 if (pState.isArray()) {
-                    for (CoreValue value : pState.getValues()) {
-                        if (uuid.equals(value.getString())) {
+                    for (String value : pState.getValue(Type.STRINGS)) {
+                        if (uuid.equals(value)) {
                             return true;
                         }
                     }
@@ -265,9 +266,8 @@ public class IdentifierManager {
 
         PropertyState pMixin = tree.getProperty(JcrConstants.JCR_MIXINTYPES);
         if (pMixin != null) {
-            List<CoreValue> mixinTypes = pMixin.getValues();
-            for (CoreValue mixinType : mixinTypes) {
-                if (ntName.equals(mixinType.getString())) {
+            for (String mixinType : pMixin.getValue(STRINGS)) {
+                if (ntName.equals(mixinType)) {
                     return true;
                 }
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java?rev=1394256&r1=1394255&r2=1394256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
Thu Oct  4 20:48:23 2012
@@ -20,6 +20,7 @@ import java.util.Set;
 
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.memory.StringValue;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -84,8 +85,8 @@ public class PropertyIndexLookup {
 
         if (property != null) {
             // We have an index for this property, so use it
-            for (CoreValue path : property.getValues()) {
-                paths.add(path.getString());
+            for (String path : property.getValue(Type.STRINGS)) {
+                paths.add(path);
             }
         } else {
             // No index available, so first check this node for a match

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java?rev=1394256&r1=1394255&r2=1394256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
Thu Oct  4 20:48:23 2012
@@ -45,6 +45,8 @@ import org.slf4j.LoggerFactory;
 import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 
 /**
  * Validator implementation that check JCR node type constraints.
@@ -140,11 +142,11 @@ class TypeValidator implements Validator
     public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
         try {
             PropertyState type = after.getProperty(JCR_PRIMARYTYPE);
-            if (type == null || type.getValues().isEmpty()) {
+            if (type == null || type.count() == 0) {
                 getParentType().canAddChildNode(name);
             }
             else {
-                String ntName = type.getValues().get(0).getString();
+                String ntName = type.getValue(STRING, 0);
                 getParentType().checkAddChildNode(name, ntName);
             }
 
@@ -194,8 +196,7 @@ class TypeValidator implements Validator
         boolean primaryType = JCR_PRIMARYTYPE.equals(after.getName());
         boolean mixinType = JCR_MIXINTYPES.equals(after.getName());
         if (primaryType || mixinType) {
-            for (CoreValue cv : after.getValues()) {
-                String ntName = cv.getString();
+            for (String ntName : after.getValue(STRINGS)) {
                 NodeType nt = ntm.getNodeType(ntName);
                 if (nt.isAbstract()) {
                     throw new ConstraintViolationException("Can't create node with abstract
type: " + ntName);
@@ -213,8 +214,7 @@ class TypeValidator implements Validator
     private NodeType getPrimaryType(Tree tree) throws RepositoryException {
         PropertyState jcrPrimaryType = tree.getProperty(JCR_PRIMARYTYPE);
         if (jcrPrimaryType != null) {
-            for (CoreValue typeName : jcrPrimaryType.getValues()) {
-                String ntName = typeName.getString();
+            for (String ntName : jcrPrimaryType.getValue(STRINGS)) {
                 NodeType type = ntm.getNodeType(ntName);
                 if (type == null) {
                     log.warn("Could not find node type {} for item at {}", ntName, tree.getPath());
@@ -230,8 +230,7 @@ class TypeValidator implements Validator
         List<NodeType> types = Lists.newArrayList();
         PropertyState jcrMixinType = tree.getProperty(JCR_MIXINTYPES);
         if (jcrMixinType != null) {
-            for (CoreValue typeName : jcrMixinType.getValues()) {
-                String ntName = typeName.getString();
+            for (String ntName : jcrMixinType.getValue(STRINGS)) {
                 NodeType type = ntm.getNodeType(ntName);
                 if (type == null) {
                     log.warn("Could not find mixin type {} for item at {}", ntName, tree.getPath());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1394256&r1=1394255&r2=1394256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Thu Oct  4 20:48:23 2012
@@ -26,6 +26,7 @@ import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeTypeManager;
 
+import com.google.common.collect.ImmutableSet;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -40,7 +41,7 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
-import com.google.common.collect.ImmutableSet;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 
 /**
  * A selector within a query.
@@ -190,8 +191,8 @@ public class SelectorImpl extends Source
         ImmutableSet.Builder<String> builder = ImmutableSet.builder();
         PropertyState property = tree.getProperty(name);
         if (property != null) {
-            for (CoreValue value : property.getValues()) {
-                builder.add(value.getString());
+            for (String value : property.getValue(STRINGS)) {
+                builder.add(value);
             }
         }
         return builder.build();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java?rev=1394256&r1=1394255&r2=1394256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java
Thu Oct  4 20:48:23 2012
@@ -20,6 +20,7 @@ import java.security.Principal;
 import java.security.acl.Group;
 import java.util.HashSet;
 import java.util.Set;
+
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
@@ -31,7 +32,6 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Impersonation;
 import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalIteratorAdapter;
@@ -39,6 +39,8 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
 /**
  * ImpersonationImpl...
  */
@@ -183,8 +185,8 @@ class ImpersonationImpl implements Imper
         Tree userTree = user.getTree();
         PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS);
         if (impersonators != null) {
-            for (CoreValue v : impersonators.getValues()) {
-                princNames.add(v.getString());
+            for (String v : impersonators.getValue(STRINGS)) {
+                princNames.add(v);
             }
         }
         return princNames;



Mime
View raw message