chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1299642 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/ma...
Date Mon, 12 Mar 2012 12:02:38 GMT
Author: fmui
Date: Mon Mar 12 12:02:37 2012
New Revision: 1299642

URL: http://svn.apache.org/viewvc?rev=1299642&view=rev
Log:
Browser Binding: fixed query results

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/NavigationServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java?rev=1299642&r1=1299641&r2=1299642&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java
Mon Mar 12 12:02:37 2012
@@ -70,7 +70,7 @@ public class DiscoveryServiceImpl extend
         });
 
         Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
-        return JSONConverter.convertObjectList(json);
+        return JSONConverter.convertObjectList(json, true);
     }
 
     public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken,
Boolean includeProperties,
@@ -96,6 +96,6 @@ public class DiscoveryServiceImpl extend
             }
         }
 
-        return JSONConverter.convertObjectList(json);
+        return JSONConverter.convertObjectList(json, false);
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/NavigationServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/NavigationServiceImpl.java?rev=1299642&r1=1299641&r2=1299642&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/NavigationServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/NavigationServiceImpl.java
Mon Mar 12 12:02:37 2012
@@ -155,6 +155,6 @@ public class NavigationServiceImpl exten
         HttpUtils.Response resp = read(url);
         Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
 
-        return JSONConverter.convertObjectList(json);
+        return JSONConverter.convertObjectList(json, false);
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java?rev=1299642&r1=1299641&r2=1299642&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java
Mon Mar 12 12:02:37 2012
@@ -60,6 +60,6 @@ public class RelationshipServiceImpl ext
         HttpUtils.Response resp = read(url);
         Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
 
-        return JSONConverter.convertObjectList(json);
+        return JSONConverter.convertObjectList(json, false);
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java?rev=1299642&r1=1299641&r2=1299642&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java
Mon Mar 12 12:02:37 2012
@@ -197,7 +197,7 @@ public class JSONConstants {
         PROPERTY_KEYS.add(JSON_PROPERTY_LOCALNAME);
         PROPERTY_KEYS.add(JSON_PROPERTY_DISPLAYNAME);
         PROPERTY_KEYS.add(JSON_PROPERTY_QUERYNAME);
-        PROPERTY_KEYS.add(JSON_PROPERTY_QUERYNAME);
+        PROPERTY_KEYS.add(JSON_PROPERTY_VALUE);
         PROPERTY_KEYS.add(JSON_PROPERTY_DATATYPE);
         PROPERTY_KEYS.add(JSON_PROPERTY_CARDINALITY);
     }
@@ -292,6 +292,17 @@ public class JSONConstants {
         OBJECTINFOLDERCONTAINER_KEYS.add(JSON_OBJECTINFOLDERCONTAINER_CHILDREN);
     }
 
+    public static final String JSON_QUERYRESULTLIST_RESULTS = "results";
+    public static final String JSON_QUERYRESULTLIST_HAS_MORE_ITEMS = "hasMoreItems";
+    public static final String JSON_QUERYRESULTLIST_NUM_ITEMS = "numItems";
+
+    public static final Set<String> QUERYRESULTLIST_KEYS = new HashSet<String>();
+    static {
+        OBJECTLIST_KEYS.add(JSON_QUERYRESULTLIST_RESULTS);
+        OBJECTLIST_KEYS.add(JSON_QUERYRESULTLIST_HAS_MORE_ITEMS);
+        OBJECTLIST_KEYS.add(JSON_QUERYRESULTLIST_NUM_ITEMS);
+    }
+
     public static final String JSON_TYPE_ID = "id";
     public static final String JSON_TYPE_LOCALNAME = "localName";
     public static final String JSON_TYPE_LOCALNAMESPACE = "localNamespace";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java?rev=1299642&r1=1299641&r2=1299642&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
Mon Mar 12 12:02:37 2012
@@ -845,7 +845,7 @@ public class JSONConverter {
         }
 
         // relationships
