Skip to content
Permalink
Browse files

Merge pull request #2050 from varmenise/JENKINS-32831

[FIXED JENKINS-32831] do not fail if there are no metadata for tool installers
  • Loading branch information...
daniel-beck committed Mar 16, 2016
2 parents 37111bf + 3deb73b commit d8241ff7803ca134fa39fb88bb990fc6a0abef93
@@ -395,10 +395,12 @@ private FormValidation load(String json, long dataTimestamp) throws IOException
@Restricted(NoExternalUse.class)
public FormValidation updateNow() throws IOException {
List<JSONObject> jsonList = new ArrayList<>();
boolean toolInstallerMetadataExists = false;
for (String site : getUrls()) {
String jsonString;
try {
jsonString = loadJSONHTML(new URL(site + ".html?id=" + URLEncoder.encode(getId(), "UTF-8") + "&version=" + URLEncoder.encode(Jenkins.VERSION, "UTF-8")));
toolInstallerMetadataExists = true;
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Could not load json from " + site, e );
continue;
@@ -407,13 +409,17 @@ public FormValidation updateNow() throws IOException {
if (signatureCheck) {
FormValidation e = new JSONSignatureValidator("downloadable '"+id+"'").verifySignature(o);
if (e.kind!= Kind.OK) {
LOGGER.log(Level.WARNING, "signature check failed for " + site, e );
continue;
}
}
jsonList.add(o);
}
if (jsonList.size() == 0) {
return FormValidation.warning("None of the Update Sites passed the signature check");
if (jsonList.size() == 0 && toolInstallerMetadataExists) {
return FormValidation.warning("None of the tool installer metadata passed the signature check");
} else if (!toolInstallerMetadataExists) {
LOGGER.log(Level.WARNING, "No tool installer metadata found for " + id);
return FormValidation.ok();
}
JSONObject reducedJson = reduce(jsonList);
return load(reducedJson.toString(), System.currentTimeMillis());
@@ -136,7 +136,7 @@ public Downloadable createDownloadable() {
final DownloadFromUrlInstaller.DescriptorImpl delegate = (DownloadFromUrlInstaller.DescriptorImpl)this;
return new Downloadable(getId()) {
public JSONObject reduce(List<JSONObject> jsonList) {
if (isDefualtSchema(jsonList)) {
if (isDefaultSchema(jsonList)) {
return delegate.reduce(jsonList);
} else {
//if it's not default schema fall back to the super class implementation
@@ -153,7 +153,7 @@ public JSONObject reduce(List<JSONObject> jsonList) {
* @param jsonList the list of Update centers json files
* @return true if the schema is the default one (id, name, url), false otherwise
*/
private boolean isDefualtSchema(List<JSONObject> jsonList) {
private boolean isDefaultSchema(List<JSONObject> jsonList) {
JSONObject jsonToolInstallerList = jsonList.get(0);
ToolInstallerList toolInstallerList = (ToolInstallerList) JSONObject.toBean(jsonToolInstallerList, ToolInstallerList.class);

0 comments on commit d8241ff

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.