This creates a new API call to list the systems subscribed to a configuration 
channel.

/aron
>From d7a50fa02432f99eebd373b2a62bff045880e1ee Mon Sep 17 00:00:00 2001
From: Aron Parsons <a...@redhat.com>
Date: Mon, 19 Jul 2010 14:51:16 -0400
Subject: [PATCH] 584852 - added API configchannel.listSubscribedSystems

---
 .../xmlrpc/configchannel/ConfigChannelHandler.java |   24 ++++++++
 .../serializer/ConfigSystemDtoSerializer.java      |   59 ++++++++++++++++++++
 .../xmlrpc/serializer/SerializerRegistry.java      |    1 +
 3 files changed, 84 insertions(+), 0 deletions(-)
 create mode 100644 java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
index 7edfc33..8ce55c2 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
@@ -547,4 +547,28 @@ public class ConfigChannelHandler extends BaseHandler {
         return 1;
 
     }
+
+    /**
+     * List the systems subscribed to a configuration channel
+     * @param sessionKey the session key
+     * @param channelLabel the label of the config channel
+     * @return a list of dto's holding this info.
+     *
+     * @xmlrpc.doc Return a list of systems subscribed to a configuration channel
+     * @xmlrpc.param  #session_key()
+     * @xmlrpc.param #param_desc("string", "channelLabel",
+     *                          "label of config channel to list subscribed systems.")
+     * @xmlrpc.returntype
+     * #array()
+     * $ConfigSystemDtoSerializer
+     * #array_end()
+     */
+    public List<ConfigSystemDto> listSubscribedSystems(String sessionKey, String channelLabel) {
+        User loggedInUser = getLoggedInUser(sessionKey);
+        XmlRpcConfigChannelHelper configHelper = XmlRpcConfigChannelHelper.getInstance();
+        ConfigChannel channel = configHelper.lookupGlobal(loggedInUser,
+                                                          channelLabel);
+        ConfigurationManager cm = ConfigurationManager.getInstance();
+        return cm.listChannelSystems(loggedInUser, channel, null);
+    }
 }
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java
new file mode 100644
index 0000000..06e5b27
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2009--2010 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.xmlrpc.serializer;
+
+import com.redhat.rhn.frontend.dto.ConfigSystemDto;
+import com.redhat.rhn.frontend.xmlrpc.serializer.util.SerializerHelper;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import redstone.xmlrpc.XmlRpcCustomSerializer;
+import redstone.xmlrpc.XmlRpcException;
+import redstone.xmlrpc.XmlRpcSerializer;
+
+
+/**
+ * ConfigSystemDtoSerializer
+ * @version $Rev$
+ *
+ * @xmlrpc.doc
+ * #struct("system")
+ *   #prop("int", "id")
+ *   #prop("string", "name")
+ * #struct_end()
+ */
+public class ConfigSystemDtoSerializer implements XmlRpcCustomSerializer {
+
+    /**
+     * {...@inheritdoc}
+     */
+    public Class getSupportedClass() {
+        return ConfigSystemDto.class;
+    }
+
+    /**
+     * {...@inheritdoc}builtinserializer
+     */
+    public void serialize(Object value, Writer output, XmlRpcSerializer builtInSerializer)
+        throws XmlRpcException, IOException {
+        ConfigSystemDto dto = (ConfigSystemDto) value;
+        SerializerHelper helper = new SerializerHelper(builtInSerializer);
+        helper.add("id", dto.getId());
+        helper.add("name", dto.getName());
+        helper.writeTo(output);
+    }
+
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
index bf3935d..cf537eb 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
@@ -73,6 +73,7 @@ public class SerializerRegistry {
         SERIALIZER_CLASSES.add(ConfigChannelTypeSerializer.class);
         SERIALIZER_CLASSES.add(ConfigFileDtoSerializer.class);
         SERIALIZER_CLASSES.add(ConfigFileNameDtoSerializer.class);
+        SERIALIZER_CLASSES.add(ConfigSystemDtoSerializer.class);
         SERIALIZER_CLASSES.add(ChannelFamilySystemGroupSerializer.class);
         SERIALIZER_CLASSES.add(OrgDtoSerializer.class);
         SERIALIZER_CLASSES.add(MultiOrgUserOverviewSerializer.class);
-- 
1.5.5.6

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to