コード例 #1
0
        public void testGetContentChangesForUpdate()
        {
            if (getCapabilityChanges().Equals(enumCapabilityChanges.none))
            {
                throw new SkippedException("Content Changes Capability is not supported");
            }
            //TODO: Change document creation to default versioning state after versioning problem will be fixed
            FileableObject currentObject = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.none);

            string changeLogToken = getAndAssertRepositoryInfo().latestChangeLogToken;

            logger.log("[ObjectService->updateProperties]");
            string changeToken = "";
            string objectId    = currentObject.ObjectId;

            currentObject.addProperty(NAME_PROPERTY, FileableObject.generateObjectName(false, DateTime.Now.Ticks.ToString()));
            object            property  = currentObject.removeProperty(TYPE_ID_PROPERTY);
            cmisExtensionType extension = new cmisExtensionType();

            objectServiceClient.updateProperties(getAndAssertRepositoryId(), ref objectId, ref changeToken, currentObject.getObjectProperties(false), ref extension);

            cmisObjectListType response = receiveAndAssertContentChanges(ref changeLogToken, null);

            assertContentChanges(response, objectId, enumTypeOfChanges.updated);
            deleteAndAssertObject(objectId);
        }
コード例 #2
0
        public getFolderTreeResponse GetFolderTree(getFolderTreeRequest request)
        {
            var resultList = new cmisObjectListType();
            var repository = ModelHelper.GetRepository(request.repositoryId);

            cmisObjectInFolderContainerType root = new cmisObjectInFolderContainerType();
            IEnumerable <Kooboo.CMS.Content.Models.TextFolder> childFolders = null;

            if (request.folderId == "/")
            {
                root.objectInFolder = new cmisObjectInFolderType()
                {
                    pathSegment = "/"
                };
                childFolders = _textFolderManager.All(repository, null);
            }
            else
            {
                var textFolder = ModelHelper.GetTextFolder(request.repositoryId, request.folderId);
                root.objectInFolder = ToPathedCmisObject(textFolder);
                childFolders        = _textFolderManager.ChildFolders(textFolder);
            }
            int?maxDepth = null;

            if (!string.IsNullOrEmpty(request.depth))
            {
                maxDepth = request.depth.As <int>();
            }
            root.children = childFolders.Select(it => ToPathedCmisObjectContainer(it, maxDepth)).Where(it => it != null).ToArray();

            return(new getFolderTreeResponse(new[] { root }));
        }
コード例 #3
0
        public void testRelationshipsReceivingWithAllowableActions()
        {
            cmisObjectListType relationships = getAndAssertRelationship(false, enumIncludeRelationships.source, null, null, true, null, null);

            foreach (cmisObjectType currentObject in relationships.objects)
            {
                Assert.IsNotNull(currentObject.allowableActions, "Allowable Actions were not returned");
                Assert.IsTrue(currentObject.allowableActions.canDeleteObject, "Allowable Actions deny reading of Relationship Object Properties");
            }
        }
コード例 #4
0
 public void testRelationshipsReceivingForInvalidObjectId()
 {
     try
     {
         logger.log("Receiving relationships for non-existent object");
         logger.log("[RelationshipService->getObjectRelationships]");
         cmisObjectListType response = relationshipServiceClient.getObjectRelationships(getAndAssertRepositoryId(), INVALID_OBJECT_ID, false, enumRelationshipDirection.either, null, null, false, null, null, null);
         Assert.Fail("Relationships were received for non-existent object");
     }
     catch (FaultException <cmisFaultType> e)
     {
         logger.log("Expected error was returned");
     }
 }
コード例 #5
0
        public void testGetContentChangesForCreate()
        {
            if (getCapabilityChanges().Equals(enumCapabilityChanges.none))
            {
                throw new SkippedException("Content Changes Capability is not supported");
            }
            //TODO: Change document creation to default versioning state after versioning problem will be fixed
            string             changeLogToken = getAndAssertRepositoryInfo().latestChangeLogToken;
            string             objectId       = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.none).ObjectId;
            cmisObjectListType response       = receiveAndAssertContentChanges(ref changeLogToken, null);

            assertContentChanges(response, objectId, enumTypeOfChanges.created);
            deleteAndAssertObject(objectId);
        }
