I have tried to use DiscoClient.downloadPkg which calls DiscoClient.getPkgInfoByEphemeralId.
But I get the following error:
java.lang.NullPointerException: Cannot invoke "com.google.gson.JsonArray.size()" because "jsonArray" is null
at io.foojay.api.discoclient@2.0.39/io.foojay.api.discoclient.DiscoClient.getPkgInfoByEphemeralId(DiscoClient.java:1556)
at io.foojay.api.discoclient@2.0.39/io.foojay.api.discoclient.DiscoClient.downloadPkg(DiscoClient.java:1691)
at io.foojay.api.discoclient@2.0.39/io.foojay.api.discoclient.DiscoClient.downloadPkg(DiscoClient.java:1679)
Which is a here:
|
JsonObject jsonObject = packageInfoElement.getAsJsonObject(); |
|
JsonArray jsonArray = jsonObject.getAsJsonArray("result"); |
|
if (jsonArray.size() > 0) { |
|
final JsonObject packageInfoJson = jsonArray.get(0).getAsJsonObject(); |
The JsonObject returned by the API looks as follows:
{
"_links": {
"self": [
{
"href": "/disco/v3.0/ephemeral_ids/f7bddbcbba0e705cfa297fd965408e32",
"templated": false
}
]
},
"_embedded": {
"errors": [
{
"message": "Page Not Found"
}
]
},
"message": "Not Found"
}
The ephemeral_ids endpoint is also not documented in swagger.
I have tried this for basically all packages:
DiscoClient client = new DiscoClient();
for (Distribution distribution : client.getDistributions()) {
System.out.println(distribution.getName());
List<Pkg> packages = client.getPkgs(
List.of(distribution),
new VersionNumber(25),
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
);
for (Pkg pkg : packages) {
Path path = Paths.get("test").resolve(pkg.getFileName());
Files.createDirectories(path.getParent());
try {
client.downloadPkg(pkg.getId(), path.toAbsolutePath().toString());
return;
} catch (Exception e) {
System.out.println(distribution.getName() + " : " + pkg.getId());
e.printStackTrace();
}
}
}
Is the ephemeral_ids endpoint really part of the v3 API?
Usage in the client is confusing, here getPkgInfoByPkgId is used if API is v3:
|
if (PropertyManager.INSTANCE.getApiVersion().equals(API_VERSION_V3)) { |
|
return getPkgInfoByPkgId(pkgId, pkg.getJavaVersion()).getDirectDownloadUri(); |
|
} else { |
|
return getPkgInfoByEphemeralId(pkg.getEphemeralId(), pkg.getJavaVersion()).getDirectDownloadUri(); |
|
} |
This works well. But here if API version is v3, the package is downloaded by ephemeral id:
|
if (PropertyManager.INSTANCE.getApiVersion().equals(API_VERSION_V3)) { |
|
final Semver javaVersion = pkg.getJavaVersion(); |
|
final String ephemeralId = pkg.getEphemeralId(); |
|
return downloadPkg(ephemeralId, javaVersion, targetFileName); |
|
} else { |
|
final Semver javaVersion = pkg.getJavaVersion(); |
|
return downloadPkgByPkgId(pkgId, javaVersion, targetFileName); |
|
} |
If I invert the if-statement it works. Is it possible that some of the if-statements should be different and use the
ephemeral_ids only if not on API v3?
I have tried to use
DiscoClient.downloadPkgwhich callsDiscoClient.getPkgInfoByEphemeralId.But I get the following error:
Which is a here:
discoclient/src/main/java/io/foojay/api/discoclient/DiscoClient.java
Lines 1554 to 1557 in 8a8bb4f
The JsonObject returned by the API looks as follows:
{ "_links": { "self": [ { "href": "/disco/v3.0/ephemeral_ids/f7bddbcbba0e705cfa297fd965408e32", "templated": false } ] }, "_embedded": { "errors": [ { "message": "Page Not Found" } ] }, "message": "Not Found" }The
ephemeral_idsendpoint is also not documented in swagger.I have tried this for basically all packages:
Is the
ephemeral_idsendpoint really part of the v3 API?Usage in the client is confusing, here getPkgInfoByPkgId is used if API is v3:
discoclient/src/main/java/io/foojay/api/discoclient/DiscoClient.java
Lines 1507 to 1511 in 8a8bb4f
This works well. But here if API version is v3, the package is downloaded by ephemeral id:
discoclient/src/main/java/io/foojay/api/discoclient/DiscoClient.java
Lines 1676 to 1683 in 8a8bb4f
If I invert the if-statement it works. Is it possible that some of the if-statements should be different and use the
ephemeral_idsonly if not on API v3?