client/rhel/rhn-client-tools/src/firstboot-legacy-rhel5/rhn_login_gui.py |
17
client/rhel/rhn-client-tools/src/firstboot/rhn_create_profile_gui.py |
23
client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py |
35 -
client/rhel/rhn-client-tools/src/up2date_client/rhncli.py |
6
client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py |
1
client/rhel/rhnlib/rhn/transports.py |
4
java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml |
36 +
java/code/src/com/redhat/rhn/common/db/datasource/xml/file-list.xml |
1
java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_queries.xml |
61 --
java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChannelActionDAO.java |
98 ++-
java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChildChannelConfirmAction.java |
69 +-
java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java |
6
java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsEvent.java |
9
java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java |
72 ++
java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java |
282 ++--------
java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp |
12
16 files changed, 368 insertions(+), 364 deletions(-)
New commits:
commit 6eff470a3f6b11c78afc571dcbd673d9607d612f
Merge: 9aeefbb... 3a2d03f...
Author: Partha Aji <paji(a)redhat.com>
Date: Wed May 26 14:59:32 2010 -0400
Fixed merge conflicts
diff --cc java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index 02001dd,72bb0a2..b6835ec
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@@ -2831,6 -2832,79 +2832,77 @@@ public class ChannelManager extends Bas
Collections.sort(possibleList);
return logPath + possibleList.get(possibleList.size() - 1);
}
-
+
-
+ /**
+ * Takes a list of child channels and a set label and returns a Map
+ * with system ids as the key and a set ChannelActionDAO's
+ * as the value
+ * @param setLabel the set label of System ids
+ * @param subChans the list of channels to subscribe
+ * @param unsubChans the list of channels to unsubscribe
+ * @param user the user doing the work
+ * @return The aformentioned map
+ */
+ public static Map<Long, ChannelActionDAO> filterChildSubscriptions(
+ String setLabel, List<Channel> subChans, List<Channel>
unsubChans, User user) {
+ Map<Long, ChannelActionDAO> toRet = new HashMap<Long,
ChannelActionDAO>();
+
+ List subCids = new ArrayList();
+ for (Channel c : subChans) {
+ subCids.add(c.getId());
+ }
+ List unsubCids = new ArrayList();
+ for (Channel c : unsubChans) {
+ unsubCids.add(c.getId());
+ }
+
+ Map params = new HashMap();
+ params.put("uid", user.getId());
+ params.put("set_label", setLabel);
+
+ SelectMode m = null;
+ List<Map> subDr = Collections.EMPTY_LIST;
+ List<Map> unsubDr = Collections.EMPTY_LIST;
+ if (!subChans.isEmpty()) {
+ m = ModeFactory.getMode("Channel_queries",
+ "ssm_systems_for_child_subscription");
+ subDr = m.execute(params, subCids);
+ }
+ if (!unsubChans.isEmpty()) {
+ m = ModeFactory.getMode("Channel_queries",
+ "ssm_systems_for_child_unsubscription");
+ unsubDr = m.execute(params, unsubCids);
+ }
+
+
+ for (Map row : subDr) {
+ Long id = (Long) row.get("id");
+ ChannelActionDAO sys = toRet.get(id);
+ if (sys == null) {
+ sys = new ChannelActionDAO();
+ sys.setId(id);
+ sys.setName((String) row.get("name"));
+ toRet.put(id, sys);
+ }
+ sys.addSubscribeChannelId((Long) row.get("channel_id"));
+ sys.addSubscribeName((String) row.get("channel_name"));
+ }
+
+ for (Map row : unsubDr) {
+ Long id = (Long) row.get("id");
+ ChannelActionDAO sys = toRet.get(id);
+ if (sys == null) {
+ sys = new ChannelActionDAO();
+ sys.setId(id);
+ sys.setName((String) row.get("name"));
+ toRet.put(id, sys);
+ }
+ sys.addUnsubscribeChannelId((Long) row.get("channel_id"));
+ sys.addUnsubcribeName((String) row.get("channel_name"));
+ }
+
+ return toRet;
+ }
}
commit 3a2d03ff88a968f553e204588c39241ed1803d05
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed May 26 12:25:22 2010 +0200
595688 - cancel busy cursor after ValidationError
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
b/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
index d031193..3722ffb 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
@@ -477,6 +477,7 @@ class LoginPage:
self.alreadyRegistered = rhnreg.reserveUser(self.loginUname.get_text(),
self.loginPw.get_text())
except up2dateErrors.ValidationError, e:
+ setArrowCursor()
self.alreadyRegistered = 0
log.log_me("An exception was raised causing login to fail. This is
"
"usually correct. Exception information:")
commit 94a5ae16d12e126fc26d6646c06400c9de6a9ec6
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed May 26 11:38:38 2010 +0200
595837 - write nice error in case of "connection reset by peer" and xmlrpc
protocol error
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py
b/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py
index 0423274..186fedb 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py
@@ -91,6 +91,9 @@ class RhnCli(object):
sys.stderr.write(_("A common cause of this error is the system time
being incorrect. " \
"Verify that the time on this system is
correct.\n"))
sys.exit(1)
+ except SSL.SysCallError, socket.error:
+ sys.stderr.write("OpenSSL.SSL.SysCallError: %s\n" % str(e)
+ sys.exit(2))
except crypto.Error, e:
sys.stderr.write(_("There was a SSL crypto error: %s\n") % e)
except SystemExit, e:
@@ -101,6 +104,9 @@ class RhnCli(object):
except up2dateErrors.RpmError, e:
sys.stderr.write("%s\n" % e)
sys.exit(1)
+ except xmlrpclib.ProtocolError, e:
+ sys.stderr.write("XMLRPC ProtocolError: %s\n" % str(e)
+ sys.exit(3))
def initialize(self):
(self.options, self.args) = self.optparser.parse_args()
diff --git a/client/rhel/rhnlib/rhn/transports.py b/client/rhel/rhnlib/rhn/transports.py
index 747b5fc..3e994ea 100644
--- a/client/rhel/rhnlib/rhn/transports.py
+++ b/client/rhel/rhnlib/rhn/transports.py
@@ -164,10 +164,6 @@ class Transport(xmlrpclib.Transport):
for h in ['Content-Length', 'Host']:
req.clear_header(h)
- # XXX: should try-catch ProtocolError here. But I am not sure
- # what to do with it if I get it, so for now letting it slip
- # through to the next level is sortof working.
- # Must be fixed before ship, though. --gafton
headers, fd = req.send_http(host, handler)
if self.verbose:
commit 8e0e02493d79a4ce0a34e905ea788d12758412b3
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Wed May 26 09:40:59 2010 +0200
585188 - we need to implement fatalError for loginPageApply and
createProfilePageApply.
Otherwise the exceptions will not be shown properly.
For now, let's just have the same code there twice, in rhn_login_gui
and rhn_create_profile_gui.
diff --git a/client/rhel/rhn-client-tools/src/firstboot/rhn_create_profile_gui.py
b/client/rhel/rhn-client-tools/src/firstboot/rhn_create_profile_gui.py
index 13d974d..55420bb 100644
--- a/client/rhel/rhn-client-tools/src/firstboot/rhn_create_profile_gui.py
+++ b/client/rhel/rhn-client-tools/src/firstboot/rhn_create_profile_gui.py
@@ -22,6 +22,7 @@ import sys
sys.path.append("/usr/share/rhn")
from up2date_client import rhnreg
from up2date_client import rhnregGui
+from up2date_client import messageWindow
import gtk
from gtk import glade
@@ -53,13 +54,16 @@ class moduleClass(Module):
return RESULT_FAILURE
ret = self.createProfilePage.createProfilePageApply()
+ if self.createProfilePage.go_to_finish:
+ interface.moveToPage(moduleTitle=_("Finish Updates Setup"))
+ return RESULT_JUMP
if ret:
return RESULT_FAILURE
return RESULT_SUCCESS
def createScreen(self):
- self.createProfilePage = rhnregGui.CreateProfilePage()
+ self.createProfilePage = FirstbootCreateProfilePage()
self.vbox = gtk.VBox(spacing=5)
self.vbox.pack_start(self.createProfilePage.createProfilePageVbox(), True, True)
@@ -71,3 +75,20 @@ class moduleClass(Module):
return False
return True
+class FirstbootCreateProfilePage(rhnregGui.CreateProfilePage):
+ def __init__(self):
+ rhnregGui.CreateProfilePage.__init__(self)
+
+ def createProfilePageApply(self):
+ self.go_to_finish = False
+ return rhnregGui.CreateProfilePage.createProfilePageApply(self)
+
+ def fatalError(self, error, wrap=1):
+ msg = _("There was a communication error with the server:") \
+ + "\n\n" + error + "\n\n" \
+ + _("Would you like to go back and try again?")
+ dlg = messageWindow.YesNoDialog(msg)
+ ret = dlg.getrc()
+ if not ret:
+ self.go_to_finish = True
+
diff --git a/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
b/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
index 9320fc1..5293b12 100644
--- a/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
+++ b/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
@@ -22,6 +22,7 @@ import sys
sys.path.append("/usr/share/rhn")
from up2date_client import rhnreg
from up2date_client import rhnregGui
+from up2date_client import messageWindow
import gtk
from gtk import glade
@@ -51,7 +52,11 @@ class moduleClass(Module):
if self.loginPage.loginPageVerify():
return RESULT_FAILURE
- if self.loginPage.loginPageApply():
+ ret = self.loginPage.loginPageApply()
+ if self.loginPage.go_to_finish:
+ interface.moveToPage(moduleTitle=_("Finish Updates Setup"))
+ return RESULT_JUMP
+ if ret:
return RESULT_FAILURE
# We should try to activate hardware, even if no EUS in firstboot
@@ -79,6 +84,19 @@ class FirstbootLoginPage(rhnregGui.LoginPage):
def __init__(self):
rhnregGui.LoginPage.__init__(self)
+ def loginPageApply(self):
+ self.go_to_finish = False
+ return rhnregGui.LoginPage.loginPageApply(self)
+
+ def fatalError(self, error, wrap=1):
+ msg = _("There was a communication error with the server:") \
+ + "\n\n" + error + "\n\n" \
+ + _("Would you like to go back and try again?")
+ dlg = messageWindow.YesNoDialog(msg)
+ ret = dlg.getrc()
+ if not ret:
+ self.go_to_finish = True
+
def goToPageAfterLogin(self):
pass
commit 3434253a518d62d582e5c9b66716371da487b5b4
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Wed May 26 09:11:02 2010 +0200
Remove except which cannot be reached.
The comment
# TODO this exception can't reach here right now. ditch it and/or
# figure out how we want to provide this functionality.
which we are removing is correct -- the up2dateErrors.CommunicationError
is handled already in _loginPageApply (called from loginPageApply), so
this is a dead code.
diff --git a/client/rhel/rhn-client-tools/src/firstboot-legacy-rhel5/rhn_login_gui.py
b/client/rhel/rhn-client-tools/src/firstboot-legacy-rhel5/rhn_login_gui.py
index 6fea3ab..7bd11b0 100644
--- a/client/rhel/rhn-client-tools/src/firstboot-legacy-rhel5/rhn_login_gui.py
+++ b/client/rhel/rhn-client-tools/src/firstboot-legacy-rhel5/rhn_login_gui.py
@@ -33,8 +33,6 @@ sys.path.insert(1,"/usr/share/rhn")
import rhnreg
import rhnregGui
-import up2dateErrors
-import messageWindow
##
@@ -97,20 +95,7 @@ class RhnLoginWindow(RhnRegisterFirstbootGuiWindow,
rhnregGui.LoginPage):
assert rhnregGui.newAccount is False
- try:
- ret = self.loginPageApply()
- # TODO this exception can't reach here right now. ditch it and/or
- # figure out how we want to provide this functionality.
- except up2dateErrors.CommunicationError, e:
- msg = _("There was a communication error with the server: %s" %
e.errmsg)
- msg = msg + "\n\n" + _("Would you like to try changing the
network configuration and trying again?")
- dlg = messageWindow.YesNoDialog(msg)
- ret = dlg.getrc()
- if ret:
- return None
- else:
- self.parent.setPage("rhn_finish_gui")
- if ret:
+ if self.loginPageApply():
return None
# We should try to activate hardware, even if no EUS in firstboot
diff --git a/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
b/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
index 516156e..9320fc1 100644
--- a/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
+++ b/client/rhel/rhn-client-tools/src/firstboot/rhn_login_gui.py
@@ -22,8 +22,6 @@ import sys
sys.path.append("/usr/share/rhn")
from up2date_client import rhnreg
from up2date_client import rhnregGui
-from up2date_client import up2dateErrors
-# from up2date_client import messageWindow
import gtk
from gtk import glade
@@ -53,22 +51,7 @@ class moduleClass(Module):
if self.loginPage.loginPageVerify():
return RESULT_FAILURE
- try:
- ret = self.loginPage.loginPageApply()
- # TODO this exception can't reach here right now. ditch it and/or
- # figure out how we want to provide this functionality.
- except up2dateErrors.CommunicationError, e:
- msg = _("There was a communication error with the server: %s" %
e.errmsg)
- msg = msg + "\n\n" + _("Would you like to try changing the
network configuration and trying again?")
- dlg = messageWindow.YesNoDialog(msg)
- ret = dlg.getrc()
- if ret:
- return RESULT_FAILURE
- else:
- interface.moveToPage(moduleTitle=_("Finish Updates Setup"))
- return RESULT_JUMP
-
- if ret:
+ if self.loginPage.loginPageApply():
return RESULT_FAILURE
# We should try to activate hardware, even if no EUS in firstboot
commit 397baaff9968ec1e747cc04d5193d7c0f91521c3
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue May 25 17:42:30 2010 -0400
595473 525588 - fixing issue where child channel subscription changes would not use
the stored procedure and would instead update rhnServerChannel table directly, bypassing
all entitelment logic
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/file-list.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/file-list.xml
index f11d706..c5ec1f0 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/file-list.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/file-list.xml
@@ -21,7 +21,6 @@
<template name="Org_queries" filename="xml/Org_queries.xml"
/>
<template name="Monitoring_queries"
filename="xml/Monitoring_queries.xml" />
<template name="ssm_operation_queries"
filename="xml/ssm_operation_queries.xml" />
- <template name="ssm_queries" filename="xml/ssm_queries.xml"
/>
<template name="util_queries" filename="xml/util_queries.xml"
/>
<template name="ErrataCache_queries"
filename="xml/ErrataCache_queries.xml" />
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_queries.xml
deleted file mode 100644
index f52259a..0000000
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_queries.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<datasource_modes>
-
-<write-mode name="subscribe_server_channels_in_set">
- <query>
- INSERT INTO rhnServerChannel (server_id, channel_id)
- (
- SELECT element, element_two
- FROM rhnSet
- WHERE label = 'ssm_channel_subscribe'
- )
- </query>
-</write-mode>
-
-<write-mode name="log_subscribe_server_channels_in_set">
- <query>
- INSERT INTO rhnServerHistory (id, server_id, summary)
- (
- SELECT rhn_event_id_seq.nextval,
- s.element,
- 'subscribed to channel ' || (SELECT label FROM
rhnChannel c WHERE c.id = s.element_two)
- FROM rhnSet s
- WHERE s.label = 'ssm_channel_subscribe'
- )
- </query>
-</write-mode>
-
-<write-mode name="unsubscribe_server_channels_in_set">
- <query>
- DELETE FROM rhnServerChannel
- WHERE (server_id, channel_id)
- IN (SELECT element, element_two
- FROM rhnSet s
- WHERE s.label = 'ssm_channel_unsubscribe')
- </query>
-</write-mode>
-
-<write-mode name="log_unsubscribe_server_channels_in_set">
- <query>
- INSERT INTO rhnServerHistory (id, server_id, summary)
- (
- SELECT rhn_event_id_seq.nextval,
- s.element,
- 'unsubscribed from channel ' || (SELECT label FROM
rhnChannel c WHERE c.id = s.element_two)
- FROM rhnSet s
- WHERE s.label = 'ssm_channel_unsubscribe'
- )
- </query>
-</write-mode>
-
-<write-mode name="flag_server_channels_changed_in_set">
- <query params="set_label">
- UPDATE rhnServer
- SET channels_changed = sysdate
- WHERE id
- IN (SELECT element
- FROM rhnSet
- WHERE label = :set_label)
- </query>
-</write-mode>
-
-</datasource_modes>
\ No newline at end of file
diff --git
a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
index b43f367..979a05b 100644
---
a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
@@ -62,7 +62,7 @@ public class SsmChangeChannelSubscriptionsAction extends
AbstractDatabaseAction
long requests.
*/
try {
- SsmManager.performChannelActions(user);
+ SsmManager.performChannelActions(user, changes);
}
finally {
// Complete the action
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
b/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
index d91a837..a63583b 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
@@ -14,8 +14,8 @@
*/
package com.redhat.rhn.manager.ssm;
+import com.redhat.rhn.common.db.datasource.CallableMode;
import com.redhat.rhn.common.db.datasource.ModeFactory;
-import com.redhat.rhn.common.db.datasource.WriteMode;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.rhnset.RhnSet;
import com.redhat.rhn.domain.user.User;
@@ -98,7 +98,10 @@ public class SsmManager {
ChannelManager.getAvailableEntitlements(user.getOrg(), channel);
channelToAvailableEntitlements.put(channel, availableEntitlements);
}
-
+ //Most likely acustom channel1
+ if (availableEntitlements == null) {
+ continue;
+ }
if (availableEntitlements > 0) {
// Update our cached count for what will happen when
// the subscribe is done
@@ -133,74 +136,46 @@ public class SsmManager {
* </ul>
*
* @param user user performing the action creations
+ * @param sysMapping a collection of ChannelActionDAOs
*/
- public static void performChannelActions(User user) {
-
- long start, duration;
-
- RhnSet subscribeSet = RhnSetDecl.SSM_CHANNEL_SUBSCRIBE.get(user);
- RhnSet unsubscribeSet = RhnSetDecl.SSM_CHANNEL_UNSUBSCRIBE.get(user);
-
- Map<String, Object> params = new HashMap<String, Object>();
+ public static void performChannelActions(User user,
+ Collection<ChannelActionDAO> sysMapping) {
- // New Subscriptions
- if (subscribeSet.size() > 0) {
- start = System.currentTimeMillis();
- WriteMode doSubscriptionsMode =
ModeFactory.getWriteMode("ssm_queries",
- "subscribe_server_channels_in_set");
- doSubscriptionsMode.executeUpdate(params);
- duration = System.currentTimeMillis() - start;
- log.debug("Time to create all subscriptions: " + duration);
-
- start = System.currentTimeMillis();
- WriteMode logSubscriptionsMode =
ModeFactory.getWriteMode("ssm_queries",
- "log_subscribe_server_channels_in_set");
- logSubscriptionsMode.executeUpdate(params);
- duration = System.currentTimeMillis() - start;
- log.debug("Time to log all subscriptions: " + duration);
-
- start = System.currentTimeMillis();
- params.put("set_label", "ssm_channel_subscribe");
- WriteMode subscribeFlagMode =
ModeFactory.getWriteMode("ssm_queries",
- "flag_server_channels_changed_in_set");
- subscribeFlagMode.executeUpdate(params);
- duration = System.currentTimeMillis() - start;
- log.debug("Time to flag for all subscriptions: " + duration);
- }
-
- // Unsubscribe
- if (unsubscribeSet.size() > 0) {
- start = System.currentTimeMillis();
- WriteMode doUnsubscriptionsMode =
ModeFactory.getWriteMode("ssm_queries",
- "unsubscribe_server_channels_in_set");
- doUnsubscriptionsMode.executeUpdate(params);
- duration = System.currentTimeMillis() - start;
- log.debug("Time to do all unsubscriptions: " + duration);
-
- start = System.currentTimeMillis();
- WriteMode logUnsubscriptionsMode =
ModeFactory.getWriteMode("ssm_queries",
- "log_unsubscribe_server_channels_in_set");
- logUnsubscriptionsMode.executeUpdate(params);
- duration = System.currentTimeMillis() - start;
- log.debug("Time to log all unsubscriptions: " + duration);
-
- start = System.currentTimeMillis();
- params.put("set_label", "ssm_channel_unsubscribe");
- WriteMode unsubscribeFlagMode =
ModeFactory.getWriteMode("ssm_queries",
- "flag_server_channels_changed_in_set");
- unsubscribeFlagMode.executeUpdate(params);
- duration = System.currentTimeMillis() - start;
- log.debug("Time to flag for all unsubscriptions: " + duration);
+ for (ChannelActionDAO system : sysMapping) {
+ for (Long cid : system.getSubscribeChannelIds()) {
+ subscribeChannel(system.getId(), cid, user.getId());
+ }
+ for (Long cid : system.getUnsubscribeChannelIds()) {
+ unsubscribeChannel(system.getId(), cid);
+ }
}
-
- // Clean up the sets
- subscribeSet.clear();
- RhnSetManager.store(subscribeSet);
-
- unsubscribeSet.clear();
- RhnSetManager.store(unsubscribeSet);
}
+
+ private static void subscribeChannel(Long sid, Long cid, Long uid) {
+
+ CallableMode m = ModeFactory.getCallableMode("Channel_queries",
+ "subscribe_server_to_channel");
+
+ Map in = new HashMap();
+ in.put("server_id", sid);
+ in.put("user_id", uid);
+ in.put("channel_id", cid);
+ m.execute(in, new HashMap());
+ }
+
+
+ private static void unsubscribeChannel(Long sid, Long cid) {
+
+ CallableMode m = ModeFactory.getCallableMode("Channel_queries",
+ "unsubscribe_server_from_channel");
+ Map in = new HashMap();
+ in.put("server_id", sid);
+ in.put("channel_id", cid);
+ m.execute(in, new HashMap());
+ }
+
+
/**
* Parses through the indicated changes, populating the necessary RhnSets. This call
* is necessary before {@link #performChannelActions(User)} as the perform call
diff --git a/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
b/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
index d7dcab3..cba1e2c 100644
--- a/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
@@ -40,7 +40,7 @@
<rl:column bound="false"
sortable="false"
headerkey="ssmchildsubconfirm.jsp.canSub">
- <c:forEach items="${current.subNames}" var="chan">
+ <c:forEach items="${current.subscribeNames}" var="chan">
<c:out value="${chan}" /><br />
</c:forEach>
</rl:column>
@@ -50,7 +50,7 @@
sortable="false"
headerkey="ssmchildsubconfirm.jsp.canUnsub"
styleclass="last-column">
- <c:forEach items="${current.unsubNames}" var="chan">
+ <c:forEach items="${current.unsubcribeNames}" var="chan">
<c:out value="${chan}" /><br />
</c:forEach>
</rl:column>
commit e1aa5c1ccc9baae1f85938bbc6801e7ac3adf4fc
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue May 25 14:20:08 2010 -0400
525588 - changing SSM child channel subscription page to not use hibernate when doing
subscribng
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index ca4de55..9f85343 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -1184,6 +1184,42 @@ GROUP BY C.id, C.name
</query>
</mode>
+
+<mode name="ssm_systems_for_child_subscription">
+ <query params="set_label, uid">
+ select S.id, C.id as channel_id, S.name, C.name as channel_name
+ from rhnServer S inner join
+ rhnServerChannel SC on SC.server_id = S.id,
+ rhnChannel C,
+ rhnServerChannelArchCompat SCAC,
+ RhnSet rset
+ where
+ rset.label = :set_label and
+ rset.user_id = :uid and
+ C.parent_channel = SC.channel_id and
+ SCAC.server_arch_id = S.server_arch_id and
+ SCAC.channel_arch_id = C.channel_arch_id and
+ C.id in (%s) and
+ S.id not in (select SC2.server_id
+ from rhnServerChannel SC2
+ where SC2.channel_id = C.id)
+ </query>
+</mode>
+
+<mode name="ssm_systems_for_child_unsubscription">
+ <query params="set_label, uid">
+ select S.id, C.id as channel_id, S.name, C.name as channel_name
+ from rhnServer S inner join
+ rhnServerChannel SC on SC.server_id = S.id inner join
+ rhnChannel C on C.id = SC.channel_id inner join
+ rhnSet rset on rset.element = S.id
+ where SC.channel_id in (%s)
+ and rset.user_id = :uid
+ and rset.label = :set_label
+ </query>
+</mode>
+
+
<mode name="cloned_original_id">
<query params="cid">
SELECT original_id AS id
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChannelActionDAO.java
b/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChannelActionDAO.java
index 0905bcd..ccbb73d 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChannelActionDAO.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChannelActionDAO.java
@@ -14,10 +14,8 @@
*/
package com.redhat.rhn.frontend.action.channel.ssm;
-import com.redhat.rhn.domain.channel.Channel;
-import com.redhat.rhn.domain.server.Server;
-
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
/**
* ChannelActionDAO - stores channel subscription/unsubscription info for a specific
system
@@ -27,33 +25,36 @@ public class ChannelActionDAO {
public static final Long SUBSCRIBE = 1L;
public static final Long UNSUBSCRIBE = 2L;
+ private String name;
+ private Long id;
+ private Set<Long> subsAllowed = new HashSet<Long>();
+ private Set<Long> unsubsAllowed = new HashSet<Long>();
- private Server server;
- private List<Channel> subsAllowed;
- private List<Channel> unsubsAllowed;
+ private Set<String> subNamesAllowed = new HashSet<String>();
+ private Set<String> unsubNamesAllowed = new HashSet<String>();
/**
* What Server are we going to act on?
* @return the affected server
*/
- public Server getServer() {
- return server;
+ public Long getId() {
+ return id;
}
/**
* Set which Server we're affecting
* @param serverIn to set.
*/
- public void setServer(Server serverIn) {
- this.server = serverIn;
+ public void setId(Long serverIn) {
+ this.id = serverIn;
}
/**
- * What's the Server's ID?
- * @return getServer().getId()
+ * What's the Server's name?
+ * @param nameIn the name
*/
- public Long getId() {
- return server.getId();
+ public void setName(String nameIn) {
+ name = nameIn;
}
/**
@@ -61,39 +62,82 @@ public class ChannelActionDAO {
* @return server name.
*/
public String getName() {
- return server.getName();
+ return name;
}
/**
* What channels are we trying to subscribe this system to?
* @return list of channels to subscribe to
*/
- public List<Channel> getSubsAllowed() {
+ public Set<Long> getSubscribeChannelIds() {
return subsAllowed;
}
+
+ /**
+ * Add a channel name to subscribe (for display purposes only)
+ * @param nameIn the nameIn
+ */
+ public void addSubscribeName(String nameIn) {
+ subNamesAllowed.add(nameIn);
+ }
+
+ /**
+ * get the list of channel names to subscribe
+ * @return the list
+ */
+ public Set<String> getSubscribeNames() {
+ return subNamesAllowed;
+ }
+
+ /**
+ * Add an ubsubscribe channel name
+ * @param nameIn the name
+ */
+ public void addUnsubcribeName(String nameIn) {
+ unsubNamesAllowed.add(nameIn);
+ }
+
/**
- * Set the list of channels-to-be-subscribed
- * @param subAllowedIn Allowed channels to set.
+ * get the names of the channels for unsubscribing
+ * @return the list of names
*/
- public void setSubsAllowed(List<Channel> subAllowedIn) {
- this.subsAllowed = subAllowedIn;
+ public Set<String> getUnsubcribeNames() {
+ return unsubNamesAllowed;
}
+
+ /**
+ * add a channel for subscription
+ * @param cid the channel id
+ */
+ public void addSubscribeChannelId(Long cid) {
+ this.subsAllowed.add(cid);
+ }
+
/**
* What channels are we trying to unsubscribe this system from?
* @return list of channels to unsubscribe
*/
- public List<Channel> getUnsubsAllowed() {
+ public Set<Long> getUnsubscribeChannelIds() {
return unsubsAllowed;
}
-
+
/**
- * Set the list of channels-to-unubscribe-from
- * @param unsubsAllowedIn to set.
+ * Add an unsubscribe channel
+ * @param cid the channel id
*/
- public void setUnsubsAllowed(List<Channel> unsubsAllowedIn) {
- this.unsubsAllowed = unsubsAllowedIn;
+ public void addUnsubscribeChannelId(Long cid) {
+ this.unsubsAllowed.add(cid);
}
+
+ /**
+ * Are there any unsubscribe or subscribe channels
+ * @return if empty true
+ */
+ public boolean isEmtpy() {
+ return getUnsubscribeChannelIds().isEmpty() &&
getSubscribeChannelIds().isEmpty();
+ }
+
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChildChannelConfirmAction.java
b/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChildChannelConfirmAction.java
index 4f9fd48..edbdcfa 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChildChannelConfirmAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/channel/ssm/ChildChannelConfirmAction.java
@@ -18,13 +18,13 @@ import com.redhat.rhn.common.messaging.MessageQueue;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.rhnset.RhnSet;
import com.redhat.rhn.domain.rhnset.RhnSetElement;
-import com.redhat.rhn.domain.server.Server;
-import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.events.SsmChangeChannelSubscriptionsEvent;
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.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.ssm.SsmManager;
@@ -37,6 +37,7 @@ import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -48,7 +49,7 @@ import javax.servlet.http.HttpServletResponse;
* ChildChannelConfirmAction
* @version $Rev$
*/
-public class ChildChannelConfirmAction extends RhnAction {
+public class ChildChannelConfirmAction extends RhnAction implements Listable {
private final Log log = LogFactory.getLog(this.getClass());
@@ -67,37 +68,38 @@ public class ChildChannelConfirmAction extends RhnAction {
RequestContext requestContext = new RequestContext(request);
User user = requestContext.getLoggedInUser();
DynaActionForm daForm = (DynaActionForm)form;
- request.setAttribute("parentUrl", request.getRequestURI());
// First, find the channels the user chose to operate on, as stored
// in an RhnSet by ChildChannelAction
- List<Channel> subList = new ArrayList<Channel>();
- List<Channel> unsubList = new ArrayList<Channel>();
+ List<Channel> chanSubList = new ArrayList<Channel>();
+ List<Channel> chanUnsubList = new ArrayList<Channel>();
- findChannelsFromSet(user, subList, unsubList);
+ findChannelsFromSet(user, chanSubList, chanUnsubList);
- // Next, get the Servers that are in the SSM currently
- List<Server> servers = ServerFactory.listSystemsInSsm(user);
- // Then, get the lists of allowed subscriptions and un-subscriptions,
- // for each server
- Map<Server, List<Channel>> subs =
- SsmManager.linkChannelsToSubscribeForServers(user, servers, subList);
+ chanSubList = filterChannels(chanSubList, user);
+ Map<Long, ChannelActionDAO> sysSubList =
ChannelManager.filterChildSubscriptions(
+ RhnSetDecl.SYSTEMS.getLabel(), chanSubList, chanUnsubList, user);
- Map<Server, List<Channel>> unsubs =
- SsmManager.linkChannelsToUnsubscribeForServers(servers, unsubList);
+ //If we are going to go over our subscription limit,
+ // we need to not try to subscribe as many
+ Map<Long, ChannelActionDAO> subs =
+ SsmManager.verifyChildEntitlements(user, sysSubList, chanSubList);
- // Now, build the object that the page knows how to render
- List<ChannelActionDAO> changes = SsmManager.buildActionlist(subs, unsubs);
+ List list = new ArrayList();
+ list.addAll(subs.values());
+ request.setAttribute("data", list);
- request.setAttribute("channelchanges", changes);
+
+ ListHelper helper = new ListHelper(this, request);
+ helper.execute();
ActionForward result;
if (isSubmitted(daForm)) {
// Fire the request off asynchronously
SsmChangeChannelSubscriptionsEvent event =
- new SsmChangeChannelSubscriptionsEvent(user, changes);
+ new SsmChangeChannelSubscriptionsEvent(user, subs.values());
MessageQueue.publish(event);
result = mapping.findForward("success");
@@ -111,6 +113,25 @@ public class ChildChannelConfirmAction extends RhnAction {
return result;
}
+
+
+ protected List<Channel> filterChannels(Collection<Channel> chans, User
user) {
+ List<Channel> newChannels = new ArrayList<Channel>();
+ for (Channel c : chans) {
+ // Check for proxy and satellite channels
+ if (c.isProxy() || c.isSatellite()) {
+ continue;
+ }
+ // Verify the user roles, caching the role for the channel
+ Boolean hasAcceptableRole =
+ ChannelManager.verifyChannelSubscribe(user, c.getId());
+ if (hasAcceptableRole) {
+ newChannels.add(c);
+ }
+ }
+ return newChannels;
+ }
+
//
// Build the list of channels we're going to unsubscribe systems from - per
system,
// we only unsubscribe if the system currently IS subscribed...
@@ -136,4 +157,14 @@ public class ChildChannelConfirmAction extends RhnAction {
}
}
}
+
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext context) {
+ return (List) context.getRequest().getAttribute("data");
+ }
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
index e4d8c31..b43f367 100644
---
a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
@@ -21,7 +21,7 @@ import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.ssm.SsmManager;
import com.redhat.rhn.manager.ssm.SsmOperationManager;
-import java.util.List;
+import java.util.Collection;
/**
* Handles performing subscription changes for servers in the SSM.
@@ -36,7 +36,7 @@ public class SsmChangeChannelSubscriptionsAction extends
AbstractDatabaseAction
SsmChangeChannelSubscriptionsEvent event = (SsmChangeChannelSubscriptionsEvent)
msg;
User user = event.getUser();
- List<ChannelActionDAO> changes = event.getChanges();
+ Collection<ChannelActionDAO> changes = event.getChanges();
// Parse and store the changes into RhnSets
SsmManager.populateSsmChannelServerSets(user, changes);
diff --git
a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsEvent.java
b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsEvent.java
index c0c5f23..34e64c9 100644
---
a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsEvent.java
+++
b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsEvent.java
@@ -18,7 +18,7 @@ import com.redhat.rhn.common.messaging.EventMessage;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.action.channel.ssm.ChannelActionDAO;
-import java.util.List;
+import java.util.Collection;
/**
* Event fired to carry the information necessary to perform subscription changes
@@ -30,7 +30,7 @@ import java.util.List;
public class SsmChangeChannelSubscriptionsEvent implements EventMessage {
private User user;
- private List<ChannelActionDAO> changes;
+ private Collection<ChannelActionDAO> changes;
/**
* Creates a new SSM channel change event to fire across the message bus.
@@ -39,7 +39,8 @@ public class SsmChangeChannelSubscriptionsEvent implements EventMessage
{
* @param changesIn changes to make; cannot be <code>null</code>
*/
public SsmChangeChannelSubscriptionsEvent(User userIn,
- List<ChannelActionDAO> changesIn) {
+ Collection<ChannelActionDAO>
changesIn) {
+
if (userIn == null) {
throw new IllegalArgumentException("user cannot be null");
}
@@ -62,7 +63,7 @@ public class SsmChangeChannelSubscriptionsEvent implements EventMessage
{
/**
* @return will not be <code>null</code>
*/
- public List<ChannelActionDAO> getChanges() {
+ public Collection<ChannelActionDAO> getChanges() {
return changes;
}
diff --git a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index 3544c67..72bb0a2 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@ -50,6 +50,7 @@ import com.redhat.rhn.domain.rhnpackage.PackageFactory;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.action.channel.ssm.ChannelActionDAO;
import com.redhat.rhn.frontend.dto.ChannelOverview;
import com.redhat.rhn.frontend.dto.ChannelPerms;
import com.redhat.rhn.frontend.dto.ErrataOverview;
@@ -2831,5 +2832,79 @@ public class ChannelManager extends BaseManager {
Collections.sort(possibleList);
return logPath + possibleList.get(possibleList.size() - 1);
}
+
+
+
+
+ /**
+ * Takes a list of child channels and a set label and returns a Map
+ * with system ids as the key and a set ChannelActionDAO's
+ * as the value
+ * @param setLabel the set label of System ids
+ * @param subChans the list of channels to subscribe
+ * @param unsubChans the list of channels to unsubscribe
+ * @param user the user doing the work
+ * @return The aformentioned map
+ */
+ public static Map<Long, ChannelActionDAO> filterChildSubscriptions(
+ String setLabel, List<Channel> subChans, List<Channel>
unsubChans, User user) {
+ Map<Long, ChannelActionDAO> toRet = new HashMap<Long,
ChannelActionDAO>();
+
+ List subCids = new ArrayList();
+ for (Channel c : subChans) {
+ subCids.add(c.getId());
+ }
+ List unsubCids = new ArrayList();
+ for (Channel c : unsubChans) {
+ unsubCids.add(c.getId());
+ }
+
+ Map params = new HashMap();
+ params.put("uid", user.getId());
+ params.put("set_label", setLabel);
+
+ SelectMode m = null;
+ List<Map> subDr = Collections.EMPTY_LIST;
+ List<Map> unsubDr = Collections.EMPTY_LIST;
+ if (!subChans.isEmpty()) {
+ m = ModeFactory.getMode("Channel_queries",
+ "ssm_systems_for_child_subscription");
+ subDr = m.execute(params, subCids);
+ }
+ if (!unsubChans.isEmpty()) {
+ m = ModeFactory.getMode("Channel_queries",
+ "ssm_systems_for_child_unsubscription");
+ unsubDr = m.execute(params, unsubCids);
+ }
+
+
+ for (Map row : subDr) {
+ Long id = (Long) row.get("id");
+ ChannelActionDAO sys = toRet.get(id);
+ if (sys == null) {
+ sys = new ChannelActionDAO();
+ sys.setId(id);
+ sys.setName((String) row.get("name"));
+ toRet.put(id, sys);
+ }
+ sys.addSubscribeChannelId((Long) row.get("channel_id"));
+ sys.addSubscribeName((String) row.get("channel_name"));
+ }
+
+ for (Map row : unsubDr) {
+ Long id = (Long) row.get("id");
+ ChannelActionDAO sys = toRet.get(id);
+ if (sys == null) {
+ sys = new ChannelActionDAO();
+ sys.setId(id);
+ sys.setName((String) row.get("name"));
+ toRet.put(id, sys);
+ }
+ sys.addUnsubscribeChannelId((Long) row.get("channel_id"));
+ sys.addUnsubcribeName((String) row.get("channel_name"));
+ }
+
+ return toRet;
+ }
}
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
b/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
index eea9288..d91a837 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java
@@ -18,22 +18,22 @@ import com.redhat.rhn.common.db.datasource.ModeFactory;
import com.redhat.rhn.common.db.datasource.WriteMode;
import com.redhat.rhn.domain.channel.Channel;
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.action.channel.ssm.ChannelActionDAO;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.rhnset.RhnSetManager;
-import com.redhat.rhn.manager.system.SystemManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* The current plan for this class is to manage all SSM operations. However, as more is
@@ -59,23 +59,21 @@ public class SsmManager {
* allowed.
*
* @param user user initiating the subscription
- * @param servers all servers to map to channels; may not be
<code>null</code>
+ * @param sysMapping the map of ChannelActionDAO objects
* @param allChannels channels to attempt to subscribe each server to; may not
* be <code>null</code>
* @return mapping of each server to a non-null (but potentially empty) list of
* channels that are safe to subscribe it to
*/
- public static Map<Server, List<Channel>>
linkChannelsToSubscribeForServers(
- User user, List<Server> servers, List<Channel> allChannels) {
+ public static Map<Long, ChannelActionDAO> verifyChildEntitlements(
+ User user, Map<Long, ChannelActionDAO> sysMapping, List<Channel>
allChannels) {
- // Mappings generated from this method
- Map<Server, List<Channel>> result =
- new HashMap<Server, List<Channel>>(servers.size());
-
- // The channel roles won't change while we are processing, so it's safe
to
- // cache them rather than reload them for each channel for each server
- Map<Channel, Boolean> channelToAcceptableRole =
- new HashMap<Channel, Boolean>(allChannels.size());
+ //Load all of the channels in a map for easy lookup
+ Map<Long, Channel> idToChan = new HashMap<Long, Channel>();
+ for (Channel c : allChannels) {
+ idToChan.put(c.getId(), c);
+ }
+
// Keeps a mapping of how many entitlements are left on each channel. This map
// will be updated as the processing continues, however changes won't be
written
@@ -84,47 +82,15 @@ public class SsmManager {
// always loading the static value from the DB.
Map<Channel, Long> channelToAvailableEntitlements =
new HashMap<Channel, Long>(allChannels.size());
-
- for (Server server : servers) {
- List<Channel> allowedChannels = new ArrayList<Channel>();
- result.put(server, allowedChannels);
-
- for (Channel channel : allChannels) {
-
- // If the server is already subscribed, nothing to do
- if (server.isSubscribed(channel)) {
- continue;
- }
-
- // Check the architecture of the server against the channel
- if (!SystemManager.verifyArchCompatibility(server, channel)) {
- continue;
- }
-
- // Check for proxy and satellite channels
- if (channel.isProxy() || channel.isSatellite()) {
- continue;
- }
-
- // Make sure the parent channel and the server's base channel align
- if (!channel.getParentChannel().equals(server.getBaseChannel())) {
- continue;
- }
-
- // Verify the user roles, caching the role for the channel
- Boolean hasAcceptableRole = channelToAcceptableRole.get(channel);
- if (hasAcceptableRole == null) {
- hasAcceptableRole =
- ChannelManager.verifyChannelSubscribe(user, channel.getId());
- channelToAcceptableRole.put(channel, hasAcceptableRole);
- }
-
- if (!hasAcceptableRole) {
- continue;
- }
-
- // Make sure the channel is either free to the server or we have
- // enough available entitlements to fill it
+
+
+ for (Long sysid : sysMapping.keySet()) {
+
+ Set<Long> chanIds = sysMapping.get(sysid).getSubscribeChannelIds();
+ //Use an iterator so i can remove from the set
+ Iterator it = chanIds.iterator();
+ while (it.hasNext()) {
+ Channel channel = idToChan.get(it.next());
Long availableEntitlements =
channelToAvailableEntitlements.get(channel);
if (availableEntitlements == null) {
@@ -132,65 +98,25 @@ public class SsmManager {
ChannelManager.getAvailableEntitlements(user.getOrg(), channel);
channelToAvailableEntitlements.put(channel, availableEntitlements);
}
-
- if (!ChannelManager.isChannelFreeForSubscription(server, channel)) {
-
- if (availableEntitlements != null && availableEntitlements
< 1) {
- continue;
- }
- else if (availableEntitlements != null) {
+
+ if (availableEntitlements > 0) {
// Update our cached count for what will happen when
// the subscribe is done
availableEntitlements = availableEntitlements - 1;
channelToAvailableEntitlements.put(channel,
availableEntitlements);
+ }
+ else {
+
sysMapping.get(sysid).getSubscribeChannelIds().remove(channel.getId());
+ sysMapping.get(sysid).getSubscribeNames().remove(channel.getName());
+ if (sysMapping.get(sysid).isEmtpy()) {
+ sysMapping.remove(sysid);
}
-
}
-
- // If we didn't punch out by now, it's allowed
- log.debug("Subscribing:: Server [" + server.getId() + " to
channel [" +
- channel.getLabel() + "]");
-
- allowedChannels.add(channel);
}
-
}
-
- return result;
+ return sysMapping;
}
- /**
- * Given a list of servers and channels that should be unsubscribed, determines
which
- * channels may be removed for which servers. The mapping returned will be from
- * each server to a list of channels that may be unsubscribed. This list will not
- * be <code>null</code> but may be empty if no subscriptions are
determined to be
- * removed.
- *
- * @param servers all servers to map to channels; may not be
<code>null</code>
- * @param allChannels channels to attempt to unsubscribe each server to; may not
- * be <code>null</code>
- * @return mapping of each server to a non-null (but potentially empty) list of
- * channels that are relevant to unsubscribe
- */
- public static Map<Server, List<Channel>>
linkChannelsToUnsubscribeForServers(
- List<Server> servers,
- List<Channel> allChannels) {
- Map<Server, List<Channel>> unsubMap = new HashMap<Server,
List<Channel>>();
-
- for (Server s : servers) {
- List<Channel> allowedChans = new ArrayList<Channel>();
-
- for (Channel chan : allChannels) {
- if (s.isSubscribed(chan)) {
- allowedChans.add(chan);
- }
- }
-
- unsubMap.put(s, allowedChans);
- }
-
- return unsubMap;
- }
/**
* Performs channel subscriptions. This method assumes the changes have been
validated
@@ -284,26 +210,25 @@ public class SsmManager {
* @param actions subscription changes being made
*/
public static void populateSsmChannelServerSets(User user,
- List<ChannelActionDAO> actions)
{
+ Collection<ChannelActionDAO>
actions) {
RhnSet subscribeSet = RhnSetDecl.SSM_CHANNEL_SUBSCRIBE.get(user);
RhnSet unsubscribeSet = RhnSetDecl.SSM_CHANNEL_UNSUBSCRIBE.get(user);
for (ChannelActionDAO action : actions) {
- Server server = action.getServer();
- long serverId = server.getId();
+ long serverId = action.getId();
// New Subscriptions
- if (action.getSubsAllowed() != null) {
- for (Channel subscribeMe : action.getSubsAllowed()) {
- subscribeSet.addElement(serverId, subscribeMe.getId());
+ if (action.getSubscribeChannelIds() != null) {
+ for (Long subscribeMe : action.getSubscribeChannelIds()) {
+ subscribeSet.addElement(serverId, subscribeMe);
}
}
// Unsubscribe
- if (action.getUnsubsAllowed() != null) {
- for (Channel unsubscribeMe : action.getUnsubsAllowed()) {
- unsubscribeSet.addElement(serverId, unsubscribeMe.getId());
+ if (action.getUnsubscribeChannelIds() != null) {
+ for (Long unsubscribeMe : action.getUnsubscribeChannelIds()) {
+ unsubscribeSet.addElement(serverId, unsubscribeMe);
}
}
}
@@ -312,33 +237,6 @@ public class SsmManager {
RhnSetManager.store(unsubscribeSet);
}
- /**
- * Assembles a mapping of server to subscriptions and unsubscriptions.
- *
- * @param subs mapping of server to list of subscriptions to create; the map
- * cannot be <code>null</code> but the channel list for a
server may be
- * @param unsubs mapping of server to list of subscriptions to remove; the map
- * cannot be <code>null</code> but the channel list for a
server may be
- * @return consolidated list of subscription changes
- */
- public static List<ChannelActionDAO> buildActionlist(Map<Server,
- List<Channel>> subs, Map<Server, List<Channel>> unsubs) {
- List<ChannelActionDAO> changes = new ArrayList<ChannelActionDAO>();
- for (Server s : subs.keySet()) {
-
- // Skip servers that have no matches
- if (subs.get(s).isEmpty() && unsubs.get(s).isEmpty()) {
- continue;
- }
- ChannelActionDAO cad = new ChannelActionDAO();
- cad.setServer(s);
- cad.setSubsAllowed(subs.get(s));
- cad.setUnsubsAllowed(unsubs.get(s));
-
- changes.add(cad);
- }
- return changes;
- }
/**
* Adds the selected server IDs to the SSM RhnSet.
@@ -346,7 +244,6 @@ public class SsmManager {
* @param user cannot be <code>null</code>
* @param serverIds cannot be <code>null</code>
*/
- @SuppressWarnings("unchecked")
public static void addServersToSsm(User user, String[] serverIds) {
RhnSet set = RhnSetDecl.SYSTEMS.get(user);
set.addAll(Arrays.asList(serverIds));
diff --git a/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
b/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
index 143331d..d7dcab3 100644
--- a/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/ssm/childsubconfirm.jsp
@@ -21,9 +21,9 @@
<rl:listset name="channelchanges">
<html:hidden property="submitted" value="true"/>
<!-- Start of active users list -->
- <rl:list dataset="channelchanges"
+ <rl:list
width="100%"
- name="channelchanges"
+
styleclass="list"
emptykey="ssmchildsubconfirm.jsp.noSystems">
@@ -40,8 +40,8 @@
<rl:column bound="false"
sortable="false"
headerkey="ssmchildsubconfirm.jsp.canSub">
- <c:forEach items="${current.subsAllowed}" var="chan">
- <c:out value="<a
href=\"/rhn/channels/ChannelDetail.do?cid=${chan.id}\">${chan.name}</a>"
escapeXml="false" /><br />
+ <c:forEach items="${current.subNames}" var="chan">
+ <c:out value="${chan}" /><br />
</c:forEach>
</rl:column>
@@ -50,8 +50,8 @@
sortable="false"
headerkey="ssmchildsubconfirm.jsp.canUnsub"
styleclass="last-column">
- <c:forEach items="${current.unsubsAllowed}" var="chan">
- <c:out value="<a
href=\"/rhn/channels/ChannelDetail.do?cid=${chan.id}\">${chan.name}</a>"
escapeXml="false" /><br />
+ <c:forEach items="${current.unsubNames}" var="chan">
+ <c:out value="${chan}" /><br />
</c:forEach>
</rl:column>