Class UpgradeManager

java.lang.Object
org.jjazz.upgrade.api.UpgradeManager

public class UpgradeManager extends Object
Manage the tasks to upgrade settings from a previous version of JJazzLab to the current version.

Find the source import JJazzLab version. Call all the UpgradeTasks found in the global Lookup upon fresh start at module install (UI is not yet ready!).

  • Field Details

    • PREVIOUS_VERSIONS

      public static final String[] PREVIOUS_VERSIONS
      The previous versions of JJazzLab released to public.
  • Method Details

    • getInstance

      public static UpgradeManager getInstance()
    • getCurrentVersion

      public String getCurrentVersion()
      The current JJazzLab version.
      Returns:
      Can be null.
    • isFreshStart

      public boolean isFreshStart()
      Returns:
      True if it's the first run of this JJazzLab version (or if this module's preferences file could not be found in the Netbeans user directory).
    • getOldPreferencesFromRelativePath

      public Properties getOldPreferencesFromRelativePath(String relPath)
      Get the old properties from a specific file in the getImportSourceVersion() directory structure.

      Parameters:
      relPath - Relative path from ...config/Preferences, eg "org/jjazz/rhythm/database.properties"
      Returns:
      Can be empty if file not found or read error
    • duplicateOldPreferences

      public void duplicateOldPreferences(Preferences modulePrefs)
      Copy into modulePrefs all the "old" key/value pairs from the corresponding Properties file found in the getImportSourceVersion() directory structure.

      To be used when module codebase has not changed between 2 versions. But note that app-level codebase name changes, which impacted *all* (or almost all) module, are handled by this method via adaptPropertiesFileRelativePath().

      Parameters:
      modulePrefs - The Netbeans preferences of a module.
      See Also:
    • adaptPropertiesFileRelativePath

      public String adaptPropertiesFileRelativePath(String relPath)
      Adapt relPath to the import version.

      The returned properties file relative path takes into account possible codebase name changes which occured between getImportSourceVersion() and getCurrentVersion().

      Parameters:
      relPath - A relative path of a properties file for the current version (>=4.1.0), eg "org/jjazzlab/core/midi.properties"
      Returns:
      eg "org/jjazzlab/org/jjazz/midi.properties" for getImportSourceVersion()=4.0.2
      See Also:
    • duplicateOldPreferences

      public void duplicateOldPreferences(Preferences modulePrefs, String relPathToOldPrefFile)
      Copy into modulePrefs all the "old" key/value pairs from the specified file in the getImportSourceVersion() directory structure.

      To be used when package codebase has changed between versions.

      Parameters:
      modulePrefs - The Netbeans preferences of a module.
      relPathToOldPrefFile - Relative path from ...config/Preferences, eg "org/jjazz/rhythm/database.properties"
    • getImportSourceVersion

      public String getImportSourceVersion()
      Get the JJazzLab version from which to import settings.

      Take first directory from PREVIOUS_VERSIONS where config/Preferences subdir is present.

      Returns:
      Either a valid version string (eg "2.0.1") or null if no import version available.