Class FilePlanComponentsApiUtils

java.lang.Object
org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils

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

  • Constructor Details

    • FilePlanComponentsApiUtils

      public FilePlanComponentsApiUtils()
  • Method Details

    • setNodes

      public void setNodes(Nodes nodes)
    • setFileFolderService

      public void setFileFolderService(FileFolderService fileFolderService)
    • setFilePlanService

      public void setFilePlanService(FilePlanService filePlanService)
    • setNodeService

      public void setNodeService(NodeService nodeService)
    • setContentService

      public void setContentService(ContentService contentService)
    • setMimetypeService

      public void setMimetypeService(MimetypeService mimetypeService)
    • setDictionaryService

      public void setDictionaryService(DictionaryService dictionaryService)
    • setCapabilityService

      public void setCapabilityService(CapabilityService capabilityService)
    • setPermissionService

      public void setPermissionService(PermissionService permissionService)
    • setRecordService

      public void setRecordService(RecordService recordService)
    • setAuthenticationUtil

      public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
    • setActivityPoster

      public void setActivityPoster(ActivityPoster poster)
    • setSites

      public void setSites(RMSites sites)
    • lookupAndValidateNodeType

      public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType) throws EntityNotFoundException
      lookup node and validate type
      Parameters:
      nodeId -
      expectedNodeType -
      Returns:
      Throws:
      EntityNotFoundException
    • lookupAndValidateNodeType

      public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath) throws EntityNotFoundException
      lookup node by id and relative path and validate type
      Parameters:
      nodeId -
      expectedNodeType -
      relativePath -
      Returns:
      Throws:
      EntityNotFoundException
    • lookupAndValidateNodeType

      public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath, boolean readOnlyRelativePath) throws EntityNotFoundException
      lookup node by id and relative path and validate type
      Parameters:
      nodeId -
      expectedNodeType -
      relativePath -
      Returns:
      Throws:
      EntityNotFoundException
    • validateAndLookUpContainerNode

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

      public 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 NodeRef lookupByPlaceholder(String nodeId)
      Lookup node by placeholder
      Parameters:
      nodeId -
      Returns:
      NodeRef for corresponding id
    • getSortProperties

      public List<Pair<QName,Boolean>> getSortProperties(Parameters parameters)
      TODO
      Parameters:
      parameters -
      Returns:
    • writeContent

      public void writeContent(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 NodeRef lookupAndValidateRelativePath(NodeRef parentNodeRef, String relativePath, 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 NodeRef lookupAndValidateRelativePath(NodeRef parentNodeRef, String relativePath, boolean readOnlyRelativePath, 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<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 NodeRef createRMNode(NodeRef parentNodeRef, RMNode nodeInfo, 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 NodeRef uploadRecord(NodeRef parentNodeRef, UploadInfo uploadInfo, 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<FilterProp> getListChildrenFilterProps(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(NodeRef nodeRef, RMNode updateInfo, 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 NodeRef validateRecord(String recordId) throws InvalidArgumentException
      Validates a record
      Parameters:
      recordId - the id of the record to validate
      Returns:
      Throws:
      InvalidArgumentException
    • getContent

      public BinaryResource getContent(NodeRef nodeRef, Parameters parameters, boolean recordActivity)
    • updateTransferContainer

      public void updateTransferContainer(NodeRef nodeRef, TransferContainer transferContainerInfo, 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(NodeRef nodeRef, 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 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(FileInfo fileInfo, NodeRef parentNodeRef, String activityType)
      Posts activities for given fileInfo
      Parameters:
      fileInfo -
      parentNodeRef -
      activityType -