From 990a84f75396fe942d2cbc690a7c047223b648dd Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Thu, 4 Sep 2014 21:19:25 +0200 Subject: [PATCH] [FIXED JENKINS-24407] Restore icon class name during deserialization --- core/src/main/java/hudson/model/HealthReport.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/src/main/java/hudson/model/HealthReport.java b/core/src/main/java/hudson/model/HealthReport.java index 2e1efe05f8..bf8c776d77 100644 --- a/core/src/main/java/hudson/model/HealthReport.java +++ b/core/src/main/java/hudson/model/HealthReport.java @@ -34,7 +34,9 @@ import org.kohsuke.stapler.export.ExportedBean; import java.io.*; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Represents health of something (typically project). @@ -60,6 +62,15 @@ public class HealthReport implements Serializable, Comparable { private static final String HEALTH_0_TO_20_IMG = "health-00to19.png"; private static final String HEALTH_UNKNOWN_IMG = "empty.png"; + private static final Map iconIMGToClassMap = new HashMap(); + static { + iconIMGToClassMap.put(HEALTH_OVER_80_IMG, HEALTH_OVER_80); + iconIMGToClassMap.put(HEALTH_61_TO_80_IMG, HEALTH_61_TO_80); + iconIMGToClassMap.put(HEALTH_41_TO_60_IMG, HEALTH_41_TO_60); + iconIMGToClassMap.put(HEALTH_21_TO_40_IMG, HEALTH_21_TO_40); + iconIMGToClassMap.put(HEALTH_0_TO_20_IMG, HEALTH_0_TO_20); + } + /** * The percentage health score (from 0 to 100 inclusive). */ @@ -351,6 +362,10 @@ public class HealthReport implements Serializable, Comparable { hr.localizibleDescription = new NonLocalizable(hr.description == null ? "" : hr.description); OldDataMonitor.report(context, "1.256"); } + + if (hr.iconClassName == null && hr.iconUrl != null && iconIMGToClassMap.containsKey(hr.iconUrl)) { + hr.iconClassName = iconIMGToClassMap.get(hr.iconUrl); + } } } }