jap
Class JARHelpFileStorageManager

java.lang.Object
  extended by gui.help.AbstractHelpFileStorageManager
      extended by jap.JARHelpFileStorageManager

public final class JARHelpFileStorageManager
extends AbstractHelpFileStorageManager

Handling of the JonDo help files

Author:
Simon Pecher

Field Summary
static java.lang.String HELP_VERSION_ATTRIBUTE
           
static java.lang.String HELP_VERSION_FILE
           
static java.lang.String HELP_VERSION_NODE
           
private  ZipArchiver m_archiver
           
private  java.lang.String m_helpPath
           
 
Fields inherited from class gui.help.AbstractHelpFileStorageManager
HELP_DIR_EXISTS, HELP_FOLDER, HELP_INVALID_NOREAD, HELP_INVALID_NOWRITE, HELP_INVALID_NULL, HELP_INVALID_PATH_NOT_EXISTS, HELP_JONDO_EXISTS, HELP_NESTED, HELP_NO_DIR, HELP_VALID, HELP_VIRTUAL
 
Constructor Summary
JARHelpFileStorageManager()
           
 
Method Summary
private static void createHelpVersionDoc(java.lang.String a_extractionPath)
          creates an XML document containing the version of the JonDo help which has to match the actual JonDo version
 boolean ensureMostRecentVersion(java.lang.String helpPath)
           
 boolean extractHelpFiles(java.lang.String a_extractionPath)
           
private  boolean extractHelpFiles(java.lang.String a_extractionPath, boolean bAcceptHelpFolderInPath)
           
private  java.io.File getHelpFolder()
          convenience function that returns a file reference to the current help root folder
private  java.lang.String getHelpVersion(java.lang.String a_helpFolder)
          Reads the version string out of the help version XML file The help version number corresponds to the version number of the JonDo
 java.util.Observable getStorageObservable()
          returns an observable object which allows ViewObjects to display storage processes, i.e.
 boolean handleHelpPathChanged(java.lang.String oldHelpPath, java.lang.String newHelpPath, boolean a_bIgnoreExistingHelpDir)
          Performs the specific file storage operation to maintain a consistent file storage state when the help path changes
 boolean helpInstallationExists(java.lang.String helpPath)
           
 java.lang.String helpPathValidityCheck(java.lang.String a_absolutePath, boolean a_bIgnoreExistingHelpDir)
           
 boolean helpVersionMismatch()
          checks whether the help version number matches the JonDo version number
private  boolean installHelp(boolean a_bIgnoreExistingHelpDir)
          installs the JonDo help externally out the JonDo Jarfile in the specified external destination folder.
private  boolean isHelpInstalled()
          checks if there is a help installed in the specified external help path
private  boolean removeOldHelp(java.lang.String parentPath, boolean a_bIgnoreExistingHelpDir)
           
private  void setHelpPath(java.lang.String helpPath)
          sets the specified path for external installation of the help files performs no validityCheck, because it is only called by handleHelpPathChanged, which is invoked by the JAPModel, which itself performs a validity check
 
Methods inherited from class gui.help.AbstractHelpFileStorageManager
getInitPath, getLocalisedHelpDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HELP_VERSION_NODE

public static final java.lang.String HELP_VERSION_NODE
See Also:
Constant Field Values

HELP_VERSION_ATTRIBUTE

public static final java.lang.String HELP_VERSION_ATTRIBUTE
See Also:
Constant Field Values

HELP_VERSION_FILE

public static final java.lang.String HELP_VERSION_FILE
See Also:
Constant Field Values

m_helpPath

private java.lang.String m_helpPath

m_archiver

private ZipArchiver m_archiver
Constructor Detail

JARHelpFileStorageManager

public JARHelpFileStorageManager()
Method Detail

setHelpPath

private void setHelpPath(java.lang.String helpPath)
sets the specified path for external installation of the help files performs no validityCheck, because it is only called by handleHelpPathChanged, which is invoked by the JAPModel, which itself performs a validity check


helpVersionMismatch

public boolean helpVersionMismatch()
checks whether the help version number matches the JonDo version number

Returns:
true if the stored help version number is not exactly the same as the JonDo version number or if the number could not be retrieved (if no help is available)

handleHelpPathChanged

public boolean handleHelpPathChanged(java.lang.String oldHelpPath,
                                     java.lang.String newHelpPath,
                                     boolean a_bIgnoreExistingHelpDir)
Description copied from class: AbstractHelpFileStorageManager
Performs the specific file storage operation to maintain a consistent file storage state when the help path changes

Specified by:
handleHelpPathChanged in class AbstractHelpFileStorageManager
Parameters:
oldHelpPath - the path of the help files before the change.
newHelpPath - the path where the help files shall be installed
a_bIgnoreExistingHelpDir - true if any existing directory named help will be removed in the installation folder
Returns:
true if the storage layer could be maintained consistent, false otherwise. In the latter case the file storage layer must be in the same state as if there has not been a change at all.

helpPathValidityCheck

public java.lang.String helpPathValidityCheck(java.lang.String a_absolutePath,
                                              boolean a_bIgnoreExistingHelpDir)
Specified by:
helpPathValidityCheck in class AbstractHelpFileStorageManager

getStorageObservable

public java.util.Observable getStorageObservable()
Description copied from class: AbstractHelpFileStorageManager
returns an observable object which allows ViewObjects to display storage processes, i.e. to display the file installation progress in a JProgressBar

Specified by:
getStorageObservable in class AbstractHelpFileStorageManager
Returns:
an observable object from which to obtain storage process informations or null if the manager has no such object associated with it.

extractHelpFiles

public boolean extractHelpFiles(java.lang.String a_extractionPath)
Overrides:
extractHelpFiles in class AbstractHelpFileStorageManager

extractHelpFiles

private boolean extractHelpFiles(java.lang.String a_extractionPath,
                                 boolean bAcceptHelpFolderInPath)

installHelp

private boolean installHelp(boolean a_bIgnoreExistingHelpDir)
installs the JonDo help externally out the JonDo Jarfile in the specified external destination folder. This routine overrides already installed JonDo help files.


createHelpVersionDoc

private static void createHelpVersionDoc(java.lang.String a_extractionPath)
creates an XML document containing the version of the JonDo help which has to match the actual JonDo version


removeOldHelp

private boolean removeOldHelp(java.lang.String parentPath,
                              boolean a_bIgnoreExistingHelpDir)

isHelpInstalled

private boolean isHelpInstalled()
checks if there is a help installed in the specified external help path

Returns:
true if a help folder exists in the user defined help path. If no help path is specified by the user the default path (the folder where the Jarfile is situated) is checked.

getHelpVersion

private java.lang.String getHelpVersion(java.lang.String a_helpFolder)
Reads the version string out of the help version XML file The help version number corresponds to the version number of the JonDo

Parameters:
versionFile - the XML file where the help version is specified.
Returns:
the help version number as string, or null if no version string was found in versionFile

getHelpFolder

private java.io.File getHelpFolder()
convenience function that returns a file reference to the current help root folder

Returns:
a file reference to the current help root folder or null if helpPath is null

ensureMostRecentVersion

public boolean ensureMostRecentVersion(java.lang.String helpPath)
Specified by:
ensureMostRecentVersion in class AbstractHelpFileStorageManager

helpInstallationExists

public boolean helpInstallationExists(java.lang.String helpPath)
Specified by:
helpInstallationExists in class AbstractHelpFileStorageManager