diff --git a/java/code/src/com/redhat/rhn/domain/errata/Errata.java b/java/code/src/com/redhat/rhn/domain/errata/Errata.java index b85c67aa1367..ccd747dad334 100644 --- a/java/code/src/com/redhat/rhn/domain/errata/Errata.java +++ b/java/code/src/com/redhat/rhn/domain/errata/Errata.java @@ -642,23 +642,6 @@ public void addKeyword(Keyword keywordIn) { } - /** - * Checks whether a keyword is already associated with an erratum. - * @param keywordIn The keyword to check. - * @return returns whether keyword is already associated with given erratum - */ - public boolean containsKeyword(String keywordIn) { - if (this.keywords == null) { - return false; - } - for (Keyword k : this.keywords) { - if (k.getKeyword().equals(keywordIn)) { - return true; - } - } - return false; - } - /** * @return Returns the keywords. */ @@ -675,11 +658,20 @@ public void setKeywords(Set k) { /** * Search for the given keyword in the set - * @param s The keyword to search for + * + * @param keyword The keyword to search for * @return true if keyword was found */ - public boolean hasKeyword(String s) { - return containsKeyword(s); + public boolean hasKeyword(String keyword) { + if (this.keywords == null || keyword == null) { + return false; + } + for (Keyword k : this.keywords) { + if (k.getKeyword().equals(keyword)) { + return true; + } + } + return false; } /** diff --git a/java/code/src/com/redhat/rhn/domain/errata/Keyword.java b/java/code/src/com/redhat/rhn/domain/errata/Keyword.java index b3548094638f..dcc536de61f3 100644 --- a/java/code/src/com/redhat/rhn/domain/errata/Keyword.java +++ b/java/code/src/com/redhat/rhn/domain/errata/Keyword.java @@ -25,6 +25,17 @@ * Keyword */ public class Keyword extends BaseDomainHelper implements Serializable { + /** + * A keyword signaling that a system reboot is advisable following the application of the errata. + * Typical example is if the errata requires kernel update. + * */ + public static final String REBOOT_SUGGESTED = "reboot_suggested"; + + /** + * A keyword signaling that a reboot of the package manager is advisable following the application of + * the errata. This is commonly used to address update stack issues before proceeding with other updates. + * */ + public static final String RESTART_SUGGESTED = "restart_suggested"; private String keyword; private Errata errata; diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java index 5c7067105bbd..4a6852036160 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java @@ -79,8 +79,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; -import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -125,16 +125,18 @@ public class ErrataHandler extends BaseHandler { * #prop("string", "references") * #prop("string", "notes") * #prop("string", "solution") + * #prop_desc("boolean", "reboot_suggested", "A boolean flag signaling whether a system reboot is + * advisable following the application of the errata. Typical example is upon kernel update.") + * #prop_desc("boolean", "restart_suggested", "A boolean flag signaling a weather reboot of + * the package manager is advisable following the application of the errata. This is commonly + * used to address update stack issues before proceeding with other updates.") * #struct_end() */ @ReadOnly public Map getDetails(User loggedInUser, String advisoryName) throws FaultException { - // Get the logged in user. We don't care what roles this user has, we - // just want to make sure the caller is logged in. - Errata errata = lookupAccessibleErratum(advisoryName, empty(), loggedInUser.getOrg()); - Map errataMap = new HashMap<>(); + Map errataMap = new LinkedHashMap<>(); errataMap.put("id", errata.getId()); if (errata.getIssueDate() != null) { @@ -187,6 +189,8 @@ public Map getDetails(User loggedInUser, String advisoryName) th errataMap.put("severity", errata.getSeverity().getLocalizedLabel()); } + errataMap.put("reboot_suggested", errata.hasKeyword(Keyword.REBOOT_SUGGESTED)); + errataMap.put("restart_suggested", errata.hasKeyword(Keyword.RESTART_SUGGESTED)); return errataMap; } diff --git a/java/spacewalk-java.changes.HoussemNasri.errata-reboot-suggested b/java/spacewalk-java.changes.HoussemNasri.errata-reboot-suggested new file mode 100644 index 000000000000..f72ea2d76543 --- /dev/null +++ b/java/spacewalk-java.changes.HoussemNasri.errata-reboot-suggested @@ -0,0 +1,2 @@ +- Include reboot_suggested and restart_suggested booleans in + errata.getDetails API response