Package org.apache.chemistry.opencmis.commons.data

Examples of org.apache.chemistry.opencmis.commons.data.ContentStream


        // be version
        // series?
        fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);
        String pwcId = idHolder.getValue();

        ContentStream altContent = fCreator.createAlternateContent();
        Properties newProps = fCreator.getUpdatePropertyList(VersionTestTypeSystemCreator.PROPERTY_ID, PROP_VALUE_NEW);
        idHolder = new Holder<String>(pwcId);
//        assertTrue(isCheckedOut(docId));
        assertTrue(isCheckedOut(pwcId));
View Full Code Here


        // be version
        // series?
        fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);
        String pwcId = idHolder.getValue();

        ContentStream altContent = fCreator.createAlternateContent();
        Properties newProps = fCreator.getUpdatePropertyList(VersionTestTypeSystemCreator.PROPERTY_ID, PROP_VALUE_NEW);
        idHolder = new Holder<String>(pwcId);
//        assertTrue(isCheckedOut(docId));
        assertTrue(isCheckedOut(pwcId));

        // Test check-in and pass content and properties
        String checkinComment = "Checkin with content and properties.";
        fVerSvc.checkIn(fRepositoryId, idHolder, true, newProps, altContent, checkinComment, null, null, null, null);

        // get latest major version
        versioningState = VersioningState.MAJOR;
        boolean isMajor = true;
        ObjectData objData = fVerSvc.getObjectOfLatestVersion(fRepositoryId, docId, docId, isMajor, "*", false,
                IncludeRelationships.NONE, null, false, false, null);
        checkVersionProperties(verId, versioningState, objData.getProperties().getProperties(), checkinComment);
        ContentStream retrievedContent = fObjSvc.getContentStream(fRepositoryId, objData.getId(), null, BigInteger
                .valueOf(-1) /* offset */, BigInteger.valueOf(-1) /* length */, null);
        assertTrue(fCreator.verifyContent(retrievedContent, fCreator.createAlternateContent()));

        // get latest non-major version, must be the same as before
        versioningState = VersioningState.MAJOR;
View Full Code Here

        // create second version with different content
        Holder<String> idHolder = new Holder<String>(verIdV1);
        Holder<Boolean> contentCopied = new Holder<Boolean>(false);
        fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);

        ContentStream content2 = createContent('a');
        Properties newProps = fCreator.getUpdatePropertyList(VersionTestTypeSystemCreator.PROPERTY_ID,
                "PropertyFromVersion2");
        idHolder = new Holder<String>(verIdV1);
        // Test check-in and pass content and properties
        String checkinComment = "Checkin from Unit Test-2.";
        fVerSvc.checkIn(fRepositoryId, idHolder, true, newProps, content2, checkinComment, null, null, null, null);
        String verIdV2 = idHolder.getValue();

        // create third version with different content
        contentCopied = new Holder<Boolean>(false);
        fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);
        ContentStream content3 = super.createContent('a');
        newProps = fCreator.getUpdatePropertyList(VersionTestTypeSystemCreator.PROPERTY_ID, "PropertyFromVersion3");
        // Test check-in and pass content and properties
        checkinComment = "Checkin from Unit Test-3.";
        fVerSvc.checkIn(fRepositoryId, idHolder, true, newProps, content3, checkinComment, null, null, null, null);
        /* String verIdV3 = */idHolder.getValue();

        // Try to update version2 which should fail (on a versioned document
        // only a document that
        // is checked out can be modified.
        try {
            fCreator.updateProperty(verIdV2, VersionTestTypeSystemCreator.PROPERTY_ID, "ChangeWithoutCheckout");
            fail("updateProperty for an older version should fail.");
        } catch (Exception e) {
            assertTrue(e instanceof CmisUpdateConflictException);
        }
        // try to set content on an older version
        ContentStream content4 = super.createContent('x');
        idHolder = new Holder<String>(verIdV2);
        try {
            fObjSvc.setContentStream(fRepositoryId, idHolder, true, null, content4, null);
            fail("setContentStream for an older version should fail.");
        } catch (Exception e) {
View Full Code Here

                }
            }

            // check content
            for (Document document : documents.values()) {
                ContentStream contentStream = document.getContentStream();
                if (contentStream == null) {
                    addResult(createResult(FAILURE, "Document has no content! Id: " + document.getId()));
                    continue;
                }
View Full Code Here

            try {
                contentBytes = CONTENT2.getBytes("UTF-8");
            } catch (Exception e) {
            }

            ContentStream contentStream = new ContentStreamImpl(workDoc.getName(),
                    BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes));

            workDoc.setContentStream(contentStream, true, true);

            // test new content
View Full Code Here

        Session session = clientSession.getSession();
        return session.getTypeDescendants(null, -1, true);
    }

    public ContentStream createContentStream(String filename) throws Exception {
        ContentStream content = null;
        if ((filename != null) && (filename.length() > 0)) {
            File file = new File(filename);
            InputStream stream = new FileInputStream(file);

            content = clientSession.getSession().getObjectFactory()
View Full Code Here

        String id = createDocument(fRootFolderId, true);
        if (id != null) {
            log.info("createDocument succeeded with created id: " + id);
        }

        ContentStream sd = fObjSvc.getContentStream(fRepositoryId, id, null, BigInteger.valueOf(-1) /* offset */,
                BigInteger.valueOf(-1) /* length */, null);
        verifyContentResult(sd);

        // delete content again
        Holder<String> idHolder = new Holder<String>(id);
        fObjSvc.deleteContentStream(fRepositoryId, idHolder, null, null);
        try {
            sd = fObjSvc.getContentStream(fRepositoryId, id, null, BigInteger.valueOf(-1) /* offset */, BigInteger
                    .valueOf(-1) /* length */, null);
            fail("getContentStream with non existing content should raise a CmisConstraintException");
        } catch (Exception e) {
            assertTrue(e instanceof CmisConstraintException);
        }
        // create content again in a second call
        ContentStream contentStream = createContent();
        fObjSvc.setContentStream(fRepositoryId, idHolder, true, null, contentStream, null);
        sd = fObjSvc.getContentStream(fRepositoryId, id, null, BigInteger.valueOf(-1) /* offset */, BigInteger
                .valueOf(-1) /* length */, null);
        verifyContentResult(sd);

View Full Code Here

            throws Exception {
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, name);
        properties.put(PropertyIds.OBJECT_TYPE_ID, type);

        ContentStream content = createContentStream(filename);
        clientSession.getSession()
                .createDocument(properties, currentFolder, content, versioningState, null, null, null);
    }
View Full Code Here

                    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);
        }
    }
View Full Code Here

        } catch (Exception e) {
            fail("createDocumentFromSource() failed with exception: " + e);
        }

        // get content from second document and compare it with original one
        ContentStream sd = fObjSvc.getContentStream(fRepositoryId, id2, null, BigInteger.valueOf(-1) /* offset */,
                BigInteger.valueOf(-1) /* length */, null);
        verifyContentResult(sd);

        // cleanup
        fObjSvc.deleteObject(fRepositoryId, id1, true, null);
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.data.ContentStream

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.