simplify code

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1425055 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-21 17:54:37 +00:00
parent 523213b737
commit 09208ec81a
1 changed files with 3 additions and 38 deletions

View File

@ -42,7 +42,7 @@ import java.util.Map;
* @author Olivier Lamy * @author Olivier Lamy
* @since 1.4-M4 * @since 1.4-M4
*/ */
@Service( "userManager#archiva" ) @Service("userManager#archiva")
public class ArchivaConfigurableUsersManager public class ArchivaConfigurableUsersManager
extends ConfigurableUserManager extends ConfigurableUserManager
{ {
@ -58,7 +58,7 @@ public class ArchivaConfigurableUsersManager
private List<UserManagerListener> listeners = new ArrayList<UserManagerListener>(); private List<UserManagerListener> listeners = new ArrayList<UserManagerListener>();
@Inject @Inject
@Named( value = "cache#users" ) @Named(value = "cache#users")
private Cache usersCache; private Cache usersCache;
@Override @Override
@ -244,42 +244,7 @@ public class ArchivaConfigurableUsersManager
public User getGuestUser() public User getGuestUser()
throws UserNotFoundException, UserManagerException throws UserNotFoundException, UserManagerException
{ {
User user = null; return findUser( GUEST_USERNAME );
if ( useUsersCache() )
{
user = (User) usersCache.get( GUEST_USERNAME );
if ( user != null )
{
return user;
}
}
UserNotFoundException lastException = null;
for ( UserManager userManager : userManagerPerId.values() )
{
try
{
user = userManager.getGuestUser();
if ( user != null )
{
if ( useUsersCache() )
{
usersCache.put( user.getUsername(), user );
}
return user;
}
}
catch ( UserNotFoundException e )
{
lastException = e;
}
}
if ( user == null && lastException != null )
{
throw lastException;
}
return user;
} }
@Override @Override