Package org.apache.chemistry.opencmis.client.api

Examples of org.apache.chemistry.opencmis.client.api.ObjectId


            // update
            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put(PropertyIds.NAME, NAME2);

            ObjectId newId = workDoc.updateProperties(properties, false);
            Document doc2 = (Document) session.getObject(newId, SELECT_ALL_NO_CACHE_OC);

            addResult(checkObject(session, doc2, getAllProperties(doc2), "Updated document compliance"));

            f = createResult(FAILURE, "Document name doesn't match updated value!");
View Full Code Here


    }

    // --- update properties ---

    public CmisObject updateProperties(Map<String, ?> properties) {
        ObjectId objectId = updateProperties(properties, true);
        if (objectId == null) {
            return null;
        }

        if (!getObjectId().equals(objectId.getId())) {
            return getSession().getObject(objectId, getCreationContext());
        }

        return this;
    }
View Full Code Here

public abstract class AbstractWriteObjectIT extends AbstractSessionTest {

    @Test
    public void createFolder() {
        ObjectId parentId = session.createObjectId(fixture.getTestRootId());
        String folderName = UUID.randomUUID().toString();
        String typeId = FixtureData.FOLDER_TYPE_ID.value();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, folderName);
        properties.put(PropertyIds.OBJECT_TYPE_ID, typeId);

        ObjectId id = session.createFolder(properties, parentId);
        assertNotNull(id);
    }
View Full Code Here

        assertNotNull(id);
    }

    @Test
    public void createDocument() throws IOException {
        ObjectId parentId = session.createObjectId(fixture.getTestRootId());
        String folderName = UUID.randomUUID().toString();
        String typeId = FixtureData.DOCUMENT_TYPE_ID.value();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, folderName);
        properties.put(PropertyIds.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 = session.getObjectFactory().createContentStream(filename, buf1.length, mimetype,
                in1);
        assertNotNull(contentStream);

        ObjectId id = session.createDocument(properties, parentId, contentStream, VersioningState.NONE);
        assertNotNull(id);

        // verify content
        Document doc = (Document) session.getObject(id);
        assertNotNull(doc);
View Full Code Here

        assertEquals(content1, content2);
    }

    @Test
    public void createBigDocument() {
        ObjectId parentId = session.createObjectId(fixture.getTestRootId());
        String folderName = UUID.randomUUID().toString();
        String typeId = FixtureData.DOCUMENT_TYPE_ID.value();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, folderName);
        properties.put(PropertyIds.OBJECT_TYPE_ID, typeId);

        String filename = UUID.randomUUID().toString();
        String mimetype = "application/octet-stream";

        final int size = 10 * 1024 * 1024; // 10 MiB

        InputStream in = new InputStream() {

            private int counter = -1;

            @Override
            public int read() throws IOException {
                counter++;
                if (counter >= size) {
                    return -1;
                }

                return '0' + (counter / 10);
            }
        };

        ContentStream contentStream = session.getObjectFactory().createContentStream(filename, size, mimetype, in);
        assertNotNull(contentStream);

        long start = System.currentTimeMillis();
        ObjectId id = session.createDocument(properties, parentId, contentStream, VersioningState.NONE);
        long end = System.currentTimeMillis();

        assertNotNull(id);
       
        Document doc = (Document) session.getObject(id);
View Full Code Here

        log.info("createDocument with " + size + " bytes:" + (end - start) + "ms");
    }

    @Test
    public void setBigContent() {
        ObjectId parentId = session.createObjectId(fixture.getTestRootId());
        String folderName = UUID.randomUUID().toString();
        String typeId = FixtureData.DOCUMENT_TYPE_ID.value();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, folderName);
        properties.put(PropertyIds.OBJECT_TYPE_ID, typeId);

        String filename = UUID.randomUUID().toString();
        String mimetype = "application/octet-stream";

        ObjectId id = session.createDocument(properties, parentId, null, VersioningState.NONE);
        assertNotNull(id);

        // verify content
        Document doc = (Document) session.getObject(id);
        assertNotNull(doc);
View Full Code Here

            String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
            Document srcDocument = (Document) session.getObjectByPath(path);
            assertNotNull("Document not found: " + path, srcDocument);
            String srcContent = getContentAsString(srcDocument.getContentStream());

            ObjectId parentFolder = session.createObjectId(fixture.getTestRootId());
            String name = UUID.randomUUID().toString();

            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put(PropertyIds.NAME, name);

            ObjectId dstDocumentId = session.createDocumentFromSource(srcDocument, properties, parentFolder,
                    VersioningState.NONE);
            assertNotNull(dstDocumentId);
            Document dstDocument = (Document) session.getObject(dstDocumentId);
            String dstContent = getContentAsString(dstDocument.getContentStream());
            assertEquals(srcContent, dstContent);
View Full Code Here

        String id = document.getId();
        assertNotNull(id);

        // update single property
        ObjectId newId = document.updateProperties(properties);
        assertNotNull(newId);
        assertEquals(id, newId.getId()); // should not be a new version

        session.clear();

        // verify
        String s1 = FixtureData.DOCUMENT1_NAME.toString();
View Full Code Here

        return sbuf.toString();
    }

    @Test
    public void createDocumentAndSetContent() throws IOException {
        ObjectId parentId = session.createObjectId(fixture.getTestRootId());
        String folderName = UUID.randomUUID().toString();
        String typeId = FixtureData.DOCUMENT_TYPE_ID.value();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, folderName);
        properties.put(PropertyIds.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 = session.getObjectFactory().createContentStream(filename, buf1.length, mimetype,
                in1);
        assertNotNull(contentStream);

        ObjectId id = session.createDocument(properties, parentId, null, VersioningState.NONE);
        assertNotNull(id);

        // set and verify content
        Document doc = (Document) session.getObject(id);
        assertNotNull(doc);
View Full Code Here

    }

    @Ignore
    @Test
    public void createDocumentAndSetContentNoOverwrite() throws IOException {
        ObjectId parentId = session.createObjectId(fixture.getTestRootId());
        String folderName = UUID.randomUUID().toString();
        String typeId = FixtureData.DOCUMENT_TYPE_ID.value();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, folderName);
        properties.put(PropertyIds.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 = session.getObjectFactory().createContentStream(filename, buf1.length, mimetype,
                in1);
        assertNotNull(contentStream);

        ObjectId id = session.createDocument(properties, parentId, null, VersioningState.NONE);
        assertNotNull(id);

        // set and verify content
        Document doc = (Document) session.getObject(id);
        assertNotNull(doc);
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.client.api.ObjectId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.