jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r914994 - /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java
Date Mon, 22 Feb 2010 17:59:21 GMT
Author: angela
Date: Mon Feb 22 17:59:20 2010
New Revision: 914994

URL: http://svn.apache.org/viewvc?rev=914994&view=rev
Log:
JCR-2508: JsonWriter: missing handling of new JCR 2.0 property types

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java?rev=914994&r1=914993&r2=914994&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java
Mon Feb 22 17:59:20 2010
@@ -170,9 +170,7 @@
             }
         } else {
             boolean isMultiple = p.isMultiple();
-            if (type == PropertyType.NAME || type == PropertyType.PATH ||
-                    type == PropertyType.REFERENCE || type == PropertyType.DATE ||
-                    (isMultiple && p.getValues().length == 0)) {
+            if (requiresTypeInfo(type) || (isMultiple && p.getValues().length ==
0)) {
                 /* special property types that have no correspondence in JSON
                    are transported as String. the type is transported with an
                    extra key-value pair, the key having a leading ':' the value
@@ -182,7 +180,7 @@
                  */
                 writeKeyValue(w, ":" +  p.getName(), PropertyType.nameFromValue(type), true);
             }
-            /* append key-value pair containg the jcr value(s).
+            /* append key-value pair containing the jcr value(s).
                for String, Boolean, Double, Long -> types in json available */
             if (isMultiple) {
                 writeKeyArray(w, p.getName(), p.getValues());
@@ -192,6 +190,22 @@
         }
     }
 
+    private static boolean requiresTypeInfo(int type) {
+        switch (type) {
+            case PropertyType.NAME:
+            case PropertyType.PATH:
+            case PropertyType.REFERENCE:
+            case PropertyType.DATE:
+            case PropertyType.WEAKREFERENCE:
+            case PropertyType.URI:
+            case PropertyType.DECIMAL:
+                return true;
+            default:
+                // any other property type
+                return false;
+        }
+    }
+
     private static void writeKeyValue(Writer w, String key, String value, boolean hasNext)
throws IOException {
         writeKey(w, key);
         w.write(JsonUtil.getJsonString(value));



Mime
View raw message