Package org.alfresco.utility.data
Class DataContent
- All Implemented Interfaces:
DSL<DataContent>
Utility for creating files and folders, asserting they exist in repository
-
Field Summary
Fields inherited from class org.alfresco.utility.data.TestData
currentUser, EMAIL, PASSWORD, tasProperties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAspect(List<XMLAspectData> aspects) Adding aspects to ContentModelsaddEmailAlias(String alias) Add Email Alias aspect (emailserver:aliasable)dataContent.usingSite(testSite).usingResource(testFolder).addEmailAlias("aliasTas");voidaddFileToFavorites(FileModel file) Add file to favoritesvoidaddFolderToFavorites(FolderModel folder) Add folder to favoritesvoidaddTagToContent(TagModel model) Creates a tag for a content file You must use this in correlation withTestData.usingResource(ContentModel)voidvoidvoidassertContentHasTag(String cmisObjectPath, TagModel model) Verify content has tagvoidassertContentSizeIs(long sizeInBytes) Asserting the size of the contentvoidassertContentVersionIs(String version) Asserting the version of the contentvoidCheck out documentbooleancheckContent(String fullPath, UserModel userModel) voidCheck in document.voidCheck out documentvoidcloseContentStream(org.apache.chemistry.opencmis.commons.data.ContentStream contentStream) It will create a new file in current resourceFileModel newRandomFile = FileModel.getRandomFileModel(); dataContent.usingUser(testUser).usingSite(testSite).createContent(newRandomFile);createContent(org.alfresco.dataprep.CMISUtil.DocumentType documentType) This is the entry point of the createContent() method to make REST API or CMIS callcreateContent(FileModel fileModel) This is the entry point of the createContent() method to make REST API or CMIS callcreateContentCmisApi(FileModel fileModel) Creates a random document based onCMISUtil.DocumentTypepassed using CMIS Return theDocumentobject on success creationdataContent.usingSite(site).createContent(sourceFile);createContentDocTypeCmisApi(org.alfresco.dataprep.CMISUtil.DocumentType documentType) Creates a random document based onCMISUtil.DocumentTypepassed using CMIS Return theDocumentobject on success creationdataContent.usingUser(userModel).usingResource(myFolder).createContent(DocumentType.TEXT_PLAIN);createContentDocTypeV1Api(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel, org.alfresco.dataprep.CMISUtil.DocumentType documentType) Creates a random document based onCMISUtil.DocumentTypepassed using REST API Return theDocumentobject on success creationdataContent.usingUser(userModel).usingResource(myFolder).createContent(DocumentType.TEXT_PLAIN);createContentV1Api(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel) Creates a file using REST API Return theFileModelobject on success creationcreateCustomContent(ContentModel contentModel, String objectTypeID, CustomObjectTypeProperties objectTypeProperty) It will create a new folder in current resourceFolderModel newRandomFolder = FolderModel.getRandomFolderModel(); dataContent.usingUser(testUser).usingSite(testSite).createFolder(newRandomFolder);createFolder(FolderModel folderModel) This is the entry point of the createFolder() method to make REST API or CMIS call.createFolder(FolderModel folderModel, boolean useV1API) Create a folder.createFolderCmisApi(String folderName) It will create a random folder in current resource using CMISdataContent.usingUser(testUser).usingSite(testSite).createFolder();createFolderV1Api(org.alfresco.dataprep.AlfrescoHttpClient client, FolderModel folderModel, String username, String password) It will create a random folder in current resource using REST APIdataContent.usingUser(testUser).usingSite(testSite).createFolder();voidUse this to delete the last resource, either file or folderdataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent();voidUse this to delete the last resource, either file or folder using CmisApidataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent();voiddeleteContentV1RestApi(org.alfresco.dataprep.AlfrescoHttpClient client) Use this to delete the last resource, either file or folder using V1 RestApidataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent();voiddeleteSite(SiteModel site) Delete a sitevoiddeleteTree(FolderModel from) Delete parent folder along with all children in itvoiddeployContentModel(String localModelXMLFilePath) voidemptyUserTrashcan(UserModel user) org.apache.chemistry.opencmis.client.api.DocumentgetCMISDocument(String filePath) Get the corresponding CMIS Document Object of a file using only the file pathorg.apache.chemistry.opencmis.client.api.FoldergetCMISFolder(String folderPath) Get the corresponding CMIS Folder Object of a file using only the file pathorg.alfresco.dataprep.ContentActionsorg.apache.chemistry.opencmis.commons.data.ContentStreamgetContentStream(String fileName, String content) Create a content stream from some content.Returns customModel file is one exists or is deployed using deployContentModel otherwise nullvoidrenameContent(ContentModel newContent) Use this to rename a file or a folderdataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFolder).renameContent(newRepoFolder);voidsetCustomModel(String localModelXMLFilePath) Deploy a custom content model to repository http://docs.alfresco.com/5.1/tasks/deploy-dynamic.htmlvoidsetInheritPermissions(boolean inheritPermissions) voidupdateContent(String newContent) Update document contentvoidupdateContent(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel) This method updates the content of the created documentvoidupdateContent(org.alfresco.dataprep.AlfrescoHttpClient client, FileModel fileModel, org.alfresco.dataprep.CMISUtil.DocumentType documentType) This method updates the content of the created documentuploadDocument(File fileToUpload) Defines the current user to be AdminCall this method if you want to use another user rather than admin defined inTasPropertiesproperties filevoidwaitUntilContentIsCreated(String fullPath) Wait and retry for 15 seconds checking if a resource is createdvoidwaitUntilContentIsCreatedInLinux(String fullPath) Wait and retry for 15 seconds checking if a resource is created for Linux OSvoidwaitUntilContentIsDeleted(String fullPath) Methods inherited from class org.alfresco.utility.data.TestData
assertExtensionAmpExists, assertLogLineIs, getAdminUser, getAlfrescoHome, getCurrentSite, getCurrentSpace, getCurrentUser, getDataDictionaryPath, getLastNodeId, getLastResource, getRootPath, getSitesPath, getUserHomesPath, isAFile, setCurrentSite, setCurrentSpace, setCurrentUser, setLastNodeId, setLastResource, usingLastServerLogLines, usingResource, usingRoot, usingSite, usingSite, usingUserHome, usingUserHome, withJMX
-
Constructor Details
-
DataContent
public DataContent()
-
-
Method Details
-
getContentActions
public org.alfresco.dataprep.ContentActions getContentActions() -
usingUser
Description copied from class:TestDataCall this method if you want to use another user rather than admin defined inTasPropertiesproperties file- Specified by:
usingUserin interfaceDSL<DataContent>- Overrides:
usingUserin classTestData<DataContent>
-
usingAdmin
Description copied from interface:DSLDefines the current user to be Admin- Specified by:
usingAdminin interfaceDSL<DataContent>- Overrides:
usingAdminin classTestData<DataContent>- Returns:
-
createFolder
It will create a new folder in current resourceFolderModel newRandomFolder = FolderModel.getRandomFolderModel(); dataContent.usingUser(testUser).usingSite(testSite).createFolder(newRandomFolder); -
createFolder
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
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 APIdataContent.usingUser(testUser).usingSite(testSite).createFolder(); -
createFolderCmisApi
It will create a random folder in current resource using CMISdataContent.usingUser(testUser).usingSite(testSite).createFolder(); -
deleteContent
public void deleteContent()Use this to delete the last resource, either file or folderdataContent.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 RestApidataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent(); -
deleteContentCmisApi
public void deleteContentCmisApi()Use this to delete the last resource, either file or folder using CmisApidataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFile).deleteContent(); -
renameContent
Use this to rename a file or a folderdataContent.usingUser(adminUser).usingSite(siteModel).usingResource(repoFolder).renameContent(newRepoFolder);- Parameters:
newContent-
-
addEmailAlias
Add Email Alias aspect (emailserver:aliasable)dataContent.usingSite(testSite).usingResource(testFolder).addEmailAlias("aliasTas");- Parameters:
alias-- Returns:
-
createContent
It will create a new file in current resourceFileModel newRandomFile = FileModel.getRandomFileModel(); dataContent.usingUser(testUser).usingSite(testSite).createContent(newRandomFile); -
createContent
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 theFileModelobject on success creation- Parameters:
client-fileModel-- Returns:
-
updateContent
This method updates the content of the created document- Parameters:
client-fileModel-
-
createContentCmisApi
Creates a random document based onCMISUtil.DocumentTypepassed using CMIS Return theDocumentobject on success creationdataContent.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 onCMISUtil.DocumentTypepassed using REST API Return theDocumentobject on success creationdataContent.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 onCMISUtil.DocumentTypepassed using CMIS Return theDocumentobject on success creationdataContent.usingUser(userModel).usingResource(myFolder).createContent(DocumentType.TEXT_PLAIN);- Parameters:
documentType-- Returns:
- Throws:
DataPreparationException
-
assertContentExist
- Throws:
TestConfigurationException
-
assertContentDoesNotExist
- Throws:
TestConfigurationException
-
checkContent
- Parameters:
fullPath- - the full path to CMIS objectuserModel-- Throws:
TestConfigurationException
-
waitUntilContentIsDeleted
-
waitUntilContentIsCreated
Wait and retry for 15 seconds checking if a resource is created- Parameters:
fullPath-
-
waitUntilContentIsCreatedInLinux
Wait and retry for 15 seconds checking if a resource is created for Linux OS- Parameters:
fullPath-
-
deleteSite
Delete a site- Parameters:
site-
-
deleteTree
Delete parent folder along with all children in it- Parameters:
from-
-
setCustomModel
Deploy a custom content model to repository http://docs.alfresco.com/5.1/tasks/deploy-dynamic.html- Parameters:
localModelXMLFilePath-- Throws:
TestConfigurationException
-
deployContentModel
- Throws:
TestConfigurationException
-
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
Creates a tag for a content file You must use this in correlation withTestData.usingResource(ContentModel)- Parameters:
fileModel-model- tag model- Throws:
TestConfigurationException
-
assertContentHasTag
Verify content has tag- Parameters:
cmisObjectPath-model-
-
getNodeRef
- Returns:
- nodeRef of the current resource used
You can use this in correlation with
TestData.usingResource(ContentModel)and/orTestData.usingSite(SiteModel), etc.
-
getCMISDocument
Get the corresponding CMIS Document Object of a file using only the file path- Parameters:
filePath-- Returns:
Document
-
getCMISFolder
Get the corresponding CMIS Folder Object of a file using only the file path- Parameters:
filePath-- Returns:
Folder
-
addAspect
Adding aspects to ContentModels- Parameters:
object-
-
addFileToFavorites
Add file to favorites- Throws:
DataPreparationException
-
addFolderToFavorites
Add folder to favorites- Throws:
DataPreparationException
-
assertContentVersionIs
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
Update document content- Parameters:
newContent-
-
checkIn
Check in document.- Parameters:
newContent-majorVersion- true to set major version(e.g. 2.0)checkInComment-
-
setInheritPermissions
public void setInheritPermissions(boolean inheritPermissions) -
emptyUserTrashcan
-
uploadDocument
-