コード例 #6
0
 public void testRelationshipsReceivingForInvalidRepositoryId()
 {
     try
     {
         logger.log("[RelationshipService->getObjectRelationships]");
         logger.log("Receiving relationships for incorrect repositoryId");
         cmisObjectListType response = relationshipServiceClient.getObjectRelationships(INVALID_REPOSITORY_ID, getAndAssertRootFolder(), false, enumRelationshipDirection.either, null, null, false, null, null, null);
         Assert.Fail("Relationships were received for non-existent repository");
     }
     catch (FaultException <cmisFaultType> e)
     {
         assertException(e, enumServiceException.invalidArgument);
         logger.log("Expected error was returned");
     }
 }
コード例 #7
0
        public void testFilteredRelationshipsReceiving()
        {
            string             filter   = OBJECT_IDENTIFIER_PROPERTY + "," + TYPE_ID_PROPERTY + "," + SOURCE_OBJECT_ID + "," + TARGET_OBJECT_ID;
            cmisObjectListType response = getAndAssertRelationship(false, enumIncludeRelationships.source, null, filter, false, null, null);

            foreach (cmisObjectType currentObject in response.objects)
            {
                Assert.IsNotNull(currentObject.properties, "Properties of one of the Relationship Objects are undefined");
                cmisProperty[] properties = currentObject.properties.Items;
                Assert.IsTrue((4 == properties.Length), "Filter allows only 4 properties");
                searchAndAssertPropertyByName(properties, OBJECT_IDENTIFIER_PROPERTY, false);
                searchAndAssertPropertyByName(properties, TYPE_ID_PROPERTY, false);
                searchAndAssertPropertyByName(properties, SOURCE_OBJECT_ID, false);
                searchAndAssertPropertyByName(properties, TARGET_OBJECT_ID, false);
            }
        }
コード例 #8
0
        private cmisObjectListType receiveAndAssertContentChanges(ref string changeLogToken, Nullable <long> maxItems)
        {
            logger.log("[DiscoveryService->getContentChanges]");
            cmisObjectListType result = discoveryServiceClient.getContentChanges(getAndAssertRepositoryId(), ref changeLogToken, false, ANY_PROPERTY_FILTER, false, false, maxItems, null);

            Assert.IsNotNull(result, ("Get Content Changes response is undefined for '" + changeLogToken + "' Change Log Token"));
            Assert.IsFalse(isValueNotSet(result.objects), ("Get Content Changes response is empty for '" + changeLogToken + "' Change Log Token"));
            if (null != result.numItems)
            {
                int numItems = Convert.ToInt32(result.numItems);
                if (null != maxItems)
                {
                    Assert.IsTrue(numItems <= maxItems, ("Get Content Changes result contains not valid amount of Entries. Expectd amount: " + maxItems + ", but actual: " + result.numItems));
                }
            }
            return(result);
        }
コード例 #9
0
        private cmisObjectType[] executeAndAssertQuery(string query, int pageSize, int skipCount, bool allVersions, bool allowableActions, enumIncludeRelationships relationships, string renditionFilter)
        {
            logger.log("Executing query '" + query + "', pageSize=" + pageSize + ", skipCount=" + skipCount);
            logger.log("[DiscoveryService->query]");
            cmisObjectListType response = discoveryServiceClient.query(getAndAssertRepositoryId(), query, allVersions, allowableActions, relationships, renditionFilter, pageSize, skipCount, null);

            Assert.IsNotNull(response, "response is null");
            Assert.IsNotNull(response.objects, "Objects are undefined");
            Assert.IsTrue(response.objects.Length > 0, "number of returned objects < 1");
            if ((DOCS_COUNT - skipCount) >= pageSize)
            {
                Assert.IsTrue((response.objects.Length > 0 && response.objects.Length <= PAGE_SIZE), "number of returned objects(" + response.objects.Length + ") is not equal to expected(0 < N <=" + pageSize + ")");
            }
            logger.log("Query successfully executed, number of returned objects=" + response.objects.Length);
            logger.log("");
            return(response.objects);
        }
