java/code/src/com/redhat/rhn/domain/token/ActivationKey.java | 9 +++++++--
java/code/src/com/redhat/rhn/domain/token/ActivationKeyFactory.java | 2 +-
java/code/src/com/redhat/rhn/frontend/xmlrpc/activationkey/ActivationKeyHandler.java | 5 +++++
java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/TokenSerializer.java | 1 +
4 files changed, 14 insertions(+), 3 deletions(-)
New commits:
commit 4a19cab55087491ea355697e67f2f87fe957345e
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Tue Aug 30 18:29:32 2011 +0200
725050 - en/disable activation keys using API
diff --git a/java/code/src/com/redhat/rhn/domain/token/ActivationKey.java b/java/code/src/com/redhat/rhn/domain/token/ActivationKey.java
index 210c301..eef6d79 100644
--- a/java/code/src/com/redhat/rhn/domain/token/ActivationKey.java
+++ b/java/code/src/com/redhat/rhn/domain/token/ActivationKey.java
@@ -196,8 +196,13 @@ public class ActivationKey extends BaseDomainHelper {
/**
* @param disabled The disabled to set
*/
- public void setDisabled(Long disabled) {
- this.getToken().setDisabled(disabled);
+ public void setDisabled(Boolean disabled) {
+ if (disabled) {
+ this.getToken().disable();
+ }
+ else {
+ this.getToken().enable();
+ }
}
/**
diff --git a/java/code/src/com/redhat/rhn/domain/token/ActivationKeyFactory.java b/java/code/src/com/redhat/rhn/domain/token/ActivationKeyFactory.java
index e17e897..a1c2d3d 100644
--- a/java/code/src/com/redhat/rhn/domain/token/ActivationKeyFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/token/ActivationKeyFactory.java
@@ -137,7 +137,7 @@ public class ActivationKeyFactory extends HibernateFactory {
}
newKey.setNote((String)Scrubber.scrub(note));
newKey.getToken().setDeployConfigs(false); // Don't deploy configs by default
- newKey.setDisabled(new Long(0)); // Enable by default
+ newKey.setDisabled(Boolean.FALSE); // Enable by default
newKey.setUsageLimit(usageLimit);
if (baseChannel != null) {
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/activationkey/ActivationKeyHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/activationkey/ActivationKeyHandler.java
index fa83829..f3ff1f7 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/activationkey/ActivationKeyHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/activationkey/ActivationKeyHandler.java
@@ -295,6 +295,7 @@ public class ActivationKeyHandler extends BaseHandler {
validKeys.add("usage_limit");
validKeys.add("unlimited_usage_limit");
validKeys.add("universal_default");
+ validKeys.add("disabled");
validateMap(validKeys, details);
User user = getLoggedInUser(sessionKey);
@@ -345,6 +346,10 @@ public class ActivationKeyHandler extends BaseHandler {
aKey.setUniversalDefault(universalDefault.booleanValue());
}
+ if (details.containsKey("disabled")) {
+ aKey.setDisabled((Boolean)details.get("disabled"));
+ }
+
manager.update(aKey, description, baseChannel);
return 1;
}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/TokenSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/TokenSerializer.java
index ef5725c..6093895 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/TokenSerializer.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/TokenSerializer.java
@@ -138,5 +138,6 @@ public class TokenSerializer implements XmlRpcCustomSerializer {
Boolean universalDefault = Boolean.valueOf(token.isOrgDefault());
helper.add("universal_default", universalDefault);
+ helper.add("disabled", Boolean.valueOf(token.isTokenDisabled()));
}
}