diff --git a/core/src/net/sf/openrocket/communication/ReleaseInfo.java b/core/src/net/sf/openrocket/communication/ReleaseInfo.java index 88be31f98..4ab256814 100644 --- a/core/src/net/sf/openrocket/communication/ReleaseInfo.java +++ b/core/src/net/sf/openrocket/communication/ReleaseInfo.java @@ -1,9 +1,12 @@ package net.sf.openrocket.communication; +import net.sf.openrocket.util.ArrayList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.json.JsonArray; import javax.json.JsonObject; +import java.util.List; /** * Class containing info about a GitHub release. All the info is stored in a JSON objects, retrieved using the GitHub @@ -60,6 +63,23 @@ public class ReleaseInfo { return this.obj.get("html_url").toString(); } + /** + * Get the download URLs of the assets from the GitHub release JSON object. + * @return list of asset download URLs (e.g. 'https://github.com/openrocket/openrocket/releases/download/release-15.03/OpenRocket-15.03-installer.exe') + */ + public List getAssetURLs() { + if (this.obj == null) return null; + List assetURLs = new ArrayList<>(); + + JsonArray assets = this.obj.getJsonArray("assets"); + for (int i = 0; i < assets.size(); i++) { + String url = assets.getJsonObject(i).getString("browser_download_url"); + assetURLs.add(url); + } + + return assetURLs; + } + @Override public String toString() { return String.format("releaseTag = %s ; releaseNotes = %s ; releaseURL = %s", getReleaseTag(), getReleaseNotes(),