java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml | 20 +
java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java | 28 ++
java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml | 5
java/code/src/com/redhat/rhn/frontend/action/systems/ErrataSetupAction.java | 37 +++
java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml | 28 ++
java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java | 28 ++
java/code/src/com/redhat/rhn/manager/system/SystemManager.java | 27 ++
java/code/webapp/WEB-INF/pages/systems/systemcurrency.jsp | 106
++++++----
8 files changed, 235 insertions(+), 44 deletions(-)
New commits:
commit 74119c6b248c8a3a1c85a2ea46afe4bee637eb17
Author: Colin Coe <coec(a)spacey.coesta.com>
Date: Wed Jul 28 20:20:46 2010 +0800
System currency phase 2
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
index 5fcafbd..b3e3e69 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Errata_queries.xml
@@ -214,6 +214,26 @@ ORDER BY E.update_date DESC, E.id
</query>
</mode>
+<mode name="security_relevant_to_system_by_synopsis"
class="com.redhat.rhn.frontend.dto.ErrataOverview">
+ <query params="user_id, sid, type, synopsis">
+SELECT DISTINCT E.id, E.update_date,
+ E.synopsis AS ADVISORY_SYNOPSIS,
+ E.advisory_name AS ADVISORY_NAME,
+ E.advisory_type AS ADVISORY_TYPE,
+ :sid as ASSOCIATED_SYSTEM
+ FROM rhnErrata E,
+ rhnServerNeededErrataCache SNEC
+ WHERE EXISTS (SELECT server_id FROM rhnUserServerPerms USP
+ WHERE USP.user_id = :user_id
+ AND USP.server_id = :sid)
+ AND SNEC.server_id = :sid
+ AND SNEC.errata_id = E.id
+ AND E.advisory_type = :type
+ AND substr(E.synopsis, 1, 1) = :synopsis
+ORDER BY E.update_date DESC, E.id
+ </query>
+</mode>
+
<mode name="relevant_to_system_sorted_by_priority">
<query params="user_id, sid">
SELECT E.synopsis AS ERRATA_SYNOPSIS, E.advisory_type
diff --git a/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
b/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
index fce92fa..6dec3ad 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
@@ -74,6 +74,10 @@ public class ErrataFactory extends HibernateFactory {
public static final String ERRATA_TYPE_ENHANCEMENT = "Product Enhancement
Advisory";
public static final String ERRATA_TYPE_SECURITY = "Security Advisory";
+ public static final String ERRATA_TYPE_SECURITY_CRIT = "Security Advisory
(Critical)";
+ public static final String ERRATA_TYPE_SECURITY_IMP = "Security Advisory
(Important)";
+ public static final String ERRATA_TYPE_SECURITY_MOD = "Security Advisory
(Moderate)";
+ public static final String ERRATA_TYPE_SECURITY_LOW = "Security Advisory
(Low)";
private ErrataFactory() {
super();
@@ -637,6 +641,30 @@ public class ErrataFactory extends HibernateFactory {
return retval;
}
+ /*
+ * Lookup a Security Errata by the synopsis string
+ * @param synopsis to search for
+ * @return the Errata found
+ */
+ public static List lookupErratasBySynopsis(String synopsis) {
+ Session session = null;
+ List retval = null;
+ try {
+ session = HibernateFactory.getSession();
+ retval =
session.getNamedQuery("PublishedErrata.findSecurityBySynopsis")
+ .setString("type",
ERRATA_TYPE_SECURITY)
+ .setString("synopsis", synopsis)
+ //Retrieve from cache if there
+ .setCacheable(true).list();
+ }
+ catch (HibernateException he) {
+ log.error("Error loading ActionArchTypes from DB", he);
+ throw new
+ HibernateRuntimeException("Error loading ActionArchTypes from
db");
+ }
+ return retval;
+ }
+
/**
* Finds published errata by id
* @param id errata id
diff --git a/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml
b/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml
index fcc6b68..08d0cfc 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml
@@ -85,6 +85,11 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
where e.advisoryType = :type]]>
</query>
+ <query name="PublishedErrata.findSecurityBySynopsis">
+ <![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
+ where e.advisoryType = :type
+ and substr(e.synopsis, 1, 1) = :synopsis]]>
+ </query>
<query name="PublishedErrata.findById">
<![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
where e.id = :id]]>
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataSetupAction.java
b/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataSetupAction.java
index 6091b4f..b82d14e 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataSetupAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataSetupAction.java
@@ -59,6 +59,12 @@ public class ErrataSetupAction extends RhnAction implements Listable {
public static final String BUGFIX = "errata.create.bugfixadvisory";
public static final String ENHANCE =
"errata.create.productenhancementadvisory";
+ // Used by System Currency page
+ public static final String SECUR_CRIT =
"errata.create.securityadvisory.crit";
+ public static final String SECUR_IMP =
"errata.create.securityadvisory.imp";
+ public static final String SECUR_MOD =
"errata.create.securityadvisory.mod";
+ public static final String SECUR_LOW =
"errata.create.securityadvisory.low";
+
public static final String SELECTOR = "type";
@@ -239,10 +245,13 @@ public class ErrataSetupAction extends RhnAction implements Listable
{
User user = context.getLoggedInUser();
Long sid = context.getRequiredParam("sid");
String type = context.getParam(SELECTOR, false);
+ String synopsis = "";
+ Boolean currency = false;
LocalizationService ls = LocalizationService.getInstance();
List<String> typeList = new ArrayList<String>();
+ String eType = new String();
if (ls.getMessage(BUGFIX).equals(type)) {
typeList.add(ErrataFactory.ERRATA_TYPE_BUG);
@@ -257,13 +266,37 @@ public class ErrataSetupAction extends RhnAction implements Listable
{
typeList.add(ErrataFactory.ERRATA_TYPE_BUG);
typeList.add(ErrataFactory.ERRATA_TYPE_ENHANCEMENT);
}
- else {
+ else if (ls.getMessage(SECUR_CRIT).equals(type)) {
+ eType = ErrataFactory.ERRATA_TYPE_SECURITY;
+ synopsis = "C";
+ currency = true;
+ }
+ else if (ls.getMessage(SECUR_IMP).equals(type)) {
+ eType = ErrataFactory.ERRATA_TYPE_SECURITY;
+ synopsis = "I";
+ currency = true;
+ }
+ else if (ls.getMessage(SECUR_MOD).equals(type)) {
+ eType = ErrataFactory.ERRATA_TYPE_SECURITY;
+ synopsis = "M";
+ currency = true;
+ }
+ else if (ls.getMessage(SECUR_LOW).equals(type)) {
+ eType = ErrataFactory.ERRATA_TYPE_SECURITY;
+ synopsis = "L";
+ currency = true;
+ }
+ else { // ALL
typeList.add(ErrataFactory.ERRATA_TYPE_BUG);
typeList.add(ErrataFactory.ERRATA_TYPE_ENHANCEMENT);
typeList.add(ErrataFactory.ERRATA_TYPE_SECURITY);
}
- return SystemManager.relevantErrata(user, sid, typeList);
+ if (currency) {
+ return SystemManager.relevantCurrencyErrata(user, sid, eType, synopsis);
+ } else {
+ return SystemManager.relevantErrata(user, sid, typeList);
+ }
}
}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index ea8c37d..6fba2c2 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -2650,6 +2650,34 @@ available for this kickstart profile to function properly.
</context-group>
</trans-unit>
+ <trans-unit id="errata.create.securityadvisory.crit">
+<source>Security Advisory (Critical)</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/errata/Create.do</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="errata.create.securityadvisory.imp">
+<source>Security Advisory (Important)</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/errata/Create.do</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="errata.create.securityadvisory.mod">
+<source>Security Advisory (Moderate)</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/errata/Create.do</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="errata.create.securityadvisory.low">
+<source>Security Advisory (Low)</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/errata/Create.do</context>
+ </context-group>
+ </trans-unit>
+
<trans-unit id="errata.search.could_not_execute_query">
<source>Could not execute query: {0}</source>
<context-group name="ctx">
diff --git a/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
b/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
index 475fe76..697ad01 100644
--- a/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
+++ b/java/code/src/com/redhat/rhn/manager/errata/ErrataManager.java
@@ -738,6 +738,15 @@ public class ErrataManager extends BaseManager {
}
/**
+ * Lookup all Security Errata by synopsis
+ * @param synopsis the synopsis to use to query the set of Errata
+ * @return List of Errata found
+ */
+ public static List lookupErrataBySynopsis(String synopsis) {
+ return ErrataFactory.lookupErratasBySynopsis(synopsis);
+ }
+
+ /**
* Looks up published errata by errata id
* @param id errata id
* @return Errata if found, otherwise null
@@ -897,6 +906,25 @@ public class ErrataManager extends BaseManager {
}
/**
+ * Returns a list of advisory types available for an errata
+ * (exclusive to System Currency page)
+ * @return advisory types
+ */
+ public static List<String> currencyAdvisoryTypes() {
+ List<String> advTypes = new ArrayList<String>();
+ LocalizationService ls = LocalizationService.getInstance();
+ advTypes.add(ls.getMessage("errata.create.securityadvisory.crit",
+ LocalizationService.DEFAULT_LOCALE));
+ advTypes.add(ls.getMessage("errata.create.securityadvisory.imp",
+ LocalizationService.DEFAULT_LOCALE));
+ advTypes.add(ls.getMessage("errata.create.securityadvisory.mod",
+ LocalizationService.DEFAULT_LOCALE));
+ advTypes.add(ls.getMessage("errata.create.securityadvisory.low",
+ LocalizationService.DEFAULT_LOCALE));
+ return advTypes;
+ }
+
+ /**
* Returns a list of l10n-ed advisory types available for an errata
* @return l10n-ed advisory type labels
*/
diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
index 1bb9557..991b66f 100644
--- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
@@ -791,6 +791,33 @@ public class SystemManager extends BaseManager {
return dr;
}
+ /**
+ * Returns a list of errata relevant to a system
+ * @param user The user
+ * @param sid System Id
+ * @param types of errata types (strings) to include
+ * @return a list of ErrataOverviews
+ */
+ public static DataResult<ErrataOverview> relevantCurrencyErrata(User user,
+ Long sid, String type,
+ String synopsis) {
+ SelectMode m = ModeFactory.getMode("Errata_queries",
+ "security_relevant_to_system_by_synopsis");
+
+ Map params = new HashMap();
+ params.put("user_id", user.getId());
+ params.put("sid", sid);
+ params.put("type", type);
+ params.put("synopsis", synopsis);
+
+ Map elabParams = new HashMap();
+ elabParams.put("sid", sid);
+ elabParams.put("user_id", user.getId());
+
+ DataResult<ErrataOverview> dr = m.execute(params);
+ dr.setElaborationParams(elabParams);
+ return dr;
+ }
/**
* Returns a list of errata relevant to a system by type
diff --git a/java/code/webapp/WEB-INF/pages/systems/systemcurrency.jsp
b/java/code/webapp/WEB-INF/pages/systems/systemcurrency.jsp
index cbc4329..4a56c12 100644
--- a/java/code/webapp/WEB-INF/pages/systems/systemcurrency.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/systemcurrency.jsp
@@ -55,18 +55,20 @@
sortattr="created"
defaultsort="desc">
<c:choose>
- <c:when test="${current.critical >=
10}">
- <font color="red">
- </c:when>
- <c:when test="${current.critical >=
5}">
- <font color="orange">
- </c:when>
+ <c:when test="${current.critical > 0}">
+ <a
href="/rhn/systems/details/ErrataList.do?sid=${current.id}&type=${rhn:localize('errata.create.securityadvisory.crit')}">${current.critical}</a>
+ </c:when>
+ <c:otherwise>
+ ${current.critical}
+ </c:otherwise>
</c:choose>
- ${current.critical}
<c:choose>
- <c:when test="${current.critical >=
5}">
- </font>
- </c:when>
+ <c:when test="${current.critical >=
10}">
+ <img height="10%" width="10%"
src="/img/icon_crit_update.gif"/>
+ </c:when>
+ <c:when test="${current.critical >= 5}">
+ <img height="10%" width="10%"
src="/img/rhn-icon-warning.gif"/>
+ </c:when>
</c:choose>
</rl:column>
<!-- Important Errata Column -->
@@ -76,18 +78,20 @@
sortattr="created"
defaultsort="desc">
<c:choose>
- <c:when test="${current.important >=
15}">
- <font color="red">
- </c:when>
- <c:when test="${current.important >=
10}">
- <font color="orange">
- </c:when>
- </c:choose>
+ <c:when test="${current.important > 0}">
+ <a
href="/rhn/systems/details/ErrataList.do?sid=${current.id}&type=${rhn:localize('errata.create.securityadvisory.imp')}">${current.important}</a>
+ </c:when>
+ <c:otherwise>
${current.important}
+ </c:otherwise>
+ </c:choose>
<c:choose>
- <c:when test="${current.important >=
10}">
- </font>
- </c:when>
+ <c:when test="${current.important >=
15}">
+ <img height="10%" width="10%"
src="/img/icon_crit_update.gif"/>
+ </c:when>
+ <c:when test="${current.important >=
10}">
+ <img height="10%" width="10%"
src="/img/rhn-icon-warning.gif"/>
+ </c:when>
</c:choose>
</rl:column>
<!-- Moderate Errata Column -->
@@ -97,18 +101,20 @@
sortattr="created"
defaultsort="desc">
<c:choose>
- <c:when test="${current.moderate >=
20}">
- <font color="red">
- </c:when>
- <c:when test="${current.moderate >=
15}">
- <font color="orange">
- </c:when>
- </c:choose>
+ <c:when test="${current.moderate > 0}">
+ <a
href="/rhn/systems/details/ErrataList.do?sid=${current.id}&type=${rhn:localize('errata.create.securityadvisory.mod')}">${current.moderate}</a>
+ </c:when>
+ <c:otherwise>
${current.moderate}
+ </c:otherwise>
+ </c:choose>
<c:choose>
- <c:when test="${current.moderate >=
15}">
- </font>
- </c:when>
+ <c:when test="${current.moderate >=
20}">
+ <img height="10%" width="10%"
src="/img/icon_crit_update.gif"/>
+ </c:when>
+ <c:when test="${current.moderate >=
15}">
+ <img height="10%" width="10%"
src="/img/rhn-icon-warning.gif"/>
+ </c:when>
</c:choose>
</rl:column>
<!-- Low Errata Column -->
@@ -118,18 +124,20 @@
sortattr="created"
defaultsort="desc">
<c:choose>
- <c:when test="${current.low >= 25}">
- <font color="red">
- </c:when>
- <c:when test="${current.low >= 20}">
- <font color="orange">
- </c:when>
+ <c:when test="${current.low > 0}">
+ <a
href="/rhn/systems/details/ErrataList.do?sid=${current.id}&type=${rhn:localize('errata.create.securityadvisory.low')}">${current.low}</a>
+ </c:when>
+ <c:otherwise>
+ ${current.low}
+ </c:otherwise>
</c:choose>
- ${current.low}
<c:choose>
- <c:when test="${current.low >= 20}">
- </font>
- </c:when>
+ <c:when test="${current.low >= 25}">
+ <img height="10%" width="10%"
src="/img/icon_crit_update.gif"/>
+ </c:when>
+ <c:when test="${current.low >= 20}">
+ <img height="10%" width="10%"
src="/img/rhn-icon-warning.gif"/>
+ </c:when>
</c:choose>
</rl:column>
<!-- Bugfix Errata Column -->
@@ -138,7 +146,14 @@
headerkey="systemcurrency.jsp.bug"
sortattr="created"
defaultsort="desc">
- ${current.bug}
+ <c:choose>
+ <c:when test="${current.bug > 0}">
+ <a
href="/rhn/systems/details/ErrataList.do?sid=${current.id}&type=${rhn:localize('errata.create.bugfixadvisory')}">${current.bug}</a>
+ </c:when>
+ <c:otherwise>
+ ${current.bug}
+ </c:otherwise>
+ </c:choose>
</rl:column>
<!-- Enhancement Errata Column -->
<rl:column sortable="true"
@@ -146,7 +161,14 @@
headerkey="systemcurrency.jsp.enhancement"
sortattr="created"
defaultsort="desc">
- ${current.enhancement}
+ <c:choose>
+ <c:when test="${current.enhancement >
0}">
+ <a
href="/rhn/systems/details/ErrataList.do?sid=${current.id}&type=${rhn:localize('errata.create.productenhancementadvisory')}">${current.enhancement}</a>
+ </c:when>
+ <c:otherwise>
+ ${current.enhancement}
+ </c:otherwise>
+ </c:choose>
</rl:column>
<!-- Score Column -->
<rl:column sortable="true"