use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.
the class NewsProviderTest method getNewsJson.
protected List<NewsEntry> getNewsJson() throws ParseException, JsonProcessingException {
NewsEntry entry1 = new NewsEntry(new SemanticVersion("1.0.0"), "news1.0.0");
NewsEntry entry2 = new NewsEntry(new SemanticVersion("2.0.0"), "news2.0.0");
NewsEntry entry3 = new NewsEntry(new SemanticVersion("3.0.0"), "news3.0.0");
List<NewsEntry> entries = Arrays.asList(entry2, entry1, entry3);
return entries;
}
use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.
the class FromPythonMigration method migrateFromUrl.
@Transactional
public MigrationResult migrateFromUrl(String nzbhydra1BaseUrl, boolean doMigrateDatabase, boolean checkForDocker) {
logger.info("Received request to migrate from URL " + nzbhydra1BaseUrl);
if (checkForDocker && DebugInfosProvider.isRunInDocker()) {
return MigrationResult.requirementsNotMet("You seem to be running NZBHydra2 in a docker container. Please copy the files from your v1 data folder to the v2 data folder and provide the correct file paths in the file based migration");
}
OkHttpResponse versionsResponse = callHydraUrl(nzbhydra1BaseUrl, "get_versions");
if (!versionsResponse.isSuccessful()) {
String msg = "Unable to connect to NZBHydra 1: " + versionsResponse.getMessage();
logger.error(msg);
return MigrationResult.requirementsNotMet(msg);
}
Map<String, String> migrationData = null;
try {
Map<String, String> versionsData = new ObjectMapper().readValue(versionsResponse.getBody(), mapTypeReference);
String currentVersionString = versionsData.get("currentVersion");
SemanticVersion currentVersion = new SemanticVersion(currentVersionString);
if (currentVersion.compareTo(new SemanticVersion("0.2.220")) < 0) {
String msg = "Unable to migrate from NZBHydra 1 version " + currentVersionString + ". Must be at least 0.2.220";
logger.error(msg);
return MigrationResult.requirementsNotMet(msg);
}
OkHttpResponse migrationResponse = callHydraUrl(nzbhydra1BaseUrl, "migration");
migrationData = new ObjectMapper().readValue(migrationResponse.getBody(), mapTypeReference);
migrationData.put("doMigrateDatabase", String.valueOf(doMigrateDatabase));
} catch (Exception e) {
logger.error("Unexpected error while migrating", e);
return MigrationResult.requirementsNotMet("Unexpected error while migrating: " + e.getMessage());
}
return startMigration(migrationData);
}
use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.
the class NewsProvider method getNewsForCurrentVersionAndAfter.
public List<NewsEntry> getNewsForCurrentVersionAndAfter() throws IOException {
List<ShownNews> shownNews = shownNewsRepository.findAll();
SemanticVersion from = shownNews.size() == 1 ? new SemanticVersion(shownNews.get(0).getVersion()) : null;
SemanticVersion to = new SemanticVersion(updateManager.getCurrentVersionString());
List<NewsEntry> news = getNews();
return news.stream().filter(x -> !(from != null && from.isSameOrNewer(x.getShowForVersion()) || x.getShowForVersion().isUpdateFor(to))).collect(Collectors.toList());
}
use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.
the class UpdateManager method getLatestVersion.
private SemanticVersion getLatestVersion() throws UpdateException {
Release latestRelease = latestReleaseCache.get();
latestVersion = new SemanticVersion(latestRelease.getTagName());
return latestVersion;
}
use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.
the class UpdateManager method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (Objects.equals(currentVersionString, "@project.version@")) {
currentVersionString = "1.0.0";
logger.warn("Version string not found. Using 1.0.0");
}
currentVersion = new SemanticVersion(currentVersionString);
}
Aggregations