Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisObjectService.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisObjectService.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisObjectService.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisObjectService.java Thu Apr 15 14:35:55 2010 @@ -24,7 +24,7 @@ import java.util.List; import org.apache.chemistry.opencmis.commons.api.ExtensionsData; import org.apache.chemistry.opencmis.commons.bindings.AccessControlList; import org.apache.chemistry.opencmis.commons.bindings.AllowableActionsData; -import org.apache.chemistry.opencmis.commons.bindings.ContentStreamData; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.bindings.FailedToDeleteData; import org.apache.chemistry.opencmis.commons.bindings.Holder; import org.apache.chemistry.opencmis.commons.bindings.ObjectData; @@ -51,7 +51,7 @@ public interface CmisObjectService { * </p> */ String createDocument(CallContext context, String repositoryId, PropertiesData properties, - String folderId, ContentStreamData contentStream, VersioningState versioningState, + String folderId, ContentStream contentStream, VersioningState versioningState, List<String> policies, AccessControlList addAces, AccessControlList removeAces, ExtensionsData extension); @@ -109,7 +109,7 @@ public interface CmisObjectService { * </p> */ ObjectData create(CallContext context, String repositoryId, PropertiesData properties, - String folderId, ContentStreamData contentStream, VersioningState versioningState, + String folderId, ContentStream contentStream, VersioningState versioningState, List<String> policies, ExtensionsData extension, ObjectInfoHolder objectInfos); /** @@ -173,7 +173,7 @@ public interface CmisObjectService { * Bindings: AtomPub, Web Services * </p> */ - ContentStreamData getContentStream(CallContext context, String repositoryId, String objectId, + ContentStream getContentStream(CallContext context, String repositoryId, String objectId, String streamId, BigInteger offset, BigInteger length, ExtensionsData extension); /** @@ -230,7 +230,7 @@ public interface CmisObjectService { * </p> */ void setContentStream(CallContext context, String repositoryId, Holder<String> objectId, - Boolean overwriteFlag, Holder<String> changeToken, ContentStreamData contentStream, + Boolean overwriteFlag, Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension); /**
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisVersioningService.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisVersioningService.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisVersioningService.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-spi/src/main/java/org/apache/chemistry/opencmis/server/spi/CmisVersioningService.java Thu Apr 15 14:35:55 2010 @@ -22,7 +22,7 @@ import java.util.List; import org.apache.chemistry.opencmis.commons.api.ExtensionsData; import org.apache.chemistry.opencmis.commons.bindings.AccessControlList; -import org.apache.chemistry.opencmis.commons.bindings.ContentStreamData; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.bindings.Holder; import org.apache.chemistry.opencmis.commons.bindings.ObjectData; import org.apache.chemistry.opencmis.commons.bindings.PropertiesData; @@ -61,7 +61,7 @@ public interface CmisVersioningService { ExtensionsData extension); public ObjectData checkIn(CallContext context, String repositoryId, Holder<String> objectId, - Boolean major, PropertiesData properties, ContentStreamData contentStream, + Boolean major, PropertiesData properties, ContentStream contentStream, String checkinComment, List<String> policies, AccessControlList addAces, AccessControlList removeAces, ExtensionsData extension, ObjectInfoHolder objectInfos); Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/AbstractServiceWrapper.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/AbstractServiceWrapper.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/AbstractServiceWrapper.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/AbstractServiceWrapper.java Thu Apr 15 14:35:55 2010 @@ -20,7 +20,7 @@ package org.apache.chemistry.opencmis.se import java.math.BigInteger; -import org.apache.chemistry.opencmis.commons.bindings.ContentStreamData; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.bindings.Holder; import org.apache.chemistry.opencmis.commons.bindings.PropertiesData; import org.apache.chemistry.opencmis.commons.enums.AclPropagation; @@ -145,7 +145,7 @@ public abstract class AbstractServiceWra /** * Throws an exception if the given content object is <code>null</code>. */ - protected void checkContentStream(ContentStreamData content) { + protected void checkContentStream(ContentStream content) { if (content == null) { throw new CmisInvalidArgumentException("Content must be set!"); } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectServiceWrapper.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectServiceWrapper.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectServiceWrapper.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectServiceWrapper.java Thu Apr 15 14:35:55 2010 @@ -24,7 +24,7 @@ import java.util.List; import org.apache.chemistry.opencmis.commons.api.ExtensionsData; import org.apache.chemistry.opencmis.commons.bindings.AccessControlList; import org.apache.chemistry.opencmis.commons.bindings.AllowableActionsData; -import org.apache.chemistry.opencmis.commons.bindings.ContentStreamData; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.bindings.FailedToDeleteData; import org.apache.chemistry.opencmis.commons.bindings.Holder; import org.apache.chemistry.opencmis.commons.bindings.ObjectData; @@ -76,7 +76,7 @@ public class ObjectServiceWrapper extend * org.apache.opencmis.server.spi.ObjectInfoHolder) */ public ObjectData create(CallContext context, String repositoryId, PropertiesData properties, - String folderId, ContentStreamData contentStream, VersioningState versioningState, + String folderId, ContentStream contentStream, VersioningState versioningState, List<String> policies, ExtensionsData extension, ObjectInfoHolder objectInfos) { checkRepositoryId(repositoryId); checkProperties(properties); @@ -104,7 +104,7 @@ public class ObjectServiceWrapper extend * org.apache.opencmis.commons.api.ExtensionsData) */ public String createDocument(CallContext context, String repositoryId, PropertiesData properties, - String folderId, ContentStreamData contentStream, VersioningState versioningState, + String folderId, ContentStream contentStream, VersioningState versioningState, List<String> policies, AccessControlList addAces, AccessControlList removeAces, ExtensionsData extension) { checkRepositoryId(repositoryId); @@ -325,7 +325,7 @@ public class ObjectServiceWrapper extend * .spi.CallContext, java.lang.String, java.lang.String, java.lang.String, java.math.BigInteger, * java.math.BigInteger, org.apache.opencmis.commons.api.ExtensionsData) */ - public ContentStreamData getContentStream(CallContext context, String repositoryId, + public ContentStream getContentStream(CallContext context, String repositoryId, String objectId, String streamId, BigInteger offset, BigInteger length, ExtensionsData extension) { checkRepositoryId(repositoryId); @@ -488,7 +488,7 @@ public class ObjectServiceWrapper extend * org.apache.opencmis.commons.api.ExtensionsData) */ public void setContentStream(CallContext context, String repositoryId, Holder<String> objectId, - Boolean overwriteFlag, Holder<String> changeToken, ContentStreamData contentStream, + Boolean overwriteFlag, Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) { checkRepositoryId(repositoryId); checkHolderId("Object Id", objectId); Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/VersioningServiceWrapper.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/VersioningServiceWrapper.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/VersioningServiceWrapper.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/VersioningServiceWrapper.java Thu Apr 15 14:35:55 2010 @@ -22,7 +22,7 @@ import java.util.List; import org.apache.chemistry.opencmis.commons.api.ExtensionsData; import org.apache.chemistry.opencmis.commons.bindings.AccessControlList; -import org.apache.chemistry.opencmis.commons.bindings.ContentStreamData; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.bindings.Holder; import org.apache.chemistry.opencmis.commons.bindings.ObjectData; import org.apache.chemistry.opencmis.commons.bindings.PropertiesData; @@ -91,7 +91,7 @@ public class VersioningServiceWrapper ex * org.apache.opencmis.server.spi.ObjectInfoHolder) */ public ObjectData checkIn(CallContext context, String repositoryId, Holder<String> objectId, - Boolean major, PropertiesData properties, ContentStreamData contentStream, + Boolean major, PropertiesData properties, ContentStream contentStream, String checkinComment, List<String> policies, AccessControlList addAces, AccessControlList removeAces, ExtensionsData extension, ObjectInfoHolder objectInfos) { checkRepositoryId(repositoryId); Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java Thu Apr 15 14:35:55 2010 @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.bindings.ContentStreamData; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.bindings.ObjectData; import org.apache.chemistry.opencmis.commons.bindings.PropertiesData; import org.apache.chemistry.opencmis.commons.bindings.PropertyData; @@ -71,7 +71,7 @@ public abstract class AbstractSimpleBind // set up content byte[] content = "This is a test file!".getBytes(); - ContentStreamData contentStream = getBinding().getObjectFactory() + ContentStream contentStream = getBinding().getObjectFactory() .createContentStream(BigInteger.valueOf(content.length), "text/plain", "test", new ByteArrayInputStream(content)); Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyContentStreamIT.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyContentStreamIT.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyContentStreamIT.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyContentStreamIT.java Thu Apr 15 14:35:55 2010 @@ -24,34 +24,34 @@ import java.io.InputStream; import junit.framework.Assert; -import org.apache.chemistry.opencmis.client.api.ContentStream; import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.junit.Test; public class ReadOnlyContentStreamIT extends AbstractSessionTest { - @Test - public void readContentStream() throws IOException { - String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" - + FixtureData.DOCUMENT1_NAME.toString(); - Document document = (Document) this.session.getObjectByPath(path); - Assert.assertNotNull("document not found: " + path, document); - - ContentStream s = document.getContentStream(); - - Assert.assertNotNull(s.getMimeType()); - s.getLength(); - s.getFileName(); - - InputStream is = s.getStream(); - Assert.assertNotNull(is); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - baos.write(is.read()); - byte[] b = baos.toByteArray(); - - Assert.assertNotNull(b); - Assert.assertTrue(b.length > 0); - } + @Test + public void readContentStream() throws IOException { + String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + + FixtureData.DOCUMENT1_NAME.toString(); + Document document = (Document) this.session.getObjectByPath(path); + Assert.assertNotNull("document not found: " + path, document); + + ContentStream s = document.getContentStream(); + + Assert.assertNotNull(s.getMimeType()); + s.getLength(); + s.getFileName(); + + InputStream is = s.getStream(); + Assert.assertNotNull(is); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.write(is.read()); + byte[] b = baos.toByteArray(); + + Assert.assertNotNull(b); + Assert.assertTrue(b.length > 0); + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectIT.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectIT.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectIT.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectIT.java Thu Apr 15 14:35:55 2010 @@ -25,20 +25,14 @@ import static org.junit.Assert.assertTru import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; -import org.apache.chemistry.opencmis.client.api.ContentStream; import org.apache.chemistry.opencmis.client.api.Document; import org.apache.chemistry.opencmis.client.api.ObjectId; -import org.apache.chemistry.opencmis.client.api.Property; -import org.apache.chemistry.opencmis.client.api.objecttype.ObjectType; import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.api.PropertyDefinition; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.enums.CmisProperties; import org.apache.chemistry.opencmis.commons.enums.VersioningState; import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException; @@ -46,246 +40,246 @@ import org.junit.Test; public class WriteObjectIT extends AbstractSessionTest { - @Test - public void createFolder() { - ObjectId parentId = this.session - .createObjectId(Fixture.getTestRootId()); - String folderName = UUID.randomUUID().toString(); - String typeId = FixtureData.FOLDER_TYPE_ID.value(); - - - /* - ObjectType ot = this.session.getTypeDefinition(typeId); - Collection<PropertyDefinition<?>> pdefs = ot.getPropertyDefintions() - .values(); - List<Property<?>> properties = new ArrayList<Property<?>>(); - Property<?> prop = null; - - for (PropertyDefinition<?> pd : pdefs) { - try { - CmisProperties cmisp = CmisProperties.fromValue(pd.getId()); - switch (cmisp) { - case NAME: - prop = this.session.getObjectFactory().createProperty(pd, - folderName); - properties.add(prop); - break; - case OBJECT_TYPE_ID: - prop = this.session.getObjectFactory().createProperty(pd, - typeId); - properties.add(prop); - break; - default: - break; - } - } catch (Exception e) { - // custom property definition - } - - } - */ - - Map<String, Object> properties = new HashMap<String, Object>(); - properties.put(PropertyIds.CMIS_NAME, folderName); - properties.put(PropertyIds.CMIS_OBJECT_TYPE_ID, typeId); - - ObjectId id = this.session.createFolder(properties, parentId, null, - null, null); - assertNotNull(id); - } - - @Test - public void createDocument() throws IOException { - ObjectId parentId = this.session - .createObjectId(Fixture.getTestRootId()); - String folderName = UUID.randomUUID().toString(); - String typeId = FixtureData.DOCUMENT_TYPE_ID.value(); - - /* - ObjectType ot = this.session.getTypeDefinition(typeId); - Collection<PropertyDefinition<?>> pdefs = ot.getPropertyDefintions() - .values(); - List<Property<?>> properties = new ArrayList<Property<?>>(); - Property<?> prop = null; - - for (PropertyDefinition<?> pd : pdefs) { - try { - CmisProperties cmisp = CmisProperties.fromValue(pd.getId()); - switch (cmisp) { - case NAME: - prop = this.session.getObjectFactory().createProperty(pd, - folderName); - properties.add(prop); - break; - case OBJECT_TYPE_ID: - prop = this.session.getObjectFactory().createProperty(pd, - typeId); - properties.add(prop); - break; - default: - break; - } - } catch (Exception e) { - /* - * custom property definition (note: document type should not - * have further mandatory properties) - */ + @Test + public void createFolder() { + ObjectId parentId = this.session + .createObjectId(Fixture.getTestRootId()); + String folderName = UUID.randomUUID().toString(); + String typeId = FixtureData.FOLDER_TYPE_ID.value(); + + + /* + ObjectType ot = this.session.getTypeDefinition(typeId); + Collection<PropertyDefinition<?>> pdefs = ot.getPropertyDefintions() + .values(); + List<Property<?>> properties = new ArrayList<Property<?>>(); + Property<?> prop = null; + + for (PropertyDefinition<?> pd : pdefs) { + try { + CmisProperties cmisp = CmisProperties.fromValue(pd.getId()); + switch (cmisp) { + case NAME: + prop = this.session.getObjectFactory().createProperty(pd, + folderName); + properties.add(prop); + break; + case OBJECT_TYPE_ID: + prop = this.session.getObjectFactory().createProperty(pd, + typeId); + properties.add(prop); + break; + default: + break; + } + } catch (Exception e) { + // custom property definition + } + + } + */ + + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put(PropertyIds.CMIS_NAME, folderName); + properties.put(PropertyIds.CMIS_OBJECT_TYPE_ID, typeId); + + ObjectId id = this.session.createFolder(properties, parentId, null, + null, null); + assertNotNull(id); + } + + @Test + public void createDocument() throws IOException { + ObjectId parentId = this.session + .createObjectId(Fixture.getTestRootId()); + String folderName = UUID.randomUUID().toString(); + String typeId = FixtureData.DOCUMENT_TYPE_ID.value(); + + /* + ObjectType ot = this.session.getTypeDefinition(typeId); + Collection<PropertyDefinition<?>> pdefs = ot.getPropertyDefintions() + .values(); + List<Property<?>> properties = new ArrayList<Property<?>>(); + Property<?> prop = null; + + for (PropertyDefinition<?> pd : pdefs) { + try { + CmisProperties cmisp = CmisProperties.fromValue(pd.getId()); + switch (cmisp) { + case NAME: + prop = this.session.getObjectFactory().createProperty(pd, + folderName); + properties.add(prop); + break; + case OBJECT_TYPE_ID: + prop = this.session.getObjectFactory().createProperty(pd, + typeId); + properties.add(prop); + break; + default: + break; + } + } catch (Exception e) { + /* + * custom property definition (note: document type should not + * have further mandatory properties) + */ /* this.log - .info( - "Custom property found but not supported in test case!", - e); - } - } + .info( + "Custom property found but not supported in test case!", + e); + } + } */ - - Map<String, Object> properties = new HashMap<String, Object>(); - properties.put(PropertyIds.CMIS_NAME, folderName); - properties.put(PropertyIds.CMIS_OBJECT_TYPE_ID, typeId); - - String filename = UUID.randomUUID().toString(); - String mimetype = "text/html; charset=UTF-8"; - String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all."; - - byte[] buf1 = content1.getBytes("UTF-8"); - ByteArrayInputStream in1 = new ByteArrayInputStream(buf1); - ContentStream contentStream = this.session.getObjectFactory() - .createContentStream(filename, buf1.length, mimetype, in1); - assertNotNull(contentStream); - - ObjectId id = this.session.createDocument(properties, parentId, - contentStream, VersioningState.NONE, null, null, null); - assertNotNull(id); - - // verify content - Document doc = (Document) this.session.getObject(id); - assertNotNull(doc); - // Assert.assertEquals(buf1.length, doc.getContentStreamLength()); - // Assert.assertEquals(mimetype, doc.getContentStreamMimeType()); - // Assert.assertEquals(filename, doc.getContentStreamFileName()); - String content2 = this.getContentAsString(doc.getContentStream()); - assertEquals(content1, content2); - } - - @Test - public void createDocumentFromSource() throws IOException { - try { - // verify content - String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" - + FixtureData.DOCUMENT1_NAME; - Document srcDocument = (Document) this.session - .getObjectByPath(path); - assertNotNull("Document not found: " + path, srcDocument); - String srcContent = this.getContentAsString(srcDocument - .getContentStream()); - - ObjectId parentFolder = session.createObjectId(Fixture - .getTestRootId()); - /* - List<Property<?>> srcProperties = srcDocument.getProperties(); - assertNotNull(srcProperties); - List<Property<?>> dstProperties = new ArrayList<Property<?>>(); - - for (Property<?> p : srcProperties) { - if (p.getId().equalsIgnoreCase(CmisProperties.NAME.value())) { - // change the name - String name = UUID.randomUUID().toString(); - Property<String> pn = this.session.getObjectFactory() - .createProperty(p.getDefinition(), name); - dstProperties.add(pn); - } else { - dstProperties.add(p); - } - } + + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put(PropertyIds.CMIS_NAME, folderName); + properties.put(PropertyIds.CMIS_OBJECT_TYPE_ID, typeId); + + String filename = UUID.randomUUID().toString(); + String mimetype = "text/html; charset=UTF-8"; + String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all."; + + byte[] buf1 = content1.getBytes("UTF-8"); + ByteArrayInputStream in1 = new ByteArrayInputStream(buf1); + ContentStream contentStream = this.session.getObjectFactory() + .createContentStream(filename, buf1.length, mimetype, in1); + assertNotNull(contentStream); + + ObjectId id = this.session.createDocument(properties, parentId, + contentStream, VersioningState.NONE, null, null, null); + assertNotNull(id); + + // verify content + Document doc = (Document) this.session.getObject(id); + assertNotNull(doc); + // Assert.assertEquals(buf1.length, doc.getContentStreamLength()); + // Assert.assertEquals(mimetype, doc.getContentStreamMimeType()); + // Assert.assertEquals(filename, doc.getContentStreamFileName()); + String content2 = this.getContentAsString(doc.getContentStream()); + assertEquals(content1, content2); + } + + @Test + public void createDocumentFromSource() throws IOException { + try { + // verify content + String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + + FixtureData.DOCUMENT1_NAME; + Document srcDocument = (Document) this.session + .getObjectByPath(path); + assertNotNull("Document not found: " + path, srcDocument); + String srcContent = this.getContentAsString(srcDocument + .getContentStream()); + + ObjectId parentFolder = session.createObjectId(Fixture + .getTestRootId()); + /* + List<Property<?>> srcProperties = srcDocument.getProperties(); + assertNotNull(srcProperties); + List<Property<?>> dstProperties = new ArrayList<Property<?>>(); + + for (Property<?> p : srcProperties) { + if (p.getId().equalsIgnoreCase(CmisProperties.NAME.value())) { + // change the name + String name = UUID.randomUUID().toString(); + Property<String> pn = this.session.getObjectFactory() + .createProperty(p.getDefinition(), name); + dstProperties.add(pn); + } else { + dstProperties.add(p); + } + } */ - String name = UUID.randomUUID().toString(); - - Map<String, Object> properties = new HashMap<String, Object>(); - properties.put(PropertyIds.CMIS_NAME, name); - - ObjectId dstDocumentId = this.session.createDocumentFromSource( - srcDocument, properties, parentFolder, - VersioningState.NONE, null, null, null); - assertNotNull(dstDocumentId); - Document dstDocument = (Document) this.session - .getObject(dstDocumentId); - String dstContent = this.getContentAsString(dstDocument - .getContentStream()); - assertEquals(srcContent, dstContent); - - } catch (CmisNotSupportedException e) { - // not an error - this.log.info(e.getMessage()); - } - } - - @Test - public void deleteAndCreateContent() throws IOException { - // verify content - - String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" - + FixtureData.DOCUMENT1_NAME; - Document document = (Document) this.session.getObjectByPath(path); - assertNotNull("Document not found: " + path, document); - - // check default content - ContentStream contentStream = document.getContentStream(); - assertNotNull(contentStream); - String contentString = this.getContentAsString(contentStream); - assertNotNull(contentString); - - // delete and set new content - // ObjectId id = (return id not supported by AtomPub) - document.deleteContentStream(); - // assertNotNull(id); - - String filename = UUID.randomUUID().toString(); - String mimetype = "text/html; charset=UTF-8"; - String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all."; - - byte[] buf1 = content1.getBytes("UTF-8"); - ByteArrayInputStream in1 = new ByteArrayInputStream(buf1); - contentStream = this.session.getObjectFactory().createContentStream( - filename, buf1.length, mimetype, in1); - assertNotNull(contentStream); - - document.setContentStream(true, contentStream); - - // check default content - ContentStream contentStream2 = document.getContentStream(); - assertNotNull(contentStream2); - String contentString2 = this.getContentAsString(contentStream2); - assertNotNull(contentString2); - - assertEquals(content1, contentString2); - } - - @Test - public void updateProperties() { - // verify content - String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" - + FixtureData.DOCUMENT1_NAME; - Document document = (Document) this.session.getObjectByPath(path); - assertNotNull("Document not found: " + path, document); - - document.setProperty(CmisProperties.NAME.value(), "Neuer Name"); - document.updateProperties(); - assertTrue(true); - } - - private String getContentAsString(ContentStream stream) throws IOException { - assertNotNull(stream); - InputStream in2 = stream.getStream(); - assertNotNull(in2); - StringBuffer sbuf = null; - sbuf = new StringBuffer(in2.available()); - int count; - byte[] buf2 = new byte[100]; - while ((count = in2.read(buf2)) != -1) { - for (int i = 0; i < count; i++) { - sbuf.append((char) buf2[i]); - } - } - in2.close(); - return sbuf.toString(); - } + String name = UUID.randomUUID().toString(); + + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put(PropertyIds.CMIS_NAME, name); + + ObjectId dstDocumentId = this.session.createDocumentFromSource( + srcDocument, properties, parentFolder, + VersioningState.NONE, null, null, null); + assertNotNull(dstDocumentId); + Document dstDocument = (Document) this.session + .getObject(dstDocumentId); + String dstContent = this.getContentAsString(dstDocument + .getContentStream()); + assertEquals(srcContent, dstContent); + + } catch (CmisNotSupportedException e) { + // not an error + this.log.info(e.getMessage()); + } + } + + @Test + public void deleteAndCreateContent() throws IOException { + // verify content + + String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + + FixtureData.DOCUMENT1_NAME; + Document document = (Document) this.session.getObjectByPath(path); + assertNotNull("Document not found: " + path, document); + + // check default content + ContentStream contentStream = document.getContentStream(); + assertNotNull(contentStream); + String contentString = this.getContentAsString(contentStream); + assertNotNull(contentString); + + // delete and set new content + // ObjectId id = (return id not supported by AtomPub) + document.deleteContentStream(); + // assertNotNull(id); + + String filename = UUID.randomUUID().toString(); + String mimetype = "text/html; charset=UTF-8"; + String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all."; + + byte[] buf1 = content1.getBytes("UTF-8"); + ByteArrayInputStream in1 = new ByteArrayInputStream(buf1); + contentStream = this.session.getObjectFactory().createContentStream( + filename, buf1.length, mimetype, in1); + assertNotNull(contentStream); + + document.setContentStream(true, contentStream); + + // check default content + ContentStream contentStream2 = document.getContentStream(); + assertNotNull(contentStream2); + String contentString2 = this.getContentAsString(contentStream2); + assertNotNull(contentString2); + + assertEquals(content1, contentString2); + } + + @Test + public void updateProperties() { + // verify content + String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + + FixtureData.DOCUMENT1_NAME; + Document document = (Document) this.session.getObjectByPath(path); + assertNotNull("Document not found: " + path, document); + + document.setProperty(CmisProperties.NAME.value(), "Neuer Name"); + document.updateProperties(); + assertTrue(true); + } + + private String getContentAsString(ContentStream stream) throws IOException { + assertNotNull(stream); + InputStream in2 = stream.getStream(); + assertNotNull(in2); + StringBuffer sbuf = null; + sbuf = new StringBuffer(in2.available()); + int count; + byte[] buf2 = new byte[100]; + while ((count = in2.read(buf2)) != -1) { + for (int i = 0; i < count; i++) { + sbuf.append((char) buf2[i]); + } + } + in2.close(); + return sbuf.toString(); + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java?rev=934426&r1=934425&r2=934426&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java Thu Apr 15 14:35:55 2010 @@ -33,7 +33,7 @@ import org.apache.chemistry.opencmis.com import org.apache.chemistry.opencmis.commons.api.ExtensionsData; import org.apache.chemistry.opencmis.commons.bindings.AccessControlList; import org.apache.chemistry.opencmis.commons.bindings.BindingsObjectFactory; -import org.apache.chemistry.opencmis.commons.bindings.ContentStreamData; +import org.apache.chemistry.opencmis.commons.bindings.ContentStream; import org.apache.chemistry.opencmis.commons.bindings.NavigationService; import org.apache.chemistry.opencmis.commons.bindings.ObjectData; import org.apache.chemistry.opencmis.commons.bindings.ObjectInFolderData; @@ -391,7 +391,7 @@ public class ObjectGenerator { } private String createDocument(String folderId, int no, int level) { - ContentStreamData contentStream = null; + ContentStream contentStream = null; VersioningState versioningState = VersioningState.NONE; List<String> policies = null; AccessControlList addACEs = null; @@ -444,9 +444,9 @@ public class ObjectGenerator { } } - private ContentStreamData createContent() { + private ContentStream createContent() { ContentStreamDataImpl content = new ContentStreamDataImpl(); - content.setFilename("data.txt"); + content.setFileName("data.txt"); content.setMimeType("text/plain"); int len = fContentSizeInK * 1024; // size of document in K byte[] b = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
