Class FilesPlugin

    • Field Detail

      • CHECK_DISK_QUOTA

        public static DMXEvent CHECK_DISK_QUOTA
    • Constructor Detail

      • FilesPlugin

        public FilesPlugin()
    • Method Detail

      • getFileTopic

        public Topic getFileTopic​(String repoPath)
        Description copied from interface: FilesService
        Returns the File topic representing the file at a given repository path. If no such File topic exists it is created.
        Specified by:
        getFileTopic in interface FilesService
        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 FilesService.pathPrefix() methods.

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

        public Topic getFolderTopic​(String repoPath)
        Description copied from interface: FilesService
        Returns the Folder topic representing the folder at a given repository path. If no such Folder topic exists it is created.
        Specified by:
        getFolderTopic in interface FilesService
        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 FilesService.pathPrefix() methods.

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

        public RelatedTopic getChildFileTopic​(long folderTopicId,
                                              String repoPath)
        Description copied from interface: FilesService
        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.

        Specified by:
        getChildFileTopic in interface FilesService
        Parameters:
        folderTopicId - ID of the parent Folder topic.
        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 FilesService.pathPrefix() methods.

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

        public RelatedTopic getChildFolderTopic​(long folderTopicId,
                                                String repoPath)
        Description copied from interface: FilesService
        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.

        Specified by:
        getChildFolderTopic in interface FilesService
        Parameters:
        folderTopicId - ID of the parent Folder topic.
        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 FilesService.pathPrefix() methods.

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

        public StoredFile storeFile​(UploadedFile file,
                                    String repoPath)
                             throws FileRepositoryException
        Description copied from interface: FilesService
        Receives an uploaded file, stores it in the file repository, and creates a corresponding File topic.
        Specified by:
        storeFile in interface FilesService
        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 FilesService.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

        public Topic createFile​(InputStream in,
                                String repoPath)
        Description copied from interface: FilesService
        Creates a file in the file repository and a corresponding File topic.
        Specified by:
        createFile in interface FilesService
        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 FilesService.pathPrefix() methods.

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

        public RelatedTopic createFolder​(String folderName,
                                         String repoPath)
                                  throws FileRepositoryException
        Description copied from interface: FilesService
        Creates a folder in the file repository. Note: no corresponding Folder topic is created.
        Specified by:
        createFolder in interface FilesService
        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 FilesService.pathPrefix() methods.

        Throws:
        FileRepositoryException
      • getRepositoryPath

        public String getRepositoryPath​(URL url)
        Description copied from interface: FilesService
        Checks if the given URL refers to the file repository of this DMX installation.
        Specified by:
        getRepositoryPath in interface FilesService
        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

        public File getFile​(String repoPath)
        Description copied from interface: FilesService
        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.

        Specified by:
        getFile in interface FilesService
        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 FilesService.pathPrefix() methods.

      • getFile

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

        public boolean fileExists​(String repoPath)
        Description copied from interface: FilesService
        Checks if a file/directory with the given repository path exists in the file repository.
        Specified by:
        fileExists in interface FilesService
        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 FilesService.pathPrefix() methods.

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

        public String pathPrefix()
        Description copied from interface: FilesService
        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.
        Specified by:
        pathPrefix in interface FilesService
      • pathPrefix

        public String pathPrefix​(long workspaceId)
        Description copied from interface: FilesService
        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.
        Specified by:
        pathPrefix in interface FilesService
      • openFile

        public int openFile​(long fileTopicId)
        Specified by:
        openFile in interface FilesService
      • staticResourceFilter

        public void staticResourceFilter​(javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response)
        Specified by:
        staticResourceFilter in interface StaticResourceFilter
      • repoPath

        public String repoPath​(File path)