remove non used method with parameter Object principal

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1418771 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-08 22:32:34 +00:00
parent 86a6ec5580
commit 3257c3fac5
7 changed files with 10 additions and 202 deletions

View File

@ -150,32 +150,13 @@ public interface UserManager
*/
List<User> findUsersByQuery( UserQuery query );
/**
* Find a User using the principal.
*
* @param principal the principal to look for.
* @return the user.
* @throws UserNotFoundException if the user was not found.
*/
User findUser( Object principal )
throws UserNotFoundException;
/**
* true if the user exists, false if it doesn't
*
* @param principal
* @return true, if user exists
*/
boolean userExists( Object principal );
/**
* Delete a user using the principal.
*
* @param principal the principal to look for.
* @throws UserNotFoundException the user was not found.
*/
void deleteUser( Object principal )
throws UserNotFoundException;
boolean userExists( String principal );
/**
* Delete a user using the username.

View File

@ -93,13 +93,6 @@ public class CachedUserManager
return this.userImpl.createUser( username, fullName, emailAddress );
}
public void deleteUser( Object principal )
throws UserNotFoundException
{
usersCache.remove( principal );
this.userImpl.deleteUser( principal );
}
public void deleteUser( String username )
throws UserNotFoundException
{
@ -156,22 +149,6 @@ public class CachedUserManager
}
}
public User findUser( Object principal )
throws UserNotFoundException
{
Object el = usersCache.get( principal );
if ( el != null )
{
return (User) el;
}
else
{
User user = this.userImpl.findUser( principal );
usersCache.put( principal, user );
return user;
}
}
public UserQuery createUserQuery()
{
return userImpl.createUserQuery();
@ -240,14 +217,14 @@ public class CachedUserManager
return this.userImpl.updateUser( user, passwordChangeRequired );
}
public boolean userExists( Object principal )
public boolean userExists( String userName )
{
if ( usersCache.hasKey( principal ) )
if ( usersCache.hasKey( userName ) )
{
return true;
}
return this.userImpl.userExists( principal );
return this.userImpl.userExists( userName );
}
public void userManagerInit( boolean freshDatabase )

View File

@ -85,12 +85,6 @@ public class ConfigurableUserManager
return userManagerImpl.createUserQuery();
}
public void deleteUser( Object principal )
throws UserNotFoundException
{
userManagerImpl.deleteUser( principal );
}
public void deleteUser( String username )
throws UserNotFoundException
{
@ -108,12 +102,6 @@ public class ConfigurableUserManager
return userManagerImpl.findUser( username );
}
public User findUser( Object principal )
throws UserNotFoundException
{
return userManagerImpl.findUser( principal );
}
@Override
public User getGuestUser()
throws UserNotFoundException
@ -173,9 +161,9 @@ public class ConfigurableUserManager
return userManagerImpl.updateUser( user, passwordChangeRequired );
}
public boolean userExists( Object principal )
public boolean userExists( String userName )
{
return userManagerImpl.userExists( principal );
return userManagerImpl.userExists( userName );
}
public void setUserManagerImpl( UserManager userManagerImpl )

View File

@ -242,27 +242,6 @@ public class JdoUserManager
return (User) addObject( user );
}
public void deleteUser( Object principal )
{
try
{
User user = findUser( principal );
if ( user.isPermanent() )
{
throw new PermanentUserException( "Cannot delete permanent user [" + user.getUsername() + "]." );
}
fireUserManagerUserRemoved( user );
removeObject( user );
}
catch ( UserNotFoundException e )
{
log.warn( "Unable to delete user " + principal + ", user not found.", e );
}
}
public void deleteUser( String username )
{
try
@ -307,29 +286,6 @@ public class JdoUserManager
RedbackJdoUtils.removeAll( getPersistenceManager(), UsersManagementModelloMetadata.class );
}
public User findUser( Object principal )
throws UserNotFoundException
{
if ( principal == null )
{
throw new UserNotFoundException( "Unable to find user based on null principal." );
}
try
{
return (User) RedbackJdoUtils.getObjectById( getPersistenceManager(), JdoUser.class, principal.toString(),
null );
}
catch ( RedbackObjectNotFoundException e )
{
throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e );
}
catch ( RedbackStoreException e )
{
throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e );
}
}
public User findUser( String username )
throws UserNotFoundException
{
@ -341,7 +297,7 @@ public class JdoUserManager
return (User) getObjectById( username, null );
}
public boolean userExists( Object principal )
public boolean userExists( String principal )
{
try
{

View File

@ -127,29 +127,6 @@ public class LdapUserManager
return new LdapUserQuery();
}
public void deleteUser( Object principal )
throws UserNotFoundException
{
if ( principal != null )
{
clearFromCache( principal.toString() );
}
LdapConnection ldapConnection = getLdapConnection();
try
{
DirContext context = ldapConnection.getDirContext();
controller.removeUser( principal, context );
}
catch ( LdapControllerException e )
{
log.error( "Failed to delete user: {}", principal, e );
}
finally
{
closeLdapConnection( ldapConnection );
}
}
public void deleteUser( String username )
throws UserNotFoundException
@ -245,58 +222,6 @@ public class LdapUserManager
return guestUser;
}
public User findUser( Object principal )
throws UserNotFoundException
{
if ( principal == null )
{
throw new UserNotFoundException( "Unable to find user based on null principal." );
}
if ( GUEST_USERNAME.equals( principal.toString() ) )
{
return getGuestUser();
}
// REDBACK-289/MRM-1488
// look for the user in the cache first
LdapUser ldapUser = ldapCacheService.getUser( principal.toString() );
if ( ldapUser != null )
{
log.debug( "User {} found in cache.", principal );
return ldapUser;
}
LdapConnection ldapConnection = getLdapConnection();
try
{
DirContext context = ldapConnection.getDirContext();
User user = controller.getUser( principal, context );
// REDBACK-289/MRM-1488
log.debug( "Adding user {} to cache..", principal );
ldapCacheService.addUser( (LdapUser) user );
return user;
}
catch ( LdapControllerException e )
{
log.error( "Failed to find user: {}", principal, e );
return null;
}
catch ( MappingException e )
{
log.error( "Failed to map user: {}", principal, e );
return null;
}
finally
{
closeLdapConnection( ldapConnection );
}
}
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
{
LdapUserQuery query = new LdapUserQuery();
@ -437,7 +362,7 @@ public class LdapUserManager
return user;
}
public boolean userExists( Object principal )
public boolean userExists( String principal )
{
if ( principal == null )
{

View File

@ -138,21 +138,7 @@ public class MemoryUserManager
return user;
}
public User findUser( Object principal )
throws UserNotFoundException
{
triggerInit();
User user = users.get( principal );
if ( user == null )
{
throw new UserNotFoundException( "Cannot find the user with the principal '" + principal + "'." );
}
return user;
}
public boolean userExists( Object principal )
public boolean userExists( String principal )
{
try
{
@ -165,11 +151,6 @@ public class MemoryUserManager
}
}
public void deleteUser( Object principal )
throws UserNotFoundException
{
deleteUser( principal.toString() );
}
public User createUser( String username, String fullName, String emailAddress )
{

View File

@ -109,7 +109,7 @@ public class AbstractUserManagerTestCase
try
{
Object obj = null;
getUserManager().findUser( obj );
getUserManager().findUser( null );
fail( "findUser() with null Object Should have thrown a UserNotFoundException." );
}
catch ( UserNotFoundException e )