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

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


                String targetId = targetIdField.getText();

                try {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                    ObjectId objectId = getClientModel().createRelationship(name, type, sourceId, targetId);

                    if (objectId != null) {
                        getClientModel().loadObject(objectId.getId());
                    }

                    thisDialog.setVisible(false);
                    thisDialog.dispose();
                } catch (Exception e) {
View Full Code Here


public abstract class AbstractTransientObjectIT extends AbstractSessionTest {

    @Test
    public void transientUpdate() throws Exception {
        ObjectId parentId = session
                .createObjectId(this.fixture.getTestRootId());
        String filename1 = UUID.randomUUID().toString();
        String typeId = FixtureData.DOCUMENT_TYPE_ID.value();

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

        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 contentStream1 = session.getObjectFactory()
                .createContentStream(filename1, buf1.length, mimetype, in1);
        assertNotNull(contentStream1);

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

        // prepare new non-cache operation context
        OperationContext oc = session.createOperationContext();
        oc.setFilterString("*");
        oc.setCacheEnabled(false);

        // set new name and save
        Document doc2 = (Document) session.getObject(id, oc);
        TransientDocument tdoc2 = doc2.getTransientDocument();

        assertEquals(filename1, tdoc2.getName());

        ContentStream cs2 = tdoc2.getContentStream();
        assertNotNull(cs2);
        assertContent(buf1, readContent(cs2));

        String filename2 = UUID.randomUUID().toString();
        tdoc2.setName(filename2);
        assertEquals(filename2, tdoc2.getName());

        ObjectId id2 = tdoc2.save();
        assertNotNull(id2);

        // set new content and save
        Document doc3 = (Document) session.getObject(id2, oc);
        TransientDocument tdoc3 = doc3.getTransientDocument();

        assertEquals(filename2, tdoc3.getName());

        ContentStream cs3 = tdoc3.getContentStream();
        assertNotNull(cs3);
        assertContent(buf1, readContent(cs3));

        String content3 = "Es rauscht noch.";

        byte[] buf3 = content3.getBytes("UTF-8");
        ByteArrayInputStream in3 = new ByteArrayInputStream(buf3);
        ContentStream contentStream3 = session.getObjectFactory()
                .createContentStream(tdoc3.getName(), buf3.length, mimetype,
                        in3);
        assertNotNull(contentStream3);

        tdoc3.setContentStream(contentStream3, true);

        ObjectId id3 = tdoc3.save();
        assertNotNull(id3);

        // set new name, delete content and save
        Document doc4 = (Document) session.getObject(id3, oc);
        TransientDocument tdoc4 = doc4.getTransientDocument();

        assertEquals(tdoc3.getName(), tdoc4.getName());

        ContentStream cs4 = tdoc4.getContentStream();
        assertNotNull(cs4);
        assertContent(buf3, readContent(cs4));

        String filename4 = UUID.randomUUID().toString();
        tdoc4.setName(filename4);
        assertEquals(filename4, tdoc4.getName());

        tdoc4.deleteContentStream();

        ObjectId id4 = tdoc4.save();
        assertNotNull(id4);

        // delete object
        Document doc5 = (Document) session.getObject(id4, oc);
        TransientDocument tdoc5 = doc5.getTransientDocument();

        assertEquals(filename4, tdoc5.getName());

        ContentStream cs5 = tdoc4.getContentStream();
        assertNull(cs5);

        assertEquals(false, tdoc5.isMarkedForDelete());

        tdoc5.delete(true);

        assertEquals(true, tdoc5.isMarkedForDelete());

        ObjectId id5 = tdoc5.save();
        assertNull(id5);

        // check
        try {
            this.session.getObject(id4, oc);
View Full Code Here

                newFolderName);

        tfolder.save();
        session2.clear();

        ObjectId id = session2.createObjectId(tfolder.getId());

        Folder folder3 = (Folder) session2.getObject(id);
        assertNotNull(folder3);
        assertEquals(folder3.getProperty(PropertyIds.NAME).getValueAsString(),
                newFolderName);
View Full Code Here

                newDocName);

        tdoc.save();
        session2.clear();

        ObjectId id = session2.createObjectId(tdoc.getId());

        Document doc3 = (Document) session2.getObject(id);
        assertNotNull(doc3);
        assertEquals(doc3.getProperty(PropertyIds.NAME).getValueAsString(),
                newDocName);
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

    }

    @Test
    @Ignore
    public void createHugeDocument() {
        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

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.