jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1535431 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/main/java/org/a...
Date Thu, 24 Oct 2013 16:27:42 GMT
Author: jukka
Date: Thu Oct 24 16:27:41 2013
New Revision: 1535431

URL: http://svn.apache.org/r1535431
Log:
OAK-1111: Node#setProperty(String, Calendar) doesn't take time zone in account

Use strings to represent date values

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java
    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/plugins/memory/MultiGenericPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiLongPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.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/SinglePropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/Conversions.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/DateVersionSelector.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryPropertyBuilderTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStatesTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionHistoryDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java Thu Oct 24 16:27:41 2013
@@ -61,8 +61,8 @@ public final class Type<T> implements Co
     public static final Type<Double> DOUBLE =
             create(PropertyType.DOUBLE, false, "DOUBLE");
 
-    /** Map {@code Long} to {@link PropertyType#DATE} */
-    public static final Type<Long> DATE =
+    /** Map {@code String} to {@link PropertyType#DATE} */
+    public static final Type<String> DATE =
             create(PropertyType.DATE, false, "DATE");
 
     /** Map {@code Boolean} to {@link PropertyType#BOOLEAN} */
@@ -109,8 +109,8 @@ public final class Type<T> implements Co
     public static final Type<Iterable<Double>> DOUBLES =
             create(PropertyType.DOUBLE, true, "DOUBLES");
 
-    /** Map {@code Iterable<Long>} to array of {@link PropertyType#DATE} */
-    public static final Type<Iterable<Long>> DATES =
+    /** Map {@code Iterable<String>} to array of {@link PropertyType#DATE} */
+    public static final Type<Iterable<String>> DATES =
             create(PropertyType.DATE, true, "DATES");
 
     /** Map {@code Iterable<Boolean>} to array of {@link PropertyType#BOOLEAN} */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java Thu Oct 24 16:27:41 2013
