Class DocumentManagerImpl

  • All Implemented Interfaces:
    DocumentManager

    public class DocumentManagerImpl
    extends Object
    implements DocumentManager
    Basic Implementation of DocumentManager
    Since:
    3.5
    Author:
    Marco Meschieri - LogicalDOC
    • Constructor Detail

      • DocumentManagerImpl

        public DocumentManagerImpl()
    • Method Detail

      • setDocumentDAO

        public void setDocumentDAO​(DocumentDAO documentDAO)
      • setTemplateDAO

        public void setTemplateDAO​(TemplateDAO templateDAO)
      • setIndexer

        public void setIndexer​(SearchEngine indexer)
      • setVersionDAO

        public void setVersionDAO​(VersionDAO versionDAO)
      • setStorer

        public void setStorer​(Storer storer)
      • replaceFile

        public void replaceFile​(long docId,
                                String fileVersion,
                                InputStream content,
                                DocumentHistory transaction)
                         throws Exception
        Description copied from interface: DocumentManager
        Replaces the file of a given version
        Specified by:
        replaceFile in interface DocumentManager
        Parameters:
        docId - the document to be updated
        fileVersion - the file version
        content - the file to use
        transaction - entry to log the event (set the user)
        Throws:
        Exception - if an error occurs, this exception is thrown
      • replaceFile

        public void replaceFile​(long docId,
                                String fileVersion,
                                File newFile,
                                DocumentHistory transaction)
                         throws Exception
        Description copied from interface: DocumentManager
        Replaces the file of a given version
        Specified by:
        replaceFile in interface DocumentManager
        Parameters:
        docId - the document to be updated
        fileVersion - the file version
        newFile - the file to use
        transaction - entry to log the event (set the user)
        Throws:
        Exception - if an error occurs, this exception is thrown
      • checkin

        public void checkin​(long docId,
                            File file,
                            String filename,
                            boolean release,
                            AbstractDocument docVO,
                            DocumentHistory transaction)
                     throws Exception
        Description copied from interface: DocumentManager
        Checks in the given document
        Specified by:
        checkin in interface DocumentManager
        Parameters:
        docId - the document to be checked in
        file - of the new document version
        filename - new filename (can also be the old one)
        release - True if this is a new release(eg: 2.0) rather than a subversion(eg: 1.1)
        docVO - The value object containing document's metadata applied during the checkin (optional)
        transaction - entry to log the event, set the user and comment
        Throws:
        Exception - if an error occurs, this exception is thrown
      • checkin

        public void checkin​(long docId,
                            InputStream content,
                            String filename,
                            boolean release,
                            AbstractDocument docVO,
                            DocumentHistory transaction)
                     throws Exception
        Description copied from interface: DocumentManager
        Checks in the given document
        Specified by:
        checkin in interface DocumentManager
        Parameters:
        docId - the document to be checked in
        content - input stream pointing to the new document version
        filename - new filename (can also be the old one)
        release - True if this is a new release(eg: 2.0) rather than a subversion(eg: 1.1)
        docVO - The value object containing document's metadata applied during the checkin (optional)
        transaction - entry to log the event, set the user and comment
        Throws:
        Exception - if an error occurs, this exception is thrown
      • lock

        public void lock​(long docId,
                         int status,
                         DocumentHistory transaction)
                  throws PersistenceException
        Description copied from interface: DocumentManager
        Locks the given document
        Specified by:
        lock in interface DocumentManager
        Parameters:
        docId - the document to be locked
        status - the lock type (used to populate status attribute of the document)
        transaction - entry to log the event (set the user)
        Throws:
        PersistenceException - if an error occurs, this exception is thrown
      • deleteFromIndex

        public void deleteFromIndex​(Document doc)
        Utility method for document removal from index
        Specified by:
        deleteFromIndex in interface DocumentManager
        Parameters:
        doc - the document to delete from the index
      • reindex

        public long reindex​(long docId,
                            String content,
                            DocumentHistory transaction)
                     throws Exception
        Description copied from interface: DocumentManager
        Re-indexes an existing document in the full-text index.
        Specified by:
        reindex in interface DocumentManager
        Parameters:
        docId - The document to be indexed
        content - The content to use as document's body (can be null to parse the file)
        transaction - entry to log the event (set the user)
        Returns:
        the number of milliseconds required to parse the document
        Throws:
        Exception - if an error occurs, this exception is thrown
      • create

        public Document create​(InputStream content,
                               Document docVO,
                               DocumentHistory transaction)
                        throws Exception
        Description copied from interface: DocumentManager
        Creates a new Document. Saves the information provided. That also includes updating the search index for example.
        Specified by:
        create in interface DocumentManager
        Parameters:
        content - The document's content
        docVO - The value object containing the document's metadata
        transaction - The transaction metadata (remember to set the user and the comment)
        Returns:
        The newly created document
        Throws:
        Exception - raised if the document cannot be created
      • create

        public Document create​(File file,
                               Document docVO,
                               DocumentHistory transaction)
                        throws PersistenceException
        Description copied from interface: DocumentManager
        Creates a new Document. Saves the information provided. That also includes updating the search index for example.
        Specified by:
        create in interface DocumentManager
        Parameters:
        file - The document's file
        docVO - The value object containing the document's metadata
        transaction - The trandaction metadata (remember to set the user and the comment)
        Returns:
        The newly created document
        Throws:
        PersistenceException - raised if the document cannot be created
      • countPages

        public int countPages​(Document doc)
        Description copied from interface: DocumentManager
        Counts the number of pages of a document
        Specified by:
        countPages in interface DocumentManager
        Parameters:
        doc - the document
        Returns:
        the number of pages
      • copyToFolder

        public Document copyToFolder​(Document doc,
                                     Folder folder,
                                     DocumentHistory transaction)
                              throws Exception
        Description copied from interface: DocumentManager
        Copy a document to the specified folder.
        Specified by:
        copyToFolder in interface DocumentManager
        Parameters:
        doc - The document to move
        folder - The target folder
        transaction - entry to log the event (set the user)
        Returns:
        The created document
        Throws:
        Exception - raised if the document cannot be copied
      • makeImmutable

        public void makeImmutable​(long docId,
                                  DocumentHistory transaction)
                           throws PersistenceException
        Description copied from interface: DocumentManager
        Marks the document, with the given docId, as immutable and save the given document history
        Specified by:
        makeImmutable in interface DocumentManager
        Parameters:
        docId - identifier of the document
        transaction - entry to log the event (set the user)
        Throws:
        PersistenceException - raised if the document cannot be marked immutable
      • createAlias

        public Document createAlias​(Document doc,
                                    Folder folder,
                                    String aliasType,
                                    DocumentHistory transaction)
                             throws PersistenceException
        Description copied from interface: DocumentManager
        Create an alias(shortcut) associated to the given doc to the specified folder.
        Specified by:
        createAlias in interface DocumentManager
        Parameters:
        doc - The document for which will be created the shortcut
        folder - The target folder
        aliasType - the alias type(null for the original file or pdf for it's pdf conversion)
        transaction - entry to log the event (set the user)
        Returns:
        The created document
        Throws:
        PersistenceException
      • setUserDAO

        public void setUserDAO​(UserDAO userDAO)
      • setFolderDAO

        public void setFolderDAO​(FolderDAO folderDAO)
      • setDocumentNoteDAO

        public void setDocumentNoteDAO​(DocumentNoteDAO documentNoteDAO)
      • archiveFolder

        public long archiveFolder​(long folderId,
                                  DocumentHistory transaction)
                           throws PersistenceException
        Description copied from interface: DocumentManager
        Archives all the documents in a folder's tree
        Specified by:
        archiveFolder in interface DocumentManager
        Parameters:
        folderId - The root folder
        transaction - entry to log the event (set the user)
        Returns:
        Total number of archived documents
        Throws:
        PersistenceException - raised if at least a document cannot be archived
      • createDownloadTicket

        public Ticket createDownloadTicket​(long docId,
                                           String suffix,
                                           Integer expireHours,
                                           Date expireDate,
                                           Integer maxDownloads,
                                           String urlPrefix,
                                           DocumentHistory transaction)
                                    throws PersistenceException
        Description copied from interface: DocumentManager
        Creates a new download ticket.
        Specified by:
        createDownloadTicket in interface DocumentManager
        Parameters:
        docId - The document id
        suffix - can be null or 'conversion.pdf'
        expireHours - expiration time expressed in hours
        expireDate - exact expiration date expressed in the format yyyy-MM-dd
        maxDownloads - maximum number of admitted downloads
        urlPrefix - prefiz of the url, by default the general setting 'server.url' will be used
        transaction - entry to log the event (set the user)
        Returns:
        The created ticket with the url property filled
        Throws:
        PersistenceException - raised if the download ticket cannot be created
      • setTicketDAO

        public void setTicketDAO​(TicketDAO ticketDAO)
      • unprotect

        public boolean unprotect​(String sid,
                                 long docId,
                                 String password)
        Description copied from interface: DocumentManager
        Tries to unprotect a document, If the password is correct, the document stays unprotected for all the duration of the session.
        Specified by:
        unprotect in interface DocumentManager
        Parameters:
        sid - Session identifier
        docId - The document id
        password - The password to try
        Returns:
        True if the file gets unprotected
      • promoteVersion

        public void promoteVersion​(long docId,
                                   String version,
                                   DocumentHistory transaction)
                            throws Exception
        Description copied from interface: DocumentManager
        Promotes an old version to the current default one. If you promote a prior version, what it does is make it the default version again. (regardless of there being many versions).
        Specified by:
        promoteVersion in interface DocumentManager
        Parameters:
        docId - the document to be updated
        version - the version
        transaction - entry to log the event (set the user)
        Throws:
        Exception - if an error occurs, this exception is thrown
      • enforceFilesIntoFolderStorage

        public int enforceFilesIntoFolderStorage​(long rootFolderId,
                                                 DocumentHistory transaction)
                                          throws Exception
        Description copied from interface: DocumentManager
        Moves all the files of the documents in the given tree from it's original location to the storage defined in the owning folder
        Specified by:
        enforceFilesIntoFolderStorage in interface DocumentManager
        Parameters:
        rootFolderId - identifier of the root of the tree to process
        transaction - informations about the transaction, optional
        Returns:
        number of moved files
        Throws:
        Exception - In case of error during the process
      • merge

        public Document merge​(Collection<Document> documents,
                              long targetFolderId,
                              String fileName,
                              DocumentHistory transaction)
                       throws Exception
        Description copied from interface: DocumentManager
        Merges a set of documents into a single PDF file
        Specified by:
        merge in interface DocumentManager
        Parameters:
        documents - the list of documents to merge(the order counts)
        targetFolderId - identifier of the target folder
        fileName - name of the output file(must ends with .pdf)
        transaction - informations about the transaction, optional
        Returns:
        the generated merged document
        Throws:
        Exception - generic error happened