Interface FilesService

  • All Known Implementing Classes:
    FilesPlugin

    public interface FilesService
    • Method Detail

      • getFileTopic

        Topic getFileTopic​(String repoPath)
        Returns the File topic representing the file at a given repository path. If no such File topic exists it is created.
        Parameters:
        repoPath - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        Returns:
        The File topic. Its child topics ("File Name", "Path", "Media Type", "Size") are included.
      • getFolderTopic

        Topic getFolderTopic​(String repoPath)
        Returns the Folder topic representing the folder at a given repository path. If no such Folder topic exists it is created.
        Parameters:
        repoPath - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        Returns:
        The Folder topic. Its child topics ("Folder Name", "Path") are included.
      • getChildFileTopic

        RelatedTopic getChildFileTopic​(long folderTopicId,
                                       String repoPath)
        Returns the File topic representing the file at a given repository path. If no such File topic exists it is created.

        Creates an association (type "Composition") between the File topic (role type "Child") and its parent Folder topic (role type "Parent"), if not exists already.

        Parameters:
        repoPath - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        folderTopicId - ID of the parent Folder topic.
        Returns:
        The File topic. Its child topics ("File Name", "Path", "Media Type", "Size") are included.
      • getChildFolderTopic

        RelatedTopic getChildFolderTopic​(long folderTopicId,
                                         String repoPath)
        Returns the Folder topic representing the folder at a given repository path. If no such Folder topic exists it is created.

        Creates an association (type "Composition") between the Folder topic (role type "Child") and its parent Folder topic (role type "Parent"), if not exists already.

        Parameters:
        repoPath - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        folderTopicId - ID of the parent Folder topic.
        Returns:
        The Folder topic. Its child topics ("Folder Name", "Path") are included.
      • storeFile

        StoredFile storeFile​(UploadedFile file,
                             String repoPath)
                      throws FileRepositoryException
        Receives an uploaded file, stores it in the file repository, and creates a corresponding File topic.
        Parameters:
        repoPath - The directory where to store the uploaded file. The directory must exist.

        A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        Returns:
        a StoredFile object which holds 2 information: the name of the uploaded file, and the ID of the created File topic. ### FIXDOC
        Throws:
        FileRepositoryException
      • createFile

        Topic createFile​(InputStream in,
                         String repoPath)
        Creates a file in the file repository and a corresponding File topic.
        Parameters:
        in - The input stream the file content is read from.
        repoPath - The path and filename of the file to be created. If that file exists already it is overwritten. ### TODO: rethink overwriting

        A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        Returns:
        the File topic that corresponds to the created file.
      • createFolder

        RelatedTopic createFolder​(String folderName,
                                  String repoPath)
                           throws FileRepositoryException
        Creates a folder in the file repository. Note: no corresponding Folder topic is created.
        Parameters:
        repoPath - The directory where to create the folder.

        A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        Throws:
        FileRepositoryException
      • getRepositoryPath

        String getRepositoryPath​(URL url)
        Checks if the given URL refers to the file repository of this DMX installation.
        Returns:
        the refered file's/directory's repository path, or null if the URL does not refer to the file repository of this DMX installation.
      • getFile

        File getFile​(String repoPath)
        Accesses a file/directory in the file repository by the given repository path. If no such file/directory exists a FileRepositoryException is thrown.

        Note: this method does not require the corresponding File/Folder topic to exist.

        Parameters:
        repoPath - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        Throws:
        FileRepositoryException - with status code 404 if no such file/directory exists in the file repository.
      • getFile

        File getFile​(long fileTopicId)
        Convenience method to access the file/directory in the file repository that is represented by the given File/Folder topic.
        Parameters:
        fileTopicId - ID of a File/Folder topic.
      • fileExists

        boolean fileExists​(String repoPath)
        Checks if a file/directory with the given repository path exists in the file repository.
        Parameters:
        repoPath - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

        If per-workspace file repos are active (dmx.filerepo.per_workspace=true) the repository path must contain the workspace prefix as the first path segment, e.g. "/workspace-1234" where 1234 is the workspace ID.

        However there is one exception to that rule: if and only if "/" is passed as the repository path the workspace prefix is determined automatically with the semantics of current workspace, based on the request's workspace cookie.

        For support with constructing a repository path see the pathPrefix() methods.

        Returns:
        true if the file exists, false otherwise.
      • pathPrefix

        String pathPrefix()
        Returns a prefix that can be used for constructing a repository path. In case of per-workspace file repos are active (dmx.filerepo.per_workspace=true) the prefix represents the current workspace (e.g. "/workspace-1234"), based on the workspace cookie. In case of per-workspace file repos are not active an empty string is returned.
      • pathPrefix

        String pathPrefix​(long workspaceId)
        Returns a prefix that can be used for constructing a repository path. In case of per-workspace file repos are active (dmx.filerepo.per_workspace=true) the prefix represents the given workspace (e.g. "/workspace-1234"). In case of per-workspace file repos are not active an empty string is returned.
      • openFile

        int openFile​(long fileTopicId)