de.esprit.appsuite.appstore

## Class AppCacheUpdater

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<ApplicationContext>
    - - de.esprit.appsuite.appstore.AppCacheUpdater

- All Implemented Interfaces:
    ApplicationObject<ApplicationContext>, SimpleLogSupport, Dumpable
  Direct Known Subclasses:
    AppCacheFileUpdater, AppCacheTransferUpdater, AppCacheUrlUpdater

      public abstract class AppCacheUpdater
      extends AbstractApplicationObject<ApplicationContext>

  This class encapsulates the base functionality for mirroring repository files to a local cache-directory. The implementation ensures that a local file is up to date with the according one in the remote repository. It has two main tasks:
  1. It mirrors appStore description files to the local cache directory.
  2. It extracts the appStore software zip-archive to the according launch directory in the local cache.
  Author:
    Rainer Buesch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `cacheSubDir`
    `static java.lang.String` | `logSubDir`
    `static java.lang.String` | `timestampFileName`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AppCacheUpdater(ApplicationContext ctx, LogChannel logCh, java.io.File appCacheRoot)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.io.File` | `buildTimestampFile(java.lang.String relativePath)`
    `protected void` | `copyStream(FileDataType dataType, java.io.InputStream inStream, java.io.OutputStream outStream)`
    `protected void` | `createDirectoryPathFor(java.io.File file)`
    `java.io.File` | `getAppCacheDir()` Returns the software subdirectory of the local cache which is <cacheRootDir>/appCache;
    `java.io.File` | `getAppCacheRoot()` Returns the root directory of the local cache.
    `java.io.File` | `getAppLogsDir()` Returns the software subdirectory of the local cache which is <cacheRootDir>/appLogs;
    `protected java.io.FileFilter` | `getExcludeFilter()`
    `void` | `init()`
    `boolean` | `isEnabled()`
    `protected boolean` | `isInstallationSourceAvailable()` Tells whether the repository (which may reside on a remote server) is currently available.
    `abstract boolean` | `mirrorConfigFile(java.lang.String relativePath, java.lang.String fileName)` Mirrors the given file from a repository directory to a local cache directory The repositoryDir as well as the cacheDir are defined by the constructor of the implementing class.
    `abstract boolean` | `mirrorZipContent(AbstractAsyncTask installTask, java.lang.String relativePath, java.lang.String fileName)` Extracts a ZIP-file containing an application software from the remote repository to the local cache directory.
    `protected void` | `performExtraction(AbstractAsyncTask installTask, java.io.InputStream inStream, FileInfo fileInfo, java.io.File targetDir, java.lang.String repository, java.io.File timestampFile, long timestamp)`
    `void` | `setEnabled(boolean isEnabled)`

    - ### 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`

- - ### Field Detail

    - #### timestampFileName

          public static final java.lang.String timestampFileName

      See Also:
        Constant Field Values

    - #### cacheSubDir

          public static final java.lang.String cacheSubDir

      See Also:
        Constant Field Values

    - #### logSubDir

          public static final java.lang.String logSubDir

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AppCacheUpdater

          protected AppCacheUpdater(ApplicationContext ctx,
                         LogChannel logCh,
                         java.io.File appCacheRoot)

  - ### Method Detail

    - #### setEnabled

          public void setEnabled(boolean isEnabled)

    - #### isEnabled

          public boolean isEnabled()

    - #### buildTimestampFile

          protected java.io.File buildTimestampFile(java.lang.String relativePath)

    - #### getExcludeFilter

          protected java.io.FileFilter getExcludeFilter()

    - #### init

          public void init()
                    throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### mirrorConfigFile

          public abstract boolean mirrorConfigFile(java.lang.String relativePath,
                                 java.lang.String fileName)
                                            throws java.lang.Exception

      Mirrors the given file from a repository directory to a local cache directory The repositoryDir as well as the cacheDir are defined by the constructor of the implementing class.
      Throws:
        `java.lang.Exception`

    - #### mirrorZipContent

          public abstract boolean mirrorZipContent(AbstractAsyncTask installTask,
                                 java.lang.String relativePath,
                                 java.lang.String fileName)
                                            throws java.lang.Exception

      Extracts a ZIP-file containing an application software from the remote repository to the local cache directory. Note that after extraction a timestamp-file named AppLastInstalled.ndf is written to the installation directory. This file is used for up-to-date-checks on further launches.
      Parameters:
        `installTask` -
      Throws:
        `java.lang.Exception`

    - #### isInstallationSourceAvailable

          protected boolean isInstallationSourceAvailable()

      Tells whether the repository (which may reside on a remote server) is currently available.

    - #### getAppCacheRoot

          public final java.io.File getAppCacheRoot()

      Returns the root directory of the local cache.

    - #### getAppCacheDir

          public final java.io.File getAppCacheDir()

      Returns the software subdirectory of the local cache which is <cacheRootDir>/appCache;

    - #### getAppLogsDir

          public final java.io.File getAppLogsDir()

      Returns the software subdirectory of the local cache which is <cacheRootDir>/appLogs;

    - #### createDirectoryPathFor

          protected void createDirectoryPathFor(java.io.File file)
                                         throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### copyStream

          protected final void copyStream(FileDataType dataType,
                        java.io.InputStream inStream,
                        java.io.OutputStream outStream)
                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### performExtraction

          protected void performExtraction(AbstractAsyncTask installTask,
                               java.io.InputStream inStream,
                               FileInfo fileInfo,
                               java.io.File targetDir,
                               java.lang.String repository,
                               java.io.File timestampFile,
                               long timestamp)
                                    throws java.lang.Exception

      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.