Class WorkspaceExplorerResourceDAO

    • Method Detail

      • setPluginInfo

        public void setPluginInfo​(String pluginName,
                                  String featureName,
                                  String id)
        Description copied from interface: PluginAware
        Sets the plugin info relative to the current component.
        Note : The feature name may be null if the targeted component in declared at plugin level.
        Specified by:
        setPluginInfo in interface PluginAware
        Parameters:
        pluginName - Unique identifier for the plugin hosting the extension
        featureName - Unique feature identifier (unique for a given pluginName)
        id - Unique identifier of this component
      • addFolder

        public Map<String,​ObjectaddFolder​(String parentId,
                                                  String inputName,
                                                  String description)
                                           throws IllegalAccessException
        Add a folder
        Parameters:
        parentId - Identifier of the parent collection. Can be null to add folder to root folder.
        inputName - The desired name
        description - The folder description
        Returns:
        The created folder or an error if a folder with same name already exists.
        Throws:
        IllegalAccessException - If the user has no sufficient rights
      • addFolder

        public Map<String,​ObjectaddFolder​(String parentId,
                                                  String inputName,
                                                  String description,
                                                  Boolean renameIfExists)
        Add a folder
        Parameters:
        parentId - Identifier of the parent collection. Can be null to add folder to root folder.
        inputName - The desired name
        description - The folder description
        renameIfExists - True to rename if existing
        Returns:
        The result map with id, parentId and name keys
      • renameFolder

        public Map<String,​ObjectrenameFolder​(String id,
                                                     String name)
        Rename a folder
        Parameters:
        id - Identifier of the folder to edit
        name - The new name
        Returns:
        The result map with id and name keys
      • editFolder

        public Map<String,​ObjecteditFolder​(String id,
                                                   String inputName,
                                                   String description)
        Edit a folder
        Parameters:
        id - Identifier of the folder to edit
        inputName - The desired name
        description - The folder description
        Returns:
        The result map with id and name keys
      • deleteFolder

        public Map<String,​ObjectdeleteFolder​(String id)
        Delete a folder
        Parameters:
        id - Identifier of the folder to delete
        Returns:
        The result map with the parent id key
      • resourceExists

        public boolean resourceExists​(String parentId,
                                      String name)
        Determines if a resource with given name already exists
        Overrides:
        resourceExists in class ExplorerResourcesDAO
        Parameters:
        parentId - the id of parent collection. Can be null.
        name - the name of resource
        Returns:
        true if a resource with same name exists
      • renameFile

        public Map<String,​ObjectrenameFile​(String id,
                                                   String name)
        Rename a folder
        Parameters:
        id - Identifier of the folder to edit
        name - The new name
        Returns:
        The result map with id and name keys
      • editFile

        public Map<String,​ObjecteditFile​(String id,
                                                 String inputName,
                                                 String description,
                                                 Collection<String> tags)
        Edit a file
        Parameters:
        id - Identifier of the file to edit
        inputName - The desired name
        description - The file description
        tags - The file tags
        Returns:
        The result map with id and name keys
      • setTags

        public Map<String,​ObjectsetTags​(String resourceId,
                                                List<Object> tags)
        Set tags to resource
        Parameters:
        resourceId - the id of resources
        tags - the file tags to set
        Returns:
        the file tags
      • copyFiles

        public Map<String,​ObjectcopyFiles​(List<String> ids,
                                                  String targetId)
                                           throws RepositoryException
        Copy file resources
        Parameters:
        ids - The list of identifiers for the resources to copy
        targetId - The id of target to copy into. Can be null to copy into root folder.
        Returns:
        The result map with a message key in case of an error or with the list of uncopied/copied resources
        Throws:
        RepositoryException - If there is a repository error
      • moveDocuments

        public Map<String,​ObjectmoveDocuments​(List<String> ids,
                                                      String targetId)
                                               throws RepositoryException
        Move documents (files or folders)
        Parameters:
        ids - The list of identifiers for the objects to move
        targetId - The id of target to move into. Can be null to move documents to root folder.
        Returns:
        The result map with a message key in case of an error or with the list of unmoved/moved objects
        Throws:
        RepositoryException - If there is a repository error
      • searchFiles

        public Map<String,​ObjectsearchFiles​(String query,
                                                    String lang)
                                             throws Exception
        Search for files in the document module
        Parameters:
        query - The search query
        lang - The search language
        Returns:
        A result map containing a resources entry which is a list of the files data
        Throws:
        Exception - if an exception occurs
      • searchFilesByType

        public Map<String,​ObjectsearchFilesByType​(String type)
                                                   throws Exception
        Search for files by their type
        Parameters:
        type - The file type
        Returns:
        A result map containing a resources entry which is a list of the files data
        Throws:
        Exception - if an exception occurs
      • getFolder

        public Map<String,​ObjectgetFolder​(String folderId)
        Get folder
        Parameters:
        folderId - the folder id
        Returns:
        the folder as JSON object
      • getFile

        public Map<String,​ObjectgetFile​(String resourceId)
        Get file
        Parameters:
        resourceId - the resource id
        Returns:
        the file as JSON object
      • getFolders

        public List<Map<String,​Object>> getFolders​(String parentId)
        Get the child folders
        Parameters:
        parentId - the parent id. Can be null to get root folders
        Returns:
        the sub folders
      • getFiles

        public List<Map<String,​Object>> getFiles​(String parentId)
        Get the child files
        Parameters:
        parentId - the parent id. Can be null to get root files
        Returns:
        the child files
      • getFoldersAndFiles

        public Map<String,​ObjectgetFoldersAndFiles​(String folderId)
        Get the child folders and files
        Parameters:
        folderId - the parent id. Can be null to get root folders and files
        Returns:
        the child folders and files
      • getChildDocumentsData

        public List<Map<String,​Object>> getChildDocumentsData​(String parentId,
                                                                    boolean excludeFolders,
                                                                    boolean excludeFiles)
        Retrieves the children of a document and extracts its data.
        Parameters:
        parentId - Identifier of the parent collection. Can be null to get children of root folder.
        excludeFolders - Folders will be excluded if true
        excludeFiles - Files will be excluded if true
        Returns:
        The map of information
      • getChildDocumentsData

        public List<Map<String,​Object>> getChildDocumentsData​(ResourceCollection document,
                                                                    boolean excludeFolders,
                                                                    boolean excludeFiles)
        Retrieves the children of a document and extracts its data.
        Parameters:
        document - the document
        excludeFolders - Folders will be excluded if true
        excludeFiles - Files will be excluded if true
        Returns:
        The map of information
      • getDocumentData

        @Deprecated
        public Map<String,​ObjectgetDocumentData​(String id,
                                                        boolean excludeFilesInFolderHierarchy)
        Deprecated.
        Retrieves the set of standard data for a document (folder or resource)
        Parameters:
        id - the document id or null to get root document
        excludeFilesInFolderHierarchy - Should child files be taken into account when extracting data of a folder
        Returns:
        The map of data
      • getDocumentsData

        public List<Map<String,​Object>> getDocumentsData​(List<String> ids,
                                                               boolean excludeFilesInFolderHierarchy)
        Retrieves the set of standard data for a list of documents
        Parameters:
        ids - The list of document identifiers
        excludeFilesInFolderHierarchy - Should child files be taken into account when extracting data of a folder
        Returns:
        The map of data
      • generateWebdavUri

        public String generateWebdavUri​(String documentId)
        Generates an uri to open a document through webdav
        Parameters:
        documentId - The document identifier
        Returns:
        The generated uri
      • _extractDocumentData

        protected Map<String,​Object_extractDocumentData​(AmetysObject document,
                                                                boolean excludeFolders,
                                                                boolean excludeFiles)
        Internal method to extract the valuable data of a document
        Parameters:
        document - The document (file or folder)
        excludeFolders - Folders will be excluded if true
        excludeFiles - Files will be excluded if true
        Returns:
        the valuable document data
      • _hasChildren

        protected boolean _hasChildren​(ResourceCollection folder,
                                       boolean ignoreFiles)
        Internal method to detect if a document has child
        Parameters:
        folder - The folder
        ignoreFiles - Should child files be taken into account to compute the 'hasChildDocuments' data.
        Returns:
        the valuable folder data
      • _extractFolderRightData

        protected Map<String,​Object_extractFolderRightData​(ResourceCollection folder)
        Internal method to extract the data concerning the right of the current user for a folder
        Parameters:
        folder - The folder
        Returns:
        The map of right data. Keys are the rights id, and values indicates whether the current user has the right or not.
      • addFile

        public Map<String,​ObjectaddFile​(Part part,
                                                String parentId,
                                                boolean unarchive,
                                                boolean allowRename,
                                                boolean allowUpdate)
        Add a file
        Parameters:
        part - The uploaded part corresponding to the file
        parentId - Identifier of the parent collection
        unarchive - True if the file is an archive that should be unarchived (only available for ZIP file)
        allowRename - True if the file can be renamed if it already exists
        allowUpdate - True if the file can be updated if it already exists (and allowRename is false)
        Returns:
        The result map with id, parentId and name keys
      • addFile

        public Map<String,​ObjectaddFile​(InputStream inputStream,
                                                String fileName,
                                                String parentId,
                                                boolean unarchive,
                                                boolean allowRename,
                                                boolean allowUpdate)
        Add a file
        Parameters:
        inputStream - The uploaded input stream
        fileName - desired file name
        parentId - Identifier of the parent collection
        unarchive - True if the file is an archive that should be unarchived (only available for ZIP file)
        allowRename - True if the file can be renamed if it already exists
        allowUpdate - True if the file can be updated if it already exists (and allowRename is false)
        Returns:
        The result map with id, parentId and name keys
      • _extractFileData

        protected Map<String,​Object_extractFileData​(Resource file)
        Internal method to extract the valuable data of a file
        Parameters:
        file - The file
        Returns:
        the valuable file data
      • _extractFileRightData

        protected Map<String,​Object_extractFileRightData​(Resource file)
        Internal method to extract the data concerning the right of the current user for file
        Parameters:
        file - The file
        Returns:
        The map of right data. Keys are the rights id, and values indicates whether the current user has the right or not.
      • _extractFileLockData

        protected Map<String,​Object_extractFileLockData​(Resource file)
        Internal method to extract the data relative to the lock state of a file
        Parameters:
        file - The file
        Returns:
        The image specific data
      • _canView

        protected boolean _canView​(ResourceCollection folder)
        Indicates if the current user can view the folder
        Parameters:
        folder - The folder to test
        Returns:
        true if the folder can be viewed
      • _canView

        protected boolean _canView​(Resource file)
        Indicates if the current user can view the file
        Parameters:
        file - The file to test
        Returns:
        true if the file can be viewed
      • addCMISCollection

        public Map<String,​ObjectaddCMISCollection​(String parentId,
                                                          String originalName,
                                                          String url,
                                                          String login,
                                                          String password,
                                                          String repoId,
                                                          boolean renameIfExists)
        Description copied from class: ExplorerResourcesDAO
        Creates a new CMIS folder (see CMISRootResourcesCollection)
        Overrides:
        addCMISCollection in class ExplorerResourcesDAO
        Parameters:
        parentId - the id of parent folder
        originalName - the original name if CMIS folder
        url - The url of CMIS repository
        login - The user's login to access CMIS repository
        password - The user's password to access CMIS repository
        repoId - The id of CMIS repository
        renameIfExists - true to automatically renamed CMIS folder if requested name already exists
        Returns:
        the result map with id of created node
      • getDocumentsCount

        public Long getDocumentsCount​(Project project)
        Count the total of documents in the project
        Parameters:
        project - The project
        Returns:
        The total of documents, or null if the module is not activated