コード例 #10
0
        public void testGetContentChangesForSecurity()
        {
            if (getCapabilityChanges().Equals(enumCapabilityChanges.none))
            {
                throw new SkippedException("Content Changes Capability is not supported");
            }
            //TODO: Change document creation to default versioning state after versioning problem will be fixed
            string objectId = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.none).ObjectId;

            string changeLogToken            = getAndAssertRepositoryInfo().latestChangeLogToken;
            cmisAccessControlListType acList = createSimpleACL(aclPrincipalId, PERMISSION_WRITE);

            logger.log("[ACLService->applyACL]");
            aclServiceClient.applyACL(getAndAssertRepositoryId(), objectId, acList, null, getACLPropagation(), null);

            cmisObjectListType response = receiveAndAssertContentChanges(ref changeLogToken, null);

            assertContentChanges(response, objectId, enumTypeOfChanges.security);
        }
コード例 #11
0
        private void assertContentChanges(cmisObjectListType actualObjects, string expectedObjectId, enumTypeOfChanges expectedChangeType)
        {
            bool found = false;

            foreach (cmisObjectType currentObject in actualObjects.objects)
            {
                Assert.IsNotNull(currentObject, "One of the Change Event Entries is in 'not set' state solely");
                Assert.IsNotNull(currentObject.properties, "Properties of one of the Change Event Entries are undefined");
                Assert.IsNotNull(currentObject.changeEventInfo, "ChangeEventInfo of one of the Change Event Entries is undefined");
                String id = (string)searchAndAssertPropertyByName(currentObject.properties.Items, OBJECT_IDENTIFIER_PROPERTY, false);
                Assert.IsNotNull(id, "'cmis:objectId' property of one of the Change Event Entries is undefined");
                logger.log("Recived Change Log Entry [ChangeType='" + currentObject.changeEventInfo.changeType + "', ObjectId='" + id + "']");
                if (expectedObjectId.Equals(id) && expectedChangeType.Equals(currentObject.changeEventInfo.changeType))
                {
                    found = true;
                }
            }
            logger.log("");
            Assert.IsTrue(found, "Expected Change Event is not found in received items");
        }
コード例 #12
0
        private cmisObjectListType getAndAssertRelationship(bool includeSubTypes, enumIncludeRelationships relationshipDirection, string typeId, string filter, bool allowableActions, Nullable <long> maxItems, Nullable <long> skipCount)
        {
            RelationshipObject relationship = createAndAssertRelationship(getAndAssertRelationshipTypeId(), getAndAssertRootFolder(), false, false, false);

            string objectId = null;
            enumRelationshipDirection direction = enumRelationshipDirection.either;

            switch (relationshipDirection)
            {
            case enumIncludeRelationships.source:
            {
                objectId  = relationship.SourceObject.ObjectId;
                direction = enumRelationshipDirection.source;
                break;
            }

            case enumIncludeRelationships.target:
            {
                objectId  = relationship.TargetObject.ObjectId;
                direction = enumRelationshipDirection.target;
                break;
            }

            case enumIncludeRelationships.both:
            {
                objectId = relationship.SourceObject.ObjectId;
                break;
            }
            }
            logger.log("[RelationshipService->getObjectRelationships]");
            logger.log("Getting relationships for object with objectId='" + objectId + "', direction=" + relationshipDirection);
            cmisObjectListType response = relationshipServiceClient.getObjectRelationships(getAndAssertRepositoryId(), objectId, includeSubTypes, direction, typeId, filter, allowableActions, maxItems, skipCount, null);

            Assert.IsNotNull(response, "Object Relationships were not returned");
            assertRelationships(objectId, response.objects, relationshipDirection);
            logger.log("Relationships were successfully received");
            logger.log("");
            deleteAndAssertRelationship(relationship);
            return(response);
        }
コード例 #13
0
        public void testGetContentChangesPagination()
        {
            if (getCapabilityChanges().Equals(enumCapabilityChanges.none))
            {
                throw new SkippedException("Content Changes Capability is not supported");
            }
            string changeLogToken                = getAndAssertRepositoryInfo().latestChangeLogToken;
            IList <ChangeEntry>    testData      = createTestData(4, false);
            IList <cmisObjectType> receivedItems = new List <cmisObjectType>();
            bool hasMore = true;

            while (hasMore)
            {
                cmisObjectListType items = receiveAndAssertContentChanges(ref changeLogToken, 3);
                if (items != null)
                {
                    hasMore = items.hasMoreItems;
                    if (items.objects != null)
                    {
                        foreach (cmisObjectType receivedObject in items.objects)
                        {
                            receivedItems.Add(receivedObject);
                        }
                    }
                }
                else
                {
                    hasMore = false;
                }
            }
            cmisObjectListType allReceivedObjects = new cmisObjectListType();

            allReceivedObjects.objects = new cmisObjectType[receivedItems.Count];
            receivedItems.CopyTo(allReceivedObjects.objects, 0);
            foreach (ChangeEntry changeEntry in testData)
            {
                assertContentChanges(allReceivedObjects, changeEntry.Id, changeEntry.ChangeType);
            }
        }
