Class UpdateManager
java.lang.Object
org.nuxeo.connect.update.task.update.UpdateManager
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
backupFile
(File fileToBackup, String path) Backup the given file in the registry storage.protected void
boolean
createBaseVersion
(Entry entry) Create a base version for the given entry if needed.createEntry
(String key) Create a new entry in the registry given the entry key.protected boolean
deleteOldFile
(File targetFile, File oldFile, boolean deleteOnExit) void
doUpdate
(File oldFile, UpdateOptions opt) Update oldFile with file pointed by optorg.nuxeo.connect.update.task.update.JarUtils.Match
<File> findBackupJar
(String key) org.nuxeo.connect.update.task.update.JarUtils.Match
<File> findInstalledJar
(String key) protected File
getKey
(UpdateOptions opt) Ugly method to know what file is going to be deleted before it is, so that it can be undeployed for hotreload.getServerRelativePath
(File someFile) protected File
getTargetFile
(String path) org.nuxeo.connect.update.task.Task
getTask()
void
load()
protected void
removeBackup
(String path) Remove the backup given its path.void
rollback
(RollbackOptions opt) Perform a rollback.protected void
rollbackBaseVersion
(Entry entry, RollbackOptions opt) protected void
rollbackVersion
(Entry entry, Version version, RollbackOptions opt) protected UpdateOptions
shouldUpdate
(String key, UpdateOptions opt, org.nuxeo.connect.update.task.update.JarUtils.Match<File> currentJar) Look if an update is required, taking into account the given UpdateOptions, the currently installed JAR and the other available JARs.void
store()
update
(UpdateOptions opt)
-
Field Details
-
STUDIO_SNAPSHOT_VERSION
- See Also:
-
task
protected org.nuxeo.connect.update.task.Task task -
registry
-
file
-
backupRoot
-
serverRoot
-
-
Constructor Details
-
UpdateManager
-
-
Method Details
-
getServerRoot
-
getBackupRoot
-
getTask
public org.nuxeo.connect.update.task.Task getTask() -
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
-
getKey
-
update
- 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
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
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
-
createEntry
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
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
Remove the backup given its path. This is also removing the md5. -
getBackup
-
getTargetFile
-
copy
- Throws:
org.nuxeo.connect.update.PackageException
-
deleteOldFile
-
findInstalledJar
-
findBackupJar
-
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
-