jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r914988 - in /jackrabbit/trunk/jackrabbit-jcr-server/src: main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java test/java/org/apache/jackrabbit/webdav/jcr/JcrValueTypeTest.java
Date Mon, 22 Feb 2010 17:54:14 GMT
Author: angela
Date: Mon Feb 22 17:54:14 2010
New Revision: 914988

URL: http://svn.apache.org/viewvc?rev=914988&view=rev
Log:
JCR-2507 : JcrValueType#typeFromContentType throws IllegalArgumentException for type weak-ref
and uri

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/JcrValueTypeTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java?rev=914988&r1=914987&r2=914988&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
Mon Feb 22 17:54:14 2010
@@ -82,8 +82,13 @@
     }
 
     public static int typeFromContentType(String contentType) {
-        if (contentType != null && TYPE_LOOKUP.containsKey(contentType)) {
-            return TYPE_LOOKUP.get(contentType);
+        if (contentType != null) {
+            // remove charset if present
+            int pos = contentType.indexOf(';');
+            String ct = (pos == -1) ? contentType : contentType.substring(0, pos);
+            if (TYPE_LOOKUP.containsKey(ct)) {
+                return TYPE_LOOKUP.get(ct);
+            }
         }
 
         // some invalid content type argument that does not match any of the

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/JcrValueTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/JcrValueTypeTest.java?rev=914988&r1=914987&r2=914988&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/JcrValueTypeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/JcrValueTypeTest.java
Mon Feb 22 17:54:14 2010
@@ -32,6 +32,12 @@
         }
     }
 
+    public void testTypeFromContentTypeIncludingCharSet() {
+        for (int i = PropertyType.UNDEFINED; i <= PropertyType.DECIMAL; i++) {
+            String ct = JcrValueType.contentTypeFromType(i) + "; charset=UTF-8";
+            assertEquals(i, JcrValueType.typeFromContentType(ct));
+        }
+    }
     public void testTypeFromInvalidContentType() {
         String[] invalids = new String[] {null, "", "jcr-value/invalid", "invalid/as-well"};
 



Mime
View raw message