java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSetupAction.java
| 95 ++++-
java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSubmitAction.java
| 177 ----------
java/code/src/com/redhat/rhn/frontend/action/kickstart/test/KickstartPackageProfileActionTest.java
| 4
java/code/src/com/redhat/rhn/frontend/taglibs/list/RadioColumnTag.java
| 19 +
java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
| 5
java/code/webapp/WEB-INF/pages/kickstart/packageprofiles.jsp
| 51 +-
java/code/webapp/WEB-INF/struts-config.xml
| 15
7 files changed, 127 insertions(+), 239 deletions(-)
New commits:
commit b99361d53f3a3ef256cf4f3be9360bdd08d57409
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Jun 30 17:33:00 2009 -0400
508966 - fixed issue where could not set package profile for a kickstart, rewrote to
new list tag
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSetupAction.java
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSetupAction.java
index cbaf6f3..bcf5302 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSetupAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSetupAction.java
@@ -14,53 +14,104 @@
*/
package com.redhat.rhn.frontend.action.kickstart;
-import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.domain.kickstart.KickstartData;
import com.redhat.rhn.domain.kickstart.KickstartFactory;
-import com.redhat.rhn.frontend.listview.PageControl;
+import com.redhat.rhn.domain.rhnpackage.profile.Profile;
import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.taglibs.list.ListTagHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.profile.ProfileManager;
-import com.redhat.rhn.manager.rhnset.RhnSetDecl;
-import java.util.Iterator;
-import java.util.LinkedList;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
/**
* KickstartPackageProfilesEditAction - setup for listing the profiles available
* for selection.
* @version $Rev: 1 $
*/
-public class KickstartPackageProfileSetupAction extends BaseKickstartListSetupAction {
+public class KickstartPackageProfileSetupAction extends RhnAction implements Listable {
+
+
+ public static final String UPDATE_METHOD =
"kickstart.packageprofile.jsp.submit";
+ public static final String CLEAR_METHOD =
"kickstart.packageprofile.jsp.clear";
/**
+ *
* {@inheritDoc}
*/
- protected Iterator getCurrentItemsIterator(KickstartData ksdata) {
- List l = new LinkedList();
- if (ksdata.getKickstartDefaults().getProfile() != null) {
- l.add(ksdata.getKickstartDefaults().getProfile());
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+
+ RequestContext context = new RequestContext(request);
+
+
+
+ KickstartData ks = KickstartFactory.lookupKickstartDataByIdAndOrg(
+ context.getCurrentUser().getOrg(),
context.getRequiredParam("ksid"));
+
+
+ ListHelper helper = new ListHelper(this, request);
+ helper.execute();
+
+ if (context.wasDispatched("kickstart.packageprofile.jsp.submit")) {
+ String selected = ListTagHelper.getRadioSelection(helper.getListName(),
+ request);
+ if (StringUtils.isNumeric(selected)) {
+ Profile prof = ProfileManager.lookupByIdAndOrg(new Long(selected),
+ context.getCurrentUser().getOrg());
+ ks.getKickstartDefaults().setProfile(prof);
+
+ Map params = new HashMap();
+ params.put("ksid", ks.getId());
+ getStrutsDelegate().saveMessage(UPDATE_METHOD, request);
+ return
getStrutsDelegate().forwardParams(mapping.findForward("success"),
+ params);
+ }
}
- return l.iterator();
- }
+ else if (context.wasDispatched("kickstart.packageprofile.jsp.clear"))
{
+ ks.getKickstartDefaults().setProfile(null);
+ KickstartFactory.saveKickstartData(ks);
+ request.setAttribute("ksid", ks.getId());
+ Map params = new HashMap();
+ params.put("ksid", ks.getId());
+ getStrutsDelegate().saveMessage(CLEAR_METHOD, request);
+ return
getStrutsDelegate().forwardParams(mapping.findForward("success"),
+ params);
- /**
- * {@inheritDoc}
- */
- public RhnSetDecl getSetDecl() {
- return RhnSetDecl.PACKAGE_PROFILES;
+ }
+ if (ks.getKickstartDefaults().getProfile() != null) {
+ ListTagHelper.selectRadioValue(helper.getListName(),
+ ks.getKickstartDefaults().getProfile().getId().toString(), request);
+ }
+ return mapping.findForward("default");
}
/**
+ *
* {@inheritDoc}
*/
- protected DataResult getDataResult(RequestContext rctx, PageControl pc) {
+ public List getResult(RequestContext rctx) {
KickstartData ksdata = KickstartFactory
- .lookupKickstartDataByIdAndOrg(rctx.getCurrentUser().getOrg(),
- rctx.getRequiredParam(RequestContext.KICKSTART_ID));
+ .lookupKickstartDataByIdAndOrg(rctx.getCurrentUser().getOrg(),
+ rctx.getRequiredParam(RequestContext.KICKSTART_ID));
return ProfileManager.compatibleWithChannel(
- ksdata.getKickstartDefaults().getKstree().getChannel(),
- rctx.getCurrentUser().getOrg(), pc);
+ ksdata.getKickstartDefaults().getKstree().getChannel(),
+ rctx.getCurrentUser().getOrg(), null);
}
+
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSubmitAction.java
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSubmitAction.java
deleted file mode 100644
index df9dc12..0000000
---
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartPackageProfileSubmitAction.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * Copyright (c) 2009 Red Hat, Inc.
- *
- * This software is licensed to you under the GNU General Public License,
- * version 2 (GPLv2). There is NO WARRANTY for this software, express or
- * implied, including the implied warranties of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
- * along with this software; if not, see
- *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * Red Hat trademarks are not licensed under GPLv2. No permission is
- * granted to use or replicate Red Hat trademarks that are incorporated
- * in this software or its documentation.
- */
-package com.redhat.rhn.frontend.action.kickstart;
-
-import com.redhat.rhn.common.db.datasource.DataResult;
-import com.redhat.rhn.domain.kickstart.KickstartData;
-import com.redhat.rhn.domain.kickstart.KickstartFactory;
-import com.redhat.rhn.domain.rhnpackage.profile.Profile;
-import com.redhat.rhn.domain.rhnpackage.profile.ProfileFactory;
-import com.redhat.rhn.domain.rhnset.RhnSet;
-import com.redhat.rhn.domain.rhnset.RhnSetElement;
-import com.redhat.rhn.domain.user.User;
-import com.redhat.rhn.frontend.struts.RequestContext;
-import com.redhat.rhn.manager.kickstart.KickstartPackageProfileCommand;
-import com.redhat.rhn.manager.profile.ProfileManager;
-import com.redhat.rhn.manager.rhnset.RhnSetDecl;
-import com.redhat.rhn.manager.rhnset.RhnSetManager;
-
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * KickstartPackageProfileSubmitAction
- * @version $Rev$
- */
-public class KickstartPackageProfileSubmitAction extends
- BaseKickstartListSubmitAction {
-
- public static final String UPDATE_METHOD =
"kickstart.packageprofile.jsp.submit";
- public static final String CLEAR_METHOD =
"kickstart.packageprofile.jsp.clear";
-
- /**
- * {@inheritDoc}
- */
- protected void operateOnRemovedElements(List elements,
- HttpServletRequest request) {
-
- if (elements.size() > 0) {
- RequestContext rctx = new RequestContext(request);
- KickstartPackageProfileCommand cmd = new
- KickstartPackageProfileCommand(
- rctx.getRequiredParam(RequestContext.KICKSTART_ID),
- rctx.getCurrentUser());
- cmd.setProfile(null);
- cmd.store();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void operateOnAddedElements(List elements,
- HttpServletRequest request) {
-
- RequestContext rctx = new RequestContext(request);
- KickstartPackageProfileCommand cmd = new
- KickstartPackageProfileCommand(
- rctx.getRequiredParam(RequestContext.KICKSTART_ID),
- rctx.getCurrentUser());
- Long pid = null;
- if (elements.size() > 0) {
- pid = ((RhnSetElement) elements.get(0)).getElement();
- Profile p = ProfileFactory.lookupByIdAndOrg(pid,
- rctx.getCurrentUser().getOrg());
- cmd.setProfile(p);
- cmd.store();
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- public RhnSetDecl getSetDecl() {
- return RhnSetDecl.PACKAGE_PROFILES;
- }
-
- /**
- * {@inheritDoc}
- */
- protected DataResult getDataResult(User user,
- ActionForm formIn,
- HttpServletRequest request) {
-
- RequestContext rctx = new RequestContext(request);
- KickstartData ksdata = KickstartFactory
- .lookupKickstartDataByIdAndOrg(rctx.getCurrentUser().getOrg(),
- rctx.getRequiredParam(RequestContext.KICKSTART_ID));
-
- DataResult dr = ProfileManager.compatibleWithChannel(
- ksdata.getKickstartDefaults().getKstree().getChannel(),
- rctx.getCurrentUser().getOrg(), null);
- return dr;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void processMethodKeys(Map map) {
- map.put(UPDATE_METHOD, "operateOnDiff");
- map.put(CLEAR_METHOD, "clearSelection");
- }
-
- protected Iterator getCurrentItemsIterator(RequestContext ctx) {
- KickstartData ksdata = KickstartFactory
- .lookupKickstartDataByIdAndOrg(ctx.getCurrentUser().getOrg(),
- ctx.getRequiredParam(RequestContext.KICKSTART_ID));
-
- List l = new LinkedList();
- if (ksdata.getKickstartDefaults().getProfile() != null) {
- l.add(ksdata.getKickstartDefaults().getProfile());
- }
- return l.iterator();
-
- }
-
- /**
- * This is executed if the clear button is pushed. Clears all associated package
- * profiles from from the selected kickstart
- *
- * @param mapping The ActionMapping used to select this instance
- * @param formIn The optional ActionForm bean for this request (if any)
- * @param request The HTTP request we are processing
- * @param response The HTTP response we are creating
- * @return Describes where and how control should be forwarded.
- */
- public ActionForward clearSelection(ActionMapping mapping,
- ActionForm formIn,
- HttpServletRequest request,
- HttpServletResponse response) {
-
- RequestContext rctx = new RequestContext(request);
- KickstartPackageProfileCommand cmd = new
- KickstartPackageProfileCommand(
- rctx.getRequiredParam(RequestContext.KICKSTART_ID),
- rctx.getCurrentUser());
- cmd.setProfile(null);
- cmd.store();
-
- ArrayList added = new ArrayList();
- ArrayList removed = new ArrayList();
-
- RhnSet currentSet = updateSet(request);
- for (Iterator it = currentSet.getElements().iterator(); it.hasNext();) {
- removed.add(it.next());
- }
- currentSet.clear();
- RhnSetManager.store(currentSet);
-
- generateUserMessage(added, removed, request);
- Map params = makeParamMap(formIn, request);
- return
getStrutsDelegate().forwardParams(mapping.findForward("default"), params);
- }
-
-}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/test/KickstartPackageProfileActionTest.java
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/test/KickstartPackageProfileActionTest.java
index bd2bd4f..2d8d53a 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/test/KickstartPackageProfileActionTest.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/test/KickstartPackageProfileActionTest.java
@@ -19,7 +19,7 @@ import com.redhat.rhn.domain.kickstart.KickstartFactory;
import com.redhat.rhn.domain.kickstart.test.KickstartDataTest;
import com.redhat.rhn.domain.rhnpackage.profile.Profile;
import com.redhat.rhn.domain.role.RoleFactory;
-import com.redhat.rhn.frontend.action.kickstart.KickstartPackageProfileSubmitAction;
+import com.redhat.rhn.frontend.action.kickstart.KickstartPackageProfileSetupAction;
import com.redhat.rhn.frontend.dto.ProfileDto;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.manager.profile.test.ProfileManagerTest;
@@ -61,7 +61,7 @@ public class KickstartPackageProfileActionTest extends
RhnMockStrutsTestCase {
user.addRole(RoleFactory.ORG_ADMIN);
Profile p = ProfileManagerTest.createProfileWithServer(user);
addSelectedItem(p.getId());
- addDispatchCall(KickstartPackageProfileSubmitAction.UPDATE_METHOD);
+ addDispatchCall(KickstartPackageProfileSetupAction.UPDATE_METHOD);
setRequestPathInfo("/kickstart/KickstartPackageProfileEditSubmit");
actionPerform();
// Gotta make sure we can update the profile to the same entry twice
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/RadioColumnTag.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/RadioColumnTag.java
index 8f63ec0..64a3f51 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/RadioColumnTag.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/RadioColumnTag.java
@@ -45,6 +45,7 @@ public class RadioColumnTag extends TagSupport {
private String valueExpr;
private String headerStyle;
private String headerKey;
+ private boolean useDefault = true;
/**
* Sets the column width
@@ -135,7 +136,7 @@ public class RadioColumnTag extends TagSupport {
radio.setAttribute("type", "radio");
radio.setAttribute("name", getRadioName(listName));
radio.setAttribute("value", value);
- if (StringUtils.isBlank(getRadioValue())) {
+ if (StringUtils.isBlank(getRadioValue()) && useDefault) {
pageContext.getRequest().setAttribute(getRadioName(listName), value);
}
if (isSelected()) {
@@ -229,4 +230,20 @@ public class RadioColumnTag extends TagSupport {
width = "20px";
headerStyle = null;
}
+
+
+ /**
+ * @return Returns the setDefault.
+ */
+ public boolean isUseDefault() {
+ return useDefault;
+ }
+
+
+ /**
+ * @param setDefaultIn The setDefault to set.
+ */
+ public void setUseDefault(boolean setDefaultIn) {
+ this.useDefault = setDefaultIn;
+ }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
b/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
index 95e8598..2450ad1 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
@@ -242,6 +242,11 @@
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
+ <attribute>
+ <name>useDefault</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
</tag>
<tag>
<name>csv</name>
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/packageprofiles.jsp
b/java/code/webapp/WEB-INF/pages/kickstart/packageprofiles.jsp
index 42fc4fb..f9652fe 100644
--- a/java/code/webapp/WEB-INF/pages/kickstart/packageprofiles.jsp
+++ b/java/code/webapp/WEB-INF/pages/kickstart/packageprofiles.jsp
@@ -2,6 +2,8 @@
<%@ taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn" %>
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean" %>
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-html"
prefix="html" %>
+<%@ taglib
uri="http://rhn.redhat.com/tags/list" prefix="rl"
%>
+
<html:html xhtml="true">
<body>
@@ -19,34 +21,31 @@
</p>
<c:set var="pageList" value="${requestScope.pageList}" />
- <form method="post" name="rhn_list"
action="/rhn/kickstart/KickstartPackageProfileEditSubmit.do">
- <rhn:submitted />
- <rhn:list pageList="${pageList}"
noDataText="kickstart.packageprofiles.jsp.noprofiles">
-
- <rhn:listdisplay set="${requestScope.set}"
hiddenvars="${requestScope.newset}">
- <rhn:set type="radio" value="${current.id}"
buttons="false"/>
+<rl:listset name="profiles" >
+ <rl:list emptykey="kickstart.packageprofiles.jsp.noprofiles">
+ <rl:decorator name = "PageSizeDecorator"/>
+ <rl:radiocolumn value="${current.id}" styleclass="first-column"
useDefault='false'/>
- <rhn:column header="kickstart.packageprofiles.jsp.description">
+ <rl:column headerkey="kickstart.packageprofiles.jsp.description"
filterattr="name">
${current.name}
- </rhn:column>
- </rhn:listdisplay>
- </rhn:list>
-<p>
-<bean:message key="kickstart.packageprofiles.jsp.tip"
arg0="${ksdata.id}"/>
-</p>
-<hr />
-<input type="hidden" name="ksid" value="<c:out
value="${param.ksid}"/>" />
-<div align="right">
- <html:submit property="dispatch">
- <bean:message key="kickstart.packageprofile.jsp.clear"/>
- </html:submit>
- <html:submit property="dispatch">
- <bean:message key="kickstart.packageprofile.jsp.submit"/>
- </html:submit>
-
-</div>
-
- </form>
+ </rl:column>
+ </rl:list>
+ <p>
+ <bean:message key="kickstart.packageprofiles.jsp.tip"
arg0="${ksdata.id}"/>
+ </p>
+ <hr />
+ <input type="hidden" name="ksid" value="<c:out
value="${param.ksid}"/>" />
+ <div align="right">
+ <html:submit property="dispatch">
+ <bean:message key="kickstart.packageprofile.jsp.clear"/>
+ </html:submit>
+ <html:submit property="dispatch">
+ <bean:message key="kickstart.packageprofile.jsp.submit"/>
+ </html:submit>
+
+ </div>
+ <rhn:submitted />
+ </rl:listset>
</div>
</body>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 5bd6f16..6baa745 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -5160,17 +5160,10 @@
scope="request"
input="/WEB-INF/pages/kickstart/packageprofiles.jsp"
type="com.redhat.rhn.frontend.action.kickstart.KickstartPackageProfileSetupAction">
- <forward name="default"
- path="/WEB-INF/pages/kickstart/packageprofiles.jsp"/>
- </action>
-
- <action path="/kickstart/KickstartPackageProfileEditSubmit"
- scope="request"
- input="/WEB-INF/pages/kickstart/packageprofiles.jsp"
-
type="com.redhat.rhn.frontend.action.kickstart.KickstartPackageProfileSubmitAction"
- parameter="dispatch">
- <forward name="default"
- path="/kickstart/KickstartPackageProfileEdit.do"/>
+ <forward name="default"
+ path="/WEB-INF/pages/kickstart/packageprofiles.jsp" />
+ <forward name="success"
+ path="/kickstart/KickstartPackageProfileEdit.do"
redirect="true"/>
</action>
<action path="/kickstart/DownloadLog"