jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1532856 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ oak-core/src/main/java/org/apache/jackrabbit/oak/spi...
Date Wed, 16 Oct 2013 18:37:05 GMT
Author: angela
Date: Wed Oct 16 18:37:05 2013
New Revision: 1532856

URL: http://svn.apache.org/r1532856
Log:
minor improvement

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporter.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImporter.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/TextValue.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/DocViewImportHandler.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SysViewImportHandler.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporter.java?rev=1532856&r1=1532855&r2=1532856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporter.java
Wed Oct 16 18:37:05 2013
@@ -16,14 +16,11 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.accesscontrol;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import javax.annotation.CheckForNull;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -55,6 +52,8 @@ import org.apache.jackrabbit.oak.spi.xml
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * {@link ProtectedNodeImporter} implementation that handles access control lists,
  * entries and restrictions.
@@ -247,7 +246,7 @@ public class AccessControlImporter imple
             }
         }
 
-        private void setPrivilegeNames(TextValue[] txtValues) throws RepositoryException
{
+        private void setPrivilegeNames(List<? extends TextValue> txtValues) throws
RepositoryException {
             privileges = new ArrayList<Privilege>();
             for (TextValue value : txtValues) {
                 Value privilegeName = value.getValue(PropertyType.NAME);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImporter.java?rev=1532856&r1=1532855&r2=1532856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImporter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImporter.java
Wed Oct 16 18:37:05 2013
@@ -301,8 +301,7 @@ class UserImporter implements ProtectedP
             // since impersonators may be imported later on, postpone processing
             // to the end.
             // see -> process References
-            TextValue[] tvs = propInfo.getTextValues();
-            referenceTracker.processedReference(new Impersonators(a.getID(), tvs));
+            referenceTracker.processedReference(new Impersonators(a.getID(), propInfo.getTextValues()));
             return true;
 
         } else if (REP_DISABLED.equals(propName)) {
@@ -477,7 +476,7 @@ class UserImporter implements ProtectedP
             members.add(new Member(name, id));
         }
 
-        void addMembers(TextValue[] tvs) {
+        void addMembers(List<? extends TextValue> tvs) {
             for (TextValue tv : tvs) {
                 addMember(null, tv.getString());
             }
@@ -573,7 +572,7 @@ class UserImporter implements ProtectedP
         private final String userId;
         private final Set<String> principalNames = new HashSet<String>();
 
-        private Impersonators(String userId, TextValue[] values) {
+        private Impersonators(String userId, List<? extends TextValue> values) {
             this.userId = userId;
             for (TextValue v : values) {
                 principalNames.add(v.getString());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java?rev=1532856&r1=1532855&r2=1532856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java
Wed Oct 16 18:37:05 2013
@@ -18,11 +18,14 @@ package org.apache.jackrabbit.oak.spi.xm
 
 import java.util.Collections;
 import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.nodetype.PropertyDefinition;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeType;
 
@@ -51,7 +54,7 @@ public class PropInfo {
     /**
      * Value(s) of the property being imported.
      */
-    private final TextValue[] values;
+    private final List<? extends TextValue> values;
 
     /**
      * Hint indicating whether the property is multi- or single-value
@@ -64,13 +67,21 @@ public class PropInfo {
      *
      * @param name name of the property being imported
      * @param type type of the property being imported
+     * @param value value of the property being imported
+     */
+    public PropInfo(@Nullable String name, int type, @Nonnull TextValue value) {
+        this(name, type, ImmutableList.of(value), MultipleStatus.UNKNOWN);
+    }
+
+    /**
+     * Creates a property information instance.
+     *
+     * @param name name of the property being imported
+     * @param type type of the property being imported
      * @param values value(s) of the property being imported
      */
-    public PropInfo(String name, int type, TextValue[] values) {
-        this.name = name;
-        this.type = type;
-        this.values = values;
-        multipleStatus = (values.length == 1) ? MultipleStatus.UNKNOWN : MultipleStatus.MULTIPLE;
+    public PropInfo(@Nullable String name, int type, @Nonnull List<? extends TextValue>
values) {
+        this(name, type, values, ((values.size() == 1) ? MultipleStatus.UNKNOWN : MultipleStatus.MULTIPLE));
     }
 
     /**
@@ -81,11 +92,12 @@ public class PropInfo {
      * @param values value(s) of the property being imported
      * @param multipleStatus Hint indicating whether the property is
      */
-    public PropInfo(String name, int type, TextValue[] values,
-                    MultipleStatus multipleStatus) {
+    public PropInfo(@Nullable String name, int type,
+                    @Nonnull List<? extends TextValue> values,
+                    @Nonnull MultipleStatus multipleStatus) {
         this.name = name;
         this.type = type;
-        this.values = values;
+        this.values = ImmutableList.copyOf(values);
         this.multipleStatus = multipleStatus;
     }
 
@@ -121,10 +133,10 @@ public class PropInfo {
         if (multipleStatus == MultipleStatus.MULTIPLE) {
             throw new RepositoryException("TODO");
         }
-        return values[0];
+        return values.get(0);
     }
 
-    public TextValue[] getTextValues() {
+    public List<? extends TextValue> getTextValues() {
         return values;
     }
 
@@ -132,14 +144,14 @@ public class PropInfo {
         if (multipleStatus == MultipleStatus.MULTIPLE) {
             throw new RepositoryException("TODO");
         }
-        return values[0].getValue(targetType);
+        return values.get(0).getValue(targetType);
     }
 
     public List<Value> getValues(int targetType) throws RepositoryException {
-        if (values.length == 0) {
+        if (values.isEmpty()) {
             return Collections.emptyList();
         } else {
-            List<Value> vs = Lists.newArrayListWithCapacity(values.length);
+            List<Value> vs = Lists.newArrayListWithCapacity(values.size());
             for (TextValue value : values) {
                 vs.add(value.getValue(targetType));
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/TextValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/TextValue.java?rev=1532856&r1=1532855&r2=1532856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/TextValue.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/xml/TextValue.java
Wed Oct 16 18:37:05 2013
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.spi.xm
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
 
 /**
  * {@code TextValue} represents a serialized property value read
@@ -28,7 +27,7 @@ public interface TextValue {
 
     String getString();
 
-    Value getValue(int targetType) throws ValueFormatException, RepositoryException;
+    Value getValue(int targetType) throws RepositoryException;
 
     /**
      * Dispose this value, i.e. free all bound resources. Once a value has

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/DocViewImportHandler.java?rev=1532856&r1=1532855&r2=1532856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/DocViewImportHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/DocViewImportHandler.java
Wed Oct 16 18:37:05 2013
@@ -157,13 +157,10 @@ class DocViewImportHandler extends Targe
                     reader.close();
                 }
 
-                NodeInfo node =
-                        new NodeInfo(getJcrName(NamespaceRegistry.NAMESPACE_JCR, "xmltext"),
null, null, null);
-                TextValue[] values =
-                        new TextValue[]{textHandler};
+                NodeInfo node = new NodeInfo(getJcrName(NamespaceRegistry.NAMESPACE_JCR,
"xmltext"), null, null, null);
                 ArrayList<PropInfo> props = new ArrayList<PropInfo>();
                 props.add(new PropInfo(getJcrName(NamespaceRegistry.NAMESPACE_JCR, "xmlcharacters"),
-                        PropertyType.STRING, values));
+                        PropertyType.STRING, textHandler));
                 // call Importer
                 importer.startNode(node, props);
                 importer.endNode(node);
@@ -183,7 +180,7 @@ class DocViewImportHandler extends Targe
 
     private String getJcrName(String uri, String name)
             throws RepositoryException {
-        return sessionContext.getSession().getNamespacePrefix(uri) + ":" + name;
+        return sessionContext.getSession().getNamespacePrefix(uri) + ':' + name;
     }
 
     /**
@@ -193,6 +190,7 @@ class DocViewImportHandler extends Targe
      * @param nameInfo name to process
      * @return the decoded and valid jcr name or the original name if it is
      *         not encoded or if the resulting decoded name would be illegal.
+     * @throws javax.jcr.RepositoryException
      */
     private NameInfo processName(NameInfo nameInfo) throws RepositoryException {
         String decodedLocalName = ISO9075.decode(nameInfo.getLocalName());
@@ -242,21 +240,8 @@ class DocViewImportHandler extends Targe
                     continue;
                 }
 
-                NameInfo propNameInfo = new NameInfo(atts.getQName(i));
-                propNameInfo = processName(propNameInfo);
-
-                // value(s)
+                NameInfo propNameInfo = processName(new NameInfo(atts.getQName(i)));
                 String attrValue = atts.getValue(i);
-                TextValue[] propValues;
-
-                // always assume single-valued property for the time being
-                // until a way of properly serializing/detecting multi-valued
-                // properties on re-import is found (see JCR-325);
-                // see also DocViewSAXEventGenerator#leavingProperties(Node, int)
-                // TODO proper multi-value serialization support
-                propValues = new TextValue[1];
-                propValues[0] = new StringValue(attrValue, sessionContext.getValueFactory(),
currentNamePathMapper());
-
                 if (NamespaceRegistry.NAMESPACE_JCR.equals(propNameInfo.getNamespaceUri())
                         && "primaryType".equals(propNameInfo.getLocalName())) {
                     // jcr:primaryType
@@ -275,12 +260,17 @@ class DocViewImportHandler extends Targe
                         id = attrValue;
                     }
                 } else {
-                    props.add(new PropInfo(propNameInfo.getRepoQualifiedName(), PropertyType.UNDEFINED,
propValues));
+                    // always assume single-valued property for the time being
+                    // until a way of properly serializing/detecting multi-valued
+                    // properties on re-import is found (see JCR-325);
+                    // see also DocViewSAXEventGenerator#leavingProperties(Node, int)
+                    // TODO proper multi-value serialization support
+                    TextValue tv = new StringValue(attrValue, sessionContext.getValueFactory(),
currentNamePathMapper());
+                    props.add(new PropInfo(propNameInfo.getRepoQualifiedName(), PropertyType.UNDEFINED,
tv));
                 }
             }
 
-            NodeInfo node =
-                    new NodeInfo(nameInfo.getRepoQualifiedName(), nodeTypeName, mixinTypes,
id);
+            NodeInfo node = new NodeInfo(nameInfo.getRepoQualifiedName(), nodeTypeName, mixinTypes,
id);
             // all information has been collected, now delegate to importer
             importer.startNode(node, props);
             // push current node data onto stack

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java?rev=1532856&r1=1532855&r2=1532856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImporterImpl.java
Wed Oct 16 18:37:05 2013
@@ -117,6 +117,7 @@ public class ImporterImpl implements Imp
      * @param sessionContext The context of the editing session
      * @param root The write {@code Root}, which in case of a workspace import
      * is different from the {@code Root} associated with the editing session.
+     * @param initialRoot
      * @param uuidBehavior The uuid behavior
      * @param isWorkspaceImport {@code true} if this is a workspace import,
      * {@code false} otherwise.

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SysViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SysViewImportHandler.java?rev=1532856&r1=1532855&r2=1532856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SysViewImportHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SysViewImportHandler.java
Wed Oct 16 18:37:05 2013
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Stack;
-
 import javax.jcr.InvalidSerializedDataException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.PropertyType;
@@ -31,7 +30,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.xml.Importer;
 import org.apache.jackrabbit.oak.spi.xml.NodeInfo;
 import org.apache.jackrabbit.oak.spi.xml.PropInfo;
-import org.apache.jackrabbit.oak.spi.xml.TextValue;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -275,8 +273,7 @@ class SysViewImportHandler extends Targe
                 PropInfo prop = new PropInfo(
                         currentPropName == null ? null : currentPropName.getRepoQualifiedName(),
                         currentPropType,
-                        currentPropValues.toArray(new TextValue[currentPropValues.size()]),
-                        currentPropMultipleStatus);
+                        currentPropValues);
                 state.props.add(prop);
             }
             // reset temp fields



Mime
View raw message