Interface DocumentManager

  • All Known Implementing Classes:
    DocumentManagerImpl

    public interface DocumentManager
    A general manager for documents handling issues
    Since:
    3.5
    Author:
    Marco Meschieri - LogicalDOC
    • Method Detail

      • checkin

        void checkin​(long docId,
                     InputStream fileInputStream,
                     String filename,
                     boolean release,
                     AbstractDocument docVO,
                     DocumentHistory transaction)
              throws Exception
        Checks in the given document
        Parameters:
        docId - the document to be checked in
        fileInputStream - 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
      • checkin

        void checkin​(long docId,
                     File file,
                     String filename,
                     boolean release,
                     AbstractDocument docVO,
                     DocumentHistory transaction)
              throws Exception
        Checks in the given document
        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
      • checkout

        void checkout​(long docId,
                      DocumentHistory transaction)
               throws Exception
        Checks out the given document
        Parameters:
        docId - the document to be checked out
        transaction - entry to log the event (set the user)
        Throws:
        Exception - if an error occurs, this exception is thrown
      • replaceFile

        void replaceFile​(long docId,
                         String fileVersion,
                         File newFile,
                         DocumentHistory transaction)
                  throws Exception
        Replaces the file of a given version
        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
      • replaceFile

        void replaceFile​(long docId,
                         String fileVersion,
                         InputStream newFile,
                         DocumentHistory transaction)
                  throws Exception
        Replaces the file of a given version
        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
      • promoteVersion

        void promoteVersion​(long docId,
                            String version,
                            DocumentHistory transaction)
                     throws Exception
        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).
        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
      • lock

        void lock​(long docId,
                  int status,
                  DocumentHistory transaction)
           throws Exception
        Locks the given document
        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:
        Exception - if an error occurs, this exception is thrown
      • unlock

        void unlock​(long docId,
                    DocumentHistory transaction)
             throws Exception
        UNChecks out the given document
        Parameters:
        docId - the document to be unchecked out
        transaction - entry to log the event
        Throws:
        Exception - if an error occurs, this exception is thrown
      • create

        Document create​(File file,
                        Document docVO,
                        DocumentHistory transaction)
                 throws Exception
        Creates a new Document. Saves the information provided. That also includes updating the search index for example.
        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:
        Exception - raised if the document cannot be created
      • create

        Document create​(InputStream content,
                        Document docVO,
                        DocumentHistory transaction)
                 throws Exception
        Creates a new Document. Saves the information provided. That also includes updating the search index for example.
        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
      • reindex

        long reindex​(long docId,
                     String content)
              throws Exception
        Re-indexes an existing document in the full-text index.
        Parameters:
        docId - The document to be indexed
        content - The content to use as document's body (can be null to parse the file)
        Returns:
        the number of milliseconds required to parse the document
        Throws:
        Exception - if an error occurs, this exception is thrown
      • rename

        void rename​(long docId,
                    String newName,
                    DocumentHistory transaction)
             throws Exception
        Rename an existing document filename.
        Parameters:
        docId - The document to be renamed
        newName - The new filename of the document
        transaction - entry to log the event (set the user)
        Throws:
        Exception - if an error occurs, this exception is thrown
      • update

        void update​(Document doc,
                    Document docVO,
                    DocumentHistory transaction)
             throws Exception
        Updates an existing document and marks it to be re-indexed
        Parameters:
        doc - The document to be updated
        docVO - value object containing the new metadata
        transaction - entry to log the event (set the user)
        Throws:
        Exception - if an error occurs, this exception is thrown
      • deleteFromIndex

        void deleteFromIndex​(Document doc)
        Utility method for document removal from index and database update(flag indexed)
        Parameters:
        doc - the document to remove from the index
      • makeImmutable

        void makeImmutable​(long docId,
                           DocumentHistory transaction)
                    throws Exception
        Marks the document, with the given docId, as immutable and save the given document history
        Parameters:
        docId - identifier of the document
        transaction - entry to log the event (set the user)
        Throws:
        Exception - raised if the document cannot be marked immutable
      • moveToFolder

        void moveToFolder​(Document doc,
                          Folder folder,
                          DocumentHistory transaction)
                   throws Exception
        Moves a document to the specified folder. All stores(db, file system, index) will be consequently altered.
        Parameters:
        doc - The document to move
        folder - The target folder
        transaction - entry to log the event (set the user)
        Throws:
        Exception - raised if the document cannot be moved
      • copyToFolder

        Document copyToFolder​(Document doc,
                              Folder folder,
                              DocumentHistory transaction)
                       throws Exception
        Copy a document to the specified folder.
        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
      • createAlias

        Document createAlias​(Document doc,
                             Folder folder,
                             String type,
                             DocumentHistory transaction)
                      throws Exception
        Create an alias(shortcut) associated to the given doc to the specified folder.
        Parameters:
        doc - The document for which will be created the shortcut
        folder - The target folder
        type - 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:
        Exception - raised if the alias cannot be created
      • replaceAlias

        Document replaceAlias​(long aliasId,
                              DocumentHistory transaction)
                       throws Exception
        Replaces an alias with a copy of the original file
        Parameters:
        aliasId - ID of the alias to replace
        transaction - entry to log the event (set the user)
        Returns:
        The created document
        Throws:
        Exception - raised if the alias cannot be replaced
      • deleteVersion

        Version deleteVersion​(long versionId,
                              DocumentHistory transaction)
                       throws Exception
        Deletes a specific version.
        Parameters:
        versionId - The version to delete
        transaction - entry to log the event (set the user)
        Returns:
        the latest version
        Throws:
        Exception - If the version cannot be deleted
      • parseDocument

        String parseDocument​(Document doc,
                             String fileVersion)
        Retrieves the document's content as a string
        Parameters:
        doc - the document representation
        fileVersion - version fo the file
        Returns:
        The document's content
      • archiveFolder

        long archiveFolder​(long folderId,
                           DocumentHistory transaction)
                    throws Exception
        Archives all the documents in a folder's tree
        Parameters:
        folderId - The root folder
        transaction - entry to log the event (set the user)
        Returns:
        Total number of archived documents
        Throws:
        Exception - raised if at least a document cannot be archived
      • archiveDocuments

        void archiveDocuments​(long[] docIds,
                              DocumentHistory transaction)
                       throws Exception
        Archives all the documents in a folder's tree
        Parameters:
        docIds - Documents to be archived
        transaction - entry to log the event (set the user)
        Throws:
        Exception - raised if at least a document cannot be archived
      • setStorer

        void setStorer​(Storer storer)
      • createDownloadTicket

        Ticket createDownloadTicket​(long docId,
                                    String suffix,
                                    Integer expireHours,
                                    Date expireDate,
                                    Integer maxDownloads,
                                    String urlPrefix,
                                    DocumentHistory transaction)
                             throws Exception
        Creates a new download ticket.
        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:
        Exception - raised if the download ticket cannot be created
      • unprotect

        boolean unprotect​(String sid,
                          long docId,
                          String password)
        Tries to unprotect a document, If the password is correct, the document stays unprotected for all the duration of the session.
        Parameters:
        sid - Session identifier
        docId - The document id
        password - The password to try
        Returns:
        True if the file gets unprotected