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 2011/10/27 20:27:15 UTC
svn commit: r1189924 - in
/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub:
LinkCache.java ObjectServiceImpl.java
Author: fguillaume
Date: Thu Oct 27 18:27:15 2011
New Revision: 1189924
URL: http://svn.apache.org/viewvc?rev=1189924&view=rev
Log:
CMIS-461: allow getting folder rendition by stream id (atompub)
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.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/atompub/LinkCache.java?rev=1189924&r1=1189923&r2=1189924&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java Thu Oct 27 18:27:15 2011
@@ -131,7 +131,32 @@ public class LinkCache implements Serial
public void addLink(String repositoryId, String id, String rel, String type, String link) {
if (KNOWN_LINKS.contains(rel)) {
linkCache.put(link, repositoryId, id, rel, type);
+ } else if (Constants.REL_ALTERNATE.equals(rel)) {
+ // use streamId instead of type as discriminating parameter
+ String streamId = extractStreamId(link);
+ if (streamId != null) {
+ linkCache.put(link, repositoryId, id, rel, streamId);
+ }
+ }
+ }
+
+ /**
+ * Tries to extract a streamId from an alternate link.
+ */
+ // this is not strictly in the spec
+ protected String extractStreamId(String link) {
+ int i = link.lastIndexOf('?');
+ if (i > 0) {
+ String[] params = link.substring(i + 1).split("&");
+ for (String param : params) {
+ String[] parts = param.split("=", 2);
+ if (parts[0].equals(Constants.PARAM_STREAM_ID)
+ && parts.length == 2) {
+ return parts[1];
+ }
+ }
}
+ return null;
}
/**
@@ -307,7 +332,7 @@ public class LinkCache implements Serial
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#toString()
*/
@Override
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.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/atompub/ObjectServiceImpl.java?rev=1189924&r1=1189923&r2=1189924&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java Thu Oct 27 18:27:15 2011
@@ -436,16 +436,25 @@ public class ObjectServiceImpl extends A
ContentStreamImpl result = new ContentStreamImpl();
// find the link
- String link = loadLink(repositoryId, objectId, AtomPubParser.LINK_REL_CONTENT, null);
+ String link = null;
+ if (streamId != null) {
+ // use the alternate link per spec
+ link = loadLink(repositoryId, objectId, Constants.REL_ALTERNATE, streamId);
+ if (link != null) {
+ streamId = null; // we have a full URL now
+ }
+ }
+ if (link == null) {
+ link = loadLink(repositoryId, objectId, AtomPubParser.LINK_REL_CONTENT, null);
+ }
if (link == null) {
throw new CmisConstraintException("No content stream");
}
- // TODO FIXME using the content link for non-default streams is
- // incorrect, rel=alternate links should be used (if somehow the
- // stream id is known for them, which isn't the case in CMIS 1.0).
UrlBuilder url = new UrlBuilder(link);
+ // using the content URL and adding a streamId param
+ // is not spec-compliant
url.addParameter(Constants.PARAM_STREAM_ID, streamId);
// get the content