@@ -755,11 +755,9 @@ public final class KernelNodeState exten
         if (reader.matches(JsopReader.NUMBER)) {
             String number = reader.getToken();
             try {
-                return new LongPropertyState(
-                        name, Long.parseLong(number), Type.LONG);
+                return new LongPropertyState(name, Long.parseLong(number));
             } catch (NumberFormatException e) {
-                return new DoublePropertyState(
-                        name, Double.parseDouble(number));
+                return new DoublePropertyState(name, Double.parseDouble(number));
             }
         } else if (reader.matches(JsopReader.TRUE)) {
             return BooleanPropertyState.booleanProperty(name, true);
@@ -829,8 +827,6 @@ public final class KernelNodeState exten
                         values.add(Conversions.convert(value).toDouble());
                     } else if (type == PropertyType.DECIMAL) {
                         values.add(Conversions.convert(value).toDecimal());
-                    } else if (type == PropertyType.DATE) {
-                        values.add(Conversions.convert(value).toCalendar().getTimeInMillis());
                     } else {
                         values.add(StringCache.get(value));
                     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java Thu Oct 24 16:27:41 2013
@@ -22,11 +22,13 @@ import static com.google.common.base.Pre
 import static org.apache.jackrabbit.oak.api.Type.STRING;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.MISSING_NODE;
 
+import java.util.Calendar;
 import java.util.concurrent.TimeUnit;
 
 import javax.annotation.Nonnull;
 
 import com.google.common.base.Objects;
+
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
@@ -36,6 +38,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.util.ISO8601;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -151,14 +154,19 @@ public class AsyncIndexUpdate implements
     private static void preAsyncRunStatus(NodeBuilder builder) {
         builder.getChildNode(IndexConstants.INDEX_DEFINITIONS_NAME)
                 .setProperty("async-status", "running")
-                .setProperty("async-start", System.currentTimeMillis(),
-                        Type.DATE).removeProperty("async-done");
+                .setProperty("async-start", now(), Type.DATE)
+                .removeProperty("async-done");
     }
 
     private static void postAsyncRunStatus(NodeBuilder builder) {
         builder.getChildNode(IndexConstants.INDEX_DEFINITIONS_NAME)
                 .setProperty("async-status", "done")
-                .setProperty("async-done", System.currentTimeMillis(),
-                        Type.DATE).removeProperty("async-start");
+                .setProperty("async-done", now(), Type.DATE)
+                .removeProperty("async-start");
+    }
+
+    private static String now() {
+        return ISO8601.format(Calendar.getInstance());
     }
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java Thu Oct 24 16:27:41 2013
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.oak.plugins
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.Type.DATE;
 import static org.apache.jackrabbit.oak.api.Type.NAME;
 import static org.apache.jackrabbit.oak.api.Type.PATH;
 import static org.apache.jackrabbit.oak.api.Type.REFERENCE;
@@ -47,6 +48,18 @@ public class GenericPropertyState extend
     }
 
     /**
+     * Create a {@code PropertyState} from a date. No validation is performed
+     * on the string passed for {@code value}.
+     *
+     * @param name  The name of the property state
+     * @param value  The value of the property state
+     * @return  The new property state of type {@link Type#DATE}
+     */
+    public static PropertyState dateProperty(String name, String value) {
+        return new GenericPropertyState(name, value, DATE);
+    }
+
+    /**
      * Create a {@code PropertyState} from a name. No validation is performed
      * on the string passed for {@code value}.
      * @param name  The name of the property state
@@ -108,7 +121,7 @@ public class GenericPropertyState extend
 
     @Override
     public Converter getConverter() {
-        return Conversions.convert(value);
+        return Conversions.convert(value, type);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java Thu Oct 24 16:27:41 2013
@@ -18,11 +18,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.memory;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.plugins.value.Conversions.convert;
-
-import java.util.Calendar;
-
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
@@ -32,12 +27,10 @@ import org.apache.jackrabbit.oak.plugins
 
 public class LongPropertyState extends SinglePropertyState<Long> {
     private final long value;
-    private final Type<?> type;
 
-    public LongPropertyState(@Nonnull String name, long value, Type<?> type) {
+    public LongPropertyState(@Nonnull String name, long value) {
         super(name);
         this.value = value;
-        this.type = type;
     }
 
     /**
@@ -48,43 +41,7 @@ public class LongPropertyState extends S
      */
     public static PropertyState createLongProperty(
             @Nonnull String name, long value) {
-        return new LongPropertyState(name, value, Type.LONG);
-    }
-
-    /**
-     * Create a {@code PropertyState} for a date value from a long.
-     * @param name  The name of the property state
-     * @param value  The value of the property state
-     * @return  The new property state of type {@link Type#DATE}
-     */
-    public static PropertyState createDateProperty(
-            @Nonnull String name, long value) {
-        return new LongPropertyState(name, value, Type.DATE);
-    }
-
-    /**
-     * Create a {@code PropertyState} for a date.
-     * @param name  The name of the property state
-     * @param value  The value of the property state
-     * @return  The new property state of type {@link Type#DATE}
-     */
-    public static PropertyState createDateProperty(
-            @Nonnull String name, @Nonnull Calendar value) {
-        return new LongPropertyState(
-                name, convert(checkNotNull(value)).toLong(), Type.DATE);
-    }
-
-    /**
-     * Create a {@code PropertyState} for a date from a String.
-     * @param name  The name of the property state
-     * @param value  The value of the property state
-     * @return  The new property state of type {@link Type#DATE}
-     * @throws IllegalArgumentException if {@code value} is not a parseable to a date.
-     */
-    public static PropertyState createDateProperty(
-            @Nonnull String name, @Nonnull String value) {
-        return createDateProperty(
-                name, convert(checkNotNull(value)).toCalendar());
+        return new LongPropertyState(name, value);
     }
 
     @Override
@@ -94,16 +51,12 @@ public class LongPropertyState extends S
 
     @Override
     public Converter getConverter() {
-        if (type == Type.DATE) {
-            return convert(convert(value).toCalendar());
-        }
-        else {
-            return Conversions.convert(value);
-        }
+        return Conversions.convert(value);
     }
 
     @Override
     public Type<?> getType() {
-        return type;
+        return Type.LONG;
     }
+
 }

Modified: 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/plugins/memory/MemoryPropertyBuilder.java?rev=1535431&r1=1535430&r2=1535431&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/plugins/memory/MemoryPropertyBuilder.java Thu Oct 24 16:27:41 2013
@@ -181,8 +181,6 @@ public class MemoryPropertyBuilder<T> im
                     return MultiLongPropertyState.createLongProperty(name, (Iterable<Long>) values);
                 case PropertyType.DOUBLE:
                     return MultiDoublePropertyState.doubleProperty(name, (Iterable<Double>) values);
-                case PropertyType.DATE:
-                    return MultiLongPropertyState.createDatePropertyFromLong(name, (Iterable<Long>) values);
                 case PropertyType.BOOLEAN:
                     return MultiBooleanPropertyState.booleanProperty(name, (Iterable<Boolean>) values);
                 case PropertyType.DECIMAL:
@@ -201,8 +199,6 @@ public class MemoryPropertyBuilder<T> im
                     return LongPropertyState.createLongProperty(name, (Long) value);
                 case PropertyType.DOUBLE:
                     return DoublePropertyState.doubleProperty(name, (Double) value);
