chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r801408 - in /incubator/chemistry/trunk/chemistry: chemistry-api/src/main/java/org/apache/chemistry/ chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-atompub-client/src/test/resources/ chemistry-atompub-...
Date Wed, 05 Aug 2009 20:48:40 GMT
Author: fguillaume
Date: Wed Aug  5 20:48:40 2009
New Revision: 801408

URL: http://svn.apache.org/viewvc?rev=801408&view=rev
Log:
CMIS-44: updated types XML (cmisra:type), implemented types descendants and service link to
it

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleTypeManager.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java
Wed Aug  5 20:48:40 2009
@@ -105,14 +105,6 @@
 
     public static final QName REPOSITORY_SPECIFIC_INFORMATION = CMISName("repositorySpecificInformation");
 
-    public static final QName DOCUMENT_TYPE = CMISName("documentType");
-
-    public static final QName FOLDER_TYPE = CMISName("folderType");
-
-    public static final QName RELATIONSHIP_TYPE = CMISName("relationshipType");
-
-    public static final QName POLICY_TYPE = CMISName("policyType");
-
     public static final QName BASE_TYPE_ID = CMISName("baseTypeId");
 
     public static final QName ID = CMISName("id");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
Wed Aug  5 20:48:40 2009
@@ -28,6 +28,7 @@
 import org.apache.chemistry.CMIS;
 import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.atompub.AtomPub;
+import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.client.stax.AbstractEntryReader;
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.chemistry.xml.stax.ChildrenNavigator;
@@ -64,12 +65,7 @@
     @Override
     protected void readCmisElement(ReadContext context, StaxReader reader,
             APPType entry) throws XMLStreamException {
-        String localName = reader.getLocalName();
-        if (CMIS.DOCUMENT_TYPE.getLocalPart().equals(localName)
-                || CMIS.FOLDER_TYPE.getLocalPart().equals(localName)
-                || CMIS.RELATIONSHIP_TYPE.getLocalPart().equals(
-                        localName)
-                || CMIS.POLICY_TYPE.getLocalPart().equals(localName)) {
+        if (AtomPubCMIS.TYPE.getLocalPart().equals(reader.getLocalName())) {
             ChildrenNavigator children = reader.getChildren();
             Map<String, String> map = new HashMap<String, String>();
             Map<String, PropertyDefinition> pdefs = null;
@@ -93,16 +89,6 @@
                         log.error("Cannot read text element for: " + name, e);
                         continue;
                     }
-                    if (name.equals(CMIS.BASE_TYPE_ID.getLocalPart())) {
-                        // check base type coherent with base element
-                        // eg "cmis:folder" for a <cmis:folderType>
-                        if (!("cmis:" + localName).startsWith(text)) {
-                            throw new IllegalArgumentException(
-                                    String.format(
-                                            "Type element <cmis:%s> cannot have base
type: %s",
-                                            localName, text));
-                        }
-                    }
                     map.put(name, text);
                 }
             }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
Wed Aug  5 20:48:40 2009
@@ -1,5 +1,6 @@
 <?xml version='1.0' encoding='utf-8'?>
-<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901"
+  xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200901">
   <id>urn:x-id:types</id>
   <title type="text">Types</title>
   <author>
@@ -14,7 +15,7 @@
     <link href="http://127.0.0.1:8080/cmis/type/document" rel="edit" />
     <link href="http://127.0.0.1:8080/cmis/type/document" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
-    <cmis:documentType>
+    <cmisra:type>
       <cmis:id>cmis:document</cmis:id>
       <cmis:localName>cmis:document</cmis:localName>
       <cmis:queryName>Document</cmis:queryName>
@@ -29,8 +30,9 @@
       <cmis:controllablePolicy>true</cmis:controllablePolicy>
       <cmis:controllableACL>true</cmis:controllableACL>
       <cmis:fulltextindexed>true</cmis:fulltextindexed>
-      <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
-    </cmis:documentType>
+      <cmis:includedInSupertypeQuery>true
+      </cmis:includedInSupertypeQuery>
+    </cmisra:type>
   </entry>
   <entry>
     <id>urn:x-tid:folder</id>
