Class ArchiveBuilderBase

java.lang.Object
org.cdlib.mrt.utility.ArchiveBuilderBase
Direct Known Subclasses:
ArchiveBuilderBase.Tar, ArchiveBuilderBase.Zip

public abstract class ArchiveBuilderBase extends Object
Build an archive (tar, targz, or zip) from a directory
Author:
dloy
  • Field Details

  • Constructor Details

    • ArchiveBuilderBase

      public ArchiveBuilderBase(File fromDir, File toArchive, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException
      Contructor used as build method for this class
      Parameters:
      fromDir - - directory to be archived
      toArchive - - archive to this file
      logger - - process logging
      archiveType - type of archive to create see ArchiveType
      Throws:
      TException
    • ArchiveBuilderBase

      public ArchiveBuilderBase(File fromDir, OutputStream outputStream, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException
      Contructor used as build method for this class
      Parameters:
      fromDir - - directory to be archived
      toArchive - - archive to this file
      logger - - process logging
      archiveType - type of archive to create see ArchiveType
      Throws:
      TException
  • Method Details

    • getArchiveBuilderBase

      public static ArchiveBuilderBase getArchiveBuilderBase(File fromDir, File toArchive, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException
      Factory routine to get specific ArchiveBuilder for supplied ArchiveType
      Parameters:
      fromDir - - directory to be archived
      toArchive - - archive to this file
      logger - - process logging
      archiveType - type of archive to create see ArchiveType
      Returns:
      specific type of ArchiveBuilder
      Throws:
      TException
    • getArchiveBuilderBase

      public static ArchiveBuilderBase getArchiveBuilderBase(File fromDir, OutputStream outputStream, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException
      Factory routine to get specific ArchiveBuilder for supplied ArchiveType
      Parameters:
      fromDir - - directory to be archived
      toArchive - - archive to this file
      logger - - process logging
      archiveType - type of archive to create see ArchiveType
      Returns:
      specific type of ArchiveBuilder
      Throws:
      TException
    • buildArchive

      public void buildArchive(boolean includeBase) throws TException
      Create archive from constructor supplied values
      Throws:
      TException
    • setOutputStream

      protected abstract void setOutputStream(OutputStream baseOutputStream) throws TException
      Call back routine for setting archive output stream type: tar, tar.gz, zip
      Parameters:
      baseOutputStream -
      Throws:
      TException
    • addItemFile

      protected abstract void addItemFile(File entry, LoggerInf logger) throws TException
      Call back routinte to write an archive entry to archive output. Archive type specific.
      Parameters:
      entry - archive file entry
      Throws:
      TException
    • closeArchive

      protected abstract void closeArchive()
      Call back routine to close archive. Archive type specific.
    • getEntryName

      protected String getEntryName(File addFile) throws TException
      Normalize archive entry name
      Parameters:
      addFile - file used for generating archive name
      Returns:
      normalized archive name
      Throws:
      TException
    • addFiles

      protected void addFiles(File sourceLocation) throws TException
      Recursive method for finding files and adding to archive
      Parameters:
      sourceLocation - file or directory to archive
      Throws:
      TException
    • setEntry

      protected void setEntry(OutputStream out, File entry) throws TException
      Move file to archive
      Parameters:
      out - write to this output stream
      entry - file to write to output
      Throws:
      TException
    • getCRC

      public static long getCRC(File file, LoggerInf logger) throws Exception
      Throws:
      Exception
    • getDecimal

      public static long getDecimal(String hex)
    • main

      public static void main(String[] args)
      Main method
    • isDeleteFileAfterCopy

      public boolean isDeleteFileAfterCopy()
    • setDeleteFileAfterCopy

      public ArchiveBuilderBase setDeleteFileAfterCopy(boolean deleteFileAfterCopy)
    • setCompressZip

      protected ArchiveBuilderBase setCompressZip(boolean compressZip)
    • getBuildTimeMs

      public long getBuildTimeMs()
    • getBuildFileCnt

      public long getBuildFileCnt()