Class FilePlanComponentsApiUtils


  • public class FilePlanComponentsApiUtils
    extends Object
    Utility class that handles common api endpoint tasks
    Since:
    2.6
    Author:
    Ana Bozianu
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.alfresco.service.cmr.repository.NodeRef createRMNode​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef, RMNode nodeInfo, org.alfresco.rest.framework.resource.parameters.Parameters parameters)
      Create an RM node
      protected List<String> getAllowableOperations​(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName typeQName)
      Helper method that generates allowable operation for the provided node
      org.alfresco.rest.framework.resource.content.BinaryResource getContent​(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.rest.framework.resource.parameters.Parameters parameters, boolean recordActivity)  
      org.alfresco.service.namespace.QName getFilePlanType()
      Helper method to obtain file plan type or null if the rm site does not exist.
      List<org.alfresco.repo.node.getchildren.FilterProp> getListChildrenFilterProps​(org.alfresco.rest.framework.resource.parameters.Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties)
      Returns a List of filter properties specified by request parameters.
      List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​Boolean>> getSortProperties​(org.alfresco.rest.framework.resource.parameters.Parameters parameters)
      TODO
      org.alfresco.service.cmr.repository.NodeRef lookupAndValidateNodeType​(String nodeId, org.alfresco.service.namespace.QName expectedNodeType)
      lookup node and validate type
      org.alfresco.service.cmr.repository.NodeRef lookupAndValidateNodeType​(String nodeId, org.alfresco.service.namespace.QName expectedNodeType, String relativePath)
      lookup node by id and relative path and validate type
      org.alfresco.service.cmr.repository.NodeRef lookupAndValidateNodeType​(String nodeId, org.alfresco.service.namespace.QName expectedNodeType, String relativePath, boolean readOnlyRelativePath)
      lookup node by id and relative path and validate type
      org.alfresco.service.cmr.repository.NodeRef lookupAndValidateRelativePath​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef, String relativePath, boolean readOnlyRelativePath, org.alfresco.service.namespace.QName nodesType)
      Helper method that creates a relative path if it doesn't already exist and if relative path is not read only.
      org.alfresco.service.cmr.repository.NodeRef lookupAndValidateRelativePath​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef, String relativePath, org.alfresco.service.namespace.QName nodesType)
      Helper method that creates a relative path if it doesn't already exist The relative path will be build with nodes of the type specified in nodesType If the relative path already exists the method validates if the last element is of type nodesType The method does not validate the type of parentNodeRef
      org.alfresco.service.cmr.repository.NodeRef lookupByAllowedPlaceholders​(String nodeId, List<String> allowedPlaceholders)
      Lookup node by placeholder from allowed placeholder list
      org.alfresco.service.cmr.repository.NodeRef lookupByPlaceholder​(String nodeId)
      Lookup node by placeholder
      Map<org.alfresco.service.namespace.QName,​Serializable> mapToNodeProperties​(Map<String,​Object> properties)
      Helper method that converts a map of String properties into a map of QName properties
      void postActivity​(org.alfresco.service.cmr.model.FileInfo fileInfo, org.alfresco.service.cmr.repository.NodeRef parentNodeRef, String activityType)
      Posts activities for given fileInfo
      void setActivityPoster​(org.alfresco.service.cmr.activities.ActivityPoster poster)  
      void setAuthenticationUtil​(AuthenticationUtil authenticationUtil)  
      void setCapabilityService​(CapabilityService capabilityService)  
      void setContentService​(org.alfresco.service.cmr.repository.ContentService contentService)  
      void setDictionaryService​(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)  
      void setFileFolderService​(org.alfresco.service.cmr.model.FileFolderService fileFolderService)  
      void setFilePlanService​(FilePlanService filePlanService)  
      void setMimetypeService​(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)  
      void setNodes​(org.alfresco.rest.api.Nodes nodes)  
      void setNodeService​(org.alfresco.service.cmr.repository.NodeService nodeService)  
      void setPermissionService​(org.alfresco.service.cmr.security.PermissionService permissionService)  
      void setRecordService​(RecordService recordService)  
      void setSites​(RMSites sites)  
      void updateNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef, RMNode updateInfo, org.alfresco.rest.framework.resource.parameters.Parameters parameters)
      Utility method that updates a node's name and properties
      void updateTransferContainer​(org.alfresco.service.cmr.repository.NodeRef nodeRef, TransferContainer transferContainerInfo, org.alfresco.rest.framework.resource.parameters.Parameters parameters)
      Utility method that updates a transfer container's name and properties
      org.alfresco.service.cmr.repository.NodeRef uploadRecord​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef, UploadInfo uploadInfo, org.alfresco.rest.framework.resource.parameters.Parameters parameters)
      Upload a record
      org.alfresco.service.cmr.repository.NodeRef validateAndLookUpContainerNode​(String nodeId, List<String> allowedPlaceholders)
      look up node by id and validate node type is suitable container
      org.alfresco.service.cmr.repository.NodeRef validateRecord​(String recordId)
      Validates a record
      void writeContent​(org.alfresco.service.cmr.repository.NodeRef nodeRef, String fileName, InputStream stream, boolean guessEncoding)
      Write content to file
    • Constructor Detail

      • FilePlanComponentsApiUtils

        public FilePlanComponentsApiUtils()
    • Method Detail

      • setNodes

        public void setNodes​(org.alfresco.rest.api.Nodes nodes)
      • setFileFolderService

        public void setFileFolderService​(org.alfresco.service.cmr.model.FileFolderService fileFolderService)
      • setFilePlanService

        public void setFilePlanService​(FilePlanService filePlanService)
      • setNodeService

        public void setNodeService​(org.alfresco.service.cmr.repository.NodeService nodeService)
      • setContentService

        public void setContentService​(org.alfresco.service.cmr.repository.ContentService contentService)
      • setMimetypeService

        public void setMimetypeService​(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
      • setDictionaryService

        public void setDictionaryService​(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
      • setCapabilityService

        public void setCapabilityService​(CapabilityService capabilityService)
      • setPermissionService

        public void setPermissionService​(org.alfresco.service.cmr.security.PermissionService permissionService)
      • setRecordService

        public void setRecordService​(RecordService recordService)
      • setAuthenticationUtil

        public void setAuthenticationUtil​(AuthenticationUtil authenticationUtil)
      • setActivityPoster

        public void setActivityPoster​(org.alfresco.service.cmr.activities.ActivityPoster poster)
      • setSites

        public void setSites​(RMSites sites)
      • lookupAndValidateNodeType

        public org.alfresco.service.cmr.repository.NodeRef lookupAndValidateNodeType​(String nodeId,
                                                                                     org.alfresco.service.namespace.QName expectedNodeType)
                                                                              throws org.alfresco.rest.framework.core.exceptions.EntityNotFoundException
        lookup node and validate type
        Parameters:
        nodeId -
        expectedNodeType -
        Returns:
        Throws:
        org.alfresco.rest.framework.core.exceptions.EntityNotFoundException
      • lookupAndValidateNodeType

        public org.alfresco.service.cmr.repository.NodeRef lookupAndValidateNodeType​(String nodeId,
                                                                                     org.alfresco.service.namespace.QName expectedNodeType,
                                                                                     String relativePath)
                                                                              throws org.alfresco.rest.framework.core.exceptions.EntityNotFoundException
        lookup node by id and relative path and validate type
        Parameters:
        nodeId -
        expectedNodeType -
        relativePath -
        Returns:
        Throws:
        org.alfresco.rest.framework.core.exceptions.EntityNotFoundException
      • lookupAndValidateNodeType

        public org.alfresco.service.cmr.repository.NodeRef lookupAndValidateNodeType​(String nodeId,
                                                                                     org.alfresco.service.namespace.QName expectedNodeType,
                                                                                     String relativePath,
                                                                                     boolean readOnlyRelativePath)
                                                                              throws org.alfresco.rest.framework.core.exceptions.EntityNotFoundException
        lookup node by id and relative path and validate type
        Parameters:
        nodeId -
        expectedNodeType -
        relativePath -
        Returns:
        Throws:
        org.alfresco.rest.framework.core.exceptions.EntityNotFoundException
      • validateAndLookUpContainerNode

        public org.alfresco.service.cmr.repository.NodeRef validateAndLookUpContainerNode​(String nodeId,
                                                                                          List<String> allowedPlaceholders)
        look up node by id and validate node type is suitable container
        Parameters:
        nodeId -
        Returns:
      • lookupByAllowedPlaceholders

        public org.alfresco.service.cmr.repository.NodeRef lookupByAllowedPlaceholders​(String nodeId,
                                                                                       List<String> allowedPlaceholders)
        Lookup node by placeholder from allowed placeholder list
        Parameters:
        nodeId -
        allowedPlaceholders -
        Returns:
        NodeRef for corresponding id
      • lookupByPlaceholder

        public org.alfresco.service.cmr.repository.NodeRef lookupByPlaceholder​(String nodeId)
        Lookup node by placeholder
        Parameters:
        nodeId -
        Returns:
        NodeRef for corresponding id
      • getSortProperties

        public List<org.alfresco.util.Pair<org.alfresco.service.namespace.QName,​Boolean>> getSortProperties​(org.alfresco.rest.framework.resource.parameters.Parameters parameters)
        TODO
        Parameters:
        parameters -
        Returns:
      • writeContent

        public void writeContent​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                 String fileName,
                                 InputStream stream,
                                 boolean guessEncoding)
        Write content to file
        Parameters:
        nodeRef - the node to write the content to
        fileName - the name of the file (used for guessing the file's mimetype)
        stream - the input stream to write
        guessEncoding - whether to guess stream encoding
      • lookupAndValidateRelativePath

        public org.alfresco.service.cmr.repository.NodeRef lookupAndValidateRelativePath​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
                                                                                         String relativePath,
                                                                                         org.alfresco.service.namespace.QName nodesType)
        Helper method that creates a relative path if it doesn't already exist The relative path will be build with nodes of the type specified in nodesType If the relative path already exists the method validates if the last element is of type nodesType The method does not validate the type of parentNodeRef
        Parameters:
        parentNodeRef - the first node of the path
        relativePath - a string representing the relative path in the format "Folder1/Folder2/Folder3"
        nodesType - the type of all the containers in the path
        Returns:
        the last element of the relative path
      • lookupAndValidateRelativePath

        public org.alfresco.service.cmr.repository.NodeRef lookupAndValidateRelativePath​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
                                                                                         String relativePath,
                                                                                         boolean readOnlyRelativePath,
                                                                                         org.alfresco.service.namespace.QName nodesType)
        Helper method that creates a relative path if it doesn't already exist and if relative path is not read only. If relative path is read only an exception will be thrown if the provided relative path does not exist. The relative path will be build with nodes of the type specified in nodesType If the relative path already exists the method validates if the last element is of type nodesType The method does not validate the type of parentNodeRef
        Parameters:
        parentNodeRef - the first node of the path
        relativePath - a string representing the relative path in the format "Folder1/Folder2/Folder3"
        readOnlyRelativePath - the flag that indicates if the relativePath should be created if doesn't exist or not
        nodesType - the type of all the containers in the path
        Returns:
        the last element of the relative path
      • mapToNodeProperties

        public Map<org.alfresco.service.namespace.QName,​Serializable> mapToNodeProperties​(Map<String,​Object> properties)
        Helper method that converts a map of String properties into a map of QName properties
        Parameters:
        properties -
        Returns:
        a map of properties
      • createRMNode

        public org.alfresco.service.cmr.repository.NodeRef createRMNode​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
                                                                        RMNode nodeInfo,
                                                                        org.alfresco.rest.framework.resource.parameters.Parameters parameters)
        Create an RM node
        Parameters:
        parentNodeRef - the parent of the node
        nodeInfo - the node infos to create
        parameters - the object to get the parameters passed into the request
        Returns:
        the new node
      • uploadRecord

        public org.alfresco.service.cmr.repository.NodeRef uploadRecord​(org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
                                                                        UploadInfo uploadInfo,
                                                                        org.alfresco.rest.framework.resource.parameters.Parameters parameters)
        Upload a record
        Parameters:
        parentNodeRef - the parent of the record
        uploadInfo - the infos of the uploaded record
        parameters - the object to get the parameters passed into the request
        Returns:
        the new record
      • getListChildrenFilterProps

        public List<org.alfresco.repo.node.getchildren.FilterProp> getListChildrenFilterProps​(org.alfresco.rest.framework.resource.parameters.Parameters parameters,
                                                                                              Set<String> listFolderChildrenEqualsQueryProperties)
        Returns a List of filter properties specified by request parameters.
        Parameters:
        parameters - The Parameters object to get the parameters passed into the request including: - filter, sort & paging params (where, orderBy, skipCount, maxItems)
        Returns:
        The list of FilterProp. Can be null.
      • updateNode

        public void updateNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                               RMNode updateInfo,
                               org.alfresco.rest.framework.resource.parameters.Parameters parameters)
        Utility method that updates a node's name and properties
        Parameters:
        nodeRef - the node to update
        updateInfo - information to update the record with
        parameters - request parameters
      • validateRecord

        public org.alfresco.service.cmr.repository.NodeRef validateRecord​(String recordId)
                                                                   throws org.alfresco.rest.framework.core.exceptions.InvalidArgumentException
        Validates a record
        Parameters:
        recordId - the id of the record to validate
        Returns:
        Throws:
        org.alfresco.rest.framework.core.exceptions.InvalidArgumentException
      • getContent

        public org.alfresco.rest.framework.resource.content.BinaryResource getContent​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                                                                      org.alfresco.rest.framework.resource.parameters.Parameters parameters,
                                                                                      boolean recordActivity)
      • updateTransferContainer

        public void updateTransferContainer​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                            TransferContainer transferContainerInfo,
                                            org.alfresco.rest.framework.resource.parameters.Parameters parameters)
        Utility method that updates a transfer container's name and properties
        Parameters:
        nodeRef - the node to update
        transferContainerInfo - information to update the transfer container with
        parameters - request parameters
      • getAllowableOperations

        protected List<String> getAllowableOperations​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                                      org.alfresco.service.namespace.QName typeQName)
        Helper method that generates allowable operation for the provided node
        Parameters:
        nodeRef - the node to get the allowable operations for
        typeQName - the type of the provided nodeRef
        Returns:
        a sublist of [Nodes.OP_DELETE, Nodes.OP_CREATE, Nodes.OP_UPDATE] representing the allowable operations for the provided node
      • getFilePlanType

        public org.alfresco.service.namespace.QName getFilePlanType()
        Helper method to obtain file plan type or null if the rm site does not exist.
        Returns:
        file plan type or null
      • postActivity

        public void postActivity​(org.alfresco.service.cmr.model.FileInfo fileInfo,
                                 org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
                                 String activityType)
        Posts activities for given fileInfo
        Parameters:
        fileInfo -
        parentNodeRef -
        activityType -