コード例 #14
0
        public void testCheckedOutDocumentsReceving()
        {
            if (!isVersioningAllowed())
            {
                Assert.Skip("Versioning is disabled for current document type");
            }
            string folderId = createAndAssertFolder(getAndAssertRootFolder()).ObjectId;

            string[] hierarchy = createCheckedOutDocumentsHierarchy(folderId, 1 + new Random().Next(MAXIMUM_CHECKEDOUT_DOCS));

            logger.log("Receiving CheckedOutDocuments for folder, folderId=" + folderId + "'");
            logger.log("[NavigationService->getCheckedoutDocs]");
            cmisObjectListType response = navigationServiceClient.getCheckedOutDocs(getAndAssertRepositoryId(), folderId, ANY_PROPERTY_FILTER, null, false, enumIncludeRelationships.none, null, TEXTUAL_ZERO, TEXTUAL_ZERO, null);

            Assert.IsNotNull(response, "Response is null");
            Assert.IsNotNull(response.objects, "Response is empty");
            cmisObjectType[] checkedOutDocuments = response.objects;
            assertObjectCollectionsConsitence(checkedOutDocuments, createObjectsCopy(hierarchy, null, 1, (hierarchy.Length - 1)));
            logger.log("CheckedOutDocuments were successfully received");
            logger.log("");

            objectServiceClient.deleteTree(getAndAssertRepositoryId(), folderId, true, enumUnfileObject.delete, true, null);
        }
コード例 #15
0
 private void assertContentChanges(cmisObjectListType actualObjects, string expectedObjectId, enumTypeOfChanges expectedChangeType)
 {
     bool found = false;
     foreach (cmisObjectType currentObject in actualObjects.objects)
     {
         Assert.IsNotNull(currentObject, "One of the Change Event Entries is in 'not set' state solely");
         Assert.IsNotNull(currentObject.properties, "Properties of one of the Change Event Entries are undefined");
         Assert.IsNotNull(currentObject.changeEventInfo, "ChangeEventInfo of one of the Change Event Entries is undefined");
         String id = (string)searchAndAssertPropertyByName(currentObject.properties.Items, OBJECT_IDENTIFIER_PROPERTY, false);
         Assert.IsNotNull(id, "'cmis:objectId' property of one of the Change Event Entries is undefined");
         logger.log("Recived Change Log Entry [ChangeType='" + currentObject.changeEventInfo.changeType + "', ObjectId='" + id + "']");
         if (expectedObjectId.Equals(id) && expectedChangeType.Equals(currentObject.changeEventInfo.changeType))
         {
             found = true;
         }
     }
     logger.log("");
     Assert.IsTrue(found, "Expected Change Event is not found in received items");
 }
コード例 #16
0
 public void testGetContentChangesPagination()
 {
     if (getCapabilityChanges().Equals(enumCapabilityChanges.none))
     {
         throw new SkippedException("Content Changes Capability is not supported");
     }
     string changeLogToken = getAndAssertRepositoryInfo().latestChangeLogToken;
     IList<ChangeEntry> testData = createTestData(4, false);
     IList<cmisObjectType> receivedItems = new List<cmisObjectType>();
     bool hasMore = true;
     while (hasMore)
     {
         cmisObjectListType items = receiveAndAssertContentChanges(ref changeLogToken, 3);
         if (items != null)
         {
             hasMore = items.hasMoreItems;
             if (items.objects != null)
             {
                 foreach (cmisObjectType receivedObject in items.objects)
                 {
                     receivedItems.Add(receivedObject);
                 }
             }
         }
         else
         {
             hasMore = false;
         }
     }
     cmisObjectListType allReceivedObjects = new cmisObjectListType();
     allReceivedObjects.objects = new cmisObjectType[receivedItems.Count];
     receivedItems.CopyTo(allReceivedObjects.objects, 0);
     foreach (ChangeEntry changeEntry in testData)
     {
         assertContentChanges(allReceivedObjects, changeEntry.Id, changeEntry.ChangeType);
     }
 }