Hey again,
We found some errors with the prefix field of a user's properties. First, when
creating
a new user with the UI, it is not possible to leave the prefix empty, it
complains about
a non-valid value (even though an 'empty' value is actually contained in the
prefixes
list). Further, when editing a user's details it is not possible to empty the
prefix.
This is especially annoying if you used e.g. spacecmd to create a user without
a prefix.
It is then later on not even possible to edit and save such a user without
changing the
prefix. I reproduced these issues reliably on Oracle as well as on PG.
The attached patch fixes the problem by setting the apparently correct empty
value of " ",
just in case it is empty (== ""). The select in the form might even return it
correctly
as " ", but looks like it is maybe trimmed away somewhere.. This works for me
now, but
I tested the fix on PG only.
Thanks,
Johannes
--
SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
>From 7e095b96cc5d104b76cb0121ed8dc89e62ce50eb Mon Sep 17 00:00:00 2001
From: Johannes Renner
Date: Thu, 15 Nov 2012 15:21:55 +0100
Subject: [PATCH] Fix errors with unrequired field 'Prefix'
---
.../rhn/frontend/action/user/UserEditActionHelper.java |3 ++-
.../src/com/redhat/rhn/manager/user/CreateUserCommand.java | 10 +++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java b/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java
index e7726ad..3056834 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java
@@ -67,7 +67,8 @@ public abstract class UserEditActionHelper extends RhnAction {
targetUser.setFirstNames((String)form.get("firstNames"));
targetUser.setLastName((String)form.get("lastName"));
targetUser.setTitle((String)form.get("title"));
-targetUser.setPrefix((String)form.get("prefix"));
+String prefix = (String)form.get("prefix");
+targetUser.setPrefix(prefix.isEmpty() ? " " : prefix);
// Update PAM Authentication attribute
updatePamAttribute(loggedInUser, targetUser, form);
}
diff --git a/java/code/src/com/redhat/rhn/manager/user/CreateUserCommand.java b/java/code/src/com/redhat/rhn/manager/user/CreateUserCommand.java
index fa16d7c..9930aad 100644
--- a/java/code/src/com/redhat/rhn/manager/user/CreateUserCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/user/CreateUserCommand.java
@@ -224,12 +224,16 @@ public class CreateUserCommand {
* errors list.
*/
private void validatePrefix() {
-if (user.getPrefix() != null) {
+String prefix = user.getPrefix();
+if (prefix != null) {
// Make sure whether prefix is valid, if it is set
SortedSet validPrefixes = LocalizationService.getInstance().availablePrefixes();
-if (!validPrefixes.contains(user.getPrefix())) {
+if (prefix.isEmpty()) {
+user.setPrefix(" ");
+}
+if (!validPrefixes.contains(prefix)) {
errors.add(new ValidatorError("error.user_invalid_prefix",
- user.getPrefix(), validPrefixes.toString()));
+ prefix, validPrefixes.toString()));
}
}
}
--
1.7.10.4
___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel