Author: ronvoe122
Date: 2007-12-02 09:08:00-0800
New Revision: 10483
Modified:
trunk/src/java/org/tigris/scarab/attribute/UserAttribute.java
Log:
Bugfix: Look up a user referenced by an user-attribute-value only by its userId.
When a user-attribute-value is created, not only the userId is stored in the according field, but also the user-name is stored in value.
In the previous implementation the user was looked up by the stored user-name, instead of the userId.
If the name of the user had been changed, this resulted in an exception, because the user could not be found.
Modified: trunk/src/java/org/tigris/scarab/attribute/UserAttribute.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/attribute/UserAttribute.java?view=diff&rev=10483&p1=trunk/src/java/org/tigris/scarab/attribute/UserAttribute.java&p2=trunk/src/java/org/tigris/scarab/attribute/UserAttribute.java&r1=10482&r2=10483
==============================================================================
--- trunk/src/java/org/tigris/scarab/attribute/UserAttribute.java (original)
+++ trunk/src/java/org/tigris/scarab/attribute/UserAttribute.java 2007-12-02 09:08:00-0800
@@ -72,70 +72,27 @@
return getValue();
}
- public void setUser(final ScarabUser user)
- throws TorqueException
- {
- setValueOnly(user.getUserName());
- setUserIdOnly(user.getUserId());
- }
-
- public void setValue(final String username)
- {
- // can't throw an exception, so just log it
- try
- {
- if (username != null)
- {
- ScarabUser user = ScarabUserManager.getInstance(username);
- if (user != null)
- {
- setUserIdOnly(user.getUserId());
- }
- }
- else
- {
- // any reason to set a username to null, once its already set?
- setUserIdOnly(null);
- }
-
- setValueOnly(username);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- getLog().error(e);
- }
- }
-
-
/**
* Overrides super method to make sure up-to-date username is provided.
*/
public String getValue()
{
- String value = null;
try
{
- if (getUserId() != null)
- {
- ScarabUser user = ScarabUserManager.getInstance(getUserId());
- value = user.getUserName();
- }
- else
- {
- value = super.getValue();
- }
+ ScarabUser user = getScarabUser();
+ if(user!=null)
+ return user.getUserName();
+ else
+ return null;
}
- catch (TorqueException e)
+ catch (Exception e)
{
- getLog().error(e);
- value="Error. Please see logs.";
+ throw new RuntimeException(e);
}
- return value;
}
- public void init() throws TorqueException
+ public void init()
{
}
@@ -143,10 +100,7 @@
{
}
- /**
- * Returns null
- */
- public Object loadResources() throws TorqueException
+ public Object loadResources()
{
return null;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.