-                case PropertyType.DATE:
-                    return LongPropertyState.createDateProperty(name, (Long) value);
                 case PropertyType.BOOLEAN:
                     return BooleanPropertyState.booleanProperty(name, (Boolean) value);
                 case PropertyType.DECIMAL:

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiGenericPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiGenericPropertyState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiGenericPropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiGenericPropertyState.java Thu Oct 24 16:27:41 2013
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.value.Conversions.Converter;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static org.apache.jackrabbit.oak.api.Type.DATES;
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.api.Type.PATHS;
 import static org.apache.jackrabbit.oak.api.Type.REFERENCES;
@@ -43,6 +44,17 @@ public class MultiGenericPropertyState e
     }
 
     /**
+     * Create a multi valued {@code PropertyState} from a list of dates.
+     *
+     * @param name  The name of the property state
+     * @param values  The values of the property state
+     * @return  The new property state of type {@link Type#DATES}
+     */
+    public static PropertyState dateProperty(String name, Iterable<String> values) {
+        return new MultiGenericPropertyState(name, values, DATES);
+    }
+
+    /**
      * Create a multi valued {@code PropertyState} from a list of names.
      * No validation is performed on the strings passed for {@code values}.
      * @param name  The name of the property state
@@ -99,7 +111,7 @@ public class MultiGenericPropertyState e
 
     @Override
     public Converter getConverter(String value) {
-        return Conversions.convert(value);
+        return Conversions.convert(value, type.getBaseType());
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiLongPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiLongPropertyState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiLongPropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiLongPropertyState.java Thu Oct 24 16:27:41 2013
@@ -18,9 +18,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.memory;
 
-import java.util.Calendar;
-import java.util.List;
-
 import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
@@ -28,11 +25,9 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.value.Conversions.Converter;
 
 public class MultiLongPropertyState extends MultiPropertyState<Long> {
-    private final Type<?> type;
 
-    public MultiLongPropertyState(String name, Iterable<Long> values, Type<?> type) {
+    public MultiLongPropertyState(String name, Iterable<Long> values) {
         super(name, values);
-        this.type = type;
     }
 
     /**
@@ -42,60 +37,16 @@ public class MultiLongPropertyState exte
      * @return  The new property state of type {@link Type#LONGS}
      */
     public static PropertyState createLongProperty(String name, Iterable<Long> values) {
-        return new MultiLongPropertyState(name, Lists.newArrayList(values), Type.LONGS);
-    }
-
-    /**
-     * Create a multi valued {@code PropertyState} of dates from a list of longs.
-     * @param name  The name of the property state
-     * @param values  The values of the property state
-     * @return  The new property state of type {@link Type#DATES}
-     */
-    public static PropertyState createDatePropertyFromLong(String name, Iterable<Long> values) {
-        return new MultiLongPropertyState(name, Lists.newArrayList(values), Type.DATES);
-    }
-
-    /**
-     * Create a multi valued {@code PropertyState} of dates.
-     * @param name  The name of the property state
-     * @param values  The values of the property state
-     * @return  The new property state of type {@link Type#DATES}
-     */
-    public static PropertyState createDatePropertyFromCalendar(String name, Iterable<Calendar> values) {
-        List<Long> dates = Lists.newArrayList();
-        for (Calendar v : values) {
-            dates.add(Conversions.convert(v).toLong());
-        }
-        return new MultiLongPropertyState(name, dates, Type.DATES);
-    }
-
-    /**
-     * Create a multi valued {@code PropertyState} of dates from a list of strings.
-     * @param name  The name of the property state
-     * @param values  The values of the property state
-     * @return  The new property state of type {@link Type#DATES}
-     * @throws IllegalArgumentException if one of the {@code values} is not a parseable to a date.
-     */
-    public static PropertyState createDateProperty(String name, Iterable<String> values) {
-        List<Long> dates = Lists.newArrayList();
-        for (String v : values) {
-            dates.add(Conversions.convert(Conversions.convert(v).toCalendar()).toLong());
-        }
-        return new MultiLongPropertyState(name, dates, Type.DATES);
+        return new MultiLongPropertyState(name, Lists.newArrayList(values));
     }
 
     @Override
     public Converter getConverter(Long value) {
-        if (type == Type.DATES) {
-            return Conversions.convert(Conversions.convert(value).toCalendar());
-        }
-        else {
-            return Conversions.convert(value);
-        }
+        return Conversions.convert(value);
     }
 
     @Override
     public Type<?> getType() {
-        return type;
+        return Type.LONGS;
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java Thu Oct 24 16:27:41 2013
@@ -89,10 +89,10 @@ abstract class MultiPropertyState<T> ext
                     }
                 });
             case PropertyType.DATE:
-                return (S) Iterables.transform(values, new Function<T, Long>() {
+                return (S) Iterables.transform(values, new Function<T, String>() {
                     @Override
-                    public Long apply(T value) {
-                        return getConverter(value).toDate();
+                    public String apply(T value) {
+                        return getConverter(value).toString();
                     }
                 });
             case PropertyType.BOOLEAN:
@@ -172,7 +172,7 @@ abstract class MultiPropertyState<T> ext
             case PropertyType.BINARY: return (S) getConverter(values.get(index)).toBinary();
             case PropertyType.LONG: return (S) (Long) getConverter(values.get(index)).toLong();
             case PropertyType.DOUBLE: return (S) (Double) getConverter(values.get(index)).toDouble();
-            case PropertyType.DATE: return (S) getConverter(values.get(index)).toDate();
+            case PropertyType.DATE: return (S) getConverter(values.get(index)).toString();
             case PropertyType.BOOLEAN: return (S) (Boolean) getConverter(values.get(index)).toBoolean();
             case PropertyType.NAME: return (S) getConverter(values.get(index)).toString();
             case PropertyType.PATH: return (S) getConverter(values.get(index)).toString();

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=1535431&r1=1535430&r2=1535431&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 Thu Oct 24 16:27:41 2013
@@ -29,11 +29,13 @@ import javax.jcr.Value;
 
 import com.google.common.collect.Iterables;
 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.plugins.value.Conversions;
 import org.apache.jackrabbit.oak.plugins.value.ValueImpl;
+import org.apache.jackrabbit.util.ISO8601;
 
 /**
  * Utility class for creating {@link PropertyState} instances.
@@ -52,7 +54,6 @@ public final class PropertyStates {
      */
     @Nonnull
     public static PropertyState createProperty(String name, Value value) throws RepositoryException {
-
         int type = value.getType();
         switch (type) {
             case PropertyType.STRING:
@@ -63,8 +64,6 @@ public final class PropertyStates {
                 return LongPropertyState.createLongProperty(name, value.getLong());
             case PropertyType.DOUBLE:
                 return DoublePropertyState.doubleProperty(name, value.getDouble());
-            case PropertyType.DATE:
-                return LongPropertyState.createDateProperty(name, value.getLong());
             case PropertyType.BOOLEAN:
                 return BooleanPropertyState.booleanProperty(name, value.getBoolean());
             case PropertyType.DECIMAL:
@@ -125,12 +124,6 @@ public final class PropertyStates {
                     doubles.add(value.getDouble());
                 }
                 return MultiDoublePropertyState.doubleProperty(name, doubles);
-            case PropertyType.DATE:
-                List<Long> dates = Lists.newArrayList();
-                for (Value value : values) {
-                    dates.add(value.getLong());
-                }
-                return MultiLongPropertyState.createDatePropertyFromLong(name, dates);
             case PropertyType.BOOLEAN:
                 List<Boolean> booleans = Lists.newArrayList();
                 for (Value value : values) {
@@ -182,8 +175,6 @@ public final class PropertyStates {
                 return LongPropertyState.createLongProperty(name, Conversions.convert(value).toLong());
             case PropertyType.DOUBLE:
                 return DoublePropertyState.doubleProperty(name, Conversions.convert(value).toDouble());
-            case PropertyType.DATE:
-                return LongPropertyState.createDateProperty(name, Conversions.convert(value).toDate());
             case PropertyType.BOOLEAN:
                 return BooleanPropertyState.booleanProperty(name, Conversions.convert(value).toBoolean());
             case PropertyType.DECIMAL:
@@ -222,8 +213,8 @@ public final class PropertyStates {
                 : DoublePropertyState.doubleProperty(name, (Double) value);
             case PropertyType.DATE:
                 return type.isArray()
-                ? MultiLongPropertyState.createDatePropertyFromLong(name, (Iterable<Long>) value)
-                : LongPropertyState.createDateProperty(name, (Long) value);
+                ? MultiGenericPropertyState.dateProperty(name, (Iterable<String>) value)
+                : GenericPropertyState.dateProperty(name, (String) value);
             case PropertyType.BOOLEAN:
                 return type.isArray()
                 ? MultiBooleanPropertyState.booleanProperty(name, (Iterable<Boolean>) value)
@@ -279,7 +270,7 @@ public final class PropertyStates {
         } else if (value instanceof Double) {
             return DoublePropertyState.doubleProperty(name, (Double) value);
         } else if (value instanceof Calendar) {
-            return LongPropertyState.createDateProperty(name, (Calendar) value);
+            return GenericPropertyState.dateProperty(name, ISO8601.format((Calendar) value));
         } else if (value instanceof Boolean) {
             return BooleanPropertyState.booleanProperty(name, (Boolean) value);
         } else if (value instanceof BigDecimal) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java Thu Oct 24 16:27:41 2013
@@ -61,7 +61,7 @@ abstract class SinglePropertyState<T> ex
             case PropertyType.BINARY: return (S) getConverter().toBinary();
             case PropertyType.LONG: return (S) (Long) getConverter().toLong();
             case PropertyType.DOUBLE: return (S) (Double) getConverter().toDouble();
-            case PropertyType.DATE: return (S) getConverter().toDate();
+            case PropertyType.DATE: return (S) getConverter().toString();
             case PropertyType.BOOLEAN: return (S) (Boolean) getConverter().toBoolean();
             case PropertyType.NAME: return (S) getConverter().toString();
             case PropertyType.PATH: return (S) getConverter().toString();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java Thu Oct 24 16:27:41 2013
@@ -157,25 +157,14 @@ class SegmentPropertyState extends Recor
             return (T) new SegmentBlob(segment, valueId);
         } else {
             String value = segment.readString(valueId);
-            if (type == Type.STRING || type == Type.URI
+            if (type == Type.STRING || type == Type.URI || type == Type.DATE
                     || type == Type.NAME || type == Type.PATH
                     || type == Type.REFERENCE || type == Type.WEAKREFERENCE) {
                 return (T) value;
             } else {
-                Converter converter = Conversions.convert(value);
-                if (base == Type.DATE) {
-                    converter = Conversions.convert(converter.toCalendar());
-                } else if (base == Type.DECIMAL) {
-                    converter = Conversions.convert(converter.toDecimal());
-                } else if (base == Type.DOUBLE) {
-                    converter = Conversions.convert(converter.toDouble());
-                } else if (base == Type.LONG) {
-                    converter = Conversions.convert(converter.toLong());
-                }
+                Converter converter = Conversions.convert(value, base);
                 if (type == Type.BOOLEAN) {
                     return (T) Boolean.valueOf(converter.toBoolean());
-                } else if (type == Type.DATE) {
-                    return (T) converter.toDate();
                 } else if (type == Type.DECIMAL) {
                     return (T) converter.toDecimal();
                 } else if (type == Type.DOUBLE) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/Conversions.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/Conversions.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/Conversions.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/Conversions.java Thu Oct 24 16:27:41 2013
@@ -26,7 +26,9 @@ import java.util.TimeZone;
 
 import com.google.common.base.Charsets;
 import com.google.common.io.ByteStreams;
+
 import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.memory.StringBasedBlob;
 import org.apache.jackrabbit.util.ISO8601;
 
@@ -101,16 +103,6 @@ public final class Conversions {
         }
 
         /**
-         * Convert to date. This default implementation delegates to {@link #toCalendar()}
-         * and returns the <code>getTimeInMillis</code> value of the calendar.
-         * @return  date representation of the converted value
-         * @throws IllegalArgumentException  if the string cannot be parsed into a date
-         */
-        public Long toDate() {
-            return toCalendar().getTimeInMillis();
-        }
-
-        /**
          * Convert to boolean. This default implementation is based on {@code Boolean.parseBoolean(String)}.
          * @return  boolean representation of the converted value
          */
@@ -262,33 +254,39 @@ public final class Conversions {
      * @param value  The date to convert
      * @return  A converter for {@code value}
      */
-    public static Converter convert(final Calendar value) {
-        return new Converter() {
-            @Override
-            public String toString() {
-                return ISO8601.format(value);
-            }
-
-            @Override
-            public long toLong() {
-                return value.getTimeInMillis();
-            }
-
-            @Override
-            public double toDouble() {
-                return value.getTimeInMillis();
-            }
-
-            @Override
-            public Calendar toCalendar() {
-                return value;
-            }
-
-            @Override
-            public BigDecimal toDecimal() {
-                return new BigDecimal(value.getTimeInMillis());
-            }
-        };
+    public static Converter convert(final String value, Type<?> type) {
+        if (type == Type.DECIMAL) {
+            return convert(convert(value).toDecimal());
+        } else if (type == Type.DOUBLE) {
+            return convert(convert(value).toDouble());
+        } else if (type == Type.LONG) {
+            return convert(convert(value).toLong());
+        } else if (type != Type.DATE) {
+            return convert(value);
+        } else {
+            return new Converter() {
+                @Override
+                public String toString() {
+                    return value;
+                }
+                @Override
+                public Calendar toCalendar() {
+                    return ISO8601.parse(toString());
+                }
+                @Override
+                public long toLong() {
+                    return toCalendar().getTimeInMillis();
+                }
+                @Override
+                public double toDouble() {
+                    return toLong();
+                }
+                @Override
+                public BigDecimal toDecimal() {
+                    return new BigDecimal(toLong());
+                }
+            };
+        }
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java Thu Oct 24 16:27:41 2013
@@ -23,6 +23,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Calendar;
 import java.util.List;
+
 import javax.jcr.Binary;
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
@@ -33,6 +34,7 @@ import javax.jcr.ValueFormatException;
 import javax.jcr.nodetype.NodeType;
 
 import com.google.common.collect.Lists;
+
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.BlobFactory;
 import org.apache.jackrabbit.oak.api.PropertyState;
@@ -47,6 +49,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.memory.DoublePropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.GenericPropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.LongPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.memory.StringPropertyState;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.util.ISO8601;
@@ -167,7 +170,7 @@ public class ValueFactoryImpl implements
 
     @Override
     public Value createValue(Calendar value) {
-        return new ValueImpl(LongPropertyState.createDateProperty("", value), namePathMapper);
+        return new ValueImpl(PropertyStates.createProperty("", value), namePathMapper);
     }
 
     @Override
@@ -216,7 +219,7 @@ public class ValueFactoryImpl implements
                     if (ISO8601.parse(value) == null) {
                         throw new ValueFormatException("Invalid date " + value);
                     }
-                    return new ValueImpl(LongPropertyState.createDateProperty("", value), namePathMapper);
+                    return new ValueImpl(GenericPropertyState.dateProperty("", value), namePathMapper);
                 case PropertyType.BOOLEAN:
                     return createValue(Conversions.convert(value).toBoolean());
                 case PropertyType.NAME:

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java Thu Oct 24 16:27:41 2013
@@ -120,11 +120,11 @@ public class ValueImpl implements Value 
             switch (getType()) {
                 case PropertyType.STRING:
                 case PropertyType.BINARY:
-                    long value = propertyState.getValue(Type.DATE, index);
+                case PropertyType.DATE:
+                    String value = propertyState.getValue(Type.DATE, index);
                     return Conversions.convert(value).toCalendar();
                 case PropertyType.LONG:
                 case PropertyType.DOUBLE:
-                case PropertyType.DATE:
                 case PropertyType.DECIMAL:
                     return Conversions.convert(propertyState.getValue(Type.LONG, index)).toCalendar();
                 default:

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/DateVersionSelector.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/DateVersionSelector.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/DateVersionSelector.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/DateVersionSelector.java Thu Oct 24 16:27:41 2013
@@ -24,6 +24,7 @@ import javax.jcr.RepositoryException;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.util.ISO8601;
 
 /**
  * <i>Inspired by Jackrabbit 2.x</i>
@@ -58,8 +59,8 @@ public class DateVersionSelector impleme
      *
      * @param timestamp reference timestamp
      */
-    public DateVersionSelector(long timestamp) {
-        this.timestamp = timestamp;
+    public DateVersionSelector(String timestamp) {
+        this.timestamp = ISO8601.parse(timestamp).getTimeInMillis();
     }
 
     @Override
@@ -74,7 +75,7 @@ public class DateVersionSelector impleme
                 // ignore root version and labels node
                 continue;
             }
-            long c = v.getProperty(JcrConstants.JCR_CREATED).getValue(Type.DATE);
+            long c = ISO8601.parse(v.getProperty(JcrConstants.JCR_CREATED).getValue(Type.DATE)).getTimeInMillis();
             if (c > latestDate && c <= timestamp) {
                 latestDate = c;
                 latestVersion = v;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java Thu Oct 24 16:27:41 2013
@@ -18,16 +18,19 @@
  */
 package org.apache.jackrabbit.oak.plugins.version;
 
+import java.util.Calendar;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Sets;
+
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
@@ -40,6 +43,7 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.util.ISO8601;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -326,8 +330,7 @@ class ReadWriteVersionManager extends Re
         String versionUUID = IdentifierManager.generateUUID();
         version.setProperty(JCR_UUID, versionUUID, Type.STRING);
         version.setProperty(JCR_PRIMARYTYPE, NT_VERSION, Type.NAME);
-        long now = System.currentTimeMillis();
-        version.setProperty(JCR_CREATED, now, Type.DATE);
+        version.setProperty(JCR_CREATED, ISO8601.format(Calendar.getInstance()), Type.DATE);
         version.setProperty(JCR_PREDECESSORS, predecessors, Type.REFERENCES);
         version.setProperty(JCR_SUCCESSORS, Collections.<String>emptyList(), Type.REFERENCES);
 
@@ -483,4 +486,5 @@ class ReadWriteVersionManager extends Re
         }
         return history.child(JCR_VERSIONLABELS);
     }
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java Thu Oct 24 16:27:41 2013
@@ -221,7 +221,7 @@ class VersionableState {
             throws CommitFailedException {
         try {
             if (selector == null) {
-                long created = version.getProperty(JCR_CREATED).getValue(Type.DATE);
+                String created = version.getProperty(JCR_CREATED).getValue(Type.DATE);
                 selector = new DateVersionSelector(created);
             }
             restoreFrozen(frozenNode, versionable, selector);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java Thu Oct 24 16:27:41 2013
@@ -100,8 +100,8 @@ public final class PropertyValues {
     }
 
     @Nonnull
-    public static PropertyValue newDate(Long value) {
-        return new PropertyStateValue(LongPropertyState.createDateProperty("", value));
+    public static PropertyValue newDate(String value) {
+        return new PropertyStateValue(GenericPropertyState.dateProperty("", value));
     }
 
     @Nonnull

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=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java Thu Oct 24 16:27:41 2013
@@ -25,6 +25,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.List;
 
 import javax.annotation.CheckForNull;
@@ -46,6 +47,7 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.namepath.NameMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
+import org.apache.jackrabbit.util.ISO8601;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -274,7 +276,9 @@ public class NodeUtil {
     }
 
     public void setDate(String name, long time) {
-        tree.setProperty(name, time, DATE);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(time);
+        tree.setProperty(name, ISO8601.format(calendar), DATE);
     }
 
     public long getLong(String name, long defaultValue) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java Thu Oct 24 16:27:41 2013
@@ -57,6 +57,7 @@ import javax.jcr.nodetype.NoSuchNodeType
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
+
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -65,6 +66,7 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
+import org.apache.jackrabbit.util.ISO8601;
 
 /**
  * Utility providing common operations for the {@code Tree} that are not provided
@@ -285,14 +287,14 @@ public final class TreeUtil {
             String uuid = IdentifierManager.generateUUID();
             return PropertyStates.createProperty(name, uuid, STRING);
         } else if (JCR_CREATED.equals(name)) {
-            long now = Calendar.getInstance().getTime().getTime();
+            String now = ISO8601.format(Calendar.getInstance());
             return PropertyStates.createProperty(name, now, DATE);
         } else if (JCR_CREATEDBY.equals(name)) {
             if (userID != null) {
                 return PropertyStates.createProperty(name, userID, STRING);
             }
         } else if (JCR_LASTMODIFIED.equals(name)) {
-            long now = Calendar.getInstance().getTime().getTime();
+            String now = ISO8601.format(Calendar.getInstance());
             return PropertyStates.createProperty(name, now, DATE);
         } else if (JCR_LASTMODIFIEDBY.equals(name)) {
             if (userID != null) {

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=1535431&r1=1535430&r2=1535431&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 Thu Oct 24 16:27:41 2013
@@ -21,7 +21,6 @@ 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.util.ISO8601;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -75,13 +74,13 @@ public class MemoryPropertyBuilderTest {
 
     @Test
     public void testDateProperty() {
-        PropertyBuilder<Long> builder = MemoryPropertyBuilder.array(Type.DATE);
-        Long date1 = ISO8601.parse("1970-01-01T00:00:00.000Z").getTimeInMillis();
-        Long date2 = ISO8601.parse("1971-01-01T00:00:00.000Z").getTimeInMillis();
+        PropertyBuilder<String> builder = MemoryPropertyBuilder.array(Type.DATE);
+        String date1 = "1970-01-01T00:00:00.000Z";
+        String date2 = "1971-01-01T00:00:00.000Z";
         builder.setName("foo")
                 .addValue(date1)
                 .addValue(date2);
-        assertEquals(MultiLongPropertyState.createDatePropertyFromLong("foo", Arrays.asList(date1, date2)),
+        assertEquals(MultiGenericPropertyState.dateProperty("foo", Arrays.asList(date1, date2)),
                 builder.getPropertyState());
 
         builder.setScalar();
@@ -92,7 +91,7 @@ public class MemoryPropertyBuilderTest {
         }
 
         builder.removeValue(date1);
-        assertEquals(LongPropertyState.createDateProperty("foo", date2),
+        assertEquals(GenericPropertyState.dateProperty("foo", date2),
                 builder.getPropertyState());
     }
 
@@ -117,8 +116,8 @@ public class MemoryPropertyBuilderTest {
     @Test
     public void testAssignFromDate() {
         String date = "1970-01-01T00:00:00.000Z";
-        PropertyState source = LongPropertyState.createDateProperty("foo", date);
-        PropertyBuilder<Long> builder = MemoryPropertyBuilder.scalar(Type.DATE);
+        PropertyState source = GenericPropertyState.dateProperty("foo", date);
+        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.DATE);
         builder.assignFrom(source);
         assertEquals(source, builder.getPropertyState());
     }
@@ -152,8 +151,8 @@ public class MemoryPropertyBuilderTest {
     public void testAssignFromDates() {
         String date1 = "1970-01-01T00:00:00.000Z";
         String date2 = "1971-01-01T00:00:00.000Z";
-        PropertyState source = MultiLongPropertyState.createDateProperty("foo", Arrays.asList(date1, date2));
-        PropertyBuilder<Long> builder = MemoryPropertyBuilder.scalar(Type.DATE);
+        PropertyState source = MultiGenericPropertyState.dateProperty("foo", Arrays.asList(date1, date2));
+        PropertyBuilder<String> builder = MemoryPropertyBuilder.scalar(Type.DATE);
         builder.assignFrom(source);
         assertEquals(source, builder.getPropertyState());
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStatesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStatesTest.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStatesTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStatesTest.java Thu Oct 24 16:27:41 2013
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
+import org.apache.jackrabbit.util.ISO8601;
 import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
@@ -59,10 +60,10 @@ public class PropertyStatesTest {
 
     @Test
     public void dateValueFromDateProperty() throws RepositoryException {
-        long expected = Calendar.getInstance().getTimeInMillis();
+        String expected = ISO8601.format(Calendar.getInstance());
         PropertyState dateProperty = PropertyStates.createProperty(
                 "date", expected, Type.DATE);
-        long actual = dateProperty.getValue(Type.DATE);
+        String actual = dateProperty.getValue(Type.DATE);
         assertEquals(expected, actual);
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java Thu Oct 24 16:27:41 2013
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.util.ISO8601;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -85,7 +86,7 @@ public class SegmentSizeTest {
 
     @Test
     public void testDuplicateDates() {
-        long now = Calendar.getInstance().getTimeInMillis();
+        String now = ISO8601.format(Calendar.getInstance());
 
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setProperty(PropertyStates.createProperty(

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java Thu Oct 24 16:27:41 2013
@@ -424,8 +424,6 @@ public abstract class AbstractQueryTest 
                         values.add(Conversions.convert(value).toDouble());
                     } else if (type == PropertyType.DECIMAL) {
                         values.add(Conversions.convert(value).toDecimal());
-                    } else if (type == PropertyType.DATE) {
-                        values.add(Conversions.convert(value).toCalendar().getTimeInMillis());
                     } else {
                         values.add(value);
                     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java Thu Oct 24 16:27:41 2013
@@ -108,7 +108,7 @@ public class PropertyDelegate extends It
         return getSingleState().getValue(Type.STRING);
     }
 
-    public Long getDate() throws ValueFormatException, InvalidItemStateException {
+    public String getDate() throws ValueFormatException, InvalidItemStateException {
         return getSingleState().getValue(Type.DATE);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionHistoryDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionHistoryDelegate.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionHistoryDelegate.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionHistoryDelegate.java Thu Oct 24 16:27:41 2013
@@ -21,8 +21,6 @@ import static org.apache.jackrabbit.JcrC
 
 import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
 import java.util.Deque;
 import java.util.Iterator;
 import java.util.List;
@@ -37,14 +35,13 @@ import javax.jcr.version.VersionExceptio
 
 import com.google.common.base.Function;
 import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
 
 import org.apache.jackrabbit.JcrConstants;
 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.plugins.value.Conversions;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
+import org.apache.jackrabbit.util.ISO8601;
 
 /**
  * {@code VersionHistoryDelegate}...
@@ -136,14 +133,14 @@ public class VersionHistoryDelegate exte
     @Nonnull
     public Iterator<VersionDelegate> getAllVersions()
             throws RepositoryException {
-        SortedMap<Calendar, String> versions = new TreeMap<Calendar, String>();
+        SortedMap<Long, String> versions = new TreeMap<Long, String>();
         for (Iterator<NodeDelegate> it = getChildren(); it.hasNext(); ) {
             NodeDelegate n = it.next();
             String primaryType = n.getProperty(JcrConstants.JCR_PRIMARYTYPE).getString();
             if (primaryType.equals(VersionConstants.NT_VERSION)) {
                 PropertyDelegate created = n.getPropertyOrNull(JcrConstants.JCR_CREATED);
                 if (created != null) {
-                    Calendar cal = Conversions.convert(created.getDate()).toCalendar();
+                    Long cal = ISO8601.parse(created.getDate()).getTimeInMillis();
                     versions.put(cal, n.getName());
                 }
             }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java?rev=1535431&r1=1535430&r2=1535431&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java Thu Oct 24 16:27:41 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import java.util.Calendar;
+import java.util.TimeZone;
+
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
@@ -160,4 +163,23 @@ public class CRUDTest extends AbstractRe
             // expected
         }
     }
+
+    @Test
+    public void testSetPropertyDateWithTimeZone() throws RepositoryException {
+        Session session = getAdminSession();
+        Node root = session.getRootNode();
+
+        final Calendar cal = Calendar.getInstance();
+        cal.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
+        cal.setTimeInMillis(1239902100000L);
+
+        root.setProperty("start", cal);
+        session.save();
+
+        assertEquals(12, root.getProperty("start").getDate().get(Calendar.HOUR_OF_DAY));
+
+        root.getProperty("start").remove();
+        session.save();
+    }
+
 }



Mime
View raw message