Example #1
0
        public void testQueryPWCSearchable()
        {
            if (enumCapabilityQuery.none.Equals(getQueryAllowed()) || enumCapabilityQuery.fulltextonly.Equals(getQueryAllowed()))
            {
                throw new SkippedException("Metadata query isn't supported");
            }

            if (!isVersioningAllowed() || !isPWCSearchable())
            {
                Assert.Skip("Versioning isn't supported or PWCSearchable is not supported");
            }

            FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.checkedout, false);
            string         query    = "SELECT * FROM " + getAndAssertDocumentQueryName() + " WHERE  " + OBJECT_IDENTIFIER_PROPERTY + "='" + document.ObjectId + "'";

            cmisObjectType[] response = executeAndAssertQuery(query, PAGE_SIZE, 0, false, false, enumIncludeRelationships.none);
            Assert.IsNotNull(response, "response is null");
            Assert.IsTrue((response.Length >= 1), "Expected PWC was not found");
            bool found = false;

            foreach (cmisObjectType cmisObject in response)
            {
                string objectId = (string)searchAndAssertPropertyByName(cmisObject.properties.Items, OBJECT_IDENTIFIER_PROPERTY, false);
                if (document.ObjectId.Equals(objectId))
                {
                    found = true;
                }
            }
            Assert.IsTrue(found, "WorkingCopy was not found in query results");
            cmisExtensionType extension = new cmisExtensionType();

            versioningServiceClient.cancelCheckOut(getAndAssertRepositoryId(), document.ObjectId, ref extension);
        }
Example #2
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);
        }
