]> source.dussan.org Git - archiva.git/commitdiff
remove non used method with parameter Object principal
authorOlivier Lamy <olamy@apache.org>
Sat, 8 Dec 2012 22:32:34 +0000 (22:32 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 8 Dec 2012 22:32:34 +0000 (22:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1418771 13f79535-47bb-0310-9956-ffa450edef68

redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManager.java
redback-users/redback-users-providers/redback-users-cached/src/main/java/org/apache/archiva/redback/users/cached/CachedUserManager.java
redback-users/redback-users-providers/redback-users-configurable/src/main/java/org/apache/archiva/redback/users/configurable/ConfigurableUserManager.java
redback-users/redback-users-providers/redback-users-jdo/src/main/java/org/apache/archiva/redback/users/jdo/JdoUserManager.java
redback-users/redback-users-providers/redback-users-ldap/src/main/java/org/apache/archiva/redback/users/ldap/LdapUserManager.java
redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java
redback-users/redback-users-tests/src/main/java/org/apache/archiva/redback/users/provider/test/AbstractUserManagerTestCase.java

index c5f94a0385732df1dc5618ce610aae343a7d3c19..e610f047b2d6c6341f45628bff4d8c47011f206e 100644 (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.
index 6c3fc3454a6e5beaaa2e460dfb8497ce945bd29c..7cebc1f8277d4f3b494780cc695db0c27e187cd9 100644 (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 )
index 909c831b1ee91cd4cc840dfb629715c391a077e0..848aba37741046b010f4d78719e5fe4156945cd7 100644 (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 )
index 03724e0626e8fb4a6eae1eea354626c05795a381..8a68c0836e87e920cc99931dede51bf16b609b15 100644 (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
         {
index c069eddff278f14b163e8bcbbf030c67182079b6..8d2ed7e85e0fc8d6d8beedff165eaf8259b871c4 100644 (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 )
         {
index 61861e12c402f95bb1af72fe6bafc23fbb5b72b2..c3a7526b77a9f1ebc66da672f2d9278cb42f17cd 100644 (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 )
     {
index d4adc137f944a9311cd37ed4c3a4345dd428596d..2fa013acef38b5f35779071cb42511878cac7c0d 100644 (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 )