Class HibernateDocumentDAO

    • Method Detail

      • setVersionDAO

        public void setVersionDAO​(VersionDAO versionDAO)
      • setUserDAO

        public void setUserDAO​(UserDAO userDAO)
      • setDocumentHistoryDAO

        public void setDocumentHistoryDAO​(DocumentHistoryDAO documentHistoryDAO)
      • archive

        public boolean archive​(long docId,
                               DocumentHistory transaction)
        Description copied from interface: DocumentDAO
        Archives a document
        Specified by:
        archive in interface DocumentDAO
        Parameters:
        docId - identifier of the document
        transaction - entry to log the event
        Returns:
        true if document has been archived
      • unarchive

        public void unarchive​(long docId,
                              DocumentHistory transaction)
        Description copied from interface: DocumentDAO
        Restores a previously archived document
        Specified by:
        unarchive in interface DocumentDAO
        Parameters:
        docId - Ids of the document to be restored
        transaction - entry to log the event
      • delete

        public boolean delete​(long docId,
                              DocumentHistory transaction)
        Description copied from interface: DocumentDAO
        Shortcut for delete(docId, 1, transaction)
        Specified by:
        delete in interface DocumentDAO
        Parameters:
        docId - identifier of the document
        transaction - entry to log the event
        Returns:
        True if successfully deleted from the database.
      • delete

        public boolean delete​(long docId,
                              int delCode,
                              DocumentHistory transaction)
        Description copied from interface: DocumentDAO
        This method deletes the document object and insert a new document history entry.
        Specified by:
        delete in interface DocumentDAO
        Parameters:
        docId - The id of the document to delete
        delCode - The deletion code
        transaction - entry to log the event
        Returns:
        True if successfully deleted from the database.
      • findByUserId

        public List<Long> findByUserId​(long userId)
        Description copied from interface: DocumentDAO
        Finds all documents for an user.
        Specified by:
        findByUserId in interface DocumentDAO
        Parameters:
        userId - ID of the user.
        Returns:
        Collection of all documentId required for the specified user.
      • findByLockUserAndStatus

        public List<Document> findByLockUserAndStatus​(Long userId,
                                                      Integer status)
        Description copied from interface: DocumentDAO
        Finds all document of the specified status and locked by the specified user
        Specified by:
        findByLockUserAndStatus in interface DocumentDAO
        Parameters:
        userId - The user id(optional)
        status - The status code(optional)
        Returns:
        Collection of all Documents locked by the specified user and of the specified status.
      • findDocIdByTag

        public List<Long> findDocIdByTag​(String tag)
        Description copied from interface: DocumentDAO
        This method finds all Doc Ids by a tag.
        Specified by:
        findDocIdByTag in interface DocumentDAO
        Parameters:
        tag - Tag of the document.
        Returns:
        Document with specified tag.
      • store

        public boolean store​(Document doc,
                             DocumentHistory transaction)
                      throws PersistenceException
        Description copied from interface: DocumentDAO
        This method persists the document object and insert a new document history entry
        Specified by:
        store in interface DocumentDAO
        Parameters:
        doc - the document
        transaction - entry to log the event
        Returns:
        True if successfully stored in a database
        Throws:
        PersistenceException - raised in case of database errors
      • findLastModifiedByUserId

        public List<Document> findLastModifiedByUserId​(long userId,
                                                       int maxElements)
        Description copied from interface: DocumentDAO
        Finds a max number of documents last modified by an user.
        Specified by:
        findLastModifiedByUserId in interface DocumentDAO
        Parameters:
        userId - ID of the user.
        maxElements - maximum number of returned elements
        Returns:
        Collection of the last documents changed by the specified user.
      • findTags

        public List<String> findTags​(long docId)
        Description copied from interface: DocumentDAO
        Retrieves the alphabetically ordered list of all the document's tags
        Specified by:
        findTags in interface DocumentDAO
        Parameters:
        docId - identifier of the document
        Returns:
        list of the document's tags
      • findTags

        public Map<String,​Long> findTags​(String firstLetter,
                                               Long tenantId)
        Description copied from interface: DocumentDAO
        Selects all tags and counts the occurrences.
        Specified by:
        findTags in interface DocumentDAO
        Parameters:
        firstLetter - the first letter
        tenantId - identifier of the tenant
        Returns:
        the map tag - count
      • findAllTags

        public List<String> findAllTags​(String firstLetter,
                                        Long tenantId)
        Description copied from interface: DocumentDAO
        Searches for all tags,
        Specified by:
        findAllTags in interface DocumentDAO
        Parameters:
        firstLetter - Optional first letter hint
        tenantId - ID of the tenant to search in
        Returns:
        The list of all tags in the system
      • findByUserIdAndTag

        public List<Document> findByUserIdAndTag​(long userId,
                                                 String tag,
                                                 Integer max)
        Description copied from interface: DocumentDAO
        Finds authorized documents for a user having a specified tag.
        Specified by:
        findByUserIdAndTag in interface DocumentDAO
        Parameters:
        userId - ID of the user
        tag - Tag of the document
        max - Optional, defines the maximum records number
        Returns:
        Collection of found documents
      • findDocIdByUserIdAndTag

        public List<Long> findDocIdByUserIdAndTag​(long userId,
                                                  String tag)
        Description copied from interface: DocumentDAO
        Finds authorized documents ids for a user having a specified tag.
        Specified by:
        findDocIdByUserIdAndTag in interface DocumentDAO
        Parameters:
        userId - ID of the user.
        tag - Tag of the document
        Returns:
        Set of found ids.
      • findLastDownloadsByUserId

        public List<Document> findLastDownloadsByUserId​(long userId,
                                                        int maxResults)
        Description copied from interface: DocumentDAO
        Finds the last downloaded documents by the given user
        Specified by:
        findLastDownloadsByUserId in interface DocumentDAO
        Parameters:
        userId - id of the user
        maxResults - maximum number of returned elements
        Returns:
        list of documents
      • findDocIdByFolder

        public List<Long> findDocIdByFolder​(long folderId,
                                            Integer max)
        Description copied from interface: DocumentDAO
        Finds all document ids inside the given folder.
        Specified by:
        findDocIdByFolder in interface DocumentDAO
        Parameters:
        folderId - Folder identifier
        max - Optional, maximum number of returned elements
        Returns:
        Collection of all document id in the folder.
      • findByFolder

        public List<Document> findByFolder​(long folderId,
                                           Integer max)
        Description copied from interface: DocumentDAO
        Finds all documents direct children of the given folder.
        Specified by:
        findByFolder in interface DocumentDAO
        Parameters:
        folderId - Folder identifier
        max - Optional, defines the maximum records number
        Returns:
        Collection of all documents in the folder.
      • findArchivedByFolder

        public List<Document> findArchivedByFolder​(long folderId)
        Description copied from interface: DocumentDAO
        Finds archived documents in a folder (direct childeren only)
        Specified by:
        findArchivedByFolder in interface DocumentDAO
        Parameters:
        folderId - identifier of the folder
        Returns:
        list of documents
      • findLinkedDocuments

        public List<Document> findLinkedDocuments​(long docId,
                                                  String linkType,
                                                  Integer direction)
        Description copied from interface: DocumentDAO
        This method enlists documents linked to the given document.

        Important: The attribute direction defines the search logic as follows:

        • 1: docId will be compared to link's document1
        • 2: docId will be compared to link's document2
        • null: docId will be compared to both document1 and document2
        Specified by:
        findLinkedDocuments in interface DocumentDAO
        Parameters:
        docId - All documents linked to this one will be searched
        linkType - Type of the link (optional)
        direction - if 1 docId will be compared to link's document1, id 2 docId will be compared to link's document2, if null docId will be compared to both document1 and document2 of the link.
        Returns:
        The collection of linked documents
      • findByFileNameAndParentFolderId

        public List<Document> findByFileNameAndParentFolderId​(Long folderId,
                                                              String fileName,
                                                              Long excludeId,
                                                              Long tenantId,
                                                              Integer max)
        Description copied from interface: DocumentDAO
        Finds that document that lies under a specific folder (given by the id) an with a given fileName(like operator is used)
        Specified by:
        findByFileNameAndParentFolderId in interface DocumentDAO
        Parameters:
        folderId - The folder id (it can be null).
        fileName - name of the file or a part of it (you can use SQL % jolly chars, eg: contract.pdf, %ontrac%)
        excludeId - Optional id of a document that must not be considered
        tenantId - Optional id of the tenant
        max - Optional maximum number of returned elements
        Returns:
        The list of documents with the given fileName. If the folder id is null, the searched document can belong to any folder in the repository.
      • findDeletedDocIds

        public List<Long> findDeletedDocIds()
        Description copied from interface: DocumentDAO
        Gets the collection of deleted document ids
        Specified by:
        findDeletedDocIds in interface DocumentDAO
        Returns:
        collection of document identifiers
      • findDeletedDocs

        public List<Document> findDeletedDocs()
        Description copied from interface: DocumentDAO
        Finds the list of deleted documents.

        Attention: The returned objects are not fully operative and are populated with a minimal set of data.

        Specified by:
        findDeletedDocs in interface DocumentDAO
        Returns:
        the list of documents
      • computeTotalSize

        public long computeTotalSize​(Long tenantId,
                                     Long userId,
                                     boolean computeDeleted)
        Description copied from interface: DocumentDAO
        Obtains the total size of the repository, that is the sum of sizes of all documents and their versions
        Specified by:
        computeTotalSize in interface DocumentDAO
        Parameters:
        tenantId - identifier of the tenant(optional)
        userId - identifier of the publisher user (optional)
        computeDeleted - If true, even deleted documents are considered
        Returns:
        the total size expressed in bytes
      • count

        public long count​(Long tenantId,
                          boolean computeDeleted,
                          boolean computeArchived)
        Description copied from interface: DocumentDAO
        Counts the number of documents
        Specified by:
        count in interface DocumentDAO
        Parameters:
        tenantId - The tenant to search in
        computeDeleted - If true, even deleted documents are considered
        computeArchived - If true, even archived documents are considered
        Returns:
        number of documents
      • findByIndexed

        public List<Document> findByIndexed​(int indexed)
        Description copied from interface: DocumentDAO
        Finds all documents by the indexed state. Order by ascending lastModifed
        Specified by:
        findByIndexed in interface DocumentDAO
        Parameters:
        indexed - the indexed property
        Returns:
        Collection of all documents
      • restore

        public void restore​(long docId,
                            long folderId,
                            DocumentHistory transaction)
                     throws PersistenceException
        Description copied from interface: DocumentDAO
        Restores a previously deleted document
        Specified by:
        restore in interface DocumentDAO
        Parameters:
        docId - Id of the document to be restored
        folderId - Id of the folder the document will be restored into
        transaction - entry to log the event
        Throws:
        PersistenceException - raised in case of database errors
      • findByCustomId

        public Document findByCustomId​(String customId,
                                       long tenantId)
        Description copied from interface: DocumentDAO
        This method finds a document by the custom ID.
        Specified by:
        findByCustomId in interface DocumentDAO
        Parameters:
        customId - custom ID of the document.
        tenantId - ID of the contained tenant.
        Returns:
        Document with given ID.
      • makeImmutable

        public void makeImmutable​(long docId,
                                  DocumentHistory transaction)
        Description copied from interface: DocumentDAO
        Marks the document, with the given docId, as immutable. Unlocks the document if it was locked.
        Specified by:
        makeImmutable in interface DocumentDAO
        Parameters:
        docId - identifier of the document
        transaction - entry to log the event
      • deleteAll

        public void deleteAll​(Collection<Document> documents,
                              DocumentHistory transaction)
        Description copied from interface: DocumentDAO
        Shortcut for deleteAll(documents, 1, transaction)
        Specified by:
        deleteAll in interface DocumentDAO
        Parameters:
        documents - the documents
        transaction - the current session
      • deleteAll

        public void deleteAll​(Collection<Document> documents,
                              int delCode,
                              DocumentHistory transaction)
        Description copied from interface: DocumentDAO
        Deletes all documents form the database and modifies the custom ids of all documents
        Specified by:
        deleteAll in interface DocumentDAO
        Parameters:
        documents - The documents to be deleted
        delCode - The deletion code
        transaction - entry to log the event
      • setStorer

        public void setStorer​(Storer storer)
      • countByIndexed

        public long countByIndexed​(int indexed)
        Description copied from interface: DocumentDAO
        Counts the number of documents in a given indexation status(@see AbstractDocument.getIndexed()
        Specified by:
        countByIndexed in interface DocumentDAO
        Parameters:
        indexed - the indexation status to check
        Returns:
        number of documents
      • findAliasIds

        public List<Long> findAliasIds​(long docId)
        Description copied from interface: DocumentDAO
        Gets the ids of all aliases associated to the document with the given docId
        Specified by:
        findAliasIds in interface DocumentDAO
        Parameters:
        docId - identifier of the document
        Returns:
        list of identifiers of aliases
      • findDeleted

        public List<Document> findDeleted​(long userId,
                                          Integer maxHits)
        Description copied from interface: DocumentDAO
        Finds all deleted docs of a specific user.
        Specified by:
        findDeleted in interface DocumentDAO
        Parameters:
        userId - The user that performed the deletion
        maxHits - Optional, defines the max number of returned elements
        Returns:
        The documents list
      • setFolderDAO

        public void setFolderDAO​(FolderDAO folderDAO)
      • findByIds

        public List<Document> findByIds​(Long[] ids,
                                        Integer max)
        Description copied from interface: DocumentDAO
        Finds all documents whose id is included in the given pool of ids
        Specified by:
        findByIds in interface DocumentDAO
        Parameters:
        ids - identifiers of the documents
        max - Optional, maximum number of returned elements
        Returns:
        list of documents
      • deleteOrphaned

        public boolean deleteOrphaned​(long deleteUserId)
        Description copied from interface: DocumentDAO
        This method deletes the documents into deleted folders.
        Specified by:
        deleteOrphaned in interface DocumentDAO
        Parameters:
        deleteUserId - The id of the user that performs the deleting.
        Returns:
        True if successfully deleted from the database.
      • findPublishedIds

        public Collection<Long> findPublishedIds​(Collection<Long> folderIds)
        Description copied from interface: DocumentDAO
        Finds all document ids inside the specified folders that are published in the current date.
        Specified by:
        findPublishedIds in interface DocumentDAO
        Parameters:
        folderIds - Set of folder ids in which the method will search
        Returns:
        List of published document ids
      • setTenantDAO

        public void setTenantDAO​(TenantDAO tenantDAO)
      • cleanUnexistingUniqueTags

        public void cleanUnexistingUniqueTags()
        Description copied from interface: DocumentDAO
        Cleans the ld_uniquetag table removing no more used tags
        Specified by:
        cleanUnexistingUniqueTags in interface DocumentDAO
      • insertNewUniqueTags

        public void insertNewUniqueTags()
        Description copied from interface: DocumentDAO
        Puts into ld_uniquetag the new unique tags
        Specified by:
        insertNewUniqueTags in interface DocumentDAO
      • getTagCloud

        public List<TagCloud> getTagCloud​(long tenantId,
                                          int maxTags)
        Description copied from interface: DocumentDAO
        Gets the tag cloud for the given tenant
        Specified by:
        getTagCloud in interface DocumentDAO
        Parameters:
        tenantId - identifier of the tenant
        maxTags - maximum number of returned elements
        Returns:
        list of tag clouds
      • getTagCloud

        public List<TagCloud> getTagCloud​(String sid)
        Description copied from interface: DocumentDAO
        Gets the tag cloud for the given tenant
        Specified by:
        getTagCloud in interface DocumentDAO
        Parameters:
        sid - identifier of the session
        Returns:
        list of tag clouds
      • findDocument

        public Document findDocument​(long docId)
        Description copied from interface: DocumentDAO
        This method finds a document by the ID and if it is an alias the referenced document is returned instead.
        Specified by:
        findDocument in interface DocumentDAO
        Parameters:
        docId - ID of the document(or the alias)
        Returns:
        Document with given ID.
      • getWorkspace

        public Folder getWorkspace​(long docId)
        Description copied from interface: DocumentDAO
        Retrieves, the workspace where the document(or alias) is stored
        Specified by:
        getWorkspace in interface DocumentDAO
        Parameters:
        docId - identifier of a document
        Returns:
        the parent workspace
      • setPassword

        public void setPassword​(long docId,
                                String password,
                                DocumentHistory transaction)
                         throws PersistenceException
        Description copied from interface: DocumentDAO
        Protects the document with a password. The same password is replicated to all the versions
        Specified by:
        setPassword in interface DocumentDAO
        Parameters:
        docId - ID of the document
        password - The new password in clear
        transaction - history informations
        Throws:
        PersistenceException - raised in case of database errors
      • unsetPassword

        public void unsetPassword​(long docId,
                                  DocumentHistory transaction)
                           throws PersistenceException
        Description copied from interface: DocumentDAO
        Removes the password protection from the document. The same action is replicated to all the versions
        Specified by:
        unsetPassword in interface DocumentDAO
        Parameters:
        docId - ID of the document
        transaction - session informations
        Throws:
        PersistenceException - raised in case of database errors
      • findByPath

        public Document findByPath​(String path,
                                   long tenantId)
        Description copied from interface: DocumentDAO
        Finds a document by it's full path
        Specified by:
        findByPath in interface DocumentDAO
        Parameters:
        path - The path comprehensive of the file name
        tenantId - The tenant
        Returns:
        the found document
      • findDuplicatedDigests

        public List<String> findDuplicatedDigests​(Long tenantId,
                                                  Long folderId)
        Description copied from interface: DocumentDAO
        Retrieves the list of duplicated checksums
        Specified by:
        findDuplicatedDigests in interface DocumentDAO
        Parameters:
        tenantId - identifier of the tenant
        folderId - identifier of the folder
        Returns:
        list of duplicated digests