Example #3
0
        public void testCheckInContentAgainstPwcUpdatableCapability()
        {
            if (!isVersioningAllowed())
            {
                Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE);
            }
            if (!isPwcUpdatable())
            {
                Assert.Skip("PWC is Not Updatable");
            }
            if (!isContentStreamAllowed())
            {
                Assert.Skip("Content Stream is Not Allowed for Document Type");
            }
            FileableObject        document       = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.checkedout, false);
            cmisContentStreamType changedContent = FileableObject.createCmisDocumentContent("Modified.txt", FileableObject.getContentEtry());
            string            objectId           = document.ObjectId;
            string            changeToken        = null;// TODO
            cmisExtensionType extensions         = new cmisExtensionType();

            objectServiceClient.setContentStream(getAndAssertRepositoryId(), ref objectId, true, ref changeToken, changedContent, ref extensions);
            document.setId(objectId);
            document.setId(checkInAndAssert(objectId, true));
            cancelCheckoutAndDeleteDocumentWithAssertion(document.ObjectId);
        }
        public void testAddingObjectWithAllVersions()
        {
            if (!isCapabilityMultifilingEnabled())
            {
                Assert.Skip("Multi-Filing capability is not supported");
            }
            if (!isVersioningAllowed())
            {
                Assert.Skip("Versioning is not supported for " + getAndAssertDocumentTypeId() + " Document Type");
            }
            MultifiledObject  document = createAndAssertMultifilledDocument(getAndAssertRootFolder(), 5);
            string            versionedMultiFilledDocument = createAndAssertVersionedDocument(document.DocumentObject.ObjectId, 5, true);
            FileableObject    folder     = createAndAssertFolder(getAndAssertRootFolder());
            cmisExtensionType extensions = new cmisExtensionType();

            multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.DocumentObject.ObjectId, folder.ObjectId, true, ref extensions);
            cmisObjectInFolderListType children = getAndAssertChildren(folder.ObjectId, "*", null, 10L, 0L, null);

            if (!isVersionSpecificFiling())
            {
                logger.log("Children were received. Version Specific Filing is not supported. 5 Versions were created for document");
                Assert.AreEqual(1, children.objects.Length, "Amount of Children more than 1");
            }
            else
            {
                logger.log("Children were received. Version Specific Filing is supported. 5 Versions were created for document");
                Assert.IsTrue((6 == children.objects.Length), "Amount of Children is not equal to 6");
            }
            deleteAndAssertObject(versionedMultiFilledDocument, true);
            deleteAndAssertObject(folder, false);
            foreach (CmisObject parent in document.Parents)
            {
                deleteAndAssertObject(parent, false);
            }
        }
 public void testAddingFolderObjectToFolder()
 {
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
     }
     string rootFolderId = getAndAssertRootFolder();
     FileableObject parentFolder = createAndAssertFolder(rootFolderId);
     FileableObject childFolder = createAndAssertFolder(rootFolderId);
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), childFolder.ObjectId, parentFolder.ObjectId, false, ref extensions);
         deleteObjectAndLogIfFailed(childFolder, "Folder Object was created but it can't be deleted. Error cause message: ");
         deleteObjectAndLogIfFailed(parentFolder, "Folder Object was created but it can't be deleted. Error cause message: ");
         Assert.Fail("Folder Object can't be Multi-filled");
     }
     catch (Exception e)
     {
         if (e is FaultException<cmisFaultType>)
         {
             deleteAndAssertObject(parentFolder, true);
             deleteAndAssertObject(childFolder, true);
             HashSet<enumServiceException> expected = new HashSet<enumServiceException>();
             expected.Add(enumServiceException.invalidArgument);
             expected.Add(enumServiceException.notSupported);
             expected.Add(enumServiceException.storage);
             assertException((FaultException<cmisFaultType>)e, expected);
         }
         else
         {
             throw e;
         }
     }
 }
        public void testAddingObjectToInvalidFolder()
        {
            if (!isCapabilityMultifilingEnabled())
            {
                Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
            }
            FileableObject document = createAndAssertObject(getAndAssertRootFolder(), null);

            try
            {
                cmisExtensionType extensions = new cmisExtensionType();
                multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.ObjectId, INVALID_OBJECT_ID, false, ref extensions);
                deleteObjectAndLogIfFailed(document, "Document Object was created but it can't be deleted. Error cause message: ");
                Assert.Fail("Document Object was added to Inexistent Folder Object");
            }
            catch (Exception e)
            {
                deleteAndAssertObject(document, true);
                if (e is FaultException <cmisFaultType> )
                {
                    HashSet <enumServiceException> exceptions = new HashSet <enumServiceException>();
                    exceptions.Add(enumServiceException.invalidArgument);
                    exceptions.Add(enumServiceException.objectNotFound);
                    assertException((FaultException <cmisFaultType>)e, exceptions);
                }
                else
                {
                    throw e;
                }
            }
        }
        public void testInvalidRepositoryIdUsing()
        {
            if (!isCapabilityMultifilingEnabled())
            {
                Assert.Skip("Multi-filling is not supported. Test will be skipped...");
            }
            string           rootFolderId = getAndAssertRootFolder();
            MultifiledObject document     = createAndAssertMultifilledDocument(rootFolderId, 2);
            FileableObject   folder       = createAndAssertFolder(rootFolderId);

            logger.log("Invalid Repository Id using for Add Object To Folder service");
            cmisExtensionType extensions = new cmisExtensionType();

            try
            {
                multifilingServiceClient.addObjectToFolder(INVALID_REPOSITORY_ID, document.DocumentObject.ObjectId, folder.ObjectId, false, ref extensions);
                deleteMultiFilledDocumentAndLogIfFailed(document, "Multi-filled Document was created but it can't be deleted. Error cause message: ");
                deleteObjectAndLogIfFailed(folder, "Folder was created but it can't be deleted. Error cause message: ");
                Assert.Fail("Document Object was moved ignoring Invalid Repository Id");
            }
            catch (Exception e)
            {
                deleteAndAssertObject(folder, true);
                if (e is FaultException <cmisFaultType> )
                {
                    assertException((FaultException <cmisFaultType>)e, enumServiceException.invalidArgument);
                }
                else
                {
                    throw e;
                }
            }
            logger.log("Invalid Repository Id using for Remove Object From Folder service");
            try
            {
                multifilingServiceClient.removeObjectFromFolder(INVALID_REPOSITORY_ID, document.DocumentObject.ObjectId, document.Parents[0].ObjectId, ref extensions);
                deleteMultiFilledDocumentAndLogIfFailed(document, "Document was created but it can't be deleted. Error cause message: ");
                Assert.Fail("Document Object was moved ignoring Invalid Repository Id");
            }
            catch (Exception e)
            {
                if (e is FaultException <cmisFaultType> )
                {
                    assertException((FaultException <cmisFaultType>)e, enumServiceException.invalidArgument);
                }
                else
                {
                    throw e;
                }
            }
        }
        public void testAddingObjectToFolderConstraintsObservance()
        {
            if (!isCapabilityMultifilingEnabled())
            {
                Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
            }
            string         folderTypeWithAllowedList = searchForFolderTypeWithAllowingList(getAndAssertRootFolder());
            FileableObject folder = (null == folderTypeWithAllowedList) ? (null) : (createAndAssertObject(true, getAndAssertRootFolder(), folderTypeWithAllowedList));

            if (!isValueNotSet(folder))
            {
                string[]            allowedTypeIds = (string[])searchAndAssertPropertyByName(getAndAssertObjectProperties(folder.ObjectId, folder, true).Items, ALLOWED_CHILDREN_TYPE_IDS, true);
                cmisTypeContainer[] typeDefs       = getAndAssertTypeDescendants(getAndAssertBaseDocumentTypeId(), -1, true);
                string notAllowedDocumentTypeId    = enumerateAndAssertTypesForAction(typeDefs, new SearchForNotAllowedDocumentTypeIdAction(allowedTypeIds), true);
                if (!isValueNotSet(notAllowedDocumentTypeId))
                {
                    FileableObject document = createAndAssertObject(false, getAndAssertRootFolder(), notAllowedDocumentTypeId);
                    try
                    {
                        cmisExtensionType extensions = new cmisExtensionType();
                        multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.ObjectId, folder.ObjectId, false, ref extensions);
                        deleteObjectAndLogIfFailed(document, ("Document with Restricted by " + folderTypeWithAllowedList + " Folder Object Type Id was created but it can't be deleted. Error cause message: "));
                        deleteObjectAndLogIfFailed(folder, ("Folder Object with " + folderTypeWithAllowedList + " Type Id was created but it can't be deleted. Error cause message: "));
                        Assert.Fail("Object was added to Folder that is not Allow Children Objects with " + notAllowedDocumentTypeId + " Type Id");
                    }
                    catch (Exception e)
                    {
                        try
                        {
                            deleteAndAssertObject(document, true);
                        }
                        catch (Exception e1)
                        {
                            deleteAndAssertObject(folder, true);
                            throw e1;
                        }
                        if (e is FaultException <cmisFaultType> )
                        {
                            assertException((FaultException <cmisFaultType>)e, enumServiceException.constraint);
                        }
                        else
                        {
                            throw e;
                        }
                    }
                }
                deleteAndAssertObject(folder, true);
            }
        }
        private void applyAndAssertPolicy(string policyId, string objectId)
        {
            cmisExtensionType extension = new cmisExtensionType();

            try
            {
                logger.log("[PolicyService->applyPolicy]");
                logger.log("Applying to Object with Id='" + objectId + "' Policy with Id='" + policyId + "'");
                policyServiceClient.applyPolicy(getAndAssertRepositoryId(), policyId, objectId, ref extension);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Example #10
0
 private void cancelCheckoutAndAssertWithExpectedException(string repositoryId, string documentId, HashSet <enumServiceException> expectedExceptions, string caseMessage)
 {
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         logger.log("[VersioningService->cancelCheckOut()]");
         versioningServiceClient.cancelCheckOut(repositoryId, documentId, ref extensions);
         logger.log("Expected exception during Check Out Cancelling with " + caseMessage + " was not thrown");
     }
     catch (FaultException <cmisFaultType> e)
     {
         assertException(e, expectedExceptions);
     }
     catch (Exception e)
     {
         deleteAndAssertObject(documentId);
         throw e;
     }
 }
 public void testRemovingInvalidObjectFromFolder()
 {
     if (!isCapabilityUnfilingEnabled() && !isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Un-Filling and Multi-filling capabilities are not supported. Test will be skipped...");
     }
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         multifilingServiceClient.removeObjectFromFolder(getAndAssertRepositoryId(), INVALID_OBJECT_ID, getAndAssertRootFolder(), ref extensions);
         Assert.Fail("Inexistent Object was removed from folder");
     }
     catch (FaultException <cmisFaultType> e)
     {
         HashSet <enumServiceException> exceptions = new HashSet <enumServiceException>();
         exceptions.Add(enumServiceException.invalidArgument);
         exceptions.Add(enumServiceException.objectNotFound);
         assertException(e, exceptions);
     }
 }
 public void testAddingInvalidObjectToFolder()
 {
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
     }
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), INVALID_OBJECT_ID, getAndAssertRootFolder(), false, ref extensions);
         Assert.Fail("Inexistent Object was added to Folder Object");
     }
     catch (FaultException <cmisFaultType> e)
     {
         HashSet <enumServiceException> exceptions = new HashSet <enumServiceException>();
         exceptions.Add(enumServiceException.invalidArgument);
         exceptions.Add(enumServiceException.objectNotFound);
         assertException(e, exceptions);
     }
 }
        public void testRemovingObjectFromFolderAgainsUnfilingCapability()
        {
            string rootFolderId = getAndAssertRootFolder();

            if (!isCapabilityMultifilingEnabled())
            {
                Assert.Skip("Multi-Filing capability is not supported");
            }
            MultifiledObject  multiFilledDocument = createAndAssertMultifilledDocument(rootFolderId, 1);
            cmisExtensionType extensions          = new cmisExtensionType();

            if (!isCapabilityUnfilingEnabled())
            {
                logger.log("Un-Filing capability is not supported!");
                try
                {
                    multifilingServiceClient.removeObjectFromFolder(getAndAssertRepositoryId(), multiFilledDocument.DocumentObject.ObjectId, null, ref extensions);
                    deleteMultiFilledDocumentAndLogIfFailed(multiFilledDocument, "Multi-filled Document was created but it can't be deleted. Error cause message: ");
                    Assert.Fail("Un-Filing capability is not supported but Object was removed from all Parent Folder Objects");
                }
                catch (Exception e)
                {
                    deleteAndAssertMultifilledDocument(multiFilledDocument);
                    if (e is FaultException <cmisFaultType> )
                    {
                        assertException((FaultException <cmisFaultType>)e, null);
                    }
                    else
                    {
                        throw e;
                    }
                }
            }
            else
            {
                logger.log("Un-Filing is supported!");
                multifilingServiceClient.removeObjectFromFolder(getAndAssertRepositoryId(), multiFilledDocument.DocumentObject.ObjectId, null, ref extensions);
                deleteAndAssertMultifilledDocument(multiFilledDocument);
            }
        }
 public override void initialize(string testName)
 {
     if (arePoliciesAllowed())
     {
         string typeId = getAndAssertPolicyControllableTypeId();
         if (null != typeId)
         {
             cmisExtensionType extension = new cmisExtensionType();
             cmisPropertiesType properties = FileableObject.addPropertyToObject(null, NAME_PROPERTY, FileableObject.generateObjectName(true, "Policy"));
             FileableObject.addPropertyToObject(properties, TYPE_ID_PROPERTY, getAndAssertPolicyTypeId());
             policyId = objectServiceClient.createPolicy(getAndAssertRepositoryId(), properties, getAndAssertRootFolder(), null, null, null, ref extension);
         }
         if (null != typeId)
         {
             cmisTypeDefinitionType typeDefinition = getAndAssertTypeDefinition(typeId);
             policyControllableObject = createAndAssertObject(typeDefinition is cmisTypeFolderDefinitionType, getAndAssertRootFolder(), typeId);
         }
         else
         {
             policyControllableObject = createAndAssertObject(getAndAssertRootFolder(), null);
         }
     }
 }
 public override void initialize(string testName)
 {
     if (arePoliciesAllowed())
     {
         string typeId = getAndAssertPolicyControllableTypeId();
         if (null != typeId)
         {
             cmisExtensionType  extension  = new cmisExtensionType();
             cmisPropertiesType properties = FileableObject.addPropertyToObject(null, NAME_PROPERTY, FileableObject.generateObjectName(true, "Policy"));
             FileableObject.addPropertyToObject(properties, TYPE_ID_PROPERTY, getAndAssertPolicyTypeId());
             policyId = objectServiceClient.createPolicy(getAndAssertRepositoryId(), properties, getAndAssertRootFolder(), null, null, null, ref extension);
         }
         if (null != typeId)
         {
             cmisTypeDefinitionType typeDefinition = getAndAssertTypeDefinition(typeId);
             policyControllableObject = createAndAssertObject(typeDefinition is cmisTypeFolderDefinitionType, getAndAssertRootFolder(), typeId);
         }
         else
         {
             policyControllableObject = createAndAssertObject(getAndAssertRootFolder(), null);
         }
     }
 }