-        if (object.getRelationships() != null) {
+        if ((object.getRelationships() != null) && (!object.getRelationships().isEmpty()))
{
             JSONArray relationships = new JSONArray();
 
             for (ObjectData relationship : object.getRelationships()) {
@@ -873,7 +873,8 @@ public class JSONConverter {
         }
 
         // policy ids
-        if ((object.getPolicyIds() != null) && (object.getPolicyIds().getPolicyIds()
!= null)) {
+        if ((object.getPolicyIds() != null) && (object.getPolicyIds().getPolicyIds()
!= null)
+                && (!object.getPolicyIds().getPolicyIds().isEmpty())) {
             JSONArray policyIds = new JSONArray();
 
             for (String pi : object.getPolicyIds().getPolicyIds()) {
@@ -884,7 +885,7 @@ public class JSONConverter {
         }
 
         // renditions
-        if (object.getRenditions() != null) {
+        if ((object.getRenditions() != null) && (!object.getRenditions().isEmpty()))
{
             JSONArray renditions = new JSONArray();
 
             for (RenditionData rendition : object.getRenditions()) {
@@ -1085,10 +1086,17 @@ public class JSONConverter {
             }
         }
 
-        result.put(JSON_OBJECTLIST_OBJECTS, objects);
+        if (isQueryResult) {
+            result.put(JSON_QUERYRESULTLIST_RESULTS, objects);
 
-        setIfNotNull(JSON_OBJECTLIST_HAS_MORE_ITEMS, list.hasMoreItems(), result);
-        setIfNotNull(JSON_OBJECTLIST_NUM_ITEMS, list.getNumItems(), result);
+            setIfNotNull(JSON_QUERYRESULTLIST_HAS_MORE_ITEMS, list.hasMoreItems(), result);
+            setIfNotNull(JSON_QUERYRESULTLIST_NUM_ITEMS, list.getNumItems(), result);
+        } else {
+            result.put(JSON_OBJECTLIST_OBJECTS, objects);
+
+            setIfNotNull(JSON_OBJECTLIST_HAS_MORE_ITEMS, list.hasMoreItems(), result);
+            setIfNotNull(JSON_OBJECTLIST_NUM_ITEMS, list.getNumItems(), result);
+        }
 
         convertExtension(list, result);
 
@@ -2020,14 +2028,15 @@ public class JSONConverter {
     /**
      * Converts a object list.
      */
-    public static ObjectList convertObjectList(Map<String, Object> json) {
+    public static ObjectList convertObjectList(Map<String, Object> json, boolean isQueryResult)
{
         if (json == null) {
             return null;
         }
 
         ObjectListImpl result = new ObjectListImpl();
 
-        List<Object> jsonChildren = getList(json.get(JSON_OBJECTLIST_OBJECTS));
+        List<Object> jsonChildren = getList(json.get(isQueryResult ? JSON_QUERYRESULTLIST_RESULTS
+                : JSON_OBJECTLIST_OBJECTS));
         List<ObjectData> objects = new ArrayList<ObjectData>();
 
         if (jsonChildren != null) {
@@ -2040,10 +2049,11 @@ public class JSONConverter {
         }
 
         result.setObjects(objects);
-        result.setHasMoreItems(getBoolean(json, JSON_OBJECTLIST_HAS_MORE_ITEMS));
-        result.setNumItems(getInteger(json, JSON_OBJECTLIST_NUM_ITEMS));
+        result.setHasMoreItems(getBoolean(json, isQueryResult ? JSON_QUERYRESULTLIST_NUM_ITEMS
+                : JSON_OBJECTLIST_HAS_MORE_ITEMS));
+        result.setNumItems(getInteger(json, isQueryResult ? JSON_QUERYRESULTLIST_NUM_ITEMS
: JSON_OBJECTLIST_NUM_ITEMS));
 
-        convertExtension(json, result, OBJECTLIST_KEYS);
+        convertExtension(json, result, isQueryResult ? QUERYRESULTLIST_KEYS : OBJECTLIST_KEYS);
 
         return result;
     }



Mime
View raw message