java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java
| 14 ++-
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/custominfo/CustomInfoHandler.java
| 39 ++++++++++
2 files changed, 48 insertions(+), 5 deletions(-)
New commits:
commit 28be9373d18952ef29b938175ac465a6e7d21b63
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Mon Aug 29 17:51:20 2011 +0200
update custom info changes
to match appropriate API behavior
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java
b/java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java
index 4e485bf..c434434 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java
@@ -28,7 +28,6 @@ import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -57,6 +56,7 @@ public class UpdateCustomKeyAction extends RhnAction implements Listable
{
RequestContext context = new RequestContext(request);
DynaActionForm form = (DynaActionForm)formIn;
+ User loggedInUser = context.getLoggedInUser();
Long cikid = context.getParamAsLong(CIKID_PARAM);
CustomDataKey key = OrgFactory.lookupKeyById(cikid);
@@ -78,7 +78,7 @@ public class UpdateCustomKeyAction extends RhnAction implements Listable
{
request.setAttribute(MODIFIER_PARAM, key.getLastModifier().getLogin());
}
else {
- request.setAttribute(MODIFIER_PARAM, "");
+ request.setAttribute(MODIFIER_PARAM, key.getCreator().getLogin());
}
Map params = new HashMap();
@@ -88,11 +88,15 @@ public class UpdateCustomKeyAction extends RhnAction implements
Listable {
if (context.wasDispatched("system.jsp.customkey.updatebutton")) {
- key.setDescription((String)form.get(DESC_PARAM));
- key.setModified(new Date());
+ String description = (String)form.get(DESC_PARAM);
+ if (description.length() < 2) {
+ createErrorMessage(request, "system.customkey.error.tooshort",
null);
+ return mapping.findForward("default");
+ }
+ key.setDescription(description);
+ key.setLastModifier(loggedInUser);
ServerFactory.saveCustomKey(key);
-
return mapping.findForward("updated");
}
commit b5a5429292242d05fc97a52462971fd2f743de9a
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Mon Aug 29 16:20:15 2011 +0200
699527 - introduce system.custominfo.updateKey API
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/custominfo/CustomInfoHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/custominfo/CustomInfoHandler.java
index 7aadd71..d8c58aa 100644
---
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/custominfo/CustomInfoHandler.java
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/custominfo/CustomInfoHandler.java
@@ -72,6 +72,45 @@ public class CustomInfoHandler extends BaseHandler {
}
/**
+ * Update description of a custom key
+ * @param sessionKey key
+ * @param keyLabel string
+ * @param keyDescription string
+ * @return 1 on success, 0 on failure
+ * @throws FaultException A FaultException is thrown if a key doesn't exist or
+ * an iinvalid description is provided
+ *
+ * @xmlrpc.doc Update description of a custom key
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "keyLabel", "key to
change")
+ * @xmlrpc.param #param_desc("string", "keyDescription",
"new key's description")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int updateKey(String sessionKey, String keyLabel,
+ String keyDescription) throws FaultException {
+
+ User loggedInUser = getLoggedInUser(sessionKey);
+
+ CustomDataKey key = OrgFactory.lookupKeyByLabelAndOrg(keyLabel,
+ loggedInUser.getOrg());
+
+ if (key == null) {
+ throw new FaultException(-1, "keyDoesNotExist",
+ "A custom key with label: " + keyLabel + "does not
exist.");
+ }
+
+ if ((keyDescription.length() < 2)) {
+ throw new FaultException(-1, "labelOrDescriptionTooShort",
+ "Label and description must be at least two characters
long");
+ }
+
+ key.setDescription(keyDescription);
+ key.setLastModifier(loggedInUser);
+ ServerFactory.saveCustomKey(key);
+ return 1;
+ }
+
+ /**
* Delete an existing custom key
* @param sessionKey key
* @param keyLabel string