java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
| 4
java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChecksumLabelException.java
| 40 ++++
java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
| 83 +++++++++-
java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
| 7
java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
| 46 +++++
java/spacewalk-java.spec
| 6
rel-eng/packages/spacewalk-java
| 2
7 files changed, 178 insertions(+), 10 deletions(-)
New commits:
commit 2259add6f3816ddc92be6ea64571fdfb94864316
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed Aug 24 21:30:12 2011 +0200
Automatic commit of package [spacewalk-java] release [1.6.29-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index 54ba0bf..9785321 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -17,7 +17,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 1.6.28
+Version: 1.6.29
Release: 1%{?dist}
URL:
https://fedorahosted.org/spacewalk
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -547,6 +547,10 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Wed Aug 24 2011 Tomas Lestach <tlestach(a)redhat.com> 1.6.29-1
+- 662200 - allow modification of selected channel attributes via API
+ (tlestach(a)redhat.com)
+
* Tue Aug 23 2011 Tomas Lestach <tlestach(a)redhat.com> 1.6.28-1
- make the taskomatic cleanup delete faster for Postgresql (jonathan.hoser
@helmholtz-muenchen.de)
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index 04d46cf..e810e0e 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-1.6.28-1 java/
+1.6.29-1 java/
commit 964c3529a9975e5989e1a61290bc1e4afab9ebbf
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed Aug 24 18:01:13 2011 +0200
662200 - allow modification of selected channel attributes via API
introducing channel.software.setDetails API
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
index 223da37..ac54956 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java
@@ -326,7 +326,7 @@ public class EditChannelAction extends RhnAction implements Listable
{
// times where python would make this SOOOO much easier.
UpdateChannelCommand ucc = new UpdateChannelCommand();
ucc.setArchLabel((String)form.get("arch"));
- ucc.setChecksum((String)form.get("checksum"));
+ ucc.setChecksumLabel((String)form.get("checksum"));
ucc.setLabel((String)form.get("label"));
ucc.setName((String)form.get("name"));
ucc.setSummary((String)form.get("summary"));
@@ -396,7 +396,7 @@ public class EditChannelAction extends RhnAction implements Listable
{
// times where python would make this SOOOO much easier.
CreateChannelCommand ccc = new CreateChannelCommand();
ccc.setArchLabel((String)form.get("arch"));
- ccc.setChecksum((String)form.get("checksum"));
+ ccc.setChecksumLabel((String)form.get("checksum"));
ccc.setLabel((String)form.get("label"));
ccc.setName((String)form.get("name"));
ccc.setSummary((String)form.get("summary"));
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChecksumLabelException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChecksumLabelException.java
new file mode 100644
index 0000000..6e2914d
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/InvalidChecksumLabelException.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2011 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;
+
+import com.redhat.rhn.FaultException;
+
+
+/**
+ * InvalidChecksumLabelException
+ * @version $Rev$
+ */
+public class InvalidChecksumLabelException extends FaultException {
+
+ /**
+ * Constructor
+ */
+ public InvalidChecksumLabelException() {
+ super(1210, "invalidChecksumLabelLabel", "Invalid checksum
label");
+ }
+
+ /**
+ * Constructor
+ * @param label the profile label
+ */
+ public InvalidChecksumLabelException(String label) {
+ super(1210, "invalidChecksumLabelLabel", "Invalid checksum label:
" + label);
+ }
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
index b81298c..a20b5c2 100644
---
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
@@ -57,6 +57,7 @@ import com.redhat.rhn.frontend.xmlrpc.user.XmlRpcUserHelper;
import com.redhat.rhn.manager.channel.ChannelEditor;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.channel.CreateChannelCommand;
+import com.redhat.rhn.manager.channel.UpdateChannelCommand;
import com.redhat.rhn.manager.channel.repo.BaseRepoCommand;
import com.redhat.rhn.manager.channel.repo.CreateRepoCommand;
import com.redhat.rhn.manager.errata.ErrataManager;
@@ -496,6 +497,86 @@ public class ChannelSoftwareHandler extends BaseHandler {
return lookupChannelById(user, id);
}
+ /**
+ * Allows to modify channel attributes
+ * @param sessionKey WebSession containing User information.
+ * @param channelId id of channel to be modified
+ * @param details map of channel attributes to be changed
+ * @return 1 if edit was successful, exception thrown otherwise
+ *
+ * @xmlrpc.doc Allows to modify channel attributes
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("int", "channelDd", "channel
id")
+ * @xmlrpc.param
+ * #struct("channel_map")
+ * #prop_desc("string", "checksum_label", "new channel
repository checksum label
+ * (optional)")
+ * #prop_desc("string", "name", "new channel name
(optional)")
+ * #prop_desc("string", "summary", "new channel summary
(optional)")
+ * #prop_desc("string", "description", "new channel
description (optional)")
+ * #prop_desc("string", "maintainer_name", "new channel
maintainer name
+ * (optional)")
+ * #prop_desc("string", "maintainer_email", "new
channel email address
+ * (optional)")
+ * #prop_desc("string", "maintainer_phone", "new
channel phone number (optional)")
+ * #prop_desc("string", "gpg_key_url", "new channel gpg
key url (optional)")
+ * #prop_desc("string", "gpg_key_id", "new channel gpg
key id (optional)")
+ * #prop_desc("string", "gpg_key_fp", "new channel gpg
key fingerprint
+ * (optional)")
+ * #struct_end()
+
+ *(a)xmlrpc.returntype #return_int_success()
+ */
+ public int setDetails(String sessionKey, Integer channelId, Map details) {
+ User user = getLoggedInUser(sessionKey);
+ Channel channel = lookupChannelById(user, channelId);
+
+ UpdateChannelCommand ucc = new UpdateChannelCommand(user, channel);
+
+ if (details.containsKey("checksum_label")) {
+ ucc.setChecksumLabel((String) details.get("checksum_label"));
+ }
+
+ if (details.containsKey("name")) {
+ ucc.setName((String) details.get("name"));
+ }
+
+ if (details.containsKey("summary")) {
+ ucc.setSummary((String)details.get("summary"));
+ }
+
+ if (details.containsKey("description")) {
+ ucc.setDescription((String)details.get("description"));
+ }
+
+ if (details.containsKey("maintainer_name")) {
+ ucc.setMaintainerName((String)details.get("maintainer_name"));
+ }
+
+ if (details.containsKey("maintainer_email")) {
+ ucc.setMaintainerEmail((String)details.get("maintainer_email"));
+ }
+
+ if (details.containsKey("maintainer_phone")) {
+ ucc.setMaintainerPhone((String)details.get("maintainer_phone"));
+ }
+
+ if (details.containsKey("gpg_key_url")) {
+ ucc.setGpgKeyUrl((String)details.get("gpg_key_url"));
+ }
+
+ if (details.containsKey("gpg_key_id")) {
+ ucc.setGpgKeyId((String)details.get("gpg_key_id"));
+ }
+
+ if (details.containsKey("gpg_key_fp")) {
+ ucc.setGpgKeyFp((String)details.get("gpg_key_fp"));
+ }
+
+ ucc.update(channelId.longValue());
+ return 1;
+ }
+
/**
* Returns the number of available subscriptions for the given channel
@@ -605,7 +686,7 @@ public class ChannelSoftwareHandler extends BaseHandler {
ccc.setSummary(summary);
ccc.setParentLabel(parentLabel);
ccc.setUser(user);
- ccc.setChecksum(checksumType);
+ ccc.setChecksumLabel(checksumType);
ccc.setGpgKeyUrl((String)gpgKey.get("url"));
ccc.setGpgKeyId((String)gpgKey.get("id"));
ccc.setGpgKeyFp((String)gpgKey.get("fingerprint"));
diff --git a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
index 5007634..dea5fa9 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java
@@ -108,10 +108,10 @@ public class CreateChannelCommand {
}
/**
- * @param checksumIn The name to set.
+ * @param checksumLabelIn The name to set.
*/
- public void setChecksum(String checksumIn) {
- this.checksum = checksumIn;
+ public void setChecksumLabel(String checksumLabelIn) {
+ this.checksum = checksumLabelIn;
}
/**
@@ -437,5 +437,4 @@ public class CreateChannelCommand {
throw new InvalidGPGUrlException();
}
}
-
}
diff --git a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
index 0e7a7a7..2b8c3dd 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java
@@ -18,8 +18,10 @@ package com.redhat.rhn.manager.channel;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.common.ChecksumType;
+import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException;
+import com.redhat.rhn.frontend.xmlrpc.InvalidChecksumLabelException;
import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException;
/**
@@ -36,6 +38,46 @@ public class UpdateChannelCommand extends CreateChannelCommand {
}
/**
+ * prefill all channel atrributes
+ * @param userIn user, that tries to update the channel
+ * @param channelIn to be updated
+ */
+ public UpdateChannelCommand(User userIn, Channel channelIn) {
+ user = userIn;
+ label = channelIn.getLabel();
+ name = channelIn.getName();
+ summary = channelIn.getSummary();
+ description = channelIn.getDescription();
+ if (channelIn.getChannelArch() == null) {
+ archLabel = null;
+ }
+ else {
+ archLabel = channelIn.getChannelArch().getLabel();
+ }
+ if (channelIn.getParentChannel() == null) {
+ parentLabel = null;
+ }
+ else {
+ parentLabel = channelIn.getParentChannel().getLabel();
+ }
+ if (channelIn.getParentChannel() == null) {
+ parentId = null;
+ }
+ else {
+ parentId = channelIn.getParentChannel().getId();
+ }
+ gpgKeyUrl = channelIn.getGPGKeyUrl();
+ gpgKeyId = channelIn.getGPGKeyId();
+ gpgKeyFp = channelIn.getGPGKeyFp();
+ checksum = channelIn.getChecksumTypeLabel();
+ maintainerName = channelIn.getMaintainerName();
+ maintainerEmail = channelIn.getMaintainerEmail();
+ maintainerPhone = channelIn.getMaintainerPhone();
+ supportPolicy = channelIn.getSupportPolicy();
+ access = channelIn.getAccess();
+ }
+
+ /**
* Updates the Channel based on the parameters that were set.
* @param cid id of Channel to be updated.
* @return the updated Channel
@@ -66,6 +108,9 @@ public class UpdateChannelCommand extends CreateChannelCommand {
}
ChecksumType ct = ChannelFactory.findChecksumTypeByLabel(checksum);
+ if (ct == null) {
+ throw new InvalidChecksumLabelException(checksum);
+ }
if (checksumChanged(c.getChecksumTypeLabel(), ct) && c.getPackageCount()
> 0) {
// schedule repo re generation if the checksum type changed
// and the channel has packages
@@ -76,7 +121,6 @@ public class UpdateChannelCommand extends CreateChannelCommand {
c.setName(name);
c.setSummary(summary);
c.setDescription(description);
- c.setOrg(user.getOrg());
c.setBaseDir("/dev/null");
c.setGPGKeyId(gpgKeyId);
c.setGPGKeyUrl(gpgKeyUrl);