jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1330899 - in /jackrabbit/oak/trunk: oak-it/jcr/pom.xml oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
Date Thu, 26 Apr 2012 15:16:58 GMT
Author: angela
Date: Thu Apr 26 15:16:57 2012
New Revision: 1330899

URL: http://svn.apache.org/viewvc?rev=1330899&view=rev
Log:
OAK-16 : Proper ValueFactory implementation and Value handling (WIP)

- deal with ugly runtimeexceptions from name/path handling
- uncomment valuefactory test

Modified:
    jackrabbit/oak/trunk/oak-it/jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java

Modified: jackrabbit/oak/trunk/oak-it/jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/pom.xml?rev=1330899&r1=1330898&r2=1330899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Thu Apr 26 15:16:57 2012
@@ -98,7 +98,6 @@ org.apache.jackrabbit.test.api.Impersona
 org.apache.jackrabbit.test.api.CheckPermissionTest
 org.apache.jackrabbit.test.api.DocumentViewImportTest
 org.apache.jackrabbit.test.api.SerializationTest
-org.apache.jackrabbit.test.api.ValueFactoryTest
 org.apache.jackrabbit.test.api.GetWeakReferencesTest
 org.apache.jackrabbit.test.api.SessionRemoveItemTest
 org.apache.jackrabbit.test.api.HasPermissionTest

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java?rev=1330899&r1=1330898&r2=1330899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
Thu Apr 26 15:16:57 2012
@@ -148,21 +148,28 @@ public class ValueFactoryImpl implements
     @Override
     public Value createValue(String value, int type) throws ValueFormatException {
         CoreValue cv;
-        if (type == PropertyType.NAME) {
-            cv = factory.createValue(nameMapper.getOakName(value), type);
-        } else if (type == PropertyType.PATH) {
-            cv = factory.createValue(Paths.toOakPath(value, nameMapper), type);
-        } else if (type == PropertyType.DATE) {
-            if (ISO8601.parse(value) == null) {
-                throw new ValueFormatException("Invalid date " + value);
-            }
-            cv = factory.createValue(value, type);
-        } else {
-            try {
+        try {
+            if (type == PropertyType.NAME) {
+                cv = factory.createValue(nameMapper.getOakName(value), type);
+            } else if (type == PropertyType.PATH) {
+                cv = factory.createValue(Paths.toOakPath(value, nameMapper), type);
+            } else if (type == PropertyType.DATE) {
+                if (ISO8601.parse(value) == null) {
+                    throw new ValueFormatException("Invalid date " + value);
+                }
+                cv = factory.createValue(value, type);
+            } else {
                 cv = factory.createValue(value, type);
-            } catch (NumberFormatException e) {
-                throw new ValueFormatException("Invalid value " + value + " for type " +
PropertyType.nameFromValue(type));
             }
+        } catch (NumberFormatException e) {
+            throw new ValueFormatException("Invalid value " + value + " for type " + PropertyType.nameFromValue(type));
+        } catch (IllegalArgumentException e) {
+            // TODO: review exception handling in path/name resolution again
+            throw new ValueFormatException("Invalid value " + value + " for type " + PropertyType.nameFromValue(type));
+        } catch (Exception e) {
+            // TODO: review exception handling in path/name resolution again
+            // TODO: throws RuntimeException which is pretty ugly
+            throw new ValueFormatException("Invalid value " + value + " for type " + PropertyType.nameFromValue(type));
         }
 
         return new ValueImpl(cv, nameMapper);



Mime
View raw message