use of com.vdurmont.semver4j.Semver in project dhis2-core by dhis2.
the class SystemSoftwareUpdateNotifyController method checkSystemUpdate.
@GetMapping(SystemSoftwareUpdateNotifyController.RESOURCE_PATH)
@ResponseBody
public WebMessage checkSystemUpdate(@RequestParam(value = "forceVersion", required = false) String forceVersion) throws Exception {
Semver currentVersion = SystemUpdateService.getCurrentVersion();
if (forceVersion != null) {
currentVersion = new Semver(forceVersion);
}
Map<Semver, Map<String, String>> newerVersions = SystemUpdateService.getLatestNewerThan(currentVersion);
systemUpdateService.sendMessageForEachVersion(newerVersions);
WebMessage ok = WebMessageUtils.ok();
ok.setResponse(new SoftwareUpdateResponse(newerVersions));
return ok;
}
use of com.vdurmont.semver4j.Semver in project graylog2-server by Graylog2.
the class PluginVersionConstraintChecker method checkConstraints.
@Override
public Set<ConstraintCheckResult> checkConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<ConstraintCheckResult> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof PluginVersionConstraint) {
final PluginVersionConstraint versionConstraint = (PluginVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
boolean result = false;
for (Semver pluginVersion : pluginVersions) {
if (requiredVersion.isSatisfiedBy(pluginVersion)) {
result = true;
}
}
ConstraintCheckResult constraintCheckResult = ConstraintCheckResult.create(versionConstraint, result);
fulfilledConstraints.add(constraintCheckResult);
}
}
return fulfilledConstraints.build();
}
use of com.vdurmont.semver4j.Semver in project graylog2-server by Graylog2.
the class SemverDeserializerTest method successfullyDeserializesString.
@Test
public void successfullyDeserializesString() throws IOException {
final Semver version = objectMapper.readValue("\"1.3.7-rc.2+build.2.b8f12d7\"", Semver.class);
assertThat(version).isEqualTo(new Semver("1.3.7-rc.2+build.2.b8f12d7", Semver.SemverType.NPM));
}
use of com.vdurmont.semver4j.Semver in project TOSCAna by StuPro-TOSCAna.
the class MapperEngine method determineTagFromMinorVersion.
/**
* Tries to determine the tag from the list of possible minor versions
*/
private String determineTagFromMinorVersion(List<DockerImageTag> possibleTags, Semver version) {
DockerImageTag resultTag = null;
int i = 0;
DockerImageTag tag;
Semver tagVersion;
do {
tag = possibleTags.get(i);
tagVersion = tag.toVersion();
if (tagVersion.getMinor() == version.getMinor()) {
int j = i;
DockerImageTag prev = null;
DockerImageTag t = null;
Semver tv;
do {
prev = t;
t = possibleTags.get(j);
tv = t.toVersion();
j++;
} while (tv.getMinor().equals(version.getMinor()) && j < possibleTags.size());
resultTag = prev;
}
i++;
} while (i < possibleTags.size());
if (resultTag == null) {
throw new UnsupportedOperationException("Mapping failed");
}
return resultTag.getName();
}
use of com.vdurmont.semver4j.Semver in project Robot by fo0.
the class UpdateUtils method doUpdate.
public static void doUpdate() {
try {
GitHub gitHub = GitHub.connectAnonymously();
GHRepository repository = gitHub.getRepository(CONSTANTS.GITHUB_URI);
GHRelease latest = repository.getLatestRelease();
boolean newerVersionAvailable = new Semver(latest.getTagName().replaceAll("v", "")).isGreaterThan(new Semver(CONSTANTS.VERSION));
if (!newerVersionAvailable) {
Logger.info("no newer version available, skipping now");
Logger.info("current version: " + CONSTANTS.VERSION);
Logger.info("latest version: " + latest.getTagName().replaceAll("v", ""));
return;
} else {
Logger.info("detected new version");
Logger.info("current version: " + CONSTANTS.VERSION);
Logger.info("latest version: " + latest.getTagName().replaceAll("v", ""));
}
GHAsset asset = latest.getAssets().get(0);
Logger.info("downloading file from github: " + asset.getBrowserDownloadUrl());
File latestFile = File.createTempFile(Random.alphanumeric(10), ".patch");
latestFile.deleteOnExit();
FileUtils.copyToFile(new URL(asset.getBrowserDownloadUrl()).openStream(), latestFile);
Logger.info("download finished");
Logger.info("applying patch...");
File currentPath = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath());
Utils.writeBytesToFile(IOUtils.toByteArray(new FileInputStream(latestFile)), currentPath);
// FileUtils.moveFile(latestFile, currentPath);
try {
latestFile.delete();
} catch (Exception e) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations