Search in sources :

Example 1 with SemanticVersion

use of org.eclipse.openvsx.util.SemanticVersion in project openvsx by eclipse.

the class ExtensionService method getLatestVersion.

private ExtensionVersion getLatestVersion(Streamable<ExtensionVersion> versions) {
    ExtensionVersion latest = null;
    SemanticVersion latestSemver = null;
    for (var extVer : versions) {
        var semver = extVer.getSemanticVersion();
        if (latestSemver == null || latestSemver.compareTo(semver) < 0) {
            latest = extVer;
            latestSemver = semver;
        }
    }
    return latest;
}
Also used : ExtensionVersion(org.eclipse.openvsx.entities.ExtensionVersion) SemanticVersion(org.eclipse.openvsx.util.SemanticVersion)

Example 2 with SemanticVersion

use of org.eclipse.openvsx.util.SemanticVersion in project openvsx by eclipse.

the class AdminAPI method getLatestVersion.

private ExtensionVersion getLatestVersion(Extension extension) {
    ExtensionVersion latest = null;
    SemanticVersion latestSemver = null;
    for (var extVer : repositories.findVersions(extension)) {
        var semver = extVer.getSemanticVersion();
        if (latestSemver == null || latestSemver.compareTo(semver) < 0) {
            latest = extVer;
            latestSemver = semver;
        }
    }
    return latest;
}
Also used : ExtensionVersion(org.eclipse.openvsx.entities.ExtensionVersion) SemanticVersion(org.eclipse.openvsx.util.SemanticVersion)

Example 3 with SemanticVersion

use of org.eclipse.openvsx.util.SemanticVersion in project openvsx by eclipse.

the class LocalRegistryService method toExtensionVersionJson.

public ExtensionJson toExtensionVersionJson(ExtensionVersion extVersion, boolean onlyActive) {
    var extension = extVersion.getExtension();
    var json = extVersion.toExtensionJson();
    json.preview = extension.getLatest().isPreview();
    json.versionAlias = new ArrayList<>(2);
    if (extVersion == extension.getLatest())
        json.versionAlias.add("latest");
    if (extVersion == extension.getLatestPreRelease())
        json.versionAlias.add("pre-release");
    json.verified = isVerified(extVersion);
    json.namespaceAccess = "restricted";
    json.unrelatedPublisher = !json.verified;
    json.reviewCount = repositories.countActiveReviews(extension);
    var serverUrl = UrlUtil.getBaseUrl();
    json.namespaceUrl = createApiUrl(serverUrl, "api", json.namespace);
    json.reviewsUrl = createApiUrl(serverUrl, "api", json.namespace, json.name, "reviews");
    var versionStrings = onlyActive ? repositories.getActiveVersionStrings(extension) : repositories.getVersionStrings(extension);
    var allVersions = CollectionUtil.map(versionStrings, v -> new SemanticVersion(v));
    Collections.sort(allVersions, Collections.reverseOrder());
    json.allVersions = Maps.newLinkedHashMapWithExpectedSize(allVersions.size() + 2);
    if (extension.getLatest() != null)
        json.allVersions.put("latest", createApiUrl(serverUrl, "api", json.namespace, json.name, "latest"));
    if (extension.getLatestPreRelease() != null)
        json.allVersions.put("pre-release", createApiUrl(serverUrl, "api", json.namespace, json.name, "pre-release"));
    for (var version : allVersions) {
        String url = createApiUrl(serverUrl, "api", json.namespace, json.name, version.toString());
        json.allVersions.put(version.toString(), url);
    }
    json.files = Maps.newLinkedHashMapWithExpectedSize(6);
    storageUtil.addFileUrls(extVersion, serverUrl, json.files, DOWNLOAD, MANIFEST, ICON, FileResource.README, FileResource.LICENSE, FileResource.CHANGELOG);
    if (json.dependencies != null) {
        json.dependencies.forEach(ref -> {
            ref.url = createApiUrl(serverUrl, "api", ref.namespace, ref.extension);
        });
    }
    if (json.bundledExtensions != null) {
        json.bundledExtensions.forEach(ref -> {
            ref.url = createApiUrl(serverUrl, "api", ref.namespace, ref.extension);
        });
    }
    return json;
}
Also used : SemanticVersion(org.eclipse.openvsx.util.SemanticVersion)

Aggregations

SemanticVersion (org.eclipse.openvsx.util.SemanticVersion)3 ExtensionVersion (org.eclipse.openvsx.entities.ExtensionVersion)2