Search in sources :

Example 6 with SemanticVersion

use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.

the class UpdateManager method latestVersionIgnored.

public boolean latestVersionIgnored() throws UpdateException {
    SemanticVersion latestVersion = getLatestVersion();
    Optional<UpdateData> updateData = updateDataGenericStorage.get(KEY, UpdateData.class);
    if (updateData.isPresent() && updateData.get().getIgnoreVersions().contains(latestVersion)) {
        logger.debug("Version {} is in the list of ignored updates", latestVersion);
        return true;
    }
    return false;
}
Also used : SemanticVersion(org.nzbhydra.mapping.SemanticVersion)

Example 7 with SemanticVersion

use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.

the class UpdateManager method getChangesSinceCurrentVersion.

public List<ChangelogVersionEntry> getChangesSinceCurrentVersion() throws UpdateException {
    if (latestVersion == null) {
        getLatestVersion();
    }
    List<ChangelogVersionEntry> allChanges = getAllChanges();
    List<ChangelogVersionEntry> collectedVersionChanges = new ArrayList<>();
    for (ChangelogVersionEntry changelogVersionEntry : allChanges) {
        SemanticVersion version = new SemanticVersion(changelogVersionEntry.getVersion());
        if (currentVersion.isSameOrNewer(version)) {
            break;
        }
        if (version.isUpdateFor(latestVersion)) {
            // Don't show changes for version not yet released
            continue;
        }
        collectedVersionChanges.add(changelogVersionEntry);
    }
    return collectedVersionChanges;
}
Also used : ChangelogVersionEntry(org.nzbhydra.mapping.changelog.ChangelogVersionEntry) SemanticVersion(org.nzbhydra.mapping.SemanticVersion)

Example 8 with SemanticVersion

use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.

the class UpdateManager method ignore.

public void ignore(String version) {
    SemanticVersion semanticVersion = new SemanticVersion(version);
    UpdateData updateData = updateDataGenericStorage.get(KEY, UpdateData.class).orElse(new UpdateData());
    if (!updateData.getIgnoreVersions().contains(semanticVersion)) {
        updateData.getIgnoreVersions().add(semanticVersion);
    }
    updateDataGenericStorage.save(KEY, updateData);
    logger.info("Version {} ignored. Will not show update notices for this version.", semanticVersion);
}
Also used : SemanticVersion(org.nzbhydra.mapping.SemanticVersion)

Example 9 with SemanticVersion

use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.

the class NewsWeb method transform.

private List<NewsEntryForWeb> transform(List<NewsEntry> entries) {
    List<NewsEntryForWeb> transformedEntries = new ArrayList<>();
    for (NewsEntry entry : entries) {
        boolean isForCurrentVersion = entry.getShowForVersion().equals(new SemanticVersion(updateManager.getCurrentVersionString()));
        boolean isForNewerVersion = entry.getShowForVersion().isUpdateFor(new SemanticVersion(updateManager.getCurrentVersionString()));
        transformedEntries.add(new NewsEntryForWeb(entry.getShowForVersion().getAsString(), Markdown.renderMarkdownAsHtml(entry.getNewsAsMarkdown()), isForCurrentVersion, isForNewerVersion));
    }
    return transformedEntries;
}
Also used : ArrayList(java.util.ArrayList) NewsEntry(org.nzbhydra.news.NewsProvider.NewsEntry) SemanticVersion(org.nzbhydra.mapping.SemanticVersion)

Example 10 with SemanticVersion

use of org.nzbhydra.mapping.SemanticVersion in project nzbhydra2 by theotherp.

the class UpdateManagerTest method testThatChecksForUpdateAvailable.

@Test
public void testThatChecksForUpdateAvailable() throws Exception {
    assertTrue(testee.isUpdateAvailable());
    testee.currentVersion = new SemanticVersion("v2.0.0");
    assertFalse(testee.isUpdateAvailable());
}
Also used : SemanticVersion(org.nzbhydra.mapping.SemanticVersion) Test(org.junit.Test)

Aggregations

SemanticVersion (org.nzbhydra.mapping.SemanticVersion)11 IOException (java.io.IOException)2 Test (org.junit.Test)2 ChangelogVersionEntry (org.nzbhydra.mapping.changelog.ChangelogVersionEntry)2 NewsEntry (org.nzbhydra.news.NewsProvider.NewsEntry)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Instant (java.time.Instant)1 ChronoUnit (java.time.temporal.ChronoUnit)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Data (lombok.Data)1 Release (org.nzbhydra.mapping.github.Release)1 WebAccess (org.nzbhydra.okhttp.WebAccess)1 UpdateManager (org.nzbhydra.update.UpdateManager)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1