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

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


    }

    @Test
    public void testCheckOutAndOtherUser() {
        String verId = createDocument(PROP_NAME, fRootFolderId, VersioningState.MAJOR);
        ObjectData version = fObjSvc.getObject(fRepositoryId, verId, "*", false, IncludeRelationships.NONE, null,
                false, false, null);
        String docId = getVersionSeriesId(verId, version.getProperties().getProperties());
        assertTrue(null != docId && docId.length() > 0);
        assertFalse(isCheckedOut(version.getProperties().getProperties()));
        Holder<Boolean> contentCopied = new Holder<Boolean>();
        Holder<String> idHolder = new Holder<String>(verId); // or should this
        // be version
        // series?
        fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);
View Full Code Here


    }

    @Test
    public void testCancelCheckout() {
        String verId = createDocument(PROP_NAME, fRootFolderId, VersioningState.MAJOR);
        ObjectData version = fObjSvc.getObject(fRepositoryId, verId, "*", false, IncludeRelationships.NONE, null,
                false, false, null);
        String idOfLastVersion = version.getId();
        String docId = getVersionSeriesId(verId, version.getProperties().getProperties());
        assertTrue(null != docId && docId.length() > 0);
        assertFalse(isCheckedOut(version.getProperties().getProperties()));
        Holder<Boolean> contentCopied = new Holder<Boolean>();
        Holder<String> idHolder = new Holder<String>(verId); // or should this
        // be version
        // series?
        fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);
View Full Code Here

    public void testGetPropertiesOfLatestVersion() {
        VersioningState versioningState = VersioningState.MAJOR;
        String verId = createDocument(PROP_NAME, fRootFolderId, versioningState);
        getDocument(verId);

        ObjectData version = fObjSvc.getObject(fRepositoryId, verId, "*", false, IncludeRelationships.NONE, null,
                false, false, null);
        String docId = getVersionSeriesId(verId, version.getProperties().getProperties());
        assertTrue(null != docId && docId.length() > 0);

        Holder<Boolean> contentCopied = new Holder<Boolean>();
        Holder<String> idHolder = new Holder<String>(verId); // or should this
        // be version
View Full Code Here

    public void testGetLatestVersion() {
        VersioningState versioningState = VersioningState.MINOR;
        String verId = createDocument(PROP_NAME, fRootFolderId, versioningState);
        getDocument(verId);

        ObjectData version = fObjSvc.getObject(fRepositoryId, verId, "*", false, IncludeRelationships.NONE, null,
                false, false, null);
        String docId = getVersionSeriesId(verId, version.getProperties().getProperties());
        assertTrue(null != docId && docId.length() > 0);

        Holder<Boolean> contentCopied = new Holder<Boolean>();
        Holder<String> idHolder = new Holder<String>(verId); // or should this
        // 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;
        isMajor = false;
        objData = fVerSvc.getObjectOfLatestVersion(fRepositoryId, docId, docId, isMajor, "*", false,
                IncludeRelationships.NONE, null, false, false, null);
        checkVersionProperties(verId, versioningState, objData.getProperties().getProperties(), checkinComment);
        retrievedContent = fObjSvc.getContentStream(fRepositoryId, objData.getId(), null,
                BigInteger.valueOf(-1) /* offset */, BigInteger.valueOf(-1) /* length */, null);
        assertTrue(fCreator.verifyContent(retrievedContent, fCreator.createAlternateContent()));
    }
View Full Code Here

        String[] folderIds = createLevel1Folders();
        String[] verSeriesIds = new String[folderIds.length * count];
        for (int i = 0; i < folderIds.length; i++) {
            for (int j = 0; j < count; j++) {
                String verId = createDocument("MyDoc" + j, folderIds[i], VersioningState.MAJOR);
                ObjectData od = fObjSvc.getObject(fRepositoryId, verId, "*", false, IncludeRelationships.NONE, null,
                        false, false, null);
                verSeriesIds[i * folderIds.length + j] = verId;
            }
        }
        // checkout first in each folder
View Full Code Here

        // type id is:
        // VersionTestTypeSystemCreator.VERSION_TEST_DOCUMENT_TYPE_ID
        String verId = createDocument(PROP_NAME, fRootFolderId, versioningState);
        getDocument(verId);

        ObjectData version = fObjSvc.getObject(fRepositoryId, verId, "*", false, IncludeRelationships.NONE, null,
                false, false, null);
        String docId = getVersionSeriesId(verId, version.getProperties().getProperties());
        assertTrue(null != docId && docId.length() > 0);

        List<ObjectData> allVersions = fVerSvc.getAllVersions(fRepositoryId, docId, docId, "*", false, null);
        assertEquals(1, allVersions.size());

View Full Code Here

    @Override
    public String getDocument(String id) {
        String returnedId = null;
        try {
            ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false,
                    false, null);
            assertNotNull(res);
            testReturnedProperties(res.getProperties().getProperties());
            returnedId = res.getId();
            assertEquals(id, returnedId);
        } catch (Exception e) {
            fail("getObject() failed with exception: " + e);
        }
        return returnedId;
View Full Code Here

    private String createVersionSeriesWithThreeVersions() {
        String verIdV1 = createDocument(PROP_NAME, fRootFolderId, VersioningState.MAJOR);
        getDocument(verIdV1);

        ObjectData version = fObjSvc.getObject(fRepositoryId, verIdV1, "*", false, IncludeRelationships.NONE, null,
                false, false, null);
        String verSeriesId = getVersionSeriesId(verIdV1, version.getProperties().getProperties());

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

            log.info("  createDocument succeeded with created id: " + id);
        }

        log.info("  getting object");
        try {
            ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false,
                    false, null);
            assertNotNull(res);

            String returnedId = res.getId();
            assertEquals(id, returnedId);
            Map<String, PropertyData<?>> props = res.getProperties().getProperties();
            for (PropertyData<?> pd : props.values()) {
                log.info("return property id: " + pd.getId() + ", value: " + pd.getValues());
            }

            PropertyData<?> pd = props.get(PropertyIds.NAME);
View Full Code Here

            log.info("createDocument succeeded with created id: " + id);
        }

        log.info("  getting object");
        try {
            ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false,
                    false, null);
            assertNotNull(res);
            Map<String, PropertyData<?>> props = res.getProperties().getProperties();

            // check returned properties
            for (PropertyData<?> pd : props.values()) {
                log.info("  return property id: " + pd.getId() + ", value: " + pd.getValues());
            }

            String returnedId = res.getId();
            assertEquals(id, returnedId);
            PropertyData<?> pd = props.get(PropertyIds.NAME);
            assertNotNull(pd);
            assertEquals(MY_CUSTOM_NAME, pd.getFirstValue());
            pd = props.get(PropertyIds.OBJECT_TYPE_ID);
            assertEquals(TEST_CUSTOM_DOCUMENT_TYPE_ID, pd.getFirstValue());
            pd = props.get(TEST_DOCUMENT_MY_STRING_PROP_ID);
            assertEquals("My pretty string", pd.getFirstValue());
            pd = props.get(TEST_DOCUMENT_MY_INT_PROP_ID);
            assertEquals(BigInteger.valueOf(4711), pd.getFirstValue());

            // update properties:
            log.info("updating property");
            final String newStringPropVal = "My ugly string";
            final BigInteger newIntPropVal = BigInteger.valueOf(815);
            List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
            // properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME
            // , MY_CUSTOM_NAME));
            // properties.add(fFactory.createPropertyIdData(PropertyIds.
            // CMIS_OBJECT_TYPE_ID, TEST_CUSTOM_DOCUMENT_TYPE_ID));
            // Generate some property values for custom attributes
            properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_MY_STRING_PROP_ID, newStringPropVal));
            properties.add(fFactory.createPropertyIntegerData(TEST_DOCUMENT_MY_INT_PROP_ID, newIntPropVal));
            Properties newProps = fFactory.createPropertiesData(properties);

            Holder<String> idHolder = new Holder<String>(id);
            Holder<String> changeTokenHolder = new Holder<String>();
            fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
            oldChangeToken = changeTokenHolder.getValue(); // store for later
            // use
            // check if we now retrieve new values
            res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false, false, null);
            assertNotNull(res);
            props = res.getProperties().getProperties();
            for (PropertyData<?> pd2 : props.values()) {
                log.info("  return property id: " + pd2.getId() + ", value: " + pd2.getValues());
            }
            returnedId = res.getId();
            assertEquals(id, returnedId);
            pd = props.get(PropertyIds.NAME);
            assertNotNull(pd);
            assertEquals(MY_CUSTOM_NAME, pd.getFirstValue());
            pd = props.get(PropertyIds.OBJECT_TYPE_ID);
            assertEquals(TEST_CUSTOM_DOCUMENT_TYPE_ID, pd.getFirstValue());
            pd = props.get(TEST_DOCUMENT_MY_STRING_PROP_ID);
            assertEquals(newStringPropVal, pd.getFirstValue());
            pd = props.get(TEST_DOCUMENT_MY_INT_PROP_ID);
            assertEquals(newIntPropVal, pd.getFirstValue());

            // Test delete properties
            log.info("deleting property");
            properties = new ArrayList<PropertyData<?>>();
            properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_MY_STRING_PROP_ID, (String) null));
            newProps = fFactory.createPropertiesData(properties);
            Thread.sleep(100); // ensure new change token, timer resolution is
            // not good enough
            fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
            res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false, false, null);
            assertNotNull(res);
            props = res.getProperties().getProperties();
            for (PropertyData<?> pd2 : props.values()) {
                log.info("  return property id: " + pd2.getId() + ", value: " + pd2.getValues());
            }
            pd = props.get(TEST_DOCUMENT_MY_STRING_PROP_ID);
            assertNull(pd);
            // delete a required property and expect exception:
            properties = new ArrayList<PropertyData<?>>();
            properties.add(fFactory.createPropertyIntegerData(TEST_DOCUMENT_MY_INT_PROP_ID, (BigInteger) null));
            newProps = fFactory.createPropertiesData(properties);
            idHolder = new Holder<String>(id);
            try {
                fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
                fail("Deleteing a required property should fail.");
            } catch (Exception e) {
                assertTrue(e instanceof CmisConstraintException);
            }

            // Test violation of property definition constraints
            log.info("Test violation of property definition constraints");
            properties = new ArrayList<PropertyData<?>>();
            properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_MY_STRING_PROP_ID,
                    "A very long String ABCDEFHIJKLMNOPQRSTUVWXYZ"));
            newProps = fFactory.createPropertiesData(properties);
            idHolder = new Holder<String>(id);
            try {
                fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
                fail("Exceeding max String lengt h should fail.");
            } catch (Exception e) {
                assertTrue(e instanceof CmisConstraintException);
            }
            // Test stale token
            log.info("Test stale token");
            properties = new ArrayList<PropertyData<?>>();
            properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_MY_STRING_PROP_ID, "ABC"));
            newProps = fFactory.createPropertiesData(properties);
            // set outdated token
            newChangeToken = changeTokenHolder.getValue();
            changeTokenHolder.setValue(oldChangeToken);
            assertFalse(oldChangeToken.equals(newChangeToken));
            try {
                fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
                fail("Update with an outdated changeToken should fail.");
            } catch (Exception e) {
                assertTrue(e instanceof CmisUpdateConflictException);
            }

            // test a rename
            log.info("Test renaming");
            final String newName = "My Renamed Document"; // MY_CUSTOM_NAME
            properties = new ArrayList<PropertyData<?>>();
            properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, newName));
            newProps = fFactory.createPropertiesData(properties);
            changeTokenHolder.setValue(newChangeToken);
            fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
            id = idHolder.getValue(); // note that id is path and has changed!
            res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false, false, null);
            assertNotNull(res);
            props = res.getProperties().getProperties();
            pd = props.get(PropertyIds.NAME);
            assertNotNull(pd);
            assertEquals(newName, pd.getFirstValue());

            // test rename with a conflicting name
View Full Code Here

TOP

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

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.