Author: jens
Date: Tue Jun 1 12:26:31 2010
New Revision: 950037
URL: http://svn.apache.org/viewvc?rev=950037&view=rev
Log:
Deliver always a file name and a mime type for content stream (even if no one
was set during creation)
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java?rev=950037&r1=950036&r2=950037&view=diff
==============================================================================
---
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
(original)
+++
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
Tue Jun 1 12:26:31 2010
@@ -75,8 +75,14 @@ public class DocumentImpl extends Abstra
fContent = null;
} else {
fContent = new ContentStreamDataImpl();
- fContent.setFileName(content.getFileName());
- fContent.setMimeType(content.getMimeType());
+ String fileName = content.getFileName();
+ if (null == fileName || fileName.length() <= 0)
+ fileName = getName(); // use name of document as fallback
+ fContent.setFileName(fileName);
+ String mimeType = content.getMimeType();
+ if (null == mimeType || mimeType.length() <= 0)
+ mimeType = "application/octet-stream"; // use as fallback
+ fContent.setMimeType(mimeType);
try {
fContent.setContent(content.getStream());
} catch (IOException e) {
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=950037&r1=950036&r2=950037&view=diff
==============================================================================
---
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
(original)
+++
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
Tue Jun 1 12:26:31 2010
@@ -58,6 +58,7 @@ import org.apache.chemistry.opencmis.com
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
import org.apache.chemistry.opencmis.commons.spi.Holder;
+import
org.apache.chemistry.opencmis.inmemory.storedobj.impl.ContentStreamDataImpl;
import
org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
import
org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
@@ -238,6 +239,37 @@ public class ObjectServiceTest extends A
}
@Test
+ public void testCreateDocumentWithContentNoFileNameNoMimeType() {
+ log.info("starting testCreateDocumentWithContent() ...");
+ ContentStreamDataImpl contentStream = null;
+ List<String> policies = null;
+ Acl addACEs = null;
+ Acl removeACEs = null;
+ ExtensionsData extension = null;
+
+ Properties props = createDocumentProperties(DOCUMENT_ID,
DOCUMENT_TYPE_ID);
+
+ contentStream = (ContentStreamDataImpl) createContent();
+ contentStream.setFileName(null);
+ contentStream.setMimeType(null);
+
+ String id = null;
+ try {
+ id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId,
contentStream, VersioningState.NONE, policies,
+ addACEs, removeACEs, extension);
+ if (null == id)
+ fail("createDocument failed.");
+
+ ContentStream sd = fObjSvc.getContentStream(fRepositoryId, id,
null, BigInteger.valueOf(-1) /* offset */,
+ BigInteger.valueOf(-1) /* length */, null);
+ assertNotNull(sd.getMimeType());
+ assertNotNull(sd.getFileName());
+ } catch (Exception e) {
+ fail("createDocument() failed with exception: " + e);
+ }
+ }
+
+ @Test
public void testCreateDocumentFromSource() {
log.info("starting testCreateDocumentFromSource() ...");
// create a 1st document