de.esprit.appsuite.io.archive

## Class AbstractArchiver<C extends ApplicationContext>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<C>
    - - de.esprit.appsuite.task.AbstractAsyncExecutable<C>
      - - de.esprit.appsuite.io.archive.AbstractArchiver<C>

- All Implemented Interfaces:
    ApplicationObject<C>, AsyncExecutable<C>, CancellableTask, TaskMonitorSupport, SimpleLogSupport, Dumpable, Executable
  Direct Known Subclasses:
    TarArchiver, ZipArchiver

      public abstract class AbstractArchiver<C extends ApplicationContext>
      extends AbstractAsyncExecutable<C>

  This class creates a ZIP archive of either files/directories or directly from an input-stream. The result is a zipped archive file.
  Author:
    Rainer Buesch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AccumulatingProgressInputStream` | `measureStream`

    - ### Fields inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `childTaskRef, isTestMode, monitorController, resultRef, stateFlag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractArchiver(C ctx)`
    `AbstractArchiver(C ctx, ArchiveInputList inputList)`
    `AbstractArchiver(C ctx, java.io.File archiveFile)`
    `AbstractArchiver(C ctx, java.io.File zipOutFile, ArchiveInputList inputList)`
    `AbstractArchiver(C ctx, LogChannel logCh, java.io.File archiveFile, ArchiveInputList inputList)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDirectory(java.io.File dir, boolean isRecursive)` Adds the content of the given directory to the archive input list.
    `void` | `addDirectory(java.io.File dir, java.io.FileFilter filter)` Adds all files contained in the given directory to the input. if All files If the filter is not null, all files must match the given filter, otherwise all files are added.
    `void` | `addFile(java.io.File file)` Adds the given File to the archive input list.
    `void` | `addFiles(java.io.File... files)` Adds the given File(s) to the archive input list.
    `protected void` | `checkDirectoryExists(java.io.File file)`
    `protected void` | `checkFileExists(java.io.File file)`
    `protected void` | `checkHasArchivedFiles()`
    `protected CleanupFileOutputStream` | `createCleanupFileOutputStream(java.io.File archiveFile)`
    `protected void` | `doOnAddingArchiveEntry(java.lang.String entryName)`
    `void` | `executeAsync()` Contains the code to be executed asynchronously.
    `abstract FileType` | `getArchiveType()`
    `java.io.File` | `getSourceRootDir()`
    `protected void` | `incrementArchivedFileCount()`
    `protected abstract void` | `processArchiving(java.io.File archiveFile, ArchiveInputList inputList)`
    `void` | `setArchiveFile(java.io.File archiveFile)` Sets the target output file where the archive is written to.
    `void` | `setRemoveSourceFiles(boolean isRemove)` Tells whether the source files should be removed after archiving.
    `void` | `setRootDirectory(java.io.File rootDir)`
    `void` | `setSourceRootDir(java.io.File rootDir)` Sets the base dir for locating files to be archived.

    - ### Methods inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `addMonitor, checkCancelled, checkForErrorAndRethrow, clearMonitors, createRunStateFlag, doOnCancel, doOnFailure, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, handleFinish, handleStart, handleSuccess, hasError, hasMonitor, isCancellable, notifyProceeded, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled`

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface de.esprit.appsuite.launch.ApplicationObject

      `getApplicationContext`

    - ### Methods inherited from interface de.esprit.common.log.SimpleLogSupport

      `getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

- - ### Field Detail

    - #### measureStream

          protected final AccumulatingProgressInputStream measureStream

  - ### Constructor Detail

    - #### AbstractArchiver

          public AbstractArchiver(C ctx)

    - #### AbstractArchiver

          public AbstractArchiver(C ctx,
                          java.io.File archiveFile)

    - #### AbstractArchiver

          public AbstractArchiver(C ctx,
                          ArchiveInputList inputList)

    - #### AbstractArchiver

          public AbstractArchiver(C ctx,
                          java.io.File zipOutFile,
                          ArchiveInputList inputList)

    - #### AbstractArchiver

          public AbstractArchiver(C ctx,
                          LogChannel logCh,
                          java.io.File archiveFile,
                          ArchiveInputList inputList)

  - ### Method Detail

    - #### getArchiveType

          public abstract FileType getArchiveType()

    - #### checkHasArchivedFiles

          protected void checkHasArchivedFiles()
                                        throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### setSourceRootDir

          public void setSourceRootDir(java.io.File rootDir)

      Sets the base dir for locating files to be archived. All input paths added will be made relative to this rootDir. Note that the rootDir is mandatory and needs to be set before adding any content.

    - #### getSourceRootDir

          public java.io.File getSourceRootDir()

      See Also:
        `setSourceRootDir(File).`

    - #### setArchiveFile

          public void setArchiveFile(java.io.File archiveFile)

      Sets the target output file where the archive is written to.

    - #### setRemoveSourceFiles

          public void setRemoveSourceFiles(boolean isRemove)

      Tells whether the source files should be removed after archiving. Note that removing will take place after archiving has been fully completed.

    - #### addFile

          public void addFile(java.io.File file)

      Adds the given File to the archive input list.

    - #### addFiles

          public void addFiles(java.io.File... files)

      Adds the given File(s) to the archive input list.

    - #### addDirectory

          public void addDirectory(java.io.File dir,
                          java.io.FileFilter filter)

      Adds all files contained in the given directory to the input. if All files If the filter is not null, all files must match the given filter, otherwise all files are added.
      Parameters:
        `filter` - all files must match the filter if not null
      See Also:
        `addDirectory(File, boolean)`

    - #### setRootDirectory

          public void setRootDirectory(java.io.File rootDir)

    - #### addDirectory

          public void addDirectory(java.io.File dir,
                          boolean isRecursive)

      Adds the content of the given directory to the archive input list. The given directory path itself is not added.
      Parameters:
        `isRecursive` - adds the content of all sub-directories as well.
      See Also:
        `addDirectory(File, FileFilter)`

    - #### incrementArchivedFileCount

          protected void incrementArchivedFileCount()

    - #### checkDirectoryExists

          protected void checkDirectoryExists(java.io.File file)

    - #### checkFileExists

          protected void checkFileExists(java.io.File file)

    - #### doOnAddingArchiveEntry

          protected void doOnAddingArchiveEntry(java.lang.String entryName)

    - #### createCleanupFileOutputStream

          protected CleanupFileOutputStream createCleanupFileOutputStream(java.io.File archiveFile)
                                                                   throws java.io.FileNotFoundException

      Throws:
        `java.io.FileNotFoundException`

    - #### executeAsync

          public final void executeAsync()
                                  throws java.lang.Exception

      Description copied from interface: `AsyncExecutable`
      Contains the code to be executed asynchronously. WARNING: This method should never be called directly by the programmer. It rather must be called by `Runnable.run()` for async execution.
      Specified by:
        `executeAsync` in interface `AsyncExecutable<C extends ApplicationContext>`
      Specified by:
        `executeAsync` in class `AbstractAsyncExecutable<C extends ApplicationContext>`
      Throws:
        `java.lang.Exception`
      See Also:
        `for synchronous execution`

    - #### processArchiving

          protected abstract void processArchiving(java.io.File archiveFile,
                              ArchiveInputList inputList)
                                            throws java.lang.Exception

      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.