@@ -40,7 +42,7 @@
     <link href="http://127.0.0.1:8080/cmis/type/folder" rel="edit" />
     <link href="http://127.0.0.1:8080/cmis/type/folder" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
-    <cmis:folderType>
+    <cmisra:type>
       <cmis:id>cmis:folder</cmis:id>
       <cmis:localName>cmis:folder</cmis:localName>
       <cmis:queryName>Folder</cmis:queryName>
@@ -55,8 +57,9 @@
       <cmis:controllablePolicy>true</cmis:controllablePolicy>
       <cmis:controllableACL>true</cmis:controllableACL>
       <cmis:fulltextindexed>true</cmis:fulltextindexed>
-      <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
-    </cmis:folderType>
+      <cmis:includedInSupertypeQuery>true
+      </cmis:includedInSupertypeQuery>
+    </cmisra:type>
   </entry>
   <entry>
     <id>urn:x-tid:relationship</id>
@@ -66,7 +69,7 @@
     <link href="http://127.0.0.1:8080/cmis/type/relationship" rel="edit" />
     <link href="http://127.0.0.1:8080/cmis/type/relationship" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
-    <cmis:relationshipType>
+    <cmisra:type>
       <cmis:id>cmis:relationship</cmis:id>
       <cmis:localName>cmis:relationship</cmis:localName>
       <cmis:queryName>Relationship</cmis:queryName>
@@ -81,8 +84,9 @@
       <cmis:controllablePolicy>false</cmis:controllablePolicy>
       <cmis:controllableACL>false</cmis:controllableACL>
       <cmis:fulltextindexed>false</cmis:fulltextindexed>
-      <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
-    </cmis:relationshipType>
+      <cmis:includedInSupertypeQuery>true
+      </cmis:includedInSupertypeQuery>
+    </cmisra:type>
   </entry>
   <entry>
     <id>urn:x-tid:policy</id>
@@ -92,7 +96,7 @@
     <link href="http://127.0.0.1:8080/cmis/type/policy" rel="edit" />
     <link href="http://127.0.0.1:8080/cmis/type/policy" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
-    <cmis:policyType>
+    <cmisra:type>
       <cmis:id>cmis:policy</cmis:id>
       <cmis:localName>cmis:policy</cmis:localName>
       <cmis:queryName>Policy</cmis:queryName>
@@ -107,8 +111,9 @@
       <cmis:controllablePolicy>false</cmis:controllablePolicy>
       <cmis:controllableACL>false</cmis:controllableACL>
       <cmis:fulltextindexed>false</cmis:fulltextindexed>
-      <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
-    </cmis:policyType>
+      <cmis:includedInSupertypeQuery>true
+      </cmis:includedInSupertypeQuery>
+    </cmisra:type>
   </entry>
   <entry>
     <id>urn:x-tid:Root</id>
@@ -118,7 +123,7 @@
     <link href="http://127.0.0.1:8080/cmis/type/Root" rel="edit" />
     <link href="http://127.0.0.1:8080/cmis/type/Root" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
-    <cmis:folderType>
+    <cmisra:type>
       <cmis:id>Root</cmis:id>
       <cmis:localName>Root</cmis:localName>
       <cmis:queryName>Root</cmis:queryName>
@@ -133,7 +138,8 @@
       <cmis:controllablePolicy>false</cmis:controllablePolicy>
       <cmis:controllableACL>false</cmis:controllableACL>
       <cmis:fulltextindexed>false</cmis:fulltextindexed>
-      <cmis:includedInSupertypeQuery>false</cmis:includedInSupertypeQuery>
-    </cmis:folderType>
+      <cmis:includedInSupertypeQuery>false
+      </cmis:includedInSupertypeQuery>
+    </cmisra:type>
   </entry>
 </feed>

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
Wed Aug  5 20:48:40 2009
@@ -106,6 +106,8 @@
         // ?
         targetResolver.setPattern("/types/([^/?]+)",
                 TargetType.TYPE_COLLECTION, "typeid");
+        targetResolver.setPattern("/typesdescendants/([^/?]*)",
+                TargetType.TYPE_COLLECTION, "typeid");
 
         // CMIS workspaces available
 
