Class UpdateManager

java.lang.Object
org.nuxeo.connect.update.task.update.UpdateManager

public class UpdateManager extends Object
Manage jar versions update.

To manipulate the jar version registry you need to create a new instance of this class.

If you want to modify the registry then you may want to synchronize the entire update process. This is how is done in the Task run method.

Only reading the registry is thread safe.

TODO backup md5 are not really used since we rely on versions - we can remove md5

Author:
Bogdan Stefanescu
  • Field Details

    • STUDIO_SNAPSHOT_VERSION

      public static final String STUDIO_SNAPSHOT_VERSION
      See Also:
    • task

      protected org.nuxeo.connect.update.task.Task task
    • registry

      protected Map<String,Entry> registry
    • file

      protected File file
    • backupRoot

      protected File backupRoot
    • serverRoot

      protected File serverRoot
  • Constructor Details

    • UpdateManager

      public UpdateManager(File serverRoot, File regFile)
  • Method Details

    • getServerRoot

      public File getServerRoot()
    • getBackupRoot

      public File getBackupRoot()
    • getTask

      public org.nuxeo.connect.update.task.Task getTask()
    • getRegistry

      public Map<String,Entry> getRegistry()
    • load

      public void load() throws org.nuxeo.connect.update.PackageException
      Throws:
      org.nuxeo.connect.update.PackageException
    • store

      public void store() throws org.nuxeo.connect.update.PackageException
      Throws:
      org.nuxeo.connect.update.PackageException
    • getVersionPath

      public String getVersionPath(UpdateOptions opt)
    • getKey

      public String getKey(UpdateOptions opt)
    • update

      public RollbackOptions update(UpdateOptions opt) throws org.nuxeo.connect.update.PackageException
      Throws:
      org.nuxeo.connect.update.PackageException
    • shouldUpdate

      protected UpdateOptions shouldUpdate(String key, UpdateOptions opt, org.nuxeo.connect.update.task.update.JarUtils.Match<File> currentJar) throws org.nuxeo.connect.update.PackageException
      Look if an update is required, taking into account the given UpdateOptions, the currently installed JAR and the other available JARs.
      Returns:
      null if no update required, else the right UpdateOptions
      Throws:
      org.nuxeo.connect.update.PackageException
      Since:
      5.7
    • getRollbackTarget

      public File getRollbackTarget(RollbackOptions opt)
      Ugly method to know what file is going to be deleted before it is, so that it can be undeployed for hotreload.

      FIXME: will only handle simple cases for now (ignores version, etc...), e.g only tested with the main Studio jars. Should use version from RollbackOptions

      Since:
      5.6
    • rollback

      public void rollback(RollbackOptions opt) throws org.nuxeo.connect.update.PackageException
      Perform a rollback.

      TODO the deleteOnExit is inherited from the current rollback command ... may be it should be read from the version that is rollbacked. (deleteOnExit should be an attribute of the entry not of the version)

      Throws:
      org.nuxeo.connect.update.PackageException
    • rollbackBaseVersion

      protected void rollbackBaseVersion(Entry entry, RollbackOptions opt) throws org.nuxeo.connect.update.PackageException
      Throws:
      org.nuxeo.connect.update.PackageException
    • rollbackVersion

      protected void rollbackVersion(Entry entry, Version version, RollbackOptions opt) throws org.nuxeo.connect.update.PackageException
      Throws:
      org.nuxeo.connect.update.PackageException
    • getServerRelativePath

      public String getServerRelativePath(File someFile)
    • createEntry

      public Entry createEntry(String key) throws org.nuxeo.connect.update.PackageException
      Create a new entry in the registry given the entry key. A base version will be automatically created if needed.
      Throws:
      org.nuxeo.connect.update.PackageException
    • createBaseVersion

      public boolean createBaseVersion(Entry entry) throws org.nuxeo.connect.update.PackageException
      Create a base version for the given entry if needed.
      Returns:
      true if a base version was actually created, false otherwise
      Throws:
      org.nuxeo.connect.update.PackageException
      Since:
      1.4.26
    • backupFile

      protected void backupFile(File fileToBackup, String path) throws org.nuxeo.connect.update.PackageException
      Backup the given file in the registry storage. Backup is not a backup performed on removed files: it is rather like a uniformed storage of all libraries potentially installed by packages (whereas each package can have its own directory structure). So SNAPSHOT will always be overwritten. Backup of original SNAPSHOT can be found in the backup directory of the stored package.
      Throws:
      org.nuxeo.connect.update.PackageException
    • removeBackup

      protected void removeBackup(String path)
      Remove the backup given its path. This is also removing the md5.
    • getBackup

      protected File getBackup(String path)
    • getTargetFile

      protected File getTargetFile(String path)
    • copy

      protected void copy(File src, File dst) throws org.nuxeo.connect.update.PackageException
      Throws:
      org.nuxeo.connect.update.PackageException
    • deleteOldFile

      protected boolean deleteOldFile(File targetFile, File oldFile, boolean deleteOnExit)
    • findInstalledJar

      public org.nuxeo.connect.update.task.update.JarUtils.Match<File> findInstalledJar(String key)
    • findBackupJar

      public org.nuxeo.connect.update.task.update.JarUtils.Match<File> findBackupJar(String key)
    • doUpdate

      public void doUpdate(File oldFile, UpdateOptions opt) throws org.nuxeo.connect.update.PackageException
      Update oldFile with file pointed by opt
      Throws:
      org.nuxeo.connect.update.PackageException