jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1396835 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-core/sr...
Date Wed, 10 Oct 2012 22:28:24 GMT
Author: mduerig
Date: Wed Oct 10 22:28:23 2012
New Revision: 1396835

URL: http://svn.apache.org/viewvc?rev=1396835&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
- Value based PropertyState implementation
- Remove CoreValue base PropertyState implementations

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ValueBasedBlob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java Wed
Oct 10 22:28:23 2012
@@ -36,7 +36,7 @@ public interface Blob extends Comparable
     InputStream getNewStream();
 
     /**
-     * Returns the length of this blob.
+     * Returns the length of this blob or -1 if unknown.
      *
      * @return the length of this blob.
      */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
Wed Oct 10 22:28:23 2012
@@ -29,9 +29,8 @@ import com.google.common.collect.Sets;
 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.memory.CoreValues;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
-import org.apache.jackrabbit.oak.plugins.memory.StringValue;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 
 class PropertyIndexUpdate {
@@ -87,16 +86,16 @@ class PropertyIndexUpdate {
             Set<String> paths = entry.getValue();
             PropertyState property = index.getProperty(encoded);
             if (property != null) {
-                List<CoreValue> values = Lists.newArrayList();
-                for (CoreValue value : CoreValues.getValues(property)) {
-                    if (!paths.contains(value.getString())) {
+                List<String> values = Lists.newArrayList();
+                for (String value : property.getValue(Type.STRINGS)) {
+                    if (!paths.contains(values)) {
                         values.add(value);
                     }
                 }
                 if (values.isEmpty()) {
                     index.removeProperty(encoded);
                 } else {
-                    index.setProperty(PropertyStates.createProperty(encoded, values));
+                    index.setProperty(PropertyStates.stringProperty(encoded, values));
                 }
             }
         }
@@ -104,16 +103,16 @@ class PropertyIndexUpdate {
         for (Map.Entry<String, Set<String>> entry : insert.entrySet()) {
             String encoded = entry.getKey();
             Set<String> paths = entry.getValue();
-            List<CoreValue> values = Lists.newArrayList();
+            List<String> values = Lists.newArrayList();
             PropertyState property = index.getProperty(encoded);
             if (property != null) {
-                for (CoreValue value : CoreValues.getValues(property)) {
+                for (String value : property.getValue(Type.STRINGS)) {
                     values.add(value);
-                    paths.remove(value.getString());
+                    paths.remove(value);
                 }
             }
             for (String path : paths) {
-                values.add(new StringValue(path));
+                values.add(path);
             }
             if (values.isEmpty()) {
                 index.removeProperty(encoded);
@@ -121,9 +120,10 @@ class PropertyIndexUpdate {
                 throw new CommitFailedException(
                         "Uniqueness constraint violated");
             } else {
-                index.setProperty(PropertyStates.createProperty(encoded, values));
+                index.setProperty(PropertyStates
+                        .stringProperty(encoded, values));
             }
         }
     }
 
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java
Wed Oct 10 22:28:23 2012
@@ -23,16 +23,17 @@ import java.util.List;
 
 import javax.annotation.Nonnull;
 import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 
 import com.google.common.collect.Lists;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.json.JsopReader;
 import org.apache.jackrabbit.oak.api.Blob;
-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.kernel.TypeCodes;
 import org.apache.jackrabbit.oak.kernel.KernelBlob;
+import org.apache.jackrabbit.oak.kernel.TypeCodes;
 
 import static org.apache.jackrabbit.oak.api.Type.DATE;
 import static org.apache.jackrabbit.oak.api.Type.DATES;
@@ -52,64 +53,74 @@ public final class PropertyStates {
     private PropertyStates() {}
 
     @Nonnull
-    public static PropertyState createProperty(String name, CoreValue value) {
+    public static PropertyState createProperty(String name, Value value) throws RepositoryException
{
         int type = value.getType();
-        if (PropertyType.BINARY == type) {
-           return binaryProperty(name, new ValueBasedBlob(value));
-        }
-        else {
-            return createProperty(name, value.getString(), value.getType());
+        switch (type) {
+            case PropertyType.STRING:
+                return stringProperty(name, value.getString());
+            case PropertyType.BINARY:
+                return binaryProperty(name, value);
+            case PropertyType.LONG:
+                return longProperty(name, value.getLong());
+            case PropertyType.DOUBLE:
+                return doubleProperty(name, value.getDouble());
+            case PropertyType.BOOLEAN:
+                return booleanProperty(name, value.getBoolean());
+            case PropertyType.DECIMAL:
+                return decimalProperty(name, value.getDecimal());
+            default:
+                return new GenericPropertyState(name, value.getString(), Type.fromTag(type,
false));
         }
     }
 
     @Nonnull
-    public static PropertyState createProperty(String name, List<CoreValue> values)
{
-        if (values.isEmpty()) {
+    public static PropertyState createProperty(String name, Value[] values) throws RepositoryException
{
+        if (values.length == 0) {
             return emptyProperty(name, STRINGS);
         }
 
-        int type = values.get(0).getType();
+        int type = values[0].getType();
         switch (type) {
             case PropertyType.STRING:
                 List<String> strings = Lists.newArrayList();
-                for (CoreValue cv : values) {
-                    strings.add(cv.getString());
+                for (Value value : values) {
+                    strings.add(value.getString());
                 }
                 return stringProperty(name, strings);
             case PropertyType.BINARY:
                 List<Blob> blobs = Lists.newArrayList();
-                for (CoreValue cv : values) {
-                    blobs.add(new ValueBasedBlob(cv));
+                for (Value value : values) {
+                    blobs.add(new ValueBasedBlob(value));
                 }
                 return binaryPropertyFromBlob(name, blobs);
             case PropertyType.LONG:
                 List<Long> longs = Lists.newArrayList();
-                for (CoreValue cv : values) {
-                    longs.add(cv.getLong());
+                for (Value value : values) {
+                    longs.add(value.getLong());
                 }
                 return longProperty(name, longs);
             case PropertyType.DOUBLE:
                 List<Double> doubles = Lists.newArrayList();
-                for (CoreValue cv : values) {
-                    doubles.add(cv.getDouble());
+                for (Value value : values) {
+                    doubles.add(value.getDouble());
                 }
                 return doubleProperty(name, doubles);
             case PropertyType.BOOLEAN:
                 List<Boolean> booleans = Lists.newArrayList();
-                for (CoreValue cv : values) {
-                    booleans.add(cv.getBoolean());
+                for (Value value : values) {
+                    booleans.add(value.getBoolean());
                 }
                 return booleanProperty(name, booleans);
             case PropertyType.DECIMAL:
                 List<BigDecimal> decimals = Lists.newArrayList();
-                for (CoreValue cv : values) {
-                    decimals.add(cv.getDecimal());
+                for (Value value : values) {
+                    decimals.add(value.getDecimal());
                 }
                 return decimalProperty(name, decimals);
             default:
                 List<String> vals = Lists.newArrayList();
-                for (CoreValue cv : values) {
-                    vals.add(cv.getString());
+                for (Value value : values) {
+                    vals.add(value.getString());
                 }
                 return new GenericsPropertyState(name, vals, Type.fromTag(type, true));
         }
@@ -274,6 +285,10 @@ public final class PropertyStates {
         return new BinaryPropertyState(name, value);
     }
 
+    public static PropertyState binaryProperty(String name, Value value) {
+        return new BinaryPropertyState(name, new ValueBasedBlob(value));
+    }
+
     public static PropertyState stringProperty(String name, Iterable<String> values)
{
         return new StringsPropertyState(name, Lists.newArrayList(values));
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ValueBasedBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ValueBasedBlob.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ValueBasedBlob.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ValueBasedBlob.java
Wed Oct 10 22:28:23 2012
@@ -18,24 +18,116 @@
  */
 package org.apache.jackrabbit.oak.plugins.memory;
 
+import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
+import javax.annotation.Nonnull;
+import javax.jcr.Binary;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 
 public class ValueBasedBlob extends AbstractBlob {
-    private final CoreValue value;
+    private final Value value;
 
-    public ValueBasedBlob(CoreValue value) {
+    public ValueBasedBlob(Value value) {
         this.value = value;
     }
 
+    @Nonnull
     @Override
     public InputStream getNewStream() {
-        return value.getNewStream();
+        return new ValueBasedInputStream(value);
     }
 
     @Override
     public long length() {
-        return value.length();
+        try {
+            Binary binary = value.getBinary();
+            try {
+                return binary.getSize();
+            }
+            finally {
+                binary.dispose();
+            }
+        }
+        catch (RepositoryException e) {
+            return -1;
+        }
+    }
+
+    private static class ValueBasedInputStream extends InputStream {
+        private final Value value;
+
+        private Binary binary;
+        private InputStream stream;
+
+        public ValueBasedInputStream(Value value) {
+            this.value = value;
+        }
+
+        @Override
+        public int read() throws IOException {
+            return stream().read();
+        }
+
+        @Override
+        public int read(byte[] b) throws IOException {
+            return stream().read(b);
+        }
+
+        @Override
+        public int read(byte[] b, int off, int len) throws IOException {
+            return stream().read(b, off, len);
+        }
+
+        @Override
+        public long skip(long n) throws IOException {
+            return stream().skip(n);
+        }
+
+        @Override
+        public int available() throws IOException {
+            return stream().available();
+        }
+
+        @Override
+        public void close() throws IOException {
+            if (stream != null) {
+                stream.close();
+                stream = null;
+            }
+            if (binary != null) {
+                binary.dispose();
+                binary = null;
+            }
+        }
+
+        @Override
+        public synchronized void mark(int readlimit) {
+        }
+
+        @Override
+        public synchronized void reset() throws IOException {
+            throw new IOException("mark not supported");
+        }
+
+        @Override
+        public boolean markSupported() {
+            return false;
+        }
+
+        private InputStream stream() throws IOException {
+            try {
+                if (binary == null) {
+                    binary = value.getBinary();
+                    stream = binary.getStream();
+                }
+                return stream;
+            }
+            catch (RepositoryException e) {
+                throw new IOException(e);
+            }
+        }
+
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
Wed Oct 10 22:28:23 2012
@@ -19,15 +19,17 @@
 package org.apache.jackrabbit.oak.query.ast;
 
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Locale;
 
 import javax.jcr.PropertyType;
 
+import com.google.common.collect.Iterables;
 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.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.SQL2Parser;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
@@ -115,17 +117,15 @@ public class PropertyValueImpl extends D
         // asterisk - create a multi-value property
         // warning: the returned property state may have a mixed type
         // (not all values may have the same type)
-        ArrayList<CoreValue> values = new ArrayList<CoreValue>();
+
+        //TODO this doesn't play well with the idea that the types may be different
+        List<String> values = new ArrayList<String>();
         for (PropertyState p : tree.getProperties()) {
             if (matchesPropertyType(p)) {
-                if (p.isArray()) {
-                    values.addAll(CoreValues.getValues(p));
-                } else {
-                    values.add(CoreValues.getValue(p));
-                }
+                Iterables.addAll(values, p.getValue(Type.STRINGS));
             }
         }
-        return PropertyStates.createProperty("*", values);
+        return PropertyStates.stringProperty("*", values);
     }
 
     private boolean matchesPropertyType(PropertyState state) {

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=1396835&r1=1396834&r2=1396835&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
Wed Oct 10 22:28:23 2012
@@ -30,7 +30,6 @@ import javax.jcr.ValueFactory;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -222,15 +221,12 @@ public class NodeUtil {
     }
 
     public void setValues(String name, Value[] values) {
-        List<CoreValue> cvs = Lists.newArrayList();
-        for (Value value : values) {
-            try {
-                cvs.add(factory.createValue(value.getString(), value.getType()));
-            } catch (RepositoryException e) {
-                log.warn("Unable to convert a default value", e);
-            }
+        try {
+            tree.setProperty(PropertyStates.createProperty(name, values));
+        }
+        catch (RepositoryException e) {
+            log.warn("Unable to convert a default value", e);
         }
-        tree.setProperty(PropertyStates.createProperty(name, cvs));
     }
 
     public void setValues(String name, String[] values, int type) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Wed Oct 10 22:28:23 2012
@@ -18,24 +18,23 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.util.Collections;
 import java.util.Iterator;
-import java.util.List;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterators;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterators;
-
 /**
  * {@code NodeDelegate} serve as internal representations of {@code Node}s.
  * Most methods of this class throw an {@code InvalidItemStateException}
@@ -179,8 +178,7 @@ public class NodeDelegate extends ItemDe
      * @return  the set property
      */
     @Nonnull
-    public PropertyDelegate setProperty(String name, CoreValue value)
-            throws InvalidItemStateException, ValueFormatException {
+    public PropertyDelegate setProperty(String name, Value value) throws RepositoryException
{
         Tree tree = getTree();
         PropertyState old = tree.getProperty(name);
         if (old != null && old.isArray()) {
@@ -197,18 +195,17 @@ public class NodeDelegate extends ItemDe
     /**
      * Set a multi valued property
      * @param name  oak name
-     * @param value
+     * @param values
      * @return  the set property
      */
     @Nonnull
-    public PropertyDelegate setProperty(String name, List<CoreValue> value)
-            throws InvalidItemStateException, ValueFormatException {
+    public PropertyDelegate setProperty(String name, Value[] values) throws RepositoryException
{
         Tree tree = getTree();
         PropertyState old = tree.getProperty(name);
         if (old != null && ! old.isArray()) {
             throw new ValueFormatException("Attempt to set multiple values to single valued
property.");
         }
-        tree.setProperty(PropertyStates.createProperty(name, value));
+        tree.setProperty(PropertyStates.createProperty(name, values));
         return new PropertyDelegate(sessionDelegate, tree.getLocation().getChild(name));
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Wed Oct 10 22:28:23 2012
@@ -18,8 +18,8 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.io.InputStream;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -315,9 +315,7 @@ public class NodeImpl extends ItemImpl<N
                     int targetType = getTargetType(value, type);
                     Value targetValue =
                             ValueHelper.convert(value, targetType, getValueFactory());
-                    CoreValue oakValue =
-                            ValueConverter.toCoreValue(targetValue, sessionDelegate);
-                    return new PropertyImpl(dlg.setProperty(oakName, oakValue));
+                    return new PropertyImpl(dlg.setProperty(oakName, targetValue));
                 }
             }
         });
@@ -354,8 +352,13 @@ public class NodeImpl extends ItemImpl<N
                     return p;
                 } else {
                     String oakName = sessionDelegate.getOakPathOrThrow(jcrName);
-                    List<CoreValue> oakValue = ValueConverter.toCoreValues(targetValues,
sessionDelegate);
-                    return new PropertyImpl(dlg.setProperty(oakName, oakValue));
+                    ArrayList<Value> vs = Lists.newArrayList();
+                    for (Value targetValue : targetValues) {
+                        if (targetValue != null) {
+                            vs.add(targetValue);
+                        }
+                    }
+                    return new PropertyImpl(dlg.setProperty(oakName, vs.toArray(new Value[vs.size()])));
                 }
             }
         });
@@ -913,8 +916,8 @@ public class NodeImpl extends ItemImpl<N
                 // TODO: END
 
                 String jcrPrimaryType = sessionDelegate.getOakPathOrThrow(Property.JCR_PRIMARY_TYPE);
-                CoreValue cv = ValueConverter.toCoreValue(nodeTypeName, PropertyType.NAME,
sessionDelegate);
-                dlg.setProperty(jcrPrimaryType, cv);
+                Value value = sessionDelegate.getValueFactory().createValue(nodeTypeName,
PropertyType.NAME);
+                dlg.setProperty(jcrPrimaryType, value);
                 return null;
             }
         });
@@ -938,20 +941,26 @@ public class NodeImpl extends ItemImpl<N
                 boolean nodeModified = false;
                 if (mixins == null) {
                     nodeModified = true;
-                    dlg.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singletonList(cv));
+                    Value name = sessionDelegate.getValueFactory().createValue(mixinName,
PropertyType.NAME);
+                    dlg.setProperty(JcrConstants.JCR_MIXINTYPES, new Value[]{name});
                 } else {
                     List<CoreValue> values = Lists.newArrayList(mixins.getValues());
                     if (!values.contains(cv)) {
                         values.add(cv);
                         nodeModified = true;
-                        dlg.setProperty(JcrConstants.JCR_MIXINTYPES, values);
+                        Value[] jcvValues = new Value[values.size()];
+                        int k = 0;
+                        for (CoreValue v : values) {
+                            jcvValues[k++] = sessionDelegate.getValueFactory().createValue(cv);
+                        }
+
+                        dlg.setProperty(JcrConstants.JCR_MIXINTYPES, jcvValues);
                     }
                 }
 
                 // TODO: hack -- make sure we assign a UUID
                 if (nodeModified && nt.isNodeType(JcrConstants.MIX_REFERENCEABLE))
{
-                    CoreValue value = ValueConverter.toCoreValue(IdentifierManager.generateUUID(),
-                            PropertyType.STRING, sessionDelegate);
+                    Value value = sessionDelegate.getValueFactory().createValue(IdentifierManager.generateUUID());
                     dlg.setProperty(JcrConstants.JCR_UUID, value);
                 }
                 return null;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Wed Oct 10 22:28:23 2012
@@ -16,10 +16,9 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import java.util.List;
-
 import javax.annotation.Nonnull;
 import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
@@ -181,7 +180,7 @@ public class PropertyDelegate extends It
      * Set the value of the property
      * @param value
      */
-    public void setValue(CoreValue value) throws InvalidItemStateException {
+    public void setValue(Value value) throws RepositoryException {
         getLocation().set(PropertyStates.createProperty(getName(), value));
     }
 
@@ -189,7 +188,7 @@ public class PropertyDelegate extends It
      * Set the values of the property
      * @param values
      */
-    public void setValues(List<CoreValue> values) throws InvalidItemStateException
{
+    public void setValues(Value[] values) throws RepositoryException {
         getLocation().set(PropertyStates.createProperty(getName(), values));
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Wed Oct 10 22:28:23 2012
@@ -37,6 +37,7 @@ import javax.jcr.ValueFormatException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.PropertyDefinition;
 
+import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.jcr.value.ValueConverter;
 import org.apache.jackrabbit.value.ValueHelper;
@@ -675,7 +676,7 @@ public class PropertyImpl extends ItemIm
             dlg.remove();
         } else {
             Value targetValue = ValueHelper.convert(value, requiredType, sessionDelegate.getValueFactory());
-            dlg.setValue(ValueConverter.toCoreValue(targetValue, sessionDelegate));
+            dlg.setValue(targetValue);
         }
     }
 
@@ -695,7 +696,14 @@ public class PropertyImpl extends ItemIm
             dlg.remove();
         } else {
             Value[] targetValues = ValueHelper.convert(values, requiredType, sessionDelegate.getValueFactory());
-            dlg.setValues(ValueConverter.toCoreValues(targetValues, sessionDelegate));
+            List<Value> vs = Lists.newArrayList();
+            for (Value value : targetValues) {
+                if (value != null) {
+                    vs.add(value);
+                }
+            }
+
+            dlg.setValues(vs.toArray(new Value[vs.size()]));
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java?rev=1396835&r1=1396834&r2=1396835&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
Wed Oct 10 22:28:23 2012
@@ -138,8 +138,8 @@ public class QueryImpl implements Query 
         if (node == null) {
             throw new ItemExistsException("Node already exists: " + absPath);
         }
-        node.setProperty("statement", vf.getCoreValue(vf.createValue(statement)));
-        node.setProperty("language", vf.getCoreValue(vf.createValue(language)));
+        node.setProperty("statement", vf.createValue(statement));
+        node.setProperty("language", vf.createValue(language));
         NodeImpl n = new NodeImpl(node);
         n.setPrimaryType(NodeType.NT_QUERY);
         storedQueryPath = oakPath;



Mime
View raw message