Example #16
0
 private void checkInAndAssertWithExpectedException(string repositoryId, string checkedoutDocumentId, Nullable <bool> major, cmisPropertiesType properties, cmisContentStreamType content, string checkInComment, HashSet <enumServiceException> expectedExceptions, string caseMessage)
 {
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         logger.log("[VersioningService->checkIn()]");
         // TODO: applyPolicies, addACEs, removeACEs
         versioningServiceClient.checkIn(repositoryId, ref checkedoutDocumentId, major, properties, content, checkInComment, null, null, null, ref extensions);
         logger.log("Expected exception during All Versions Receiving with " + caseMessage + " was not thrown");
     }
     catch (FaultException <cmisFaultType> e)
     {
         if (expectedExceptions != null && expectedExceptions.Count > 0)
         {
             assertException(e, expectedExceptions);
         }
     }
     catch (Exception e)
     {
         cancelCheckoutAndDeleteDocumentWithAssertion(checkedoutDocumentId);
         throw e;
     }
 }
        public void testAddingFolderObjectToFolder()
        {
            if (!isCapabilityMultifilingEnabled())
            {
                Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
            }
            string         rootFolderId = getAndAssertRootFolder();
            FileableObject parentFolder = createAndAssertFolder(rootFolderId);
            FileableObject childFolder  = createAndAssertFolder(rootFolderId);

            try
            {
                cmisExtensionType extensions = new cmisExtensionType();
                multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), childFolder.ObjectId, parentFolder.ObjectId, false, ref extensions);
                deleteObjectAndLogIfFailed(childFolder, "Folder Object was created but it can't be deleted. Error cause message: ");
                deleteObjectAndLogIfFailed(parentFolder, "Folder Object was created but it can't be deleted. Error cause message: ");
                Assert.Fail("Folder Object can't be Multi-filled");
            }
            catch (Exception e)
            {
                if (e is FaultException <cmisFaultType> )
                {
                    deleteAndAssertObject(parentFolder, true);
                    deleteAndAssertObject(childFolder, true);
                    HashSet <enumServiceException> expected = new HashSet <enumServiceException>();
                    expected.Add(enumServiceException.invalidArgument);
                    expected.Add(enumServiceException.notSupported);
                    expected.Add(enumServiceException.storage);
                    assertException((FaultException <cmisFaultType>)e, expected);
                }
                else
                {
                    throw e;
                }
            }
        }
        public void testQueryPWCSearchable()
        {
            if (enumCapabilityQuery.none.Equals(getQueryAllowed()) || enumCapabilityQuery.fulltextonly.Equals(getQueryAllowed()))
            {
                throw new SkippedException("Metadata query isn't supported");
            }

            if (!isVersioningAllowed() || !isPWCSearchable())
            {
                Assert.Skip("Versioning isn't supported or PWCSearchable is not supported");
            }

            FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.checkedout, false);
            string query = "SELECT * FROM " + getAndAssertDocumentQueryName() + " WHERE  " + OBJECT_IDENTIFIER_PROPERTY + "='" + document.ObjectId + "'";
            cmisObjectType[] response = executeAndAssertQuery(query, PAGE_SIZE, 0, false, false, enumIncludeRelationships.none);
            Assert.IsNotNull(response, "response is null");
            Assert.IsTrue((response.Length >= 1), "Expected PWC was not found");
            bool found = false;
            foreach (cmisObjectType cmisObject in response)
            {
                string objectId = (string)searchAndAssertPropertyByName(cmisObject.properties.Items, OBJECT_IDENTIFIER_PROPERTY, false);
                if (document.ObjectId.Equals(objectId))
                {
                    found = true;
                }
            }
            Assert.IsTrue(found, "WorkingCopy was not found in query results");
            cmisExtensionType extension = new cmisExtensionType();
            versioningServiceClient.cancelCheckOut(getAndAssertRepositoryId(), document.ObjectId, ref extension);
        }
        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);
        }
 public void testInvalidRepositoryIdUsing()
 {
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-filling is not supported. Test will be skipped...");
     }
     string rootFolderId = getAndAssertRootFolder();
     MultifiledObject document = createAndAssertMultifilledDocument(rootFolderId, 2);
     FileableObject folder = createAndAssertFolder(rootFolderId);
     logger.log("Invalid Repository Id using for Add Object To Folder service");
     cmisExtensionType extensions = new cmisExtensionType();
     try
     {
         multifilingServiceClient.addObjectToFolder(INVALID_REPOSITORY_ID, document.DocumentObject.ObjectId, folder.ObjectId, false, ref extensions);
         deleteMultiFilledDocumentAndLogIfFailed(document, "Multi-filled Document was created but it can't be deleted. Error cause message: ");
         deleteObjectAndLogIfFailed(folder, "Folder was created but it can't be deleted. Error cause message: ");
         Assert.Fail("Document Object was moved ignoring Invalid Repository Id");
     }
     catch (Exception e)
     {
         deleteAndAssertObject(folder, true);
         if (e is FaultException<cmisFaultType>)
         {
             assertException((FaultException<cmisFaultType>)e, enumServiceException.invalidArgument);
         }
         else
         {
             throw e;
         }
     }
     logger.log("Invalid Repository Id using for Remove Object From Folder service");
     try
     {
         multifilingServiceClient.removeObjectFromFolder(INVALID_REPOSITORY_ID, document.DocumentObject.ObjectId, document.Parents[0].ObjectId, ref extensions);
         deleteMultiFilledDocumentAndLogIfFailed(document, "Document was created but it can't be deleted. Error cause message: ");
         Assert.Fail("Document Object was moved ignoring Invalid Repository Id");
     }
     catch (Exception e)
     {
         if (e is FaultException<cmisFaultType>)
         {
             assertException((FaultException<cmisFaultType>)e, enumServiceException.invalidArgument);
         }
         else
         {
             throw e;
         }
     }
 }
 public void testAddingObjectToFolderConstraintsObservance()
 {
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
     }
     string folderTypeWithAllowedList = searchForFolderTypeWithAllowingList(getAndAssertRootFolder());
     FileableObject folder = (null == folderTypeWithAllowedList) ? (null) : (createAndAssertObject(true, getAndAssertRootFolder(), folderTypeWithAllowedList));
     if (!isValueNotSet(folder))
     {
         string[] allowedTypeIds = (string[])searchAndAssertPropertyByName(getAndAssertObjectProperties(folder.ObjectId, folder, true).Items, ALLOWED_CHILDREN_TYPE_IDS, true);
         cmisTypeContainer[] typeDefs = getAndAssertTypeDescendants(getAndAssertBaseDocumentTypeId(), -1, true);
         string notAllowedDocumentTypeId = enumerateAndAssertTypesForAction(typeDefs, new SearchForNotAllowedDocumentTypeIdAction(allowedTypeIds), true);
         if (!isValueNotSet(notAllowedDocumentTypeId))
         {
             FileableObject document = createAndAssertObject(false, getAndAssertRootFolder(), notAllowedDocumentTypeId);
             try
             {
                 cmisExtensionType extensions = new cmisExtensionType();
                 multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.ObjectId, folder.ObjectId, false, ref extensions);
                 deleteObjectAndLogIfFailed(document, ("Document with Restricted by " + folderTypeWithAllowedList + " Folder Object Type Id was created but it can't be deleted. Error cause message: "));
                 deleteObjectAndLogIfFailed(folder, ("Folder Object with " + folderTypeWithAllowedList + " Type Id was created but it can't be deleted. Error cause message: "));
                 Assert.Fail("Object was added to Folder that is not Allow Children Objects with " + notAllowedDocumentTypeId + " Type Id");
             }
             catch (Exception e)
             {
                 try
                 {
                     deleteAndAssertObject(document, true);
                 }
                 catch (Exception e1)
                 {
                     deleteAndAssertObject(folder, true);
                     throw e1;
                 }
                 if (e is FaultException<cmisFaultType>)
                 {
                     assertException((FaultException<cmisFaultType>)e, enumServiceException.constraint);
                 }
                 else
                 {
                     throw e;
                 }
             }
         }
         deleteAndAssertObject(folder, true);
     }
 }
 public void testAddingInvalidObjectToFolder()
 {
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
     }
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), INVALID_OBJECT_ID, getAndAssertRootFolder(), false, ref extensions);
         Assert.Fail("Inexistent Object was added to Folder Object");
     }
     catch (FaultException<cmisFaultType> e)
     {
         HashSet<enumServiceException> exceptions = new HashSet<enumServiceException>();
         exceptions.Add(enumServiceException.invalidArgument);
         exceptions.Add(enumServiceException.objectNotFound);
         assertException(e, exceptions);
     }
 }
 public void cancelCheckOutAndAssert(string checkedOutDocumentId)
 {
     logger.log("[VersioningService->cancelCheckOut]");
     logger.log("Canceling check out document, objectId='" + checkedOutDocumentId + "'");
     cmisExtensionType extension = new cmisExtensionType();
     versioningServiceClient.cancelCheckOut(getAndAssertRepositoryId(), checkedOutDocumentId, ref extension);
     assertObjectAbsence(checkedOutDocumentId);
     logger.log("Check out was cancelled successfully");
 }
 protected string checkInAndAssert(string documentId, bool major, bool assertProperties)
 {
     if (isVersioningAllowed())
     {
         assertCheckedOutDocument(documentId, getAndAssertDocumentTypeId(), null, true);
     }
     logger.log("[VersioningService->checkIn]");
     logger.log("Checkining document='" + documentId + "'");
     cmisContentStreamType checkInContent = FileableObject.createCmisDocumentContent((CHANGED_NAME + ".txt"), checkinContentEntry);
     cmisExtensionType extension = new cmisExtensionType();
     versioningServiceClient.checkIn(getAndAssertRepositoryId(), ref documentId, major, new cmisPropertiesType(), ((isContentStreamAllowed()) ? (checkInContent) : (null)), CHECKIN_COMMENT, null, null, null, ref extension);
     if (assertProperties)
     {
         getAndAssertLatestVersionProperties(documentId, ANY_PROPERTY_FILTER, major);
         if (isContentStreamAllowed())
         {
             receiveAndAssertContentStream(documentId, checkInContent.stream);
         }
     }
     logger.log("Document was Checked In successfully");
     logger.log("");
     return documentId;
 }
 // FIXME: [BUG] because of changing our code in DMServicePortThrowsAdvice
 private void checkoutAndAssertWithExpectedException(string repositoryId, string documentId, bool forceCanceling, HashSet<enumServiceException> expectedExceptions, string caseMessage)
 {
     try
     {
         string checkedoutDocumentId = documentId;
         cmisExtensionType extensions = new cmisExtensionType();
         logger.log("[VersioningService->checkOut()]");
         versioningServiceClient.checkOut(repositoryId, ref checkedoutDocumentId, ref extensions);
         logger.log("Expected exception during Check Outing with " + caseMessage + " was not thrown");
         if (forceCanceling)
         {
             cancelCheckOutAndAssert(checkedoutDocumentId);
         }
     }
     catch (FaultException<cmisFaultType> e)
     {
         assertException(e, expectedExceptions);
     }
     catch (Exception e)
     {
         deleteAndAssertObject(documentId);
         throw e;
     }
 }
 protected string updatePropertiesUsingCredentials(string objectId, string username, string password)
 {
     string changeToken = "";
     cmisExtensionType extension = new cmisExtensionType();
     cmisPropertiesType objectProperties = new cmisPropertiesType();
     objectProperties.Items = new cmisProperty[1];
     objectProperties.Items[0] = new cmisPropertyString();
     objectProperties.Items[0].propertyDefinitionId = NAME_PROPERTY;
     ((cmisPropertyString)objectProperties.Items[0]).value = new string[] { FileableObject.generateObjectName(false, "_renamed") };
     logger.log("[ObjectService->updateProperties]");
     objectServiceClient.updateProperties(repositoryId, ref objectId, ref changeToken, objectProperties, ref extension);
     Assert.IsNotNull(objectId, "Returned objectId is null");
     return objectId;
 }
 public MultifiledObject createAndAssertMultifilledDocument(string primaryParentId, int parentsAmount)
 {
     FileableObject document = createAndAssertObject(new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertDocumentTypeId(), primaryParentId));
     FileableObject[] parents = new FileableObject[parentsAmount];
     logger.log("Adding parents for document, documentId='" + document.ObjectId + "'");
     string repositoryId = getAndAssertRepositoryId();
     for (int i = 0; i < parentsAmount; i++)
     {
         parents[i] = createAndAssertObject(new FileableObject(enumTypesOfFileableObjects.folders, getAndAssertFolderTypeId(), primaryParentId));
         logger.log("[MultiFilingService->addObjectToFolder]");
         logger.log("Adding Parent for Document, documentId='" + document.ObjectId + "',parentId='" + parents[i].ObjectId + "'");
         try
         {
             cmisExtensionType extension = new cmisExtensionType();
             multifilingServiceClient.addObjectToFolder(repositoryId, document.ObjectId, parents[i].ObjectId, false, ref extension);
         }
         catch (System.Exception e)
         {
             Assert.Fail("Adding Parent for Document with Id=" + document.ObjectId + " was failed. Error: " + e.Message);
         }
         logger.log("");
     }
     logger.log("Parents were successfully added");
     return new MultifiledObject(document, parents);
 }
 public string checkOutAndAssert(string documentId, string objectTypeId, byte[] expectedContent)
 {
     cmisExtensionType extension = new cmisExtensionType();
     logger.log("[VersioningService->checkOut]");
     bool copied = versioningServiceClient.checkOut(getAndAssertRepositoryId(), ref documentId, ref extension);
     assertCheckedOutDocument(documentId, objectTypeId, expectedContent, copied);
     logger.log("Document was successfully Checked Out. PWC Id='" + documentId + "'");
     logger.log("");
     return documentId;
 }
 private void removeAndAssertPolicy(string policyId, string objectId)
 {
     cmisExtensionType extension = new cmisExtensionType();
     try
     {
         logger.log("[PolicyService->removePolicy]");
         logger.log("Removing from Object with Id='" + objectId + "' Policy with Id='" + policyId + "'");
         policyServiceClient.removePolicy(getAndAssertRepositoryId(), policyId, objectId, ref extension);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
 public static void deleteAndAssertObject(string objectId, bool allVersions)
 {
     logger.log("[ObjectService->deleteObject]");
     string repositoryId = getAndAssertRepositoryId();
     logger.log("Deleting Object from repository, repositoryId='" + repositoryId + "', Object Id=" + objectId + "'");
     cmisExtensionType extension = new cmisExtensionType();
     objectServiceClient.deleteObject(repositoryId, objectId, allVersions, ref extension);
     assertObjectAbsence(objectId);
     logger.log("Object was successfully deleted");
     logger.log("");
 }
 public void testRemovingObjectFromFolderAgainsUnfilingCapability()
 {
     string rootFolderId = getAndAssertRootFolder();
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-Filing capability is not supported");
     }
     MultifiledObject multiFilledDocument = createAndAssertMultifilledDocument(rootFolderId, 1);
     cmisExtensionType extensions = new cmisExtensionType();
     if (!isCapabilityUnfilingEnabled())
     {
         logger.log("Un-Filing capability is not supported!");
         try
         {
             multifilingServiceClient.removeObjectFromFolder(getAndAssertRepositoryId(), multiFilledDocument.DocumentObject.ObjectId, null, ref extensions);
             deleteMultiFilledDocumentAndLogIfFailed(multiFilledDocument, "Multi-filled Document was created but it can't be deleted. Error cause message: ");
             Assert.Fail("Un-Filing capability is not supported but Object was removed from all Parent Folder Objects");
         }
         catch (Exception e)
         {
             deleteAndAssertMultifilledDocument(multiFilledDocument);
             if (e is FaultException<cmisFaultType>)
             {
                 assertException((FaultException<cmisFaultType>)e, null);
             }
             else
             {
                 throw e;
             }
         }
     }
     else
     {
         logger.log("Un-Filing is supported!");
         multifilingServiceClient.removeObjectFromFolder(getAndAssertRepositoryId(), multiFilledDocument.DocumentObject.ObjectId, null, ref extensions);
         deleteAndAssertMultifilledDocument(multiFilledDocument);
     }
 }
 protected override CmisObject performCreation()
 {
     logger.log("[ObjectService->createRelationship]");
     logger.log("Creating Relationship, Source Object Id='" + sourceObject.ObjectId + "',Target Object Id='" + targetObject.ObjectId + "'");
     cmisExtensionType extension = new cmisExtensionType();
     cmisPropertiesType properties = FileableObject.addPropertyToObject(null, TYPE_ID_PROPERTY, relationshipTypeId);
     properties = FileableObject.addPropertyToObject(properties, SOURCE_OBJECT_ID, sourceObject.ObjectId);
     properties = FileableObject.addPropertyToObject(properties, TARGET_OBJECT_ID, targetObject.ObjectId);
     string relationshipId = objectServiceClient.createRelationship(getAndAssertRepositoryId(), properties, null, null, null, ref extension);
     setObjectId(relationshipId);
     return this;
 }
 private void checkInAndAssertWithExpectedException(string repositoryId, string checkedoutDocumentId, Nullable<bool> major, cmisPropertiesType properties, cmisContentStreamType content, string checkInComment, HashSet<enumServiceException> expectedExceptions, string caseMessage)
 {
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         logger.log("[VersioningService->checkIn()]");
         // TODO: applyPolicies, addACEs, removeACEs
         versioningServiceClient.checkIn(repositoryId, ref checkedoutDocumentId, major, properties, content, checkInComment, null, null, null, ref extensions);
         logger.log("Expected exception during All Versions Receiving with " + caseMessage + " was not thrown");
     }
     catch (FaultException<cmisFaultType> e)
     {
         if (expectedExceptions != null && expectedExceptions.Count > 0)
         {
             assertException(e, expectedExceptions);
         }
     }
     catch (Exception e)
     {
         cancelCheckoutAndDeleteDocumentWithAssertion(checkedoutDocumentId);
         throw e;
     }
 }
 protected override CmisObject performCreation()
 {
     string repositoryId = getAndAssertRepositoryId();
     string result = null;
     if (IsFolder)
     {
         logger.log("[ObjectService->createFolder]");
         logger.log("Creating folder in repository with repositoryId='" + repositoryId + "',objectParentId='" + ObjectParentId + "'");
         cmisExtensionType extension = new cmisExtensionType();
         result = objectServiceClient.createFolder(repositoryId, getObjectProperties(false), ObjectParentId, null, addACEs, removeACEs, ref extension);
         logger.log("Folder was created, folderId='" + result + "'");
     }
     else
     {
         logger.log("[ObjectService->createDocument]");
         logger.log("Creating document in repository with repositoryId='" + repositoryId + "',objectParentId='" + ObjectParentId + "'");
         cmisExtensionType extension = new cmisExtensionType();
         result = objectServiceClient.createDocument(repositoryId, getObjectProperties(false), ObjectParentId, ContentStream, InitialVersion, null, addACEs, removeACEs, ref extension);
         logger.log("Document was created, objectId='" + result + "'");
     }
     logger.log("");
     setObjectId(result);
     return this;
 }
 public void testAddingObjectWithAllVersions()
 {
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-Filing capability is not supported");
     }
     if (!isVersioningAllowed())
     {
         Assert.Skip("Versioning is not supported for " + getAndAssertDocumentTypeId() + " Document Type");
     }
     MultifiledObject document = createAndAssertMultifilledDocument(getAndAssertRootFolder(), 5);
     string versionedMultiFilledDocument = createAndAssertVersionedDocument(document.DocumentObject.ObjectId, 5, true);
     FileableObject folder = createAndAssertFolder(getAndAssertRootFolder());
     cmisExtensionType extensions = new cmisExtensionType();
     multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.DocumentObject.ObjectId, folder.ObjectId, true, ref extensions);
     cmisObjectInFolderListType children = getAndAssertChildren(folder.ObjectId, "*", null, 10L, 0L, null);
     if (!isVersionSpecificFiling())
     {
         logger.log("Children were received. Version Specific Filing is not supported. 5 Versions were created for document");
         Assert.AreEqual(1, children.objects.Length, "Amount of Children more than 1");
     }
     else
     {
         logger.log("Children were received. Version Specific Filing is supported. 5 Versions were created for document");
         Assert.IsTrue((6 == children.objects.Length), "Amount of Children is not equal to 6");
     }
     deleteAndAssertObject(versionedMultiFilledDocument, true);
     deleteAndAssertObject(folder, false);
     foreach (CmisObject parent in document.Parents)
     {
         deleteAndAssertObject(parent, false);
     }
 }
 public void testAddingObjectToInvalidFolder()
 {
     if (!isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Multi-filing capability is not supported! Test will be skipped...");
     }
     FileableObject document = createAndAssertObject(getAndAssertRootFolder(), null);
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.ObjectId, INVALID_OBJECT_ID, false, ref extensions);
         deleteObjectAndLogIfFailed(document, "Document Object was created but it can't be deleted. Error cause message: ");
         Assert.Fail("Document Object was added to Inexistent Folder Object");
     }
     catch (Exception e)
     {
         deleteAndAssertObject(document, true);
         if (e is FaultException<cmisFaultType>)
         {
             HashSet<enumServiceException> exceptions = new HashSet<enumServiceException>();
             exceptions.Add(enumServiceException.invalidArgument);
             exceptions.Add(enumServiceException.objectNotFound);
             assertException((FaultException<cmisFaultType>)e, exceptions);
         }
         else
         {
             throw e;
         }
     }
 }
 public void deleteAndAssertFolder(string folderId, bool notEmptyBehaviour)
 {
     try
     {
         logger.log("[ObjectService->deleteObject]");
         string repositoryId = getAndAssertRepositoryId();
         logger.log("Deleting folder in repositoryId='" + repositoryId + "',folderId=" + folderId + "'");
         cmisExtensionType extension = new cmisExtensionType();
         objectServiceClient.deleteObject(repositoryId, folderId, false, ref extension);
         determineAssertionFailed(notEmptyBehaviour, "Not empty Folder was deleted");
         logger.log("Folder was successfully deleted");
     }
     catch (Exception e)
     {
         if (e is Assert.AssertionException)
         {
             throw e;
         }
         determineAssertionFailed(!notEmptyBehaviour, e.Message);
     }
     if (!notEmptyBehaviour)
     {
         assertObjectAbsence(folderId);
     }
 }
 public void testRemovingInvalidObjectFromFolder()
 {
     if (!isCapabilityUnfilingEnabled() && !isCapabilityMultifilingEnabled())
     {
         Assert.Skip("Un-Filling and Multi-filling capabilities are not supported. Test will be skipped...");
     }
     try
     {
         cmisExtensionType extensions = new cmisExtensionType();
         multifilingServiceClient.removeObjectFromFolder(getAndAssertRepositoryId(), INVALID_OBJECT_ID, getAndAssertRootFolder(), ref extensions);
         Assert.Fail("Inexistent Object was removed from folder");
     }
     catch (FaultException<cmisFaultType> e)
     {
         HashSet<enumServiceException> exceptions = new HashSet<enumServiceException>();
         exceptions.Add(enumServiceException.invalidArgument);
         exceptions.Add(enumServiceException.objectNotFound);
         assertException(e, exceptions);
     }
 }
        public void deleteAndAssertMultifilledDocument(MultifiledObject multifiledDocument)
        {
            if (isValueNotSet(multifiledDocument.DocumentObject))
            {
                return;
            }
            if (!isValueNotSet(multifiledDocument.Parents))
            {
                logger.log("Removing Parents for Document, documentId='" + multifiledDocument.DocumentObject.ObjectId + "'");
                string repositoryId = getAndAssertRepositoryId();
                foreach (FileableObject parent in multifiledDocument.Parents)
                {
                    if (isValueNotSet(parent) || isValueNotSet(parent.ObjectId))
                    {
                        logger.log("Invalid undefined Parent Object was faced");
                        continue;
                    }
                    logger.log("");
                    logger.log("Removing Parent with parentId='" + parent.ObjectId + "'");
                    logger.log("[MultiFilingService->removeObjectFromFolder]");
                    cmisExtensionType extension = new cmisExtensionType();
                    multifilingServiceClient.removeObjectFromFolder(repositoryId, multifiledDocument.DocumentObject.ObjectId, parent.ObjectId, ref extension);
                    logger.log("");
                    deleteAndAssertFolder(parent, false);
                }
                logger.log("Parents were successfully removed");
            }
            else
            {
                logger.log("Parents' list of Document with Id='" + multifiledDocument.DocumentObject.ObjectId + "' is empty");
            }

            deleteAndAssertObject(multifiledDocument.DocumentObject, true);
        }
 public void testCheckInContentAgainstPwcUpdatableCapability()
 {
     if (!isVersioningAllowed())
     {
         Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE);
     }
     if (!isPwcUpdatable())
     {
         Assert.Skip("PWC is Not Updatable");
     }
     if (!isContentStreamAllowed())
     {
         Assert.Skip("Content Stream is Not Allowed for Document Type");
     }
     FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.checkedout, false);
     cmisContentStreamType changedContent = FileableObject.createCmisDocumentContent("Modified.txt", FileableObject.getContentEtry());
     string objectId = document.ObjectId;
     string changeToken = null; // TODO
     cmisExtensionType extensions = new cmisExtensionType();
     objectServiceClient.setContentStream(getAndAssertRepositoryId(), ref objectId, true, ref changeToken, changedContent, ref extensions);
     document.setId(objectId);
     document.setId(checkInAndAssert(objectId, true));
     cancelCheckoutAndDeleteDocumentWithAssertion(document.ObjectId);
 }