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 2009/08/06 19:44:32 UTC
svn commit: r801742 - in
/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server:
CMISChildrenCollection.java CMISObjectsCollection.java
CMISParentsCollection.java
Author: fguillaume
Date: Thu Aug 6 17:44:32 2009
New Revision: 801742
URL: http://svn.apache.org/viewvc?rev=801742&view=rev
Log:
clean up feed/entry up/down/via links
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISParentsCollection.java
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java?rev=801742&r1=801741&r2=801742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java Thu Aug 6 17:44:32 2009
@@ -18,12 +18,15 @@
import java.util.List;
+import org.apache.abdera.model.Feed;
import org.apache.abdera.protocol.server.RequestContext;
import org.apache.abdera.protocol.server.context.ResponseContextException;
import org.apache.chemistry.ObjectEntry;
import org.apache.chemistry.ObjectId;
+import org.apache.chemistry.Property;
import org.apache.chemistry.Repository;
import org.apache.chemistry.SPI;
+import org.apache.chemistry.atompub.AtomPub;
/**
* CMIS Collection for the children of an object.
@@ -34,6 +37,36 @@
super(type, "children", id, repository);
}
+ /*
+ * ----- AbstractCollectionAdapter -----
+ */
+
+ @Override
+ protected Feed createFeedBase(RequestContext request) {
+ Feed feed = super.createFeedBase(request);
+
+ feed.addLink(getChildrenLink(id, request), AtomPub.LINK_SELF,
+ AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
+
+ // link to parent children feed, needs parent id
+ SPI spi = repository.getSPI();
+ ObjectEntry entry = spi.getProperties(spi.newObjectId(id), null, false,
+ false);
+ String pid = (String) entry.getValue(Property.PARENT_ID);
+ if (pid != null) {
+ feed.addLink(getChildrenLink(pid, request), AtomPub.LINK_UP,
+ AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
+ }
+ spi.close();
+
+ // RFC 5005 paging
+ return feed;
+ }
+
+ /*
+ * ----- AbstractEntityCollectionAdapter -----
+ */
+
@Override
public Iterable<ObjectEntry> getEntries(RequestContext request)
throws ResponseContextException {
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=801742&r1=801741&r2=801742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java Thu Aug 6 17:44:32 2009
@@ -83,12 +83,10 @@
feed.setTitle(getTitle(request));
feed.addAuthor(getAuthor(request));
feed.setUpdated(new Date()); // XXX
-
- feed.addLink(getChildrenLink(id, request), "self");
- feed.addLink(getObjectLink(id, request), AtomPubCMIS.LINK_SOURCE);
-
- // RFC 5005 paging
-
+ feed.addLink(getServiceLink(request), AtomPub.LINK_SERVICE,
+ AtomPub.MEDIA_TYPE_ATOM_SERVICE, null, null, -1);
+ feed.addLink(getObjectLink(id, request), AtomPub.LINK_VIA,
+ AtomPub.MEDIA_TYPE_ATOM_ENTRY, null, null, -1);
return feed;
}
@@ -129,6 +127,8 @@
protected String addEntryDetails(RequestContext request, Entry entry,
IRI feedIri, ObjectEntry object) throws ResponseContextException {
Factory factory = request.getAbdera().getFactory();
+ String oid = object.getId();
+ String typeId = object.getTypeId();
entry.declareNS(CMIS.CMIS_NS, CMIS.CMIS_PREFIX);
@@ -146,17 +146,20 @@
entry.setSummaryElement(t);
}
+ entry.addLink(getServiceLink(request), AtomPub.LINK_SERVICE,
+ AtomPub.MEDIA_TYPE_ATOM_SERVICE, null, null, -1);
String link = getLink(object, feedIri, request);
- entry.addLink(link, "self");
- entry.addLink(link, "edit");
+ entry.addLink(link, AtomPub.LINK_SELF, AtomPub.MEDIA_TYPE_ATOM_ENTRY,
+ null, null, -1);
+ entry.addLink(link, AtomPub.LINK_EDIT, AtomPub.MEDIA_TYPE_ATOM_ENTRY,
+ null, null, -1);
// alternate is mandated by Atom when there is no atom:content
- entry.addLink(link, "alternate");
- String typeId = object.getTypeId();
- entry.addLink(getTypeLink(typeId, request), AtomPub.LINK_DESCRIBED_BY);
- entry.addLink(getServiceLink(request), AtomPub.LINK_SERVICE);
+ entry.addLink(link, AtomPub.LINK_ALTERNATE,
+ AtomPub.MEDIA_TYPE_ATOM_ENTRY, null, null, -1);
+
+ entry.addLink(getTypeLink(typeId, request), AtomPub.LINK_DESCRIBED_BY,
+ AtomPub.MEDIA_TYPE_ATOM_ENTRY, null, null, -1);
- // CMIS links
- String oid = object.getId();
BaseType baseType = object.getBaseType();
if (baseType == BaseType.FOLDER) {
String pid = (String) object.getValue(Property.PARENT_ID);
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISParentsCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISParentsCollection.java?rev=801742&r1=801741&r2=801742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISParentsCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISParentsCollection.java Thu Aug 6 17:44:32 2009
@@ -18,12 +18,14 @@
import java.util.Collection;
+import org.apache.abdera.model.Feed;
import org.apache.abdera.protocol.server.RequestContext;
import org.apache.abdera.protocol.server.context.ResponseContextException;
import org.apache.chemistry.ObjectEntry;
import org.apache.chemistry.ObjectId;
import org.apache.chemistry.Repository;
import org.apache.chemistry.SPI;
+import org.apache.chemistry.atompub.AtomPub;
public class CMISParentsCollection extends CMISObjectsCollection {
@@ -31,6 +33,23 @@
super(type, "parents", id, repository);
}
+ /*
+ * ----- AbstractCollectionAdapter -----
+ */
+
+ @Override
+ protected Feed createFeedBase(RequestContext request) {
+ Feed feed = super.createFeedBase(request);
+ feed.addLink(getParentsLink(id, request), AtomPub.LINK_SELF,
+ AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
+ // RFC 5005 paging
+ return feed;
+ }
+
+ /*
+ * ----- AbstractEntityCollectionAdapter -----
+ */
+
@Override
public Iterable<ObjectEntry> getEntries(RequestContext request)
throws ResponseContextException {