You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2014/06/22 13:33:04 UTC
svn commit: r1604561 - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/
chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/...
Author: fmui
Date: Sun Jun 22 11:33:03 2014
New Revision: 1604561
URL: http://svn.apache.org/r1604561
Log:
AtomPub client and server: more accurate status code handling
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
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=1604561&r1=1604560&r2=1604561&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 Sun Jun 22 11:33:03 2014
@@ -819,7 +819,13 @@ public class ObjectServiceImpl extends A
throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
}
- objectId.setValue(null);
+ if (resp.getResponseCode() == 201) {
+ // unset the object ID if a new resource has been created
+ // (if the resource has been updated (200 and 204), the object ID
+ // hasn't changed)
+ objectId.setValue(null);
+ }
+
if (changeToken != null) {
changeToken.setValue(null);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java?rev=1604561&r1=1604560&r2=1604561&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Sun Jun 22 11:33:03 2014
@@ -294,7 +294,30 @@ public class ObjectService {
String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT, newObjectId);
- response.setStatus(HttpServletResponse.SC_CREATED);
+ // set status
+ if (newObjectId.equals(objectId)) {
+ if (Boolean.TRUE.equals(appendFlag)) {
+ // append stream: no new version -> OK
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.setContentLength(0);
+ } else {
+ if (!Boolean.FALSE.equals(overwriteFlag)) {
+ // set stream: no new version and overwrite ->
+ // OK: if the document had a stream,
+ // CREATED: if the document had no stream
+ // ... but we don't know, ... OK is more likely ...
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.setContentLength(0);
+ } else {
+ // set stream: no new version and not overwrite ->
+ // CREATED (the document hasn't had a stream)
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ }
+ }
+ } else {
+ // new version created -> CREATED
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ }
response.setHeader("Content-Location", location);
response.setHeader("Location", location);
}