Interface DocumentDAO

All Superinterfaces:
PersistentObjectDAO<Document>
All Known Implementing Classes:
HibernateDocumentDAO

public interface DocumentDAO extends PersistentObjectDAO<Document>
This class is a DAO-service for documents.
Version:
1.0
Author:
Michael Scholz, Marco Meschieri
  • Method Details Link icon

    • findDocument Link icon

      Document findDocument(long docId) throws PersistenceException
      This method finds a document by the ID and if it is an alias the referenced document is returned instead.
      Parameters:
      docId - ID of the document(or the alias)
      Returns:
      Document with given ID
      Throws:
      PersistenceException - an error happened in the database
    • findByCustomId Link icon

      Document findByCustomId(String customId, long tenantId) throws PersistenceException
      This method finds a document by the custom ID.
      Parameters:
      customId - custom ID of the document.
      tenantId - ID of the contained tenant.
      Returns:
      Document with given ID.
      Throws:
      PersistenceException - error at data layer
    • findByUserId Link icon

      List<Long> findByUserId(long userId) throws PersistenceException
      Finds all documents for an user.
      Parameters:
      userId - ID of the user.
      Returns:
      Collection of all documentId required for the specified user.
      Throws:
      PersistenceException - error at data layer
    • findDocIdByFolder Link icon

      List<Long> findDocIdByFolder(long folderId, Integer max) throws PersistenceException
      Finds all document ids inside the given folder.
      Parameters:
      folderId - Folder identifier
      max - Optional, maximum number of returned elements
      Returns:
      Collection of all document id in the folder.
      Throws:
      PersistenceException - error at data layer
    • findByFolder Link icon

      List<Document> findByFolder(long folderId, Integer max) throws PersistenceException
      Finds all documents direct children of the given folder.
      Parameters:
      folderId - Folder identifier
      max - Optional, defines the maximum records number
      Returns:
      Collection of all documents in the folder
      Throws:
      PersistenceException - error at data layer
    • findByLockUserAndStatus Link icon

      List<Document> findByLockUserAndStatus(Long userId, Integer status)
      Finds all document of0 the specified status and locked by the specified user
      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.
    • findLastModifiedByUserId Link icon

      List<Document> findLastModifiedByUserId(long userId, int max) throws PersistenceException
      Finds a max number of documents last modified by an user.
      Parameters:
      userId - ID of the user.
      max - maximum number of returned elements
      Returns:
      Collection of the last documents changed by the specified user.
      Throws:
      PersistenceException - error at data layer
    • findLastDownloadsByUserId Link icon

      List<Document> findLastDownloadsByUserId(long userId, int max) throws PersistenceException
      Finds the last downloaded documents by the given user
      Parameters:
      userId - id of the user
      max - maximum number of returned elements
      Returns:
      list of documents
      Throws:
      PersistenceException - error at data layer
    • findByIds Link icon

      List<Document> findByIds(Set<Long> ids, Integer max)
      Finds all documents whose id is included in the given pool of ids
      Parameters:
      ids - identifiers of the documents
      max - Optional, maximum number of returned elements
      Returns:
      list of documents
    • findDocIdByTag Link icon

      List<Long> findDocIdByTag(String tag) throws PersistenceException
      This method finds all Doc Ids by a tag.
      Parameters:
      tag - Tag of the document.
      Returns:
      Document with specified tag.
      Throws:
      PersistenceException - error at data layer
    • findTags Link icon

      Map<String,Long> findTags(String firstLetter, Long tenantId) throws PersistenceException
      Selects all tags and counts the occurrences.
      Parameters:
      firstLetter - the first letter
      tenantId - identifier of the tenant
      Returns:
      the map tag - count
      Throws:
      PersistenceException - error at data layer
    • findAllTags Link icon

      List<String> findAllTags(String firstLetter, Long tenantId) throws PersistenceException
      Searches for all tags,
      Parameters:
      firstLetter - Optional first letter hint
      tenantId - ID of the tenant to search in
      Returns:
      The list of all tags in the system
      Throws:
      PersistenceException - error at data layer
    • findByUserIdAndTag Link icon

      List<Document> findByUserIdAndTag(long userId, String tag, Integer max) throws PersistenceException
      Finds authorized documents for a user having a specified tag.
      Parameters:
      userId - ID of the user
      tag - Tag of the document
      max - Optional, defines the maximum records number
      Returns:
      Collection of found documents
      Throws:
      PersistenceException - error at data layer
    • findDocIdByUserIdAndTag Link icon

      List<Long> findDocIdByUserIdAndTag(long userId, String tag) throws PersistenceException
      Finds authorized documents ids for a user having a specified tag.
      Parameters:
      userId - ID of the user.
      tag - Tag of the document
      Returns:
      Set of found ids.
      Throws:
      PersistenceException - error at data layer
    • findLinkedDocuments Link icon

      List<Document> findLinkedDocuments(long docId, String linkType, Integer direction) throws PersistenceException
      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
      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
      Throws:
      PersistenceException - error at data layer
    • findByFileNameAndParentFolderId Link icon

      List<Document> findByFileNameAndParentFolderId(Long folderId, String fileName, Long excludeId, Long tenantId, Integer max) throws PersistenceException
      Finds that document that lies under a specific folder (given by the id) an with a given fileName(like operator is used)
      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
      Throws:
      PersistenceException - error at data layer
    • findByPath Link icon

      Document findByPath(String path, long tenantId) throws PersistenceException
      Finds a document by it's full path
      Parameters:
      path - The path comprehensive of the file name
      tenantId - The tenant
      Returns:
      the found document
      Throws:
      PersistenceException - error at data layer
    • initialize Link icon

      void initialize(Document doc)
      Initializes lazy loaded collections
      Specified by:
      initialize in interface PersistentObjectDAO<Document>
      Parameters:
      doc - The document to be initialized
    • computeTotalSize Link icon

      long computeTotalSize(Long tenantId, Long publisherId, boolean computeDeleted) throws PersistenceException
      Obtains the total size of the repository, that is the sum of sizes of all documents and their versions
      Parameters:
      tenantId - identifier of the tenant(optional)
      publisherId - identifier of the publisher user (optional)
      computeDeleted - If true, even deleted documents are considered
      Returns:
      the total size expressed in bytes
      Throws:
      PersistenceException - error at data layer
    • findDeletedDocIds Link icon

      List<Long> findDeletedDocIds() throws PersistenceException
      Gets the collection of deleted document ids
      Returns:
      collection of document identifiers
      Throws:
      PersistenceException - error at data layer
    • findDeletedDocs Link icon

      List<Document> findDeletedDocs() throws PersistenceException
      Finds the list of deleted documents.

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

      Returns:
      the list of documents
      Throws:
      PersistenceException - error at data layer
    • count Link icon

      long count(Long tenantId, boolean computeDeleted, boolean computeArchived) throws PersistenceException
      Counts the number of documents
      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
      Throws:
      PersistenceException - error at data layer
    • findByIndexed Link icon

      List<Document> findByIndexed(int indexed) throws PersistenceException
      Finds all documents by the indexed state. Order by ascending lastModifed
      Parameters:
      indexed - the indexed property
      Returns:
      Collection of all documents
      Throws:
      PersistenceException - error at data layer
    • countByIndexed Link icon

      long countByIndexed(int indexed) throws PersistenceException
      Counts the number of documents in a given indexation status(@see AbstractDocument.getIndexed()
      Parameters:
      indexed - the indexation status to check
      Returns:
      number of documents
      Throws:
      PersistenceException - error at data layer
    • restore Link icon

      void restore(long docId, long folderId, DocumentHistory transaction) throws PersistenceException
      Restores a previously deleted document
      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 - error at data layer
    • unarchive Link icon

      void unarchive(long docId, DocumentHistory transaction) throws PersistenceException
      Restores a previously archived document
      Parameters:
      docId - Ids of the document to be restored
      transaction - entry to log the event
      Throws:
      PersistenceException - error at data layer
    • makeImmutable Link icon

      void makeImmutable(long docId, DocumentHistory transaction) throws PersistenceException
      Marks the document, with the given docId, as immutable. Unlocks the document if it was locked.
      Parameters:
      docId - identifier of the document
      transaction - entry to log the event
      Throws:
      PersistenceException - error at data layer
    • deleteAll Link icon

      void deleteAll(Collection<Document> documents, DocumentHistory transaction) throws PersistenceException
      Shortcut for deleteAll(documents, 1, transaction)
      Parameters:
      documents - the documents
      transaction - the current session
      Throws:
      PersistenceException - error at data layer
    • deleteAll Link icon

      void deleteAll(Collection<Document> documents, int delCode, DocumentHistory transaction) throws PersistenceException
      Deletes all documents form the database and modifies the custom ids of all documents
      Parameters:
      documents - The documents to be deleted
      delCode - The deletion code
      transaction - entry to log the event
      Throws:
      PersistenceException - error at data layer
    • store Link icon

      void store(Document doc, DocumentHistory transaction) throws PersistenceException
      This method persists the document object and insert a new document history entry
      Parameters:
      doc - the document
      transaction - entry to log the event
      Throws:
      PersistenceException - error at data layer
    • delete Link icon

      void delete(long docId, int delCode, DocumentHistory transaction) throws PersistenceException
      This method deletes the document object and insert a new document history entry.
      Parameters:
      docId - The id of the document to delete
      delCode - The deletion code
      transaction - entry to log the event
      Throws:
      PersistenceException - error at data layer
    • delete Link icon

      void delete(long docId, DocumentHistory transaction) throws PersistenceException
      Shortcut for delete(docId, 1, transaction)
      Parameters:
      docId - identifier of the document
      transaction - entry to log the event
      Throws:
      PersistenceException - error at data layer
    • archive Link icon

      void archive(long docId, DocumentHistory transaction) throws PersistenceException
      Archives a document
      Parameters:
      docId - identifier of the document
      transaction - entry to log the event
      Throws:
      PersistenceException - error at data layer
    • findArchivedByFolder Link icon

      List<Document> findArchivedByFolder(long folderId) throws PersistenceException
      Finds archived documents in a folder (direct childeren only)
      Parameters:
      folderId - identifier of the folder
      Returns:
      list of documents
      Throws:
      PersistenceException - error at data layer
    • findAliasIds Link icon

      List<Long> findAliasIds(long docId) throws PersistenceException
      Gets the ids of all aliases associated to the document with the given docId
      Parameters:
      docId - identifier of the document
      Returns:
      list of identifiers of aliases
      Throws:
      PersistenceException - error at data layer
    • findDeleted Link icon

      List<Document> findDeleted(long userId, Integer max) throws PersistenceException
      Finds all deleted docs of a specific user.
      Parameters:
      userId - The user that performed the deletion
      max - Optional, defines the max number of returned elements
      Returns:
      The documents list
      Throws:
      PersistenceException - error at data layer
    • deleteOrphaned Link icon

      void deleteOrphaned(long deleteUserId) throws PersistenceException
      This method deletes the documents into deleted folders.
      Parameters:
      deleteUserId - The id of the user that performs the deleting
      Throws:
      PersistenceException - error at data layer
    • findPublishedIds Link icon

      Collection<Long> findPublishedIds(Collection<Long> folderIds) throws PersistenceException
      Finds all document ids inside the specified folders that are published in the current date.
      Parameters:
      folderIds - Set of folder ids in which the method will search
      Returns:
      List of published document ids
      Throws:
      PersistenceException - error at data layer
    • updateDigest Link icon

      void updateDigest(Document doc) throws PersistenceException
      Updates the document's digest (SHA-1)
      Parameters:
      doc - The document to be processed
      Throws:
      PersistenceException - error at data layer
    • cleanExpiredTransactions Link icon

      void cleanExpiredTransactions() throws PersistenceException
      Cleans all references to expired transactions. If no lock is found for a document referencing a given transaction, the transactionId will be set to null.
      Throws:
      PersistenceException - error at data layer
    • saveDocumentHistory Link icon

      void saveDocumentHistory(Document doc, DocumentHistory transaction) throws PersistenceException
      Saves a document's history
      Parameters:
      doc - the document
      transaction - the current session
      Throws:
      PersistenceException - error at data layer
    • cleanUnexistingUniqueTags Link icon

      void cleanUnexistingUniqueTags() throws PersistenceException
      Cleans the ld_uniquetag table removing no more used tags, this method is optimized and uses a couple of prepared statements, in case of error it switches to cleanUnexistingUniqueTagsOneByOne()
      Throws:
      PersistenceException - error at data layer
    • cleanUnexistingUniqueTagsOneByOne Link icon

      void cleanUnexistingUniqueTagsOneByOne() throws PersistenceException
      Cleans the ld_uniquetag table removing no more used tags programmatically one by one. This method is not as optimized as cleanUnexistingUniqueTags() and should not be invoked directly
      Throws:
      PersistenceException - error at data layer
    • insertNewUniqueTags Link icon

      void insertNewUniqueTags() throws PersistenceException
      Puts into ld_uniquetag the new unique tags
      Throws:
      PersistenceException - error at data layer
    • updateCountUniqueTags Link icon

      void updateCountUniqueTags() throws PersistenceException
      Updates the count of the unique tags
      Throws:
      PersistenceException - error at data layer
    • getTagCloud Link icon

      List<TagCloud> getTagCloud(long tenantId, int max) throws PersistenceException
      Gets the tag cloud for the given tenant
      Parameters:
      tenantId - identifier of the tenant
      max - maximum number of returned elements
      Returns:
      list of tag clouds
      Throws:
      PersistenceException - error at data layer
    • getTagCloud Link icon

      List<TagCloud> getTagCloud(String sid) throws PersistenceException
      Gets the tag cloud for the given tenant
      Parameters:
      sid - identifier of the session
      Returns:
      list of tag clouds
      Throws:
      PersistenceException - error at data layer
    • getWorkspace Link icon

      Folder getWorkspace(long docId) throws PersistenceException
      Retrieves, the workspace where the document(or alias) is stored
      Parameters:
      docId - identifier of a document
      Returns:
      the parent workspace
      Throws:
      PersistenceException - error at data layer
    • setPassword Link icon

      void setPassword(long docId, String password, DocumentHistory transaction) throws PersistenceException
      Protects the document with a password. The same password is replicated to all the versions
      Parameters:
      docId - ID of the document
      password - The new password in clear
      transaction - history informations
      Throws:
      PersistenceException - error at data layer
    • unsetPassword Link icon

      void unsetPassword(long docId, DocumentHistory transaction) throws PersistenceException
      Removes the password protection from the document. The same action is replicated to all the versions
      Parameters:
      docId - ID of the document
      transaction - session informations
      Throws:
      PersistenceException - error at data layer
    • findDuplicatedDigests Link icon

      List<String> findDuplicatedDigests(Long tenantId, Long folderId) throws PersistenceException
      Retrieves the list of duplicated checksums
      Parameters:
      tenantId - identifier of the tenant
      folderId - identifier of the folder
      Returns:
      list of duplicated digests
      Throws:
      PersistenceException - error at data layer
    • findTags Link icon

      List<String> findTags(long docId) throws PersistenceException
      Retrieves the alphabetically ordered list of all the document's tags
      Parameters:
      docId - identifier of the document
      Returns:
      list of the document's tags
      Throws:
      PersistenceException - error at data layer
    • applyParentFolderSecurity Link icon

      void applyParentFolderSecurity(long docId, DocumentHistory transaction) throws PersistenceException
      Replaces the document's security policies with those from the parent folder
      Parameters:
      docId - identifier of the document
      transaction - the current transaction
      Throws:
      PersistenceException - error at data layer
    • isWriteAllowed Link icon

      boolean isWriteAllowed(long documentId, long userId) throws PersistenceException
      This method is looking up for writing rights for a document and an user.
      Parameters:
      documentId - ID of the document
      userId - ID of the user
      Returns:
      if the write permission is granted
      Throws:
      PersistenceException - error at data layer
    • isReadAllowed Link icon

      boolean isReadAllowed(long documentId, long userId) throws PersistenceException
      Throws:
      PersistenceException
    • isPreviewAllowed Link icon

      boolean isPreviewAllowed(long documentId, long userId) throws PersistenceException
      Throws:
      PersistenceException
    • isPrintAllowed Link icon

      boolean isPrintAllowed(long documentId, long userId) throws PersistenceException
      Throws:
      PersistenceException
    • isDownloadAllowed Link icon

      boolean isDownloadAllowed(long documentId, long userId) throws PersistenceException
      Throws:
      PersistenceException
    • isMoveAllowed Link icon

      boolean isMoveAllowed(long documentId, long userId) throws PersistenceException
      Throws:
      PersistenceException
    • isPermissionAllowed Link icon

      boolean isPermissionAllowed(Permission permission, long documentId, long userId) throws PersistenceException
      This method checks if the given permission is enabled for a document and an user.
      Parameters:
      permission - the permission to check
      documentId - ID of the folder
      userId - ID of the user
      Returns:
      if the permission is granted to the user
      Throws:
      PersistenceException - error at data layer
    • getAllowedPermissions Link icon

      Set<Permission> getAllowedPermissions(long documentId, long userId) throws PersistenceException
      Finds all permissions of a user enabled on the specified document
      Parameters:
      documentId - ID of the document
      userId - ID of the user
      Returns:
      Collection of enabled permissions
      Throws:
      PersistenceException - error at data layer