jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1337132 - in /jackrabbit/oak/trunk: oak-it/jcr/pom.xml oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/value/ValueFactoryImpl.java
Date Fri, 11 May 2012 12:48:38 GMT
Author: reschke
Date: Fri May 11 12:48:38 2012
New Revision: 1337132

URL: http://svn.apache.org/viewvc?rev=1337132&view=rev
Log:
OAK-6: fix setProperty(String, PropertyType.Binary) in ValueFactory, update test exclusions

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=1337132&r1=1337131&r2=1337132&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Fri May 11 12:48:38 2012
@@ -48,11 +48,6 @@ org.apache.jackrabbit.test.api.NodeReadM
 org.apache.jackrabbit.test.api.NodeReadMethodsTest#testGetUUID
 org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUIDFailure
 org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUID
-org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_handler_session_saveBinary_recurse
-org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_skipBinary_recurse
-org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_skipBinary_noRecurse
-org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_saveBinary_noRecurse
-org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_saveBinary_recurse
 org.apache.jackrabbit.test.api.PathTest#testGetItem
 org.apache.jackrabbit.test.api.PathTest#testCreatePathValue
 org.apache.jackrabbit.test.api.PathTest#testCreateMultiplePathValue

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=1337132&r1=1337131&r2=1337132&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
Fri May 11 12:48:38 2012
@@ -31,8 +31,11 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.ValueFormatException;
+
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.util.Calendar;
 
@@ -146,33 +149,50 @@ public class ValueFactoryImpl implements
 
     @Override
     public Value createValue(String value, int type) throws ValueFormatException {
-        CoreValue cv;
         try {
-            if (type == PropertyType.NAME) {
-                String oakName = namePathMapper.getOakName(value);
-                if (oakName == null) {
-                    throw new ValueFormatException("Invalid name: " + value);
-                }
-                cv = factory.createValue(oakName, type);
-            } else if (type == PropertyType.PATH) {
-                String oakPath = namePathMapper.getOakPath(value);
-                if (oakPath == null) {
-                    throw new ValueFormatException("Invalid path: " + value);
-                }
-                cv = factory.createValue(oakPath, 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);
+            CoreValue cv;
+
+            switch (type) {
+                case PropertyType.NAME:
+                    String oakName = namePathMapper.getOakName(value);
+                    if (oakName == null) {
+                        throw new ValueFormatException("Invalid name: " + value);
+                    }
+                    cv = factory.createValue(oakName, type);
+                    break;
+
+                case PropertyType.PATH:
+                    String oakPath = namePathMapper.getOakPath(value);
+                    if (oakPath == null) {
+                        throw new ValueFormatException("Invalid path: " + value);
+                    }
+                    cv = factory.createValue(oakPath, type);
+                    break;
+
+                case PropertyType.DATE:
+                    if (ISO8601.parse(value) == null) {
+                        throw new ValueFormatException("Invalid date " + value);
+                    }
+                    cv = factory.createValue(value, type);
+                    break;
+
+                case PropertyType.BINARY:
+                    cv = factory.createValue(new ByteArrayInputStream(value.getBytes("UTF-8")));
+                    break;
+
+                default:
+                    cv = factory.createValue(value, type);
+                    break;
             }
+
+            return new ValueImpl(cv, namePathMapper);
+        } catch (UnsupportedEncodingException e) {
+            throw new ValueFormatException("Encoding UTF-8 not supported (this should not
happen!)", e);
+        } catch (IOException e) {
+            throw new ValueFormatException(e);
         } catch (NumberFormatException e) {
             throw new ValueFormatException("Invalid value " + value + " for type " + PropertyType.nameFromValue(type));
         }
-
-        return new ValueImpl(cv, namePathMapper);
     }
 
     @Override



Mime
View raw message