[Spacewalk-devel] [PATCH] Errors with unrequired field Prefix

2012-11-15 Thread Johannes Renner
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 jren...@suse.de
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

Re: [Spacewalk-devel] [PATCH] extend API call errata.setDetails to support issue_date and update_date

2012-11-15 Thread Tomas Lestach
On Wednesday 14 of November 2012 16:09:59 Jörg Steffens wrote:
 Hi,
 
 currently, the API allows to create and modify most attributes of
 erratas, but the functionality for setting the issue- and update-date is
 missing.
 
 The first attached patch adds this functionality to the API call
 errate.setDetails.
 
 The second patch integrates this to scripts/clone-errata/rhn-clone-errata.py
 
 It would be great, if those patches could get applied.
 
 regards,
 Jörg Steffens

Hello Jörg,

I committed both patches to spacewalk.

http://git.fedorahosted.org/cgit/spacewalk.git/commit/?id=4d2c9204d5e91e0ed76060a47ac8d3e1c6e84603
http://git.fedorahosted.org/cgit/spacewalk.git/commit/?id=b0524cc7fa1de90398e8b7d3762555324dd5c4f5

Thank you.
Regards,
-- 
Tomas Lestach
RHN Satellite Engineering

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