Class CmisUtil


  • public class CmisUtil
    extends java.lang.Object
    DSL utility for managing CMIS objects
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void copyChildrenFromFolder​(org.apache.chemistry.opencmis.client.api.Folder sourceFolder, org.apache.chemistry.opencmis.client.api.Folder targetFolder)
      Copy all the children of the source folder to the target folder
      org.apache.chemistry.opencmis.client.api.CmisObject copyFolder​(org.apache.chemistry.opencmis.client.api.Folder sourceFolder, org.apache.chemistry.opencmis.client.api.Folder targetFolder)
      Copy folder with all children
      java.util.List<org.apache.chemistry.opencmis.commons.data.Ace> createAce​(org.alfresco.utility.model.GroupModel group, org.alfresco.utility.constants.UserRole role)  
      java.util.List<org.apache.chemistry.opencmis.commons.data.Ace> createAce​(org.alfresco.utility.model.UserModel user, java.lang.String... permissions)  
      java.util.List<org.apache.chemistry.opencmis.commons.data.Ace> createAce​(org.alfresco.utility.model.UserModel user, org.alfresco.utility.constants.UserRole role)  
      org.apache.chemistry.opencmis.commons.data.Acl getAcls()  
      protected java.util.List<org.apache.chemistry.opencmis.client.api.Document> getAllDocumentVersions()  
      java.util.List<org.apache.chemistry.opencmis.client.api.Document> getAllDocumentVersionsBy​(org.apache.chemistry.opencmis.client.api.OperationContext context)  
      protected java.util.List<org.apache.chemistry.opencmis.commons.enums.Action> getAllowableActions()  
      java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromFolder()  
      java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromFolder​(org.apache.chemistry.opencmis.client.api.OperationContext context)  
      java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromSession()  
      java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromSession​(org.apache.chemistry.opencmis.client.api.OperationContext context)  
      java.util.Map<org.alfresco.utility.model.ContentModel,​org.apache.chemistry.opencmis.client.api.ObjectType> getChildren()
      Get the children from a parent folder
      org.apache.chemistry.opencmis.client.api.Document getCmisDocument​(java.lang.String path)
      Get Document object for a file
      org.apache.chemistry.opencmis.client.api.Folder getCmisFolder​(java.lang.String path)
      Get Folder object for a folder
      org.apache.chemistry.opencmis.client.api.CmisObject getCmisObject​(java.lang.String pathToItem)
      Get cmis object by path
      org.apache.chemistry.opencmis.client.api.CmisObject getCmisObject​(java.lang.String pathToItem, org.apache.chemistry.opencmis.client.api.OperationContext context)
      Get cmis object by path with context
      org.apache.chemistry.opencmis.client.api.CmisObject getCmisObjectById​(java.lang.String objectId)
      Get cmis object by object id
      org.apache.chemistry.opencmis.client.api.CmisObject getCmisObjectById​(java.lang.String objectId, org.apache.chemistry.opencmis.client.api.OperationContext context)
      Get cmis object by object id with OperationContext
      java.util.List<org.apache.chemistry.opencmis.client.api.CmisObject> getCmisObjectsFromContentModels​(org.alfresco.utility.model.ContentModel... contentModels)
      Returns a list of Cmis objects for the provided Content Models
      protected java.lang.String getContentAsString​(org.apache.chemistry.opencmis.commons.data.ContentStream stream)
      Helper method to get the contents of a stream
      org.apache.chemistry.opencmis.commons.data.ContentStream getContentStream​(java.lang.String content)  
      java.lang.String getDocumentContent()  
      java.util.List<org.alfresco.utility.model.FileModel> getFiles()
      Get children documents from a parent folder
      java.util.List<org.apache.chemistry.opencmis.client.api.CmisObject> getFolderDescendants​(int depth)
      Gets the folder descendants starting with the current folder
      protected org.apache.chemistry.opencmis.client.api.Folder getFolderParent()  
      java.util.List<org.alfresco.utility.model.FolderModel> getFolders()
      Get children folders from a parent folder
      java.util.List<org.apache.chemistry.opencmis.client.api.CmisObject> getFolderTree​(int depth)
      Gets only the folder descendants for the #getLastResource() folder
      java.lang.String getObjectId​(java.lang.String pathToObject)  
      java.util.Map<java.lang.String,​java.lang.Object> getProperties​(org.alfresco.utility.model.ContentModel contentModel, java.lang.String baseTypeId)  
      protected <T> org.apache.chemistry.opencmis.client.api.Property<T> getProperty​(java.lang.String propertyId)
      Returns the requested property.
      org.apache.chemistry.opencmis.client.api.Document getPWCDocument()
      Returns the PWC (private working copy) ID of the document version series
      org.alfresco.utility.model.FileModel getPWCFileModel()  
      protected java.util.List<org.apache.chemistry.opencmis.client.api.Rendition> getRenditions()  
      protected java.util.List<org.apache.chemistry.opencmis.client.api.SecondaryType> getSecondaryTypes()  
      org.apache.chemistry.opencmis.client.api.ItemIterable<org.apache.chemistry.opencmis.client.api.ObjectType> getTypeChildren​(java.lang.String baseType, boolean includePropertyDefinitions)  
      org.apache.chemistry.opencmis.client.api.ObjectType getTypeDefinition()  
      java.util.List<org.apache.chemistry.opencmis.client.api.Tree<org.apache.chemistry.opencmis.client.api.ObjectType>> getTypeDescendants​(java.lang.String baseTypeId, int depth, boolean includePropertyDefinitions)  
      java.lang.String getUserNodeRef​(org.alfresco.utility.model.UserModel user)
      Get user noderef
      protected boolean isCmisObjectContainedInCmisCheckedOutDocumentsList​(org.apache.chemistry.opencmis.client.api.CmisObject cmisObject, java.util.List<org.apache.chemistry.opencmis.client.api.Document> cmisCheckedOutDocuments)  
      protected boolean isContentInList​(org.alfresco.utility.model.ContentModel contentModel, java.util.List<org.alfresco.utility.model.ContentModel> contents)  
      protected boolean isFileInList​(org.alfresco.utility.model.FileModel fileModel, java.util.List<org.alfresco.utility.model.FileModel> files)  
      protected boolean isFolderInList​(org.alfresco.utility.model.FolderModel folderModel, java.util.List<org.alfresco.utility.model.FolderModel> folders)  
      protected boolean isPrivateWorkingCopy()  
      org.apache.chemistry.opencmis.client.api.OperationContext setIncludeAclContext()  
      void updateProperties​(java.lang.String propertyName, java.lang.Object propertyValue)
      Update property for last resource cmis object
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getCmisObjectById

        public org.apache.chemistry.opencmis.client.api.CmisObject getCmisObjectById​(java.lang.String objectId)
        Get cmis object by object id
        Parameters:
        objectId - cmis object id
        Returns:
        CmisObject cmis object
      • getCmisObjectById

        public org.apache.chemistry.opencmis.client.api.CmisObject getCmisObjectById​(java.lang.String objectId,
                                                                                     org.apache.chemistry.opencmis.client.api.OperationContext context)
        Get cmis object by object id with OperationContext
        Parameters:
        objectId - cmis object id
        context - OperationContext
        Returns:
        CmisObject cmis object
      • getCmisObject

        public org.apache.chemistry.opencmis.client.api.CmisObject getCmisObject​(java.lang.String pathToItem)
        Get cmis object by path
        Parameters:
        pathToItem - String path to item
        Returns:
        CmisObject cmis object
      • getCmisObject

        public org.apache.chemistry.opencmis.client.api.CmisObject getCmisObject​(java.lang.String pathToItem,
                                                                                 org.apache.chemistry.opencmis.client.api.OperationContext context)
        Get cmis object by path with context
        Parameters:
        pathToItem - String path to item
        context - OperationContext
        Returns:
        CmisObject cmis object
      • getCmisDocument

        public org.apache.chemistry.opencmis.client.api.Document getCmisDocument​(java.lang.String path)
        Get Document object for a file
        Parameters:
        path - String path to document
        Returns:
        Document object
      • getCmisFolder

        public org.apache.chemistry.opencmis.client.api.Folder getCmisFolder​(java.lang.String path)
        Get Folder object for a folder
        Parameters:
        path - String path to folder
        Returns:
        Folder object
      • getContentAsString

        protected java.lang.String getContentAsString​(org.apache.chemistry.opencmis.commons.data.ContentStream stream)
        Helper method to get the contents of a stream
        Parameters:
        stream -
        Returns:
        Throws:
        org.alfresco.utility.exception.IORuntimeException
      • copyChildrenFromFolder

        protected void copyChildrenFromFolder​(org.apache.chemistry.opencmis.client.api.Folder sourceFolder,
                                              org.apache.chemistry.opencmis.client.api.Folder targetFolder)
        Copy all the children of the source folder to the target folder
        Parameters:
        sourceFolder -
        targetFolder -
      • copyFolder

        public org.apache.chemistry.opencmis.client.api.CmisObject copyFolder​(org.apache.chemistry.opencmis.client.api.Folder sourceFolder,
                                                                              org.apache.chemistry.opencmis.client.api.Folder targetFolder)
        Copy folder with all children
        Parameters:
        sourceFolder - source folder
        targetFolder - target folder
        Returns:
        CmisObject of new created folder
      • isPrivateWorkingCopy

        protected boolean isPrivateWorkingCopy()
      • getPWCDocument

        public org.apache.chemistry.opencmis.client.api.Document getPWCDocument()
        Returns the PWC (private working copy) ID of the document version series
      • getPWCFileModel

        public org.alfresco.utility.model.FileModel getPWCFileModel()
      • getFolderParent

        protected org.apache.chemistry.opencmis.client.api.Folder getFolderParent()
      • getAllowableActions

        protected java.util.List<org.apache.chemistry.opencmis.commons.enums.Action> getAllowableActions()
        Returns:
        List of allowable actions for the current object
      • getProperty

        protected <T> org.apache.chemistry.opencmis.client.api.Property<T> getProperty​(java.lang.String propertyId)
        Returns the requested property. If the property is not available, null is returned
        Parameters:
        propertyId -
        Returns:
        CMIS Property
      • getRenditions

        protected java.util.List<org.apache.chemistry.opencmis.client.api.Rendition> getRenditions()
      • getSecondaryTypes

        protected java.util.List<org.apache.chemistry.opencmis.client.api.SecondaryType> getSecondaryTypes()
      • getChildren

        public java.util.Map<org.alfresco.utility.model.ContentModel,​org.apache.chemistry.opencmis.client.api.ObjectType> getChildren()
        Get the children from a parent folder
        Returns:
        Map
      • getFolderDescendants

        public java.util.List<org.apache.chemistry.opencmis.client.api.CmisObject> getFolderDescendants​(int depth)
        Gets the folder descendants starting with the current folder
        Parameters:
        depth - level of the tree that you want to go to - currentFolder -- file1.txt -- file2.txt -- folderB --- file3.txt --- file4.txt e.g. A depth of 1 will give you just the current folder descendants (file1.txt, file2.txt, folder1) e.g. A depth of -1 will return all the descendants (file1.txt, file2.txt, folder1, file3.txt and file4.txt)
      • getCmisObjectsFromContentModels

        public java.util.List<org.apache.chemistry.opencmis.client.api.CmisObject> getCmisObjectsFromContentModels​(org.alfresco.utility.model.ContentModel... contentModels)
        Returns a list of Cmis objects for the provided Content Models
        Parameters:
        contentModels -
      • getContentStream

        public org.apache.chemistry.opencmis.commons.data.ContentStream getContentStream​(java.lang.String content)
      • getAcls

        public org.apache.chemistry.opencmis.commons.data.Acl getAcls()
      • getFolderTree

        public java.util.List<org.apache.chemistry.opencmis.client.api.CmisObject> getFolderTree​(int depth)
        Gets only the folder descendants for the #getLastResource() folder
        Parameters:
        depth - level of the tree that you want to go to - currentFolder -- folderB -- folderC --- folderD e.g. A depth of 1 will give you just the current folder descendants (folderB, folderC) e.g. A depth of -1 will return all the descendants (folderB, folderC, folderD)
      • getAllDocumentVersions

        protected java.util.List<org.apache.chemistry.opencmis.client.api.Document> getAllDocumentVersions()
      • getAllDocumentVersionsBy

        public java.util.List<org.apache.chemistry.opencmis.client.api.Document> getAllDocumentVersionsBy​(org.apache.chemistry.opencmis.client.api.OperationContext context)
      • getCheckedOutDocumentsFromSession

        public java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromSession()
      • getCheckedOutDocumentsFromSession

        public java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromSession​(org.apache.chemistry.opencmis.client.api.OperationContext context)
      • getCheckedOutDocumentsFromFolder

        public java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromFolder()
      • getCheckedOutDocumentsFromFolder

        public java.util.List<org.apache.chemistry.opencmis.client.api.Document> getCheckedOutDocumentsFromFolder​(org.apache.chemistry.opencmis.client.api.OperationContext context)
      • isCmisObjectContainedInCmisCheckedOutDocumentsList

        protected boolean isCmisObjectContainedInCmisCheckedOutDocumentsList​(org.apache.chemistry.opencmis.client.api.CmisObject cmisObject,
                                                                             java.util.List<org.apache.chemistry.opencmis.client.api.Document> cmisCheckedOutDocuments)
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.Object> getProperties​(org.alfresco.utility.model.ContentModel contentModel,
                                                                                    java.lang.String baseTypeId)
      • setIncludeAclContext

        public org.apache.chemistry.opencmis.client.api.OperationContext setIncludeAclContext()
      • createAce

        public java.util.List<org.apache.chemistry.opencmis.commons.data.Ace> createAce​(org.alfresco.utility.model.UserModel user,
                                                                                        org.alfresco.utility.constants.UserRole role)
      • createAce

        public java.util.List<org.apache.chemistry.opencmis.commons.data.Ace> createAce​(org.alfresco.utility.model.GroupModel group,
                                                                                        org.alfresco.utility.constants.UserRole role)
      • createAce

        public java.util.List<org.apache.chemistry.opencmis.commons.data.Ace> createAce​(org.alfresco.utility.model.UserModel user,
                                                                                        java.lang.String... permissions)
      • getTypeDefinition

        public org.apache.chemistry.opencmis.client.api.ObjectType getTypeDefinition()
      • getTypeChildren

        public org.apache.chemistry.opencmis.client.api.ItemIterable<org.apache.chemistry.opencmis.client.api.ObjectType> getTypeChildren​(java.lang.String baseType,
                                                                                                                                          boolean includePropertyDefinitions)
      • getTypeDescendants

        public java.util.List<org.apache.chemistry.opencmis.client.api.Tree<org.apache.chemistry.opencmis.client.api.ObjectType>> getTypeDescendants​(java.lang.String baseTypeId,
                                                                                                                                                     int depth,
                                                                                                                                                     boolean includePropertyDefinitions)
      • getObjectId

        public java.lang.String getObjectId​(java.lang.String pathToObject)
      • updateProperties

        public void updateProperties​(java.lang.String propertyName,
                                     java.lang.Object propertyValue)
        Update property for last resource cmis object
        Parameters:
        propertyName - String property name (e.g. cmis:name)
        propertyValue - Object property value
      • isFolderInList

        protected boolean isFolderInList​(org.alfresco.utility.model.FolderModel folderModel,
                                         java.util.List<org.alfresco.utility.model.FolderModel> folders)
      • isFileInList

        protected boolean isFileInList​(org.alfresco.utility.model.FileModel fileModel,
                                       java.util.List<org.alfresco.utility.model.FileModel> files)
      • isContentInList

        protected boolean isContentInList​(org.alfresco.utility.model.ContentModel contentModel,
                                          java.util.List<org.alfresco.utility.model.ContentModel> contents)
      • getFolders

        public java.util.List<org.alfresco.utility.model.FolderModel> getFolders()
        Get children folders from a parent folder
        Returns:
        List
      • getFiles

        public java.util.List<org.alfresco.utility.model.FileModel> getFiles()
        Get children documents from a parent folder
        Returns:
        List
      • getDocumentContent

        public java.lang.String getDocumentContent()
      • getUserNodeRef

        public java.lang.String getUserNodeRef​(org.alfresco.utility.model.UserModel user)
        Get user noderef
        Parameters:
        user - UserModel