chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r801436 - in /incubator/chemistry/trunk/chemistry: chemistry-api/src/main/java/org/apache/chemistry/ chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/ chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/
Date Wed, 05 Aug 2009 22:04:57 GMT
Author: fguillaume
Date: Wed Aug  5 22:04:57 2009
New Revision: 801436

URL: http://svn.apache.org/viewvc?rev=801436&view=rev
Log:
CMIS-44: fixed descendants types nesting

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleTypeManager.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java?rev=801436&r1=801435&r2=801436&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
Wed Aug  5 22:04:57 2009
@@ -16,7 +16,11 @@
  */
 package org.apache.chemistry;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -55,10 +59,19 @@
     }
 
     private static final Map<String, BaseType> all = new HashMap<String, BaseType>();
+
+    public static final List<BaseType> ALL = Collections.unmodifiableList(Arrays.asList(values()));
+
+    public static final List<String> ALL_IDS;
+
     static {
+        List<String> ids = new ArrayList<String>(4);
         for (BaseType o : values()) {
-            all.put(o.value, o);
+            String id = o.getId();
+            all.put(id, o);
+            ids.add(id);
         }
+        ALL_IDS = Collections.unmodifiableList(ids);
     }
 
     public static BaseType get(String value) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java?rev=801436&r1=801435&r2=801436&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
Wed Aug  5 22:04:57 2009
@@ -18,6 +18,7 @@
 
 import java.io.Serializable;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
@@ -33,6 +34,7 @@
 import org.apache.abdera.model.Person;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.context.ResponseContextException;
+import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMIS;
 import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.PropertyType;
@@ -261,7 +263,7 @@
             }
         }
         // end property definitions
-        if ("typesdescendants".equals(getType())) {
+        if (AtomPubCMIS.COL_TYPES_DESCENDANTS.equals(getType())) {
             Collection<Type> subTypes = repository.getTypes(type.getId(), 1,
                     includePropertyDefinitions);
             if (!subTypes.isEmpty()) {
@@ -294,7 +296,16 @@
     @Override
     public Iterable<Type> getEntries(RequestContext request)
             throws ResponseContextException {
-        return repository.getTypes(id);
+        if (id == null && AtomPubCMIS.COL_TYPES_DESCENDANTS.equals(getType())) {
+            // descendants needs only the first level, it will then recurse
+            List<Type> list = new ArrayList<Type>(4);
+            for (String tid : BaseType.ALL_IDS) {
+                list.add(repository.getType(tid));
+            }
+            return list;
+        } else {
+            return repository.getTypes(id);
+        }
     }
 
     @Override
@@ -333,6 +344,7 @@
     public String getResourceName(RequestContext request) {
         return request.getTarget().getParameter("typeid");
     }
+
     @Override
     protected String getLink(Type type, IRI feedIri, RequestContext request) {
         return getTypeLink(type.getId(), request);

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java?rev=801436&r1=801435&r2=801436&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
Wed Aug  5 22:04:57 2009
@@ -451,4 +451,9 @@
         return propertyDefinitions.get(id);
     }
 
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + '(' + getId() + ')';
+    }
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleTypeManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleTypeManager.java?rev=801436&r1=801435&r2=801436&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleTypeManager.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleTypeManager.java
Wed Aug  5 22:04:57 2009
@@ -17,7 +17,6 @@
 package org.apache.chemistry.impl.simple;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -77,21 +76,25 @@
      */
     public Collection<Type> getTypes(String typeId, int depth,
             boolean returnPropertyDefinitions) {
+        List<Type> list = new LinkedList<Type>();
+        Set<String> done = new HashSet<String>();
         if (typeId == null) {
             // ignore depth
-            // TODO returnPropertyDefinitions
-            return Collections.unmodifiableCollection(types.values());
-        }
-        if (!types.containsKey(typeId)) {
-            throw new IllegalArgumentException("No such type: " + typeId);
-        }
-        // TODO spec unclear on depth 0
-        List<Type> list = new LinkedList<Type>();
-        if (depth < 0) {
-            list.add(types.get(typeId));
+            for (String tid : BaseType.ALL_IDS) {
+                list.add(types.get(tid));
+                collectSubTypes(tid, -1, returnPropertyDefinitions, list, done);
+            }
+        } else {
+            if (!types.containsKey(typeId)) {
+                throw new IllegalArgumentException("No such type: " + typeId);
+            }
+            // TODO spec unclear on depth 0
+            if (depth < 0) {
+                list.add(types.get(typeId));
+            }
+            collectSubTypes(typeId, depth, returnPropertyDefinitions, list,
+                    done);
         }
-        collectSubTypes(typeId, depth, returnPropertyDefinitions, list,
-                new HashSet<String>());
         return list;
     }
 



Mime
View raw message