add a method to find user without using caching: jdo update need the object detach from database not a cached one

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1551098 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-12-16 01:26:26 +00:00
parent 182ba92298
commit eadb1849d7
9 changed files with 68 additions and 13 deletions

View File

@ -102,6 +102,13 @@ public class MockUserManager
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException
{
return null;
}
public User getGuestUser()
throws UserNotFoundException, UserManagerException
{

View File

@ -107,7 +107,7 @@ public class DefaultPasswordService
String encodedPassword = passwordValidator.validatePassword( password, principal );
User user = securitySystem.getUserManager().findUser( principal );
User user = securitySystem.getUserManager().findUser( principal, false );
user.setPassword( password );
user.setEncodedPassword( encodedPassword );
user = securitySystem.getUserManager().updateUser( user );

View File

@ -100,6 +100,13 @@ public class MockUserManager
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException
{
return null;
}
public User getGuestUser()
throws UserNotFoundException, UserManagerException
{

View File

@ -136,6 +136,9 @@ public interface UserManager
User findUser( String username )
throws UserNotFoundException, UserManagerException;
User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException;
/**
* Get the guest user.
*

View File

@ -137,6 +137,14 @@ public class CachedUserManager
}
}
@Override
public User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException
{
// force use of cache here :-)
return findUser( username );
}
public User getGuestUser()
throws UserNotFoundException, UserManagerException
{

View File

@ -106,6 +106,13 @@ public class ConfigurableUserManager
return userManagerImpl.findUser( username );
}
@Override
public User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException
{
return userManagerImpl.findUser( username, useCache );
}
@Override
public User getGuestUser()
throws UserNotFoundException, UserManagerException

View File

@ -300,6 +300,13 @@ public class JdoUserManager
return (User) getObjectById( username, null );
}
@Override
public User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException
{
return findUser( username );
}
public boolean userExists( String principal )
throws UserManagerException
{

View File

@ -195,7 +195,8 @@ public class LdapUserManager
// TODO Implement erase!
}
public User findUser( String username )
@Override
public User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException
{
if ( username == null )
@ -203,6 +204,8 @@ public class LdapUserManager
throw new UserNotFoundException( "Unable to find user based on null username." );
}
if ( useCache )
{
// REDBACK-289/MRM-1488
// look for the user in the cache first
LdapUser ldapUser = ldapCacheService.getUser( username );
@ -211,7 +214,7 @@ public class LdapUserManager
log.debug( "User {} found in cache.", username );
return ldapUser;
}
}
LdapConnection ldapConnection = null;
try
@ -251,6 +254,12 @@ public class LdapUserManager
}
}
public User findUser( String username )
throws UserNotFoundException, UserManagerException
{
return findUser( username, true );
}
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
throws UserManagerException
{

View File

@ -212,6 +212,13 @@ public class MemoryUserManager
return user;
}
@Override
public User findUser( String username, boolean useCache )
throws UserNotFoundException, UserManagerException
{
return findUser( username );
}
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
{
triggerInit();