Examples of ContentStream


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));

        // 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);
        // Neither the version nor the version series should be checked out any
        // longer:
        assertFalse(isCheckedOut(idHolder.getValue()));
//        assertFalse(isCheckedOut(docId));
        ContentStream retrievedContent = fObjSvc.getContentStream(fRepositoryId, idHolder.getValue(), null, BigInteger
                .valueOf(-1) /* offset */, BigInteger.valueOf(-1) /* length */, null);

        // New content and property should be set
        assertTrue(fCreator.verifyContent(fCreator.createAlternateContent(), retrievedContent));
        assertTrue(fCreator.verifyProperty(idHolder.getValue(), VersionTestTypeSystemCreator.PROPERTY_ID,
View Full Code Here

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

            fail("updateProperty in a document as another user should fail.");
        } catch (Exception e) {
            assertTrue(e instanceof CmisUpdateConflictException);
        }

        ContentStream altContent = fCreator.createAlternateContent();
        Holder<String> pwcHolder = new Holder<String>(pwcId);
        try {
            fObjSvc.setContentStream(fRepositoryId, pwcHolder, true, null, altContent, null);
            fail("setContentStream in a document as another user should fail.");
        } catch (Exception e) {
            assertTrue(e instanceof CmisUpdateConflictException);
        }

        setRuntimeContext(TEST_USER);
        // Test that a check-in as same user is possible
        fVerSvc.checkIn(fRepositoryId, pwcHolder, true, null, null, "testCheckOutAndOtherUser", null, null, null, null);

        // Because nothing was changed we should have a new version with
        // identical content
        ContentStream retrievedContent = fObjSvc.getContentStream(fRepositoryId, pwcHolder.getValue(), null, BigInteger
                .valueOf(-1) /* offset */, BigInteger.valueOf(-1) /* length */, null);
        assertTrue(fCreator.verifyContent(retrievedContent, fCreator.createContent()));
        assertTrue(fCreator.verifyProperty(idHolder.getValue(), VersionTestTypeSystemCreator.PROPERTY_ID, PROP_VALUE));
    }
View Full Code Here

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

        String pwcId = idHolder.getValue();

        // Set a new content and modify property
        Properties props = fObjSvc.getProperties(fRepositoryId, pwcId, "*", null);
        String changeToken = (String) props.getProperties().get(PropertyIds.CHANGE_TOKEN).getFirstValue();
        ContentStream altContent = fCreator.createAlternateContent();
        idHolder = new Holder<String>(pwcId);
        Holder<String> tokenHolder = new Holder<String>(changeToken);
        fObjSvc.setContentStream(fRepositoryId, idHolder, true, tokenHolder, altContent, null);
        fCreator.updateProperty(idHolder.getValue(), VersionTestTypeSystemCreator.PROPERTY_ID, PROP_VALUE_NEW);

        // cancel checkout
        fVerSvc.cancelCheckOut(fRepositoryId, pwcId, null);
        try {
            // Verify that pwc no longer exists
            fObjSvc.getObject(fRepositoryId, pwcId, "*", false, IncludeRelationships.NONE, null, false, false, null);
            fail("Getting pwc after cancel checkout should fail.");
        } catch (CmisObjectNotFoundException e1) {
        } catch (Exception e2) {
            fail("Expected a CmisObjectNotFoundException after cancel checkin, but got a " + e2.getClass().getName());
        }

        // verify that the old content and properties are still valid
        assertTrue(fCreator.verifyProperty(idOfLastVersion, VersionTestTypeSystemCreator.PROPERTY_ID, PROP_VALUE));
        ContentStream retrievedContent = fObjSvc.getContentStream(fRepositoryId, idOfLastVersion, null, BigInteger
                .valueOf(-1) /* offset */, BigInteger.valueOf(-1) /* length */, null);
        assertTrue(fCreator.verifyContent(retrievedContent, fCreator.createContent()));
    }
View Full Code Here

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

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));

        // 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

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

        // 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

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

                }
            }

            // 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

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

            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

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

        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

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

        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
TOP
Copyright © 2018 www.massapi.com. 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.