chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1348638 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/...
Date Sun, 10 Jun 2012 18:21:51 GMT
Author: fmui
Date: Sun Jun 10 18:21:50 2012
New Revision: 1348638

URL: http://svn.apache.org/viewvc?rev=1348638&view=rev
Log:
CMIS-537: extended AtomPub createDocument() to send (client) and retrieve (server) the content
filename

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java
    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-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomParserTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.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/AtomEntryWriter.java?rev=1348638&r1=1348637&r2=1348638&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
Sun Jun 10 18:21:50 2012
@@ -18,7 +18,7 @@
  */
 package org.apache.chemistry.opencmis.client.bindings.spi.atompub;
 
-import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ATOM_ID;
+import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.*;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ATOM_TITLE;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ATOM_UPDATED;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_CONTENT;
@@ -55,24 +55,26 @@ public class AtomEntryWriter {
     private static final String PREFIX_ATOM = "atom";
     private static final String PREFIX_CMIS = "cmis";
     private static final String PREFIX_RESTATOM = "cmisra";
+    private static final String PREFIX_APACHE_CHEMISTY = "chemistry";
 
     private static final int BUFFER_SIZE = 64 * 1024;
 
     private final CmisObjectType object;
     private final InputStream stream;
     private final String mediaType;
+    private final String filename;
 
     /**
      * Constructor.
      */
     public AtomEntryWriter(CmisObjectType object) {
-        this(object, null, null);
+        this(object, null, null, null);
     }
 
     /**
      * Constructor.
      */
-    public AtomEntryWriter(CmisObjectType object, String mediaType, InputStream stream) {
+    public AtomEntryWriter(CmisObjectType object, String mediaType, String filename, InputStream
stream) {
         if ((object == null) || (object.getProperties() == null)) {
             throw new CmisInvalidArgumentException("Object and properties must not be null!");
         }
@@ -83,6 +85,7 @@ public class AtomEntryWriter {
 
         this.object = object;
         this.mediaType = mediaType;
+        this.filename = filename;
 
         if (stream != null && !(stream instanceof BufferedInputStream) &&
!(stream instanceof ByteArrayInputStream)) {
             // avoid double buffering
@@ -102,6 +105,7 @@ public class AtomEntryWriter {
         writer.setPrefix(PREFIX_ATOM, Constants.NAMESPACE_ATOM);
         writer.setPrefix(PREFIX_CMIS, Constants.NAMESPACE_CMIS);
         writer.setPrefix(PREFIX_RESTATOM, Constants.NAMESPACE_RESTATOM);
+        writer.setPrefix(PREFIX_APACHE_CHEMISTY, Constants.NAMESPACE_APACHE_CHEMISTRY);
 
         // start doc
         writer.writeStartDocument();
@@ -111,6 +115,9 @@ public class AtomEntryWriter {
         writer.writeNamespace(PREFIX_ATOM, Constants.NAMESPACE_ATOM);
         writer.writeNamespace(PREFIX_CMIS, Constants.NAMESPACE_CMIS);
         writer.writeNamespace(PREFIX_RESTATOM, Constants.NAMESPACE_RESTATOM);
+        if (filename != null) {
+            writer.writeNamespace(PREFIX_APACHE_CHEMISTY, Constants.NAMESPACE_APACHE_CHEMISTRY);
+        }
 
         // atom:id
         writer.writeStartElement(Constants.NAMESPACE_ATOM, TAG_ATOM_ID);
@@ -135,6 +142,12 @@ public class AtomEntryWriter {
             writer.writeCharacters(mediaType);
             writer.writeEndElement();
 
+            if (filename != null) {
+                writer.writeStartElement(Constants.NAMESPACE_APACHE_CHEMISTRY, TAG_CONTENT_FILENAME);
+                writer.writeCharacters(filename);
+                writer.writeEndElement();
+            }
+
             writer.writeStartElement(Constants.NAMESPACE_RESTATOM, TAG_CONTENT_BASE64);
             writeContent(writer);
             writer.writeEndElement();
@@ -188,7 +201,7 @@ public class AtomEntryWriter {
                 writer.writeCharacters(new String(buffer, 0, b, "US-ASCII"));
             }
         }
-        
+
         b64stream.close();
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.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/CmisAtomPubConstants.java?rev=1348638&r1=1348637&r2=1348638&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java
Sun Jun 10 18:21:50 2012
@@ -63,6 +63,7 @@ public final class CmisAtomPubConstants 
     public static final String TAG_CONTENT = "content";
     public static final String TAG_CONTENT_MEDIATYPE = "mediatype";
     public static final String TAG_CONTENT_BASE64 = "base64";
+    public static final String TAG_CONTENT_FILENAME = "filename";
 
     public static final String ATTR_DOCUMENT_TYPE = CmisTypeDocumentDefinitionType.class.getAnnotation(XmlType.class).name();
     public static final String ATTR_FOLDER_TYPE = CmisTypeFolderDefinitionType.class.getAnnotation(XmlType.class).name();

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=1348638&r1=1348637&r2=1348638&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 10 18:21:50 2012
@@ -114,14 +114,16 @@ public class ObjectServiceImpl extends A
         object.setPolicyIds(convertPolicyIds(policies));
 
         String mediaType = null;
+        String filename = null;
         InputStream stream = null;
 
         if (contentStream != null) {
             mediaType = contentStream.getMimeType();
+            filename = contentStream.getFileName();
             stream = contentStream.getStream();
         }
 
-        final AtomEntryWriter entryWriter = new AtomEntryWriter(object, mediaType, stream);
+        final AtomEntryWriter entryWriter = new AtomEntryWriter(object, mediaType, filename,
stream);
 
         // post the new folder object
         HttpUtils.Response resp = post(url, Constants.MEDIATYPE_ENTRY, new HttpUtils.Output()
{

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.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/VersioningServiceImpl.java?rev=1348638&r1=1348637&r2=1348638&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.java
Sun Jun 10 18:21:50 2012
@@ -166,14 +166,16 @@ public class VersioningServiceImpl exten
         }
 
         String mediaType = null;
+        String filename = null;
         InputStream stream = null;
 
         if (contentStream != null) {
             mediaType = contentStream.getMimeType();
+            filename = contentStream.getFileName();
             stream = contentStream.getStream();
         }
 
-        final AtomEntryWriter entryWriter = new AtomEntryWriter(object, mediaType, stream);
+        final AtomEntryWriter entryWriter = new AtomEntryWriter(object, mediaType, filename,
stream);
 
         // update
         HttpUtils.Response resp = put(url, Constants.MEDIATYPE_ENTRY, new HttpUtils.Output()
{

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomParserTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomParserTest.java?rev=1348638&r1=1348637&r2=1348638&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomParserTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomParserTest.java
Sun Jun 10 18:21:50 2012
@@ -42,9 +42,6 @@ import org.apache.chemistry.opencmis.com
 
 /**
  * Minimal test for AtomEntryWriter and AtomPubParser.
- *
- * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
- *
  */
 public class AtomParserTest extends TestCase {
 
@@ -80,7 +77,7 @@ public class AtomParserTest extends Test
         object1.setProperties(properties);
 
         // write the entry
-        AtomEntryWriter aew = new AtomEntryWriter(object1, CONTENT_TYPE, new ByteArrayInputStream(CONTENT));
+        AtomEntryWriter aew = new AtomEntryWriter(object1, CONTENT_TYPE, null, new ByteArrayInputStream(CONTENT));
         aew.write(bao);
 
         byte[] entryContent = bao.toByteArray();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java?rev=1348638&r1=1348637&r2=1348638&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
Sun Jun 10 18:21:50 2012
@@ -35,6 +35,7 @@ public final class Constants {
     public static final String NAMESPACE_APP = "http://www.w3.org/2007/app";
     public static final String NAMESPACE_RESTATOM = "http://docs.oasis-open.org/ns/cmis/restatom/200908/";
     public static final String NAMESPACE_XSI = "http://www.w3.org/2001/XMLSchema-instance";
+    public static final String NAMESPACE_APACHE_CHEMISTRY = "http://chemistry.apache.org/";
 
     // media types
     public static final String MEDIATYPE_SERVICE = "application/atomsvc+xml";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.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/AtomEntryParser.java?rev=1348638&r1=1348637&r2=1348638&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
Sun Jun 10 18:21:50 2012
@@ -67,6 +67,7 @@ public class AtomEntryParser {
     private static final String TAG_CONTENT = "content";
     private static final String TAG_BASE64 = "base64";
     private static final String TAG_MEDIATYPE = "mediatype";
+    private static final String TAG_FILENAME = "filename";
 
     private static final String ATTR_SRC = "src";
     private static final String ATTR_TYPE = "type";
@@ -336,6 +337,12 @@ public class AtomEntryParser {
                     } else {
                         skip(parser);
                     }
+                } else if (Constants.NAMESPACE_APACHE_CHEMISTRY.equals(name.getNamespaceURI()))
{
+                    if (TAG_FILENAME.equals(name.getLocalPart())) {
+                        cmisContentStream.setFileName(readText(parser));
+                    } else {
+                        skip(parser);
+                    }
                 } else {
                     skip(parser);
                 }



Mime
View raw message