jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1336250 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/ oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/ja...
Date Wed, 09 May 2012 15:52:35 GMT
Author: reschke
Date: Wed May  9 15:52:35 2012
New Revision: 1336250

URL: http://svn.apache.org/viewvc?rev=1336250&view=rev
Log:
OAK-6: add test content for property tests; add value conversion for dates, handle "." paths
in path-typed properties

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
    jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.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/value/ValueImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java?rev=1336250&r1=1336249&r2=1336250&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
Wed May  9 15:52:35 2012
@@ -143,6 +143,11 @@ public class NamePathMapperImpl implemen
             }
         }
 
+        // empty path: map to "."
+        if (oakPath.length() == 0) {
+            return ".";
+        }
+        
         // root path is special-cased early on so it does not need to
         // be considered here
         oakPath.deleteCharAt(oakPath.length() - 1);
@@ -228,6 +233,11 @@ public class NamePathMapperImpl implemen
             }
         }
 
+        // empty path: map to "."
+        if (jcrPath.length() == 0) {
+            return ".";
+        }
+
         jcrPath.deleteCharAt(jcrPath.length() - 1);
         return jcrPath.toString();
     }

Modified: jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java?rev=1336250&r1=1336249&r2=1336250&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java
(original)
+++ jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java
Wed May  9 15:52:35 2012
@@ -16,16 +16,22 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import java.util.Calendar;
+
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 public class TestContentLoader {
 
     public void loadTestContent(Session session) throws RepositoryException {
 
-        getOrAddNode(session.getRootNode(), "testdata");
+        Node data = getOrAddNode(session.getRootNode(), "testdata");
+        addPropertyTestData(getOrAddNode(data, "property"));
+
         session.save();
     }
 
@@ -36,4 +42,20 @@ public class TestContentLoader {
             return node.addNode(name);
         }
     }
+
+    /**
+     * Creates a boolean, double, long, calendar and a path property at the
+     * given node.
+     */
+    private  void addPropertyTestData(Node node) throws RepositoryException {
+        node.setProperty("boolean", true);
+        node.setProperty("double", Math.PI);
+        node.setProperty("long", 90834953485278298l);
+        Calendar c = Calendar.getInstance();
+        c.set(2005, 6, 18, 17, 30);
+        node.setProperty("calendar", c);
+        ValueFactory factory = node.getSession().getValueFactory();
+        node.setProperty("path", factory.createValue("/", PropertyType.PATH));
+        node.setProperty("multi", new String[] { "one", "two", "three" });
+    }
 }

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=1336250&r1=1336249&r2=1336250&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 May  9 15:52:35 2012
@@ -365,6 +365,12 @@ public class NodeImpl extends ItemImpl i
         checkStatus();
 
         String oakPath = sessionDelegate.getOakPathOrThrowNotFound(relPath);
+        
+        // TODO: hack
+        if (".".equals(oakPath)) {
+            return this;
+        }
+        
         NodeDelegate nd = dlg.getChild(oakPath);
         if (nd == null) {
             throw new PathNotFoundException(relPath);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java?rev=1336250&r1=1336249&r2=1336250&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueImpl.java
Wed May  9 15:52:35 2012
@@ -113,7 +113,13 @@ class ValueImpl implements Value {
     @Override
     public BigDecimal getDecimal() throws RepositoryException {
         try {
-            return value.getDecimal();
+            switch (getType()) {
+                case PropertyType.DATE:
+                    Calendar cal = getDate();
+                    return BigDecimal.valueOf(cal.getTimeInMillis());
+                default:
+                    return value.getDecimal();
+            }
         } catch (NumberFormatException e) {
             throw new ValueFormatException("Incompatible type " + PropertyType.nameFromValue(getType()));
         }
@@ -125,7 +131,13 @@ class ValueImpl implements Value {
     @Override
     public double getDouble() throws RepositoryException {
         try {
-            return value.getDouble();
+            switch (getType()) {
+                case PropertyType.DATE:
+                    Calendar cal = getDate();
+                    return cal.getTimeInMillis();
+                default:
+                    return value.getDouble();
+            }
         } catch (NumberFormatException e) {
             throw new ValueFormatException("Incompatible type " + PropertyType.nameFromValue(getType()));
         }
@@ -137,7 +149,13 @@ class ValueImpl implements Value {
     @Override
     public long getLong() throws RepositoryException {
         try {
-            return value.getLong();
+            switch (getType()) {
+                case PropertyType.DATE:
+                    Calendar cal = getDate();
+                    return cal.getTimeInMillis();
+                default:
+                    return value.getLong();
+            }
         } catch (NumberFormatException e) {
             throw new ValueFormatException("Incompatible type " + PropertyType.nameFromValue(getType()));
         }



Mime
View raw message