use of org.expath.pkg.repo.deps.Semver in project exist by eXist-db.
the class AppRestoreUtils method checkApps.
/**
* Inspects the apps contained in the backup against installed apps in the database
* and return a set of symbolic backup paths pointing to the collection of those
* apps for which newer versions are installed within the database. The returned
* paths may then be ignored during a restore.
*
* The method attempts to be fail safe to make sure even bad backups can be restored. Errors
* reading package descriptors are thus only logged and should not abort the process.
*
* @param broker the broker used for reading the backup and retrieving the expath repo
* @param descriptors a queue of backup descriptors to inspect
* @return a set of paths for which newer versions exist in the database. may be empty.
*/
public static Set<String> checkApps(final DBBroker broker, final Deque<BackupDescriptor> descriptors) {
final List<AppDetail> apps = getAppsFromBackup(broker, descriptors);
final Set<String> paths = new HashSet<>();
final Optional<ExistRepository> repo = broker.getBrokerPool().getExpathRepo();
if (repo.isPresent()) {
for (final AppDetail app : apps) {
final Packages packages = repo.get().getParentRepo().getPackages(app.name);
if (packages != null) {
final Package latest = packages.latest();
try {
final Semver version = Semver.parse(latest.getVersion());
if (version.compareTo(app.version) > 0) {
paths.add(app.path);
}
} catch (PackageException e) {
LOG.warn("Invalid semver in expath repository for {}", app.name, e);
}
}
}
}
return paths;
}
Aggregations