Class ArchiveManager


  • public class ArchiveManager
    extends Object
    Manager for archive operations handling
    Since:
    4.5
    Author:
    Matteo Caruso - LogicalDOC
    • Constructor Detail

      • ArchiveManager

        public ArchiveManager()
    • Method Detail

      • getArchiveDirectory

        public File getArchiveDirectory​(Archive archive)
        Retrieves the archive directory from/in which will be import/copied the archive's document
        Parameters:
        archive - the archive
        Returns:
        the directory that contains the archive
      • getArchiveDirectory

        public File getArchiveDirectory​(int mode,
                                        String archiveName,
                                        String id,
                                        long tenantId)
      • getArchiveDirectory

        public File getArchiveDirectory​(int mode,
                                        String archiveName,
                                        String id,
                                        String tenantName)
        Retrieves the archive directory from/in which will be import/copied the archive's documents
        Parameters:
        mode - The mode Import or Export of an archive
        archiveName - name of the archive
        id - identifier of the archive
        tenantName - name of the tenant
        Returns:
        the directory that contains the archive
      • writeIndex

        public void writeIndex​(Archive archive)
                        throws IOException,
                               com.logicaldoc.core.PersistenceException
        Writes the XML and CSV index files for the archive. Initially the file is named "index.xml.tmp". When the creation operation is successfully completed, the file is renamed as "index.xml".
        Parameters:
        archive - the archive to use for writing the index.xml
        Throws:
        IOException - cannot write the index.xml
        com.logicaldoc.core.PersistenceException - error at data layer
      • writeIndex

        public void writeIndex​(Archive archive,
                               Writer writer)
                        throws IOException,
                               com.logicaldoc.core.PersistenceException
        Writes the XML index file for the archive in the specified writer
        Parameters:
        archive - the archive to write
        writer - the writer for the index.xml
        Throws:
        IOException - cannot write the index.xml
        com.logicaldoc.core.PersistenceException - error at data layer
      • writeHtmlIndex

        public void writeHtmlIndex​(Archive archive)
                            throws IOException
        Writes the index.html file. Make sure to pass an initialized archive
        Parameters:
        archive - the archive to write as HTML
        Throws:
        IOException - cannot write the HTML index file
      • setConfig

        public void setConfig​(com.logicaldoc.util.config.ContextProperties config)
      • addEntry

        public boolean addEntry​(Archive archive,
                                com.logicaldoc.core.document.Version version,
                                com.logicaldoc.core.security.User user,
                                String sid)
        Adds a new entry taking care of locking the document, a default comment will be used
        Parameters:
        archive - the archive to alter
        version - the version to add to the archive
        user - the current user
        sid - identifier of the session
        Returns:
        if the entry has been successfully added
      • addEntry

        public boolean addEntry​(Archive archive,
                                com.logicaldoc.core.document.Version version,
                                com.logicaldoc.core.security.User user,
                                String comment,
                                String sid)
        Adds a new entry taking care of locking the document
        Parameters:
        archive - the archive to alter
        version - the version to add to the archive
        user - the current user
        comment - an optional comment
        sid - identifier of the session
        Returns:
        if the entry has been successfully added
      • delete

        public void delete​(long archiveId,
                           com.logicaldoc.core.security.User user,
                           String comment)
                    throws com.logicaldoc.core.PersistenceException
        Delete the archive with the given id and unlocks all its document.
        Parameters:
        archiveId - The id of the archive to delete
        user - The user that makes the deleting operation
        comment - an optional comment to the deletion
        Throws:
        com.logicaldoc.core.PersistenceException - error at data layer
      • setArchiveDao

        public void setArchiveDao​(ArchiveDAO archiveDao)
      • setDocumentDao

        public void setDocumentDao​(com.logicaldoc.core.document.dao.DocumentDAO documentDao)
      • closeArchive

        public void closeArchive​(long id,
                                 com.logicaldoc.core.security.User user)
                          throws com.logicaldoc.core.PersistenceException
        Throws:
        com.logicaldoc.core.PersistenceException
      • setFolderDao

        public void setFolderDao​(com.logicaldoc.core.folder.FolderDAO folderDao)
      • setTenantDao

        public void setTenantDao​(com.logicaldoc.core.security.dao.TenantDAO tenantDao)