chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r894686 - /incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
Date Wed, 30 Dec 2009 18:07:29 GMT
Author: fguillaume
Date: Wed Dec 30 18:07:29 2009
New Revision: 894686

URL: http://svn.apache.org/viewvc?rev=894686&view=rev
Log:
CMIS-84: Incorrect SPI early close when getting children feed

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

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=894686&r1=894685&r2=894686&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
Wed Dec 30 18:07:29 2009
@@ -553,6 +553,44 @@
     }
 
     @Override
+    public ResponseContext getMedia(RequestContext request) {
+        SPI spi = repository.getSPI();
+        try {
+            String id = getResourceName(request);
+            ObjectEntry object = getEntry(id, request, spi);
+            if (object == null) {
+                return new EmptyResponseContext(404);
+            }
+            ContentStream contentStream = spi.getContentStream(object, null);
+            if (contentStream == null) {
+                return new EmptyResponseContext(409, "No content");
+            }
+            InputStream stream = contentStream.getStream();
+            if (stream == null) {
+                return new EmptyResponseContext(409, "No content");
+            }
+            Date updated = getUpdated(object);
+            SizedMediaResponseContext ctx = new SizedMediaResponseContext(
+                    stream, updated, 200);
+            ctx.setSize(getContentSize(object));
+            ctx.setContentType(getContentType(object));
+            ctx.setEntityTag(EntityTag.generate(id, AtomDate.format(updated)));
+            return ctx;
+        } catch (ResponseContextException e) {
+            return e.getResponseContext();
+        } catch (ConstraintViolationException e) {
+            return new EmptyResponseContext(409, "No content");
+        } catch (IOException e) {
+            return new EmptyResponseContext(500, e.toString());
+        } catch (Exception e) {
+            log.warn(e.getMessage(), e);
+            return new EmptyResponseContext(400);
+        } finally {
+            spi.close();
+        }
+    }
+
+    @Override
     public boolean isMediaEntry(ObjectEntry object)
             throws ResponseContextException {
         SPI spi = repository.getSPI();
@@ -684,42 +722,6 @@
         return getObjectLink(object.getId(), request);
     }
 
-    // override to use a custom SizedMediaResponseContext
-    // and return 409 on no content
-    @Override
-    protected ResponseContext buildGetMediaResponse(String id,
-            ObjectEntry object) throws ResponseContextException {
-        SPI spi = repository.getSPI();
-        try {
-            ContentStream contentStream = spi.getContentStream(object, null);
-            if (contentStream == null) {
-                return new EmptyResponseContext(409, "No content");
-            }
-            InputStream stream;
-            try {
-                stream = contentStream.getStream();
-            } catch (IOException e) {
-                return new EmptyResponseContext(500, e.toString());
-            }
-            if (stream == null) {
-                return new EmptyResponseContext(409, "No content");
-            }
-            Date updated = getUpdated(object);
-            SizedMediaResponseContext ctx = new SizedMediaResponseContext(
-                    stream, updated, 200);
-            ctx.setSize(getContentSize(object));
-            ctx.setContentType(getContentType(object));
-            ctx.setEntityTag(EntityTag.generate(id, AtomDate.format(updated)));
-            return ctx;
-        } catch (ConstraintViolationException e) {
-            return new EmptyResponseContext(409, "No content");
-        } catch (IOException e) {
-            return new EmptyResponseContext(500, e.toString());
-        } finally {
-            spi.close();
-        }
-    }
-
     @Override
     public String getName(ObjectEntry object) {
         throw new UnsupportedOperationException(); // unused



Mime
View raw message