Skip to content

Commit

Permalink
Merge pull request #7617 from HoussemNasri/errata-reboot-suggested
Browse files Browse the repository at this point in the history
Include reboot_suggested and restart_suggested booleans in errata.getDetails response
  • Loading branch information
cbbayburt authored Oct 11, 2023
2 parents d147f7d + 70a7d43 commit 141a724
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
32 changes: 12 additions & 20 deletions java/code/src/com/redhat/rhn/domain/errata/Errata.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -675,11 +658,20 @@ public void setKeywords(Set<Keyword> 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;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions java/code/src/com/redhat/rhn/domain/errata/Keyword.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> 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<String, Object> errataMap = new HashMap<>();
Map<String, Object> errataMap = new LinkedHashMap<>();

errataMap.put("id", errata.getId());
if (errata.getIssueDate() != null) {
Expand Down Expand Up @@ -187,6 +189,8 @@ public Map<String, Object> 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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Include reboot_suggested and restart_suggested booleans in
errata.getDetails API response

0 comments on commit 141a724

Please sign in to comment.