@@ -127,10 +129,10 @@
                 AtomPubCMIS.COL_CHECKED_OUT, "checkedout", null, repository));
 
         workspaceInfo.addCollection(new CMISTypesCollection(
-                AtomPubCMIS.COL_TYPES_CHILDREN, repository));
+                AtomPubCMIS.COL_TYPES_CHILDREN, null, repository));
 
         workspaceInfo.addCollection(new CMISTypesCollection(
-                AtomPubCMIS.COL_TYPES_DESCENDANTS, repository));
+                AtomPubCMIS.COL_TYPES_DESCENDANTS, null, repository));
 
         workspaceInfo.addCollection(new CMISQueryFeed(repository));
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
Wed Aug  5 20:48:40 2009
@@ -23,6 +23,7 @@
 import org.apache.abdera.parser.stax.StaxStreamWriter;
 import org.apache.abdera.protocol.server.CollectionInfo;
 import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.TargetType;
 import org.apache.abdera.protocol.server.WorkspaceInfo;
 import org.apache.abdera.protocol.server.context.StreamWriterResponseContext;
 import org.apache.abdera.writer.StreamWriter;
@@ -31,6 +32,7 @@
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.RepositoryCapabilities;
 import org.apache.chemistry.RepositoryInfo;
+import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.URITemplate;
 import org.w3c.dom.Document;
@@ -65,7 +67,9 @@
                 request)) {
             sw.startWorkspace();
             sw.writeTitle(wi.getTitle(request));
+            // repository info
             RepositoryInfoWriter.write(sw, provider);
+            // collections
             for (CollectionInfo ci : wi.getCollections(request)) {
                 sw.startCollection(ci.getHref(request));
                 sw.writeAttribute(AtomPubCMIS.COLLECTION_TYPE,
@@ -75,6 +79,14 @@
                 // no AtomPub categories
                 sw.endCollection();
             }
+            // CMIS links
+            sw.startElement(AtomPub.ATOM_LINK);
+            sw.writeAttribute("type", "application/cmistree+xml");
+            sw.writeAttribute("rel", AtomPubCMIS.LINK_TYPES_DESCENDANTS);
+            String tdurl = request.absoluteUrlFor(TargetType.TYPE_SERVICE, null);
+            tdurl = tdurl.replaceFirst("/repository$", "/typesdescendants/"); // XXX
+            sw.writeAttribute("href", tdurl);
+            sw.endElement();
             // URI templates
             for (URITemplate info : provider.getURITemplates(request)) {
                 sw.startElement(AtomPubCMIS.URI_TEMPLATE);

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=801408&r1=801407&r2=801408&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 20:48:40 2009
@@ -18,6 +18,7 @@
 
 import java.io.Serializable;
 import java.net.URI;
+import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
@@ -37,6 +38,7 @@
 import org.apache.chemistry.PropertyType;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.abdera.PropertiesElement;
 
 /**
@@ -44,8 +46,8 @@
  */
 public class CMISTypesCollection extends CMISCollection<Type> {
 
-    public CMISTypesCollection(String type, Repository repository) {
-        super(type, "types", null, repository);
+    public CMISTypesCollection(String type, String id, Repository repository) {
+        super(type, "types", id, repository);
     }
 
     /*
@@ -67,6 +69,7 @@
 
     @Override
     public String getId(RequestContext request) {
+        // TODO when descendants
         return "urn:x-id:types";
     }
 
@@ -84,8 +87,9 @@
      */
 
     @Override
-    protected String addEntryDetails(RequestContext request, Entry entry,
+    public String addEntryDetails(RequestContext request, Entry entry,
             IRI feedIri, Type type) throws ResponseContextException {
+        boolean includePropertyDefinitions = "true".equals(request.getParameter("includePropertyDefinitions"));
         Factory factory = request.getAbdera().getFactory();
 
         entry.setId(getId(type));
@@ -105,67 +109,49 @@
         // CMIS links
 
         // CMIS-specific
-        // TODO refactor this to be a proper ExtensibleElement
-        QName typeElementQName;
-        switch (type.getBaseType()) {
-        case DOCUMENT:
-            typeElementQName = CMIS.DOCUMENT_TYPE;
-            break;
-        case FOLDER:
-            typeElementQName = CMIS.FOLDER_TYPE;
-            break;
-        case RELATIONSHIP:
-            typeElementQName = CMIS.RELATIONSHIP_TYPE;
-            break;
-        case POLICY:
-            typeElementQName = CMIS.POLICY_TYPE;
-            break;
-        default:
-            throw new AssertionError(type.getBaseType().getId());
-        }
-        Element dt = factory.newElement(typeElementQName, entry);
+        Element te = factory.newElement(AtomPubCMIS.TYPE, entry);
         Element el;
         // note: setText is called in a separate statement as JDK 5 has problems
         // compiling when it's on one line (compiler generics bug)
-        el = factory.newElement(CMIS.ID, dt);
+        el = factory.newElement(CMIS.ID, te);
         el.setText(type.getId());
-        el = factory.newElement(CMIS.LOCAL_NAME, dt);
+        el = factory.newElement(CMIS.LOCAL_NAME, te);
         el.setText(type.getLocalName());
         URI localNamespace = type.getLocalNamespace();
         if (localNamespace != null) {
-            el = factory.newElement(CMIS.LOCAL_NAMESPACE, dt);
+            el = factory.newElement(CMIS.LOCAL_NAMESPACE, te);
             el.setText(localNamespace.toString());
         }
-        el = factory.newElement(CMIS.QUERY_NAME, dt);
+        el = factory.newElement(CMIS.QUERY_NAME, te);
         el.setText(type.getQueryName());
-        el = factory.newElement(CMIS.DISPLAY_NAME, dt);
+        el = factory.newElement(CMIS.DISPLAY_NAME, te);
         el.setText(type.getDisplayName());
-        el = factory.newElement(CMIS.BASE_TYPE_ID, dt);
+        el = factory.newElement(CMIS.BASE_TYPE_ID, te);
         el.setText(type.getBaseType().getId());
-        el = factory.newElement(CMIS.PARENT_ID, dt);
+        el = factory.newElement(CMIS.PARENT_ID, te);
         el.setText(type.getParentId());
-        el = factory.newElement(CMIS.DESCRIPTION, dt);
+        el = factory.newElement(CMIS.DESCRIPTION, te);
         el.setText(type.getDescription());
-        el = factory.newElement(CMIS.CREATABLE, dt);
+        el = factory.newElement(CMIS.CREATABLE, te);
         el.setText(bool(type.isCreatable()));
-        el = factory.newElement(CMIS.FILEABLE, dt);
+        el = factory.newElement(CMIS.FILEABLE, te);
         el.setText(bool(type.isFileable()));
-        el = factory.newElement(CMIS.QUERYABLE, dt);
+        el = factory.newElement(CMIS.QUERYABLE, te);
         el.setText(bool(type.isQueryable()));
-        el = factory.newElement(CMIS.CONTROLLABLE_POLICY, dt);
+        el = factory.newElement(CMIS.CONTROLLABLE_POLICY, te);
         el.setText(bool(type.isControllablePolicy()));
-        el = factory.newElement(CMIS.CONTROLLABLE_ACL, dt);
+        el = factory.newElement(CMIS.CONTROLLABLE_ACL, te);
         el.setText(bool(type.isControllableACL()));
-        el = factory.newElement(CMIS.FULLTEXT_INDEXED, dt);
+        el = factory.newElement(CMIS.FULLTEXT_INDEXED, te);
         el.setText(bool(type.isFulltextIndexed()));
-        el = factory.newElement(CMIS.INCLUDED_IN_SUPERTYPE_QUERY, dt);
+        el = factory.newElement(CMIS.INCLUDED_IN_SUPERTYPE_QUERY, te);
         el.setText(bool(type.isIncludedInSuperTypeQuery()));
-        el = factory.newElement(CMIS.VERSIONABLE, dt); // docs only
+        el = factory.newElement(CMIS.VERSIONABLE, te); // docs only
         el.setText(bool(type.isVersionable()));
-        el = factory.newElement(CMIS.CONTENT_STREAM_ALLOWED, dt); // docs only
+        el = factory.newElement(CMIS.CONTENT_STREAM_ALLOWED, te); // docs only
         el.setText(type.getContentStreamAllowed().toString()); // TODO null
         // TODO allowedSourceTypes, allowedTargetTypes
-        if ("true".equals(request.getParameter("includePropertyDefinitions"))) {
+        if (includePropertyDefinitions) {
             for (PropertyDefinition pd : type.getPropertyDefinitions()) {
                 QName qname;
                 switch (pd.getType().ordinal()) {
@@ -202,7 +188,7 @@
                 default:
                     throw new AssertionError(pd.getType().name());
                 }
-                Element def = factory.newElement(qname, dt);
+                Element def = factory.newElement(qname, te);
                 el = factory.newElement(CMIS.ID, def);
                 el.setText(pd.getId());
                 String localName = pd.getLocalName();
@@ -271,6 +257,31 @@
                 default:
                     throw new AssertionError(pd.getType().name());
                 }
+                // end property definition
+            }
+        }
+        // end property definitions
+        if ("typesdescendants".equals(getType())) {
+            Collection<Type> subTypes = repository.getTypes(type.getId(), 1,
+                    includePropertyDefinitions);
+            if (!subTypes.isEmpty()) {
+                Element che = factory.newElement(AtomPubCMIS.CHILDREN, entry);
+                // TODO basic feed info
+                // AbstractCollectionAdapter.createFeedBase:
+                factory.newID(che).setValue(
+                        "urn:x-id:typesdecendants-" + type.getId());
+                // che.setTitle(getTitle(request));
+                // che.addLink("");
+                // che.addLink("", "self");
+                // che.addAuthor(getAuthor(request));
+                // che.setUpdated(new Date());
+                // AbstractEntityCollectionAdapter.addFeedDetails
+                // che.setUpdated(new Date());
+                for (Type subType : subTypes) {
+                    Entry subEntry = factory.newEntry(che);
+                    addEntryDetails(request, subEntry, null, subType);
+                }
+                // end children entry
             }
         }
         return link;
@@ -283,7 +294,7 @@
     @Override
     public Iterable<Type> getEntries(RequestContext request)
             throws ResponseContextException {
-        return repository.getTypes(null);
+        return repository.getTypes(id);
     }
 
     @Override
@@ -319,6 +330,10 @@
     }
 
     @Override
+    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-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
Wed Aug  5 20:48:40 2009
@@ -20,6 +20,7 @@
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.impl.AbstractWorkspaceManager;
 import org.apache.chemistry.Repository;
+import org.apache.chemistry.atompub.AtomPubCMIS;
 
 /**
  * Workspace manager that correctly finds the appropriate collection adapter by
@@ -40,10 +41,19 @@
         String path = spath == null ? uri : uri.substring(spath.length());
         String paths = path + '/';
         if (paths.startsWith("/types/") || paths.startsWith("/types?")) {
-            return new CMISTypesCollection(null, repository);
+            return new CMISTypesCollection(null, null, repository);
+        }
+        if (paths.startsWith("/typesdescendants/")) {
+            String id = request.getTarget().getParameter("typeid");
+            if (id.equals("")) {
+                id = null;
+            }
+            return new CMISTypesCollection(AtomPubCMIS.COL_TYPES_DESCENDANTS,
+                    id, repository);
         }
         if (paths.startsWith("/type/")) {
-            return new CMISTypesCollection(null, repository);
+            return new CMISTypesCollection(AtomPubCMIS.COL_TYPES_CHILDREN,
+                    null, repository);
         }
         if (paths.startsWith("/children/")) {
             String id = request.getTarget().getParameter("objectid");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
Wed Aug  5 20:48:40 2009
@@ -60,6 +60,8 @@
 
     public static final QName OBJECT = CMISRAName("object");
 
+    public static final QName CHILDREN = CMISRAName("children");
+
     /*
      * ----- AtomPub Collection Types -----
      */

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=801408&r1=801407&r2=801408&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 20:48:40 2009
@@ -87,6 +87,9 @@
         }
         // TODO spec unclear on depth 0
         List<Type> list = new LinkedList<Type>();
+        if (depth < 0) {
+            list.add(types.get(typeId));
+        }
         collectSubTypes(typeId, depth, returnPropertyDefinitions, list,
                 new HashSet<String>());
         return list;
@@ -94,20 +97,20 @@
 
     protected void collectSubTypes(String typeId, int depth,
             boolean returnPropertyDefinitions, List<Type> list, Set<String> done)
{
-        if (done.contains(typeId)) {
-            // TODO move cycles check to addType
-            throw new IllegalStateException("Types contain a cycle involving: "
-                    + typeId);
-        }
         // TODO returnPropertyDefinitions
-        list.add(types.get(typeId));
-        done.add(typeId);
         if (depth == 0) {
             return;
         }
-        Collection<Type> children = typesChildren.get(typeId);
-        for (Type type : children) {
-            collectSubTypes(type.getId(), depth - 1, returnPropertyDefinitions,
+        for (Type subType : typesChildren.get(typeId)) {
+            String subTypeId = subType.getId();
+            if (done.contains(subTypeId)) {
+                // TODO move cycles check to addType
+                throw new IllegalStateException(
+                        "Types contain a cycle involving: " + subTypeId);
+            }
+            done.add(subTypeId);
+            list.add(subType);
+            collectSubTypes(subTypeId, depth - 1, returnPropertyDefinitions,
                     list, done);
         }
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
Wed Aug  5 20:48:40 2009
@@ -111,19 +111,19 @@
         assertNull(repo.getType("no-such-type"));
         assertEquals(3,
                 repo.getTypes(BaseType.DOCUMENT.getId(), -1, false).size());
-        assertEquals(1, // TODO spec unclear on depth 0
+        assertEquals(0, // TODO spec unclear on depth 0
                 repo.getTypes(BaseType.DOCUMENT.getId(), 0, false).size());
-        assertEquals(2,
+        assertEquals(1,
                 repo.getTypes(BaseType.DOCUMENT.getId(), 1, false).size());
-        assertEquals(3,
+        assertEquals(2,
                 repo.getTypes(BaseType.DOCUMENT.getId(), 2, false).size());
-        assertEquals(3,
+        assertEquals(2,
                 repo.getTypes(BaseType.DOCUMENT.getId(), 3, false).size());
         assertEquals(2, repo.getTypes("doc", -1, false).size());
-        assertEquals(1, repo.getTypes("doc", 0, false).size());
-        assertEquals(2, repo.getTypes("doc", 1, false).size());
-        assertEquals(2, repo.getTypes("doc", 2, false).size());
-        assertEquals(2, repo.getTypes("doc", 3, false).size());
+        assertEquals(0, repo.getTypes("doc", 0, false).size());
+        assertEquals(1, repo.getTypes("doc", 1, false).size());
+        assertEquals(1, repo.getTypes("doc", 2, false).size());
+        assertEquals(1, repo.getTypes("doc", 3, false).size());
     }
 
     public void testRoot() throws Exception {

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java?rev=801408&r1=801407&r2=801408&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
Wed Aug  5 20:48:40 2009
@@ -39,7 +39,7 @@
     // use a fixed root id, this helps with caching in some clients
     public static final String ROOT_ID = "b7666828-f1aa-41e1-9d0a-94a7898ae569";
 
-    private static final int MINUTES = 60 * 1000; // in ms
+    private static final int MINUTES = 60;
 
     public static final String HOST = "0.0.0.0";
 
@@ -56,7 +56,7 @@
         for (int i = 0; i < args.length; i++) {
             String arg = args[i];
             if ("--help".equals(arg)) {
-                System.err.println("Usage: ... [-h HOST] [-p PORT] [-t TIME(minutes)]");
+                System.err.println("Usage: ... [-h HOST] [-p PORT] [-t TIME (minutes)]");
                 System.exit(0);
             }
             if (i == args.length - 1) {
@@ -85,7 +85,7 @@
         String url = "http://" + host + ':' + port + SERVLET_PATH
                 + CMIS_SERVICE;
         log.info("CMIS server started, AtomPub service url: " + url);
-        Thread.sleep(60 * minutes);
+        Thread.sleep(1000 * 60 * minutes);
         server.stop();
         log.info("CMIS server stopped");
     }



Mime
View raw message