java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java | 48 ++++++
java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java | 12 +
java/code/src/com/redhat/rhn/domain/errata/impl/PublishedErrata.hbm.xml | 5
java/code/src/com/redhat/rhn/domain/server/ServerFactory.java | 33 ----
java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java | 73 ++++------
java/code/src/com/redhat/rhn/manager/system/SystemManager.java | 4
java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp | 8 -
scripts/channel-to-update-level/create-channel-update | 2
8 files changed, 112 insertions(+), 73 deletions(-)
New commits:
commit 2e303d0f35bd3dd2b6b7551f79a5bade8ce87e3c
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Nov 30 13:40:40 2009 -0500
converting old hibernate max in clause limit fix to use new fix
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
index 2e5b87f..efbe49b 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -29,8 +29,6 @@ import com.redhat.rhn.frontend.xmlrpc.ChannelSubscriptionException;
import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.system.UpdateBaseChannelCommand;
-import java.util.LinkedList;
-
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.hibernate.Query;
@@ -39,10 +37,10 @@ import org.hibernate.Session;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -748,30 +746,8 @@ public class ServerFactory extends HibernateFactory {
* @return list of system ids that are solaris systems
*/
public static List<Long> listSolarisSystems(Collection<Long> systemIds) {
- return listGenericSystems(systemIds, "Server.listSolarisSystems");
- }
-
-
-
- private static List<Long> listGenericSystems(Collection<Long> systemIds, String query) {
- //Hibernate can't handle empty lists for in clauses, silly hibernate
- if (systemIds.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
- ArrayList<Long> tmpList = new ArrayList<Long>();
- List<Long> toRet = new ArrayList<Long>();
- tmpList.addAll(systemIds);
-
- for (int i = 0; i < systemIds.size();) {
- int initial = i;
- int fin = i + 500 < systemIds.size() ? i + 500 : systemIds.size();
- List<Long> sublist = tmpList.subList(i, fin);
- toRet.addAll(ServerFactory.getSession().getNamedQuery(query).
- setParameterList("sids", sublist).list());
- i = fin;
- }
-
- return toRet;
+ return singleton.listObjectsByNamedQuery("Server.listSolarisSystems",
+ new HashMap(), systemIds, "sids");
}
/**
@@ -781,7 +757,8 @@ public class ServerFactory extends HibernateFactory {
* @return list of system ids that are linux systems
*/
public static List<Long> listLinuxSystems(Collection<Long> systemIds) {
- return listGenericSystems(systemIds, "Server.listRedHatSystems");
+ return singleton.listObjectsByNamedQuery("Server.listRedHatSystems",
+ new HashMap(), systemIds, "sids");
}
}
commit 9f4dbe3d7e6224218a2cbfe5895fec100840c5e7
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Nov 30 13:40:01 2009 -0500
538559 - fixing issue where about 300 errata could not be applied to a system due to inefficient hibernate usage
diff --git a/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java b/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java
index 71dd50d..4a9b190 100644
--- a/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java
+++ b/java/code/src/com/redhat/rhn/common/hibernate/HibernateFactory.java
@@ -36,6 +36,9 @@ import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.sql.Blob;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -117,8 +120,12 @@ public abstract class HibernateFactory {
Set entrySet = parameters.entrySet();
for (Iterator itr = entrySet.iterator(); itr.hasNext();) {
Map.Entry entry = (Map.Entry) itr.next();
- if (entry.getValue() instanceof List) {
- query.setParameterList((String) entry.getKey(), (List) entry.getValue());
+ if (entry.getValue() instanceof Collection) {
+ Collection c = (Collection) entry.getValue();
+ if (c.size() > 100) {
+ LOG.error("Query exectued with Collection larger than 1000");
+ }
+ query.setParameterList((String) entry.getKey(), c);
}
else {
query.setParameter((String) entry.getKey(), entry.getValue());
@@ -196,6 +203,43 @@ public abstract class HibernateFactory {
* @param qryName Named query to use to find a list of objects.
* @param qryParams Map of named bind parameters whose keys are Strings. The
* map can also be null.
+ * @param col the collection to use as an inclause
+ * @param colLabel the label the collection will have
+ * @return List of objects returned by named query, or null if nothing
+ * found.
+ */
+ protected List listObjectsByNamedQuery(String qryName, Map qryParams,
+ Collection col, String colLabel) {
+
+ if (col.isEmpty()) {
+ return Collections.EMPTY_LIST;
+ }
+
+ ArrayList<Long> tmpList = new ArrayList<Long>();
+ List<Long> toRet = new ArrayList<Long>();
+ tmpList.addAll(col);
+
+ for (int i = 0; i < col.size();) {
+ int initial = i;
+ int fin = i + 500 < col.size() ? i + 500 : col.size();
+ List<Long> sublist = tmpList.subList(i, fin);
+
+ qryParams.put(colLabel, sublist);
+ toRet.addAll(listObjectsByNamedQuery(qryName, qryParams, false));
+ i = fin;
+ }
+ return toRet;
+ }
+
+
+
+ /**
+ * Using a named query, find all the objects matching the criteria within.
+ * Warning: This can be very expensive if the returned list is large. Use
+ * only for small tables with static data
+ * @param qryName Named query to use to find a list of objects.
+ * @param qryParams Map of named bind parameters whose keys are Strings. The
+ * map can also be null.
* @param cacheable if we should cache the results of this query
* @return List of objects returned by named query, or null if nothing
* found.
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 08136ff..8482beb 100644
--- a/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
@@ -47,6 +47,7 @@ import org.hibernate.Query;
import org.hibernate.Session;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -1030,5 +1031,16 @@ public class ErrataFactory extends HibernateFactory {
copyDetails(cloned, cloned.getOriginal(), true);
}
+ /**
+ * List errata objects by ID
+ * @param ids list of ids
+ * @return List of Errata Objects
+ */
+ public static List<Errata> listErrata(Collection<Long> ids) {
+ return singleton.listObjectsByNamedQuery("PublishedErrata.listByIds",
+ new HashMap(), ids, "list");
+ }
+
+
}
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 70ccc7a..ddf7c66 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
@@ -89,6 +89,11 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
where e.id = :id]]>
</query>
+ <query name="PublishedErrata.listByIds">
+ <![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
+ where e.id in (:list)]]>
+ </query>
+
<query name="PublishedErrata.findByAdvisoryName">
<![CDATA[from com.redhat.rhn.domain.errata.impl.PublishedErrata as e
where e.advisoryName = :advisory]]>
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java
index 1c31544..4bf16b9 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/ErrataConfirmSetupAction.java
@@ -14,22 +14,20 @@
*/
package com.redhat.rhn.frontend.action.systems;
-import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.common.util.DatePicker;
import com.redhat.rhn.domain.action.Action;
+import com.redhat.rhn.domain.errata.Errata;
+import com.redhat.rhn.domain.errata.ErrataFactory;
import com.redhat.rhn.domain.rhnset.RhnSet;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.user.User;
-import com.redhat.rhn.frontend.dto.ErrataOverview;
-import com.redhat.rhn.frontend.listview.PageControl;
import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnHelper;
-import com.redhat.rhn.frontend.struts.RhnListAction;
-import com.redhat.rhn.frontend.struts.RhnListSetHelper;
import com.redhat.rhn.frontend.struts.StrutsDelegate;
-import com.redhat.rhn.frontend.taglibs.list.ListTagHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListRhnSetHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.action.ActionManager;
-import com.redhat.rhn.manager.errata.ErrataManager;
import com.redhat.rhn.manager.system.SystemManager;
import org.apache.struts.action.ActionForm;
@@ -39,8 +37,8 @@ import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
-import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -50,9 +48,8 @@ import javax.servlet.http.HttpServletResponse;
* ErrataConfirmSetupAction
* @version $Rev$
*/
-public class ErrataConfirmSetupAction extends RhnListAction {
- public static final String DISPATCH = "dispatch";
- public static final String LIST_NAME = "errataConfirmList";
+public class ErrataConfirmSetupAction extends RhnAction implements Listable {
+
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
@@ -62,13 +59,18 @@ public class ErrataConfirmSetupAction extends RhnListAction {
RequestContext requestContext = new RequestContext(request);
User user = requestContext.getLoggedInUser();
- RhnListSetHelper helper = new RhnListSetHelper(request);
+
+
Long sid = requestContext.getRequiredParam("sid");
RhnSet set = ErrataSetupAction.getSetDecl(sid).get(user);
+ Server server = SystemManager.lookupByIdAndUser(sid, user);
+
+ ListRhnSetHelper helper = new ListRhnSetHelper(this, request,
+ ErrataSetupAction.getSetDecl(sid));
+ helper.setWillClearSet(false);
+ helper.execute();
- if (request.getParameter(DISPATCH) != null) {
- // if its one of the Dispatch actions handle it..
- helper.updateSet(set, LIST_NAME);
+ if (helper.isDispatched()) {
if (!set.isEmpty()) {
return confirmErrata(mapping, formIn, request, response);
}
@@ -76,26 +78,12 @@ public class ErrataConfirmSetupAction extends RhnListAction {
RhnHelper.handleEmptySelection(request);
}
}
-
-
-
- PageControl pc = new PageControl();
- clampListBounds(pc, request, user);
- pc.setPageSize(set.size());
-
- Server server = SystemManager.lookupByIdAndUser(sid, user);
- DataResult dr = SystemManager.errataInSet(user,
- ErrataSetupAction.getSetDecl(sid).getLabel(), pc);
- dr.setElaborationParams(Collections.EMPTY_MAP);
//Setup the datepicker widget
DatePicker picker = getStrutsDelegate().prepopulateDatePicker(request,
(DynaActionForm)formIn, "date", DatePicker.YEAR_RANGE_POSITIVE);
request.setAttribute("date", picker);
-
- request.setAttribute("pageList", dr);
request.setAttribute("system", server);
- request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI());
return getStrutsDelegate().forwardParams(mapping.findForward("default"),
request.getParameterMap());
@@ -125,15 +113,13 @@ public class ErrataConfirmSetupAction extends RhnListAction {
Map hparams = new HashMap();
Server server = SystemManager.lookupByIdAndUser(sid, user);
- DataResult errata = SystemManager.errataInSet(user,
- ErrataSetupAction.getSetDecl(sid) .getLabel(), null);
+ RhnSet set = ErrataSetupAction.getSetDecl(sid).get(user);
+ List<Errata> errataList = ErrataFactory.listErrata(set.getElementValues());
- if (server != null && !errata.isEmpty()) {
- for (int i = 0; i < errata.size(); i++) {
- Action update = ActionManager.createErrataAction(user, ErrataManager
- .lookupErrata(new Long(((ErrataOverview)errata.get(i))
- .getId().longValue()), user));
+ if (server != null && !errataList.isEmpty()) {
+ for (Errata e : errataList) {
+ Action update = ActionManager.createErrataAction(user, e);
ActionManager.addServerToAction(server.getId(), update);
update.setEarliestAction(getStrutsDelegate().readDatePicker(form, "date",
DatePicker.YEAR_RANGE_POSITIVE));
@@ -142,12 +128,12 @@ public class ErrataConfirmSetupAction extends RhnListAction {
ActionMessages msg = new ActionMessages();
Object[] args = new Object[3];
- args[0] = new Long(errata.size());
+ args[0] = new Long(errataList.size());
args[1] = server.getName();
args[2] = server.getId().toString();
StringBuffer messageKey = new StringBuffer("errata.schedule");
- if (errata.size() != 1) {
+ if (errataList.size() != 1) {
messageKey = messageKey.append(".plural");
}
@@ -185,5 +171,16 @@ public class ErrataConfirmSetupAction extends RhnListAction {
}
return params;
}
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext context) {
+ Long sid = context.getParamAsLong("sid");
+ return SystemManager.errataInSet(context.getLoggedInUser(),
+ ErrataSetupAction.getSetDecl(sid).getLabel(), null);
+ }
}
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 6e1221c..8f2bc99 100644
--- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
@@ -849,7 +849,9 @@ public class SystemManager extends BaseManager {
Map elabParams = new HashMap();
elabParams.put("user_id", user.getId());
- return makeDataResult(params, elabParams, pc, m);
+ DataResult dr = m.execute(params);
+ dr.setElaborationParams(elabParams);
+ return dr;
}
/**
diff --git a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
index 91742b4..f6348c7 100644
--- a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
@@ -19,13 +19,13 @@
<rl:listset name="erratConfirmListSet">
- <rl:list dataset="pageList"
+ <rl:list
width="100%"
- name="errataConfirmList"
styleclass="list"
emptykey="erratalist.jsp.noerrata">
<rl:decorator name="PageSizeDecorator"/>
+ <rl:decorator name="ElaborationDecorator"/>
<rl:column headerkey="erratalist.jsp.type" styleclass="first-column text-align: center;">
<c:if test="${current.securityAdvisory}">
commit 2fcc1109fa8d197f8820f6155f722b0381518b78
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Nov 24 18:57:11 2009 -0500
fixing list borders on errata apply confirm page
diff --git a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
index 162a0aa..91742b4 100644
--- a/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/errataconfirm.jsp
@@ -27,7 +27,7 @@
<rl:decorator name="PageSizeDecorator"/>
- <rl:column headerkey="erratalist.jsp.type" styleclass="text-align: center;">
+ <rl:column headerkey="erratalist.jsp.type" styleclass="first-column text-align: center;">
<c:if test="${current.securityAdvisory}">
<img src="/img/wrh-security.gif"
title="<bean:message key="erratalist.jsp.securityadvisory"/>" />
@@ -51,7 +51,7 @@
${current.advisorySynopsis}
</rl:column>
- <rl:column headerkey="erratalist.jsp.updated">
+ <rl:column headerkey="erratalist.jsp.updated" styleclass="last-column">
${current.updateDate}
</rl:column>
</rl:list>
commit 9e170616b0d7da97f5a29313cd8298e24ed41a0d
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Nov 24 18:52:01 2009 -0500
fixing cluster-storage src channel search
diff --git a/scripts/channel-to-update-level/create-channel-update b/scripts/channel-to-update-level/create-channel-update
index 9c16ca1..a64c1ca 100755
--- a/scripts/channel-to-update-level/create-channel-update
+++ b/scripts/channel-to-update-level/create-channel-update
@@ -343,6 +343,8 @@ def findSrcChan(version, release, arch, extra = None):
return "rhel-%s-%s-%s" % (arch, low_release, version)
else: #else we do, so lets process that
low_extra = extra.lower()
+ if low_extra == "clusterstorage":
+ low_extra = "cluster-storage"
if low_extra == "extra":
return "rhel-%s-%s-%s-%s" % (arch, low_release, version, low_extra)
else: