Class DataContent

java.lang.Object
org.alfresco.utility.data.TestData<DataContent>
org.alfresco.utility.data.DataContent
All Implemented Interfaces:
DSL<DataContent>

@Service @Scope("prototype") public class DataContent extends TestData<DataContent>
Utility for creating files and folders, asserting they exist in repository
  • Constructor Details

    • DataContent

      public DataContent()
  • Method Details

    • getContentActions

      public org.alfresco.dataprep.ContentActions getContentActions()
    • usingUser

      public DataContent usingUser(UserModel user)
      Description copied from class: TestData
      Call this method if you want to use another user rather than admin defined in TasProperties properties file
      Specified by:
      usingUser in interface DSL<DataContent>
      Overrides:
      usingUser in class TestData<DataContent>
    • usingAdmin

      public DataContent usingAdmin()
      Description copied from interface: DSL
      Defines the current user to be Admin
      Specified by:
      usingAdmin in interface DSL<DataContent>
      Overrides:
      usingAdmin in class TestData<DataContent>
      Returns:
    • createFolder

      public FolderModel createFolder()
      It will create a new folder in current resource FolderModel newRandomFolder = FolderModel.getRandomFolderModel(); dataContent.usingUser(testUser).usingSite(testSite).createFolder(newRandomFolder);
    • createFolder

      public FolderModel createFolder(FolderModel folderModel)
      This is the entry point of the createFolder() method to make REST API or CMIS call. If the Alfresco version is at least 5.2 then the v1 REST API will be used.
    • createFolder

      public FolderModel createFolder(FolderModel folderModel, boolean useV1API)
      Create a folder.
      Parameters:
      folderModel - The folder to create.
      useV1API - If true then the v1 REST API will be used, otherwise CMIS will be used.
      Returns:
      The folder.
    • createFolderV1Api

      public FolderModel createFolderV1Api(org.alfresco.dataprep.AlfrescoHttpClient client, FolderModel folderModel, String username, String password)
      It will create a random folder in current resource using REST API dataContent.usingUser(testUser).usingSite(testSite).createFolder();
    • createFolderCmisApi

      public FolderModel createFolderCmisApi(String folderName)
      It will create a random folder in current resource using CMIS dataContent.usingUser(testUser).usingSite(testSite).createFolder();
    • deleteContent

      public void deleteContent()
      Use this to delete the last resource, either file or folder dataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent();
    • deleteContentV1RestApi

      public void deleteContentV1RestApi(org.alfresco.dataprep.AlfrescoHttpClient client)
      Use this to delete the last resource, either file or folder using V1 RestApi dataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent();
    • deleteContentCmisApi

      public void deleteContentCmisApi()
      Use this to delete the last resource, either file or folder using CmisApi dataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent();
    • renameContent

      public void renameContent(ContentModel newContent)
      Use this to rename a file or a folder dataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFolder).renameContent(newRepoFolder);
      Parameters:
      newContent -
    • addEmailAlias

      public String addEmailAlias(String alias)
      Add Email Alias aspect (emailserver:aliasable) dataContent.usingSite(testSite).usingResource(testFolder).addEmailAlias("aliasTas");
      Parameters:
      alias -
      Returns:
    • createContent

      public FileModel createContent()
      It will create a new file in current resource FileModel newRandomFile = FileModel.getRandomFileModel(); dataContent.usingUser(testUser).usingSite(testSite).createContent(newRandomFile);
    • createContent

      public FileModel createContent(FileModel fileModel)
      This is the entry point of the createContent() method to make REST API or CMIS call
    • createContentV1Api

      public FileModel createContentV1Api(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel)
      Creates a file using REST API Return the FileModel object on success creation
      Parameters:
      client -
      fileModel -
      Returns:
    • updateContent

      public void updateContent(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel)
      This method updates the content of the created document
      Parameters:
      client -
      fileModel -
    • createContentCmisApi

      public FileModel createContentCmisApi(FileModel fileModel) throws DataPreparationException
      Creates a random document based on CMISUtil.DocumentType passed using CMIS Return the Document object on success creation dataContent.usingSite(site).createContent(sourceFile);
      Parameters:
      fileModel -
      Returns:
      Throws:
      DataPreparationException
    • createContent

      public FileModel createContent(org.alfresco.dataprep.CMISUtil.DocumentType documentType) throws DataPreparationException
      This is the entry point of the createContent() method to make REST API or CMIS call
      Throws:
      DataPreparationException
    • createContentDocTypeV1Api

      public FileModel createContentDocTypeV1Api(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel, org.alfresco.dataprep.CMISUtil.DocumentType documentType)
      Creates a random document based on CMISUtil.DocumentType passed using REST API Return the Document object on success creation dataContent.usingUser(userModel).usingResource(myFolder).createContent(DocumentType.TEXT_PLAIN);
      Parameters:
      client -
      fileModel -
      documentType -
      Returns:
      Throws:
      DataPreparationException
    • updateContent

      public void updateContent(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel, org.alfresco.dataprep.CMISUtil.DocumentType documentType)
      This method updates the content of the created document
      Parameters:
      client -
      fileModel -
      documentType -
    • createContentDocTypeCmisApi

      public FileModel createContentDocTypeCmisApi(org.alfresco.dataprep.CMISUtil.DocumentType documentType) throws DataPreparationException
      Creates a random document based on CMISUtil.DocumentType passed using CMIS Return the Document object on success creation dataContent.usingUser(userModel).usingResource(myFolder).createContent(DocumentType.TEXT_PLAIN);
      Parameters:
      documentType -
      Returns:
      Throws:
      DataPreparationException
    • assertContentExist

      public void assertContentExist() throws TestConfigurationException
      Throws:
      TestConfigurationException
    • assertContentDoesNotExist

      public void assertContentDoesNotExist() throws TestConfigurationException
      Throws:
      TestConfigurationException
    • checkContent

      public boolean checkContent(String fullPath, UserModel userModel) throws TestConfigurationException
      Parameters:
      fullPath - - the full path to CMIS object
      userModel -
      Throws:
      TestConfigurationException
    • waitUntilContentIsDeleted

      public void waitUntilContentIsDeleted(String fullPath)
    • waitUntilContentIsCreated

      public void waitUntilContentIsCreated(String fullPath)
      Wait and retry for 15 seconds checking if a resource is created
      Parameters:
      fullPath -
    • waitUntilContentIsCreatedInLinux

      public void waitUntilContentIsCreatedInLinux(String fullPath)
      Wait and retry for 15 seconds checking if a resource is created for Linux OS
      Parameters:
      fullPath -
    • deleteSite

      public void deleteSite(SiteModel site)
      Delete a site
      Parameters:
      site -
    • deleteTree

      public void deleteTree(FolderModel from)
      Delete parent folder along with all children in it
      Parameters:
      from -
    • setCustomModel

      public void setCustomModel(String localModelXMLFilePath)
      Deploy a custom content model to repository http://docs.alfresco.com/5.1/tasks/deploy-dynamic.html
      Parameters:
      localModelXMLFilePath -
      Throws:
      TestConfigurationException
    • deployContentModel

      public void deployContentModel(String localModelXMLFilePath) throws TestConfigurationException
      Throws:
      TestConfigurationException
    • getCustomModel

      public FileModel getCustomModel()
      Returns customModel file is one exists or is deployed using deployContentModel otherwise null
    • getContentStream

      public org.apache.chemistry.opencmis.commons.data.ContentStream getContentStream(String fileName, String content)
      Create a content stream from some content.
      Parameters:
      fileName - A name for the content stream.
      content - The content.
      Returns:
      The stream.
      Throws:
      IORuntimeException - if there is an issue creating the stream.
    • closeContentStream

      public void closeContentStream(org.apache.chemistry.opencmis.commons.data.ContentStream contentStream)
    • createCustomContent

      public ContentModel createCustomContent(ContentModel contentModel, String objectTypeID, CustomObjectTypeProperties objectTypeProperty)
      Parameters:
      contentModel -
      objectTypeID - Example: objectTypeID = "D:cmis:document"
      Throws:
      IORuntimeException - if there is an issue creating the content.
    • addTagToContent

      public void addTagToContent(TagModel model) throws TestConfigurationException
      Creates a tag for a content file You must use this in correlation with TestData.usingResource(ContentModel)
      Parameters:
      fileModel -
      model - tag model
      Throws:
      TestConfigurationException
    • assertContentHasTag

      public void assertContentHasTag(String cmisObjectPath, TagModel model)
      Verify content has tag
      Parameters:
      cmisObjectPath -
      model -
    • getNodeRef

      public String getNodeRef()
      Returns:
      nodeRef of the current resource used You can use this in correlation with TestData.usingResource(ContentModel) and/or TestData.usingSite(SiteModel), etc.
    • getCMISDocument

      public org.apache.chemistry.opencmis.client.api.Document getCMISDocument(String filePath)
      Get the corresponding CMIS Document Object of a file using only the file path
      Parameters:
      filePath -
      Returns:
      Document
    • getCMISFolder

      public org.apache.chemistry.opencmis.client.api.Folder getCMISFolder(String folderPath)
      Get the corresponding CMIS Folder Object of a file using only the file path
      Parameters:
      filePath -
      Returns:
      Folder
    • addAspect

      public void addAspect(List<XMLAspectData> aspects)
      Adding aspects to ContentModels
      Parameters:
      object -
    • addFileToFavorites

      public void addFileToFavorites(FileModel file) throws DataPreparationException
      Add file to favorites
      Throws:
      DataPreparationException
    • addFolderToFavorites

      public void addFolderToFavorites(FolderModel folder) throws DataPreparationException
      Add folder to favorites
      Throws:
      DataPreparationException
    • assertContentVersionIs

      public void assertContentVersionIs(String version)
      Asserting the version of the content
      Parameters:
      version -
    • assertContentSizeIs

      public void assertContentSizeIs(long sizeInBytes)
      Asserting the size of the content
      Parameters:
      sizeInBytes - size in bytes
    • checkOutDocument

      public void checkOutDocument()
      Check out document
    • cancelCheckOut

      public void cancelCheckOut()
      Check out document
    • updateContent

      public void updateContent(String newContent)
      Update document content
      Parameters:
      newContent -
    • checkIn

      public void checkIn(String newContent, boolean majorVersion, String checkInComment)
      Check in document.
      Parameters:
      newContent -
      majorVersion - true to set major version(e.g. 2.0)
      checkInComment -
    • setInheritPermissions

      public void setInheritPermissions(boolean inheritPermissions)
    • emptyUserTrashcan

      public void emptyUserTrashcan(UserModel user)
    • uploadDocument

      public FileModel uploadDocument(File fileToUpload)