public class UpdateManager extends Object
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
Modifier and Type | Field and Description |
---|---|
protected File |
backupRoot |
protected File |
file |
protected Map<String,Entry> |
registry |
protected File |
serverRoot |
static String |
STUDIO_SNAPSHOT_VERSION |
protected org.nuxeo.connect.update.task.Task |
task |
Constructor and Description |
---|
UpdateManager(File serverRoot,
File regFile) |
Modifier and Type | Method and Description |
---|---|
protected void |
backupFile(File fileToBackup,
String path)
Backup the given file in the registry storage.
|
protected void |
copy(File src,
File dst) |
Entry |
createEntry(String key)
Create a new entry in the registry given the entry key.
|
protected void |
deleteOldFile(File targetFile,
File oldFile,
boolean deleteOnExit) |
void |
doUpdate(File oldFile,
UpdateOptions opt)
Update oldFile with file pointed by opt
|
org.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 |
getBackup(String path) |
File |
getBackupRoot() |
String |
getKey(UpdateOptions opt) |
Map<String,Entry> |
getRegistry() |
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.
|
String |
getServerRelativePath(File someFile) |
File |
getServerRoot() |
protected File |
getTargetFile(String path) |
org.nuxeo.connect.update.task.Task |
getTask() |
String |
getVersionPath(UpdateOptions opt) |
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() |
RollbackOptions |
update(UpdateOptions opt) |
public static final String STUDIO_SNAPSHOT_VERSION
protected org.nuxeo.connect.update.task.Task task
protected File backupRoot
protected File serverRoot
public UpdateManager(File serverRoot, File regFile)
public File getServerRoot()
public File getBackupRoot()
public org.nuxeo.connect.update.task.Task getTask()
public Map<String,Entry> getRegistry()
public void load() throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
public void store() throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
public String getVersionPath(UpdateOptions opt)
public String getKey(UpdateOptions opt)
public RollbackOptions update(UpdateOptions opt) throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
protected UpdateOptions shouldUpdate(String key, UpdateOptions opt, org.nuxeo.connect.update.task.update.JarUtils.Match<File> currentJar) throws org.nuxeo.connect.update.PackageException
key
- opt
- currentJar
- org.nuxeo.connect.update.PackageException
public File getRollbackTarget(RollbackOptions opt)
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
public void rollback(RollbackOptions opt) throws org.nuxeo.connect.update.PackageException
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)
opt
- org.nuxeo.connect.update.PackageException
protected void rollbackBaseVersion(Entry entry, RollbackOptions opt) throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
protected void rollbackVersion(Entry entry, Version version, RollbackOptions opt) throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
public String getServerRelativePath(File someFile)
public Entry createEntry(String key) throws org.nuxeo.connect.update.PackageException
key
- Exception
org.nuxeo.connect.update.PackageException
protected void backupFile(File fileToBackup, String path) throws org.nuxeo.connect.update.PackageException
fileToBackup
- path
- org.nuxeo.connect.update.PackageException
protected void removeBackup(String path)
path
- protected File getTargetFile(String path)
protected void copy(File src, File dst) throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
protected void deleteOldFile(File targetFile, File oldFile, boolean deleteOnExit)
public org.nuxeo.connect.update.task.update.JarUtils.Match<File> findInstalledJar(String key)
public org.nuxeo.connect.update.task.update.JarUtils.Match<File> findBackupJar(String key)
public void doUpdate(File oldFile, UpdateOptions opt) throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
Copyright © 2015 Nuxeo SA. All rights reserved.