You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/02/22 16:44:01 UTC

svn commit: r912630 - in /incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server: CMISCollection.java CMISServiceResponse.java

Author: fguillaume
Date: Mon Feb 22 15:44:01 2010
New Revision: 912630

URL: http://svn.apache.org/viewvc?rev=912630&view=rev
Log:
CMIS-119: allow specifying repositoryId within link URLs

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java?rev=912630&r1=912629&r2=912630&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java Mon Feb 22 15:44:01 2010
@@ -109,6 +109,9 @@
         Map<String, String> params = new HashMap<String, String>();
         params.put("collection", name);
         params.put("id", id); // id may be null
+        if (repository != null) {
+            params.put("repository", repository.getId());
+        }
         return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
     }
 
@@ -126,73 +129,66 @@
         return request.absoluteUrlFor(TargetType.TYPE_SERVICE, null);
     }
 
-    public String getTypeLink(String tid, RequestContext request) {
+    protected String getEntrylink(String entryType, String id,
+            RequestContext request) {
         Map<String, String> params = new HashMap<String, String>();
-        params.put("entrytype", "type");
-        params.put("id", tid);
+        params.put("entrytype", entryType);
+        params.put("id", id);
+        if (repository != null) {
+            params.put("repository", repository.getId());
+        }
         return request.absoluteUrlFor(TargetType.TYPE_ENTRY, params);
     }
 
-    public String getTypeChildrenLink(String tid, RequestContext request) {
+    protected String getCollectionLink(String collection, String id,
+            RequestContext request) {
         Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", "typechildren");
-        params.put("id", tid);
+        params.put("collection", collection);
+        params.put("id", id);
+        if (repository != null) {
+            params.put("repository", repository.getId());
+        }
         return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
     }
 
-    public static String getTypeDescendantsLink(String tid, RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", "typedescendants");
-        params.put("id", tid);
-        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    public String getTypeLink(String tid, RequestContext request) {
+        return getEntrylink("type", tid, request);
     }
 
-    public String getChildrenLink(String fid, RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", "children");
-        params.put("id", fid);
-        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    public String getObjectLink(String id, RequestContext request) {
+        return getEntrylink("object", id, request);
     }
 
-    public String getDescendantsLink(String fid, RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", "descendants");
-        params.put("id", fid);
-        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    public String getMediaLink(String id, RequestContext request) {
+        return getEntrylink("file", id, request);
     }
 
-    public static String getFolderTreeLink(String fid, RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", "foldertree");
-        params.put("id", fid);
-        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    public String getTypeChildrenLink(String tid, RequestContext request) {
+        return getCollectionLink("typechildren", tid, request);
     }
 
-    public String getParentsLink(String fid, RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", "parents");
-        params.put("id", fid);
-        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    public String getTypeDescendantsLink(String tid, RequestContext request) {
+        return getCollectionLink("typedescendants", tid, request);
     }
 
-    public String getCheckedOutLink(RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", "checkedout");
-        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    public String getChildrenLink(String fid, RequestContext request) {
+        return getCollectionLink("children", fid, request);
     }
 
-    public String getObjectLink(String id, RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("entrytype", "object");
-        params.put("id", id);
-        return request.absoluteUrlFor(TargetType.TYPE_ENTRY, params);
+    public String getDescendantsLink(String fid, RequestContext request) {
+        return getCollectionLink("descendants", fid, request);
     }
 
-    public String getMediaLink(String id, RequestContext request) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("entrytype", "file");
-        params.put("id", id);
-        return request.absoluteUrlFor(TargetType.TYPE_ENTRY, params);
+    public String getFolderTreeLink(String fid, RequestContext request) {
+        return getCollectionLink("foldertree", fid, request);
+    }
+
+    public String getParentsLink(String fid, RequestContext request) {
+        return getCollectionLink("parents", fid, request);
+    }
+
+    public String getCheckedOutLink(RequestContext request) {
+        return getCollectionLink("checkedout", null, request);
     }
 
 }

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=912630&r1=912629&r2=912630&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 Mon Feb 22 15:44:01 2010
@@ -70,12 +70,18 @@
             // repository info
             RepositoryInfoWriter.write(sw, provider);
             // collections
+            CMISCollection<?> typesCol = null;
             for (CollectionInfo ci : wi.getCollections(request)) {
+                CMISCollection<?> cmisCol = (CMISCollection<?>) ci;
+                String type = cmisCol.getType();
+                if (AtomPubCMIS.COL_TYPES.equals(type)) {
+                    typesCol = cmisCol;
+                }
                 sw.startCollection(ci.getHref(request));
                 sw.writeTitle(ci.getTitle(request));
                 sw.writeAccepts(ci.getAccepts(request));
                 sw.startElement(AtomPubCMIS.COLLECTION_TYPE);
-                sw.writeElementText(((CMISCollection<?>) ci).getType());
+                sw.writeElementText(type);
                 sw.endElement();
                 // no AtomPub categories
                 sw.endCollection();
@@ -84,14 +90,13 @@
             sw.startElement(AtomPub.ATOM_LINK);
             sw.writeAttribute("rel", AtomPubCMIS.LINK_TYPE_DESCENDANTS);
             sw.writeAttribute("type", AtomPubCMIS.MEDIA_TYPE_CMIS_TREE);
-            String tdurl = CMISTypesCollection.getTypeDescendantsLink(null,
-                    request);
+            String tdurl = typesCol.getTypeDescendantsLink(null, request);
             sw.writeAttribute("href", tdurl);
             sw.endElement();
             sw.startElement(AtomPub.ATOM_LINK);
             sw.writeAttribute("rel", AtomPubCMIS.LINK_FOLDER_TREE);
             sw.writeAttribute("type", AtomPubCMIS.MEDIA_TYPE_CMIS_TREE);
-            String fturl = CMISTypesCollection.getFolderTreeLink(
+            String fturl = typesCol.getFolderTreeLink(
                     info.getRootFolderId().getId(), request);
             sw.writeAttribute("href", fturl);
             sw.endElement();