java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml |
3 +-
java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java |
4 +--
java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java |
11 +++++----
java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java |
12 ++++++----
4 files changed, 19 insertions(+), 11 deletions(-)
New commits:
commit a2f9ba58ccca28d9158b11c9f8cd1d91288a3761
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Aug 12 14:33:39 2009 -0400
517074 - Systems were pulled from the SSM rhnSet without being scoped to a specific
user ID. Updated the query to take user IDs into account.
diff --git
a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
index 6aafbb9..a530442 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
@@ -109,12 +109,13 @@
This call assumes the server IDs are stored in the set's "element"
field.
-->
<write-mode name="map_servers_to_operation">
- <query params="op_id, set_label">
+ <query params="op_id, user_id, set_label">
INSERT INTO rhnSsmOperationServer (operation_id, server_id)
(
SELECT DISTINCT :op_id, s.element
FROM rhnSet s
WHERE label = :set_label
+ AND user_id = :user_id
AND s.element NOT IN
(
SELECT sos.server_id
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 30a9fe4..a3b57e7 100644
---
a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
@@ -49,9 +49,9 @@ public class SsmChangeChannelSubscriptionsAction extends
AbstractDatabaseAction
long operationId = SsmOperationManager.createOperation(user,
"Channel Subscription Updates", null);
- SsmOperationManager.associateServersWithOperation(operationId,
+ SsmOperationManager.associateServersWithOperation(operationId, user.getId(),
RhnSetDecl.SSM_CHANNEL_SUBSCRIBE.getLabel());
- SsmOperationManager.associateServersWithOperation(operationId,
+ SsmOperationManager.associateServersWithOperation(operationId, user.getId(),
RhnSetDecl.SSM_CHANNEL_UNSUBSCRIBE.getLabel());
// Do the changes
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
b/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
index 917d187..af7a259 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
@@ -190,7 +190,7 @@ public class SsmOperationManager extends BaseManager {
// Add the server/operation mappings
if (rhnSetLabel != null) {
- associateServersWithOperation(operationId, rhnSetLabel);
+ associateServersWithOperation(operationId, user.getId(), rhnSetLabel);
}
return operationId;
@@ -242,16 +242,19 @@ public class SsmOperationManager extends BaseManager {
* Associates an operation with a group of servers against which it was run, where
* the servers are found in an RhnSet. The IDs for these servers must be stored in
* the "element" field of the RhnSet.
- *
+ *
* @param operationId identifies an existing operation to associate with servers
+ * @param userId identifies the user performing the operation
* @param setLabel identifies the set in which to find server IDs
*/
- public static void associateServersWithOperation(long operationId, String setLabel)
{
+ public static void associateServersWithOperation(long operationId, long userId,
+ String setLabel) {
WriteMode writeMode =
ModeFactory.getWriteMode("ssm_operation_queries",
"map_servers_to_operation");
- Map<String, Object> params = new HashMap<String, Object>(2);
+ Map<String, Object> params = new HashMap<String, Object>(3);
params.put("op_id", operationId);
+ params.put("user_id", userId);
params.put("set_label", setLabel);
writeMode.executeUpdate(params);
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
b/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
index e339b38..dc4d8a3 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
@@ -143,7 +143,8 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
assertEquals(0, result.size());
// Test
- SsmOperationManager.associateServersWithOperation(operationId, serverSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ serverSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
@@ -186,8 +187,10 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
String secondSetLabel = secondSet.getLabel();
// Test
- SsmOperationManager.associateServersWithOperation(operationId, serverSetLabel);
- SsmOperationManager.associateServersWithOperation(operationId, secondSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ serverSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ secondSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
@@ -235,7 +238,8 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
String secondSetLabel = secondSet.getLabel();
// Test
- SsmOperationManager.associateServersWithOperation(operationId, secondSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ secondSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);