Reducing compiler warnings and modifying generic interfaces
This commit is contained in:
parent
87e8bba27c
commit
70b9c04294
|
@ -337,7 +337,7 @@ public class DataManagementTest
|
||||||
|
|
||||||
dataManagementTool.restoreUsersDatabase( manager, targetDirectory );
|
dataManagementTool.restoreUsersDatabase( manager, targetDirectory );
|
||||||
|
|
||||||
List<User> users = manager.getUsers();
|
List<? extends User> users = manager.getUsers();
|
||||||
assertEquals( 3, users.size() );
|
assertEquals( 3, users.size() );
|
||||||
|
|
||||||
User user = users.get( 0 );
|
User user = users.get( 0 );
|
||||||
|
@ -371,7 +371,7 @@ public class DataManagementTest
|
||||||
private void assertEmpty( UserManager manager )
|
private void assertEmpty( UserManager manager )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
List<User> users = manager.getUsers();
|
List<? extends User> users = manager.getUsers();
|
||||||
assertEquals( 0, users.size() );
|
assertEquals( 0, users.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,7 @@ public class DefaultUserService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<org.apache.archiva.redback.users.User> users = userManager.getUsers();
|
List<? extends org.apache.archiva.redback.users.User> users = userManager.getUsers();
|
||||||
List<User> simpleUsers = new ArrayList<User>( users.size() );
|
List<User> simpleUsers = new ArrayList<User>( users.size() );
|
||||||
|
|
||||||
for ( org.apache.archiva.redback.users.User user : users )
|
for ( org.apache.archiva.redback.users.User user : users )
|
||||||
|
|
|
@ -19,11 +19,6 @@ package org.apache.archiva.redback.keys.cached;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import org.apache.archiva.redback.components.cache.Cache;
|
import org.apache.archiva.redback.components.cache.Cache;
|
||||||
import org.apache.archiva.redback.keys.AbstractKeyManager;
|
import org.apache.archiva.redback.keys.AbstractKeyManager;
|
||||||
import org.apache.archiva.redback.keys.AuthenticationKey;
|
import org.apache.archiva.redback.keys.AuthenticationKey;
|
||||||
|
@ -32,6 +27,10 @@ import org.apache.archiva.redback.keys.KeyManagerException;
|
||||||
import org.apache.archiva.redback.keys.KeyNotFoundException;
|
import org.apache.archiva.redback.keys.KeyNotFoundException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CachedKeyManager
|
* CachedKeyManager
|
||||||
*
|
*
|
||||||
|
@ -94,7 +93,7 @@ public class CachedKeyManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationKey findKey( String key )
|
public AuthenticationKey findKey( String key )
|
||||||
throws KeyNotFoundException, KeyManagerException
|
throws KeyManagerException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -146,7 +145,7 @@ public class CachedKeyManager
|
||||||
return keysCache;
|
return keysCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeysCache( Cache keysCache )
|
public void setKeysCache( Cache<String, AuthenticationKey> keysCache )
|
||||||
{
|
{
|
||||||
this.keysCache = keysCache;
|
this.keysCache = keysCache;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,10 +100,10 @@ public interface UserManager
|
||||||
* @return the List of {@link User} Objects.
|
* @return the List of {@link User} Objects.
|
||||||
* @throws UserManagerException
|
* @throws UserManagerException
|
||||||
*/
|
*/
|
||||||
List<User> getUsers()
|
List<? extends User> getUsers()
|
||||||
throws UserManagerException;
|
throws UserManagerException;
|
||||||
|
|
||||||
List<User> getUsers( boolean orderAscending )
|
List<? extends User> getUsers( boolean orderAscending )
|
||||||
throws UserManagerException;
|
throws UserManagerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,13 +156,13 @@ public interface UserManager
|
||||||
User getGuestUser()
|
User getGuestUser()
|
||||||
throws UserNotFoundException, UserManagerException;
|
throws UserNotFoundException, UserManagerException;
|
||||||
|
|
||||||
List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
List<? extends User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
||||||
throws UserManagerException;
|
throws UserManagerException;
|
||||||
|
|
||||||
List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
List<? extends User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
||||||
throws UserManagerException;
|
throws UserManagerException;
|
||||||
|
|
||||||
List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
List<? extends User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
||||||
throws UserManagerException;
|
throws UserManagerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +172,7 @@ public interface UserManager
|
||||||
* @param query the query.
|
* @param query the query.
|
||||||
* @return a List of {@link User} objects.
|
* @return a List of {@link User} objects.
|
||||||
*/
|
*/
|
||||||
List<User> findUsersByQuery( UserQuery query )
|
List<? extends User> findUsersByQuery( UserQuery query )
|
||||||
throws UserManagerException;
|
throws UserManagerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,17 +54,20 @@ public class CachedUserManager
|
||||||
@Named(value = "cache#users")
|
@Named(value = "cache#users")
|
||||||
private Cache<String, User> usersCache;
|
private Cache<String, User> usersCache;
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isReadOnly()
|
public boolean isReadOnly()
|
||||||
{
|
{
|
||||||
return userImpl.isReadOnly();
|
return userImpl.isReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User createGuestUser()
|
public User createGuestUser()
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userImpl.createGuestUser();
|
return userImpl.createGuestUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User addUser( User user )
|
public User addUser( User user )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -75,11 +78,13 @@ public class CachedUserManager
|
||||||
return this.userImpl.addUser( user );
|
return this.userImpl.addUser( user );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addUserManagerListener( UserManagerListener listener )
|
public void addUserManagerListener( UserManagerListener listener )
|
||||||
{
|
{
|
||||||
this.userImpl.addUserManagerListener( listener );
|
this.userImpl.addUserManagerListener( listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addUserUnchecked( User user )
|
public void addUserUnchecked( User user )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -90,6 +95,7 @@ public class CachedUserManager
|
||||||
this.userImpl.addUserUnchecked( user );
|
this.userImpl.addUserUnchecked( user );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User createUser( String username, String fullName, String emailAddress )
|
public User createUser( String username, String fullName, String emailAddress )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -97,6 +103,7 @@ public class CachedUserManager
|
||||||
return this.userImpl.createUser( username, fullName, emailAddress );
|
return this.userImpl.createUser( username, fullName, emailAddress );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteUser( String username )
|
public void deleteUser( String username )
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -104,6 +111,7 @@ public class CachedUserManager
|
||||||
this.userImpl.deleteUser( username );
|
this.userImpl.deleteUser( username );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void eraseDatabase()
|
public void eraseDatabase()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -116,6 +124,7 @@ public class CachedUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User findUser( String username )
|
public User findUser( String username )
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -145,6 +154,7 @@ public class CachedUserManager
|
||||||
return findUser( username );
|
return findUser( username );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User getGuestUser()
|
public User getGuestUser()
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -161,70 +171,81 @@ public class CachedUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UserQuery createUserQuery()
|
public UserQuery createUserQuery()
|
||||||
{
|
{
|
||||||
return userImpl.createUserQuery();
|
return userImpl.createUserQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<User> findUsersByQuery( UserQuery query )
|
@Override
|
||||||
|
public List<? extends User> findUsersByQuery( UserQuery query )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
log.debug( "NOT CACHED - .findUsersByQuery(UserQuery)" );
|
log.debug( "NOT CACHED - .findUsersByQuery(UserQuery)" );
|
||||||
return this.userImpl.findUsersByQuery( query );
|
return this.userImpl.findUsersByQuery( query );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
log.debug( "NOT CACHED - .findUsersByEmailKey(String, boolean)" );
|
log.debug( "NOT CACHED - .findUsersByEmailKey(String, boolean)" );
|
||||||
return this.userImpl.findUsersByEmailKey( emailKey, orderAscending );
|
return this.userImpl.findUsersByEmailKey( emailKey, orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
log.debug( "NOT CACHED - .findUsersByFullNameKey(String, boolean)" );
|
log.debug( "NOT CACHED - .findUsersByFullNameKey(String, boolean)" );
|
||||||
return this.userImpl.findUsersByFullNameKey( fullNameKey, orderAscending );
|
return this.userImpl.findUsersByFullNameKey( fullNameKey, orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
log.debug( "NOT CACHED - .findUsersByUsernameKey(String, boolean)" );
|
log.debug( "NOT CACHED - .findUsersByUsernameKey(String, boolean)" );
|
||||||
return this.userImpl.findUsersByUsernameKey( usernameKey, orderAscending );
|
return this.userImpl.findUsersByUsernameKey( usernameKey, orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return "cached";
|
return "cached";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getUsers()
|
@Override
|
||||||
|
public List<? extends User> getUsers()
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
log.debug( "NOT CACHED - .getUsers()" );
|
log.debug( "NOT CACHED - .getUsers()" );
|
||||||
return this.userImpl.getUsers();
|
return this.userImpl.getUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getUsers( boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> getUsers( boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
log.debug( "NOT CACHED - .getUsers(boolean)" );
|
log.debug( "NOT CACHED - .getUsers(boolean)" );
|
||||||
return this.userImpl.getUsers( orderAscending );
|
return this.userImpl.getUsers( orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void removeUserManagerListener( UserManagerListener listener )
|
public void removeUserManagerListener( UserManagerListener listener )
|
||||||
{
|
{
|
||||||
this.userImpl.removeUserManagerListener( listener );
|
this.userImpl.removeUserManagerListener( listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User updateUser( User user )
|
public User updateUser( User user )
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
return updateUser( user, false );
|
return updateUser( user, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User updateUser( User user, boolean passwordChangeRequired )
|
public User updateUser( User user, boolean passwordChangeRequired )
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -235,6 +256,7 @@ public class CachedUserManager
|
||||||
return this.userImpl.updateUser( user, passwordChangeRequired );
|
return this.userImpl.updateUser( user, passwordChangeRequired );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean userExists( String userName )
|
public boolean userExists( String userName )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -246,6 +268,7 @@ public class CachedUserManager
|
||||||
return this.userImpl.userExists( userName );
|
return this.userImpl.userExists( userName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void userManagerInit( boolean freshDatabase )
|
public void userManagerInit( boolean freshDatabase )
|
||||||
{
|
{
|
||||||
if ( userImpl instanceof UserManager )
|
if ( userImpl instanceof UserManager )
|
||||||
|
@ -256,6 +279,7 @@ public class CachedUserManager
|
||||||
usersCache.clear();
|
usersCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void userManagerUserAdded( User user )
|
public void userManagerUserAdded( User user )
|
||||||
{
|
{
|
||||||
if ( userImpl instanceof UserManager )
|
if ( userImpl instanceof UserManager )
|
||||||
|
@ -269,6 +293,7 @@ public class CachedUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void userManagerUserRemoved( User user )
|
public void userManagerUserRemoved( User user )
|
||||||
{
|
{
|
||||||
if ( userImpl instanceof UserManager )
|
if ( userImpl instanceof UserManager )
|
||||||
|
@ -282,6 +307,7 @@ public class CachedUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void userManagerUserUpdated( User user )
|
public void userManagerUserUpdated( User user )
|
||||||
{
|
{
|
||||||
if ( userImpl instanceof UserManager )
|
if ( userImpl instanceof UserManager )
|
||||||
|
@ -305,7 +331,7 @@ public class CachedUserManager
|
||||||
this.userImpl = userImpl;
|
this.userImpl = userImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cache getUsersCache()
|
public Cache<String, User> getUsersCache()
|
||||||
{
|
{
|
||||||
return usersCache;
|
return usersCache;
|
||||||
}
|
}
|
||||||
|
@ -315,16 +341,19 @@ public class CachedUserManager
|
||||||
this.usersCache = usersCache;
|
this.usersCache = usersCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
// no op configurable impl do the job
|
// no op configurable impl do the job
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isFinalImplementation()
|
public boolean isFinalImplementation()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDescriptionKey()
|
public String getDescriptionKey()
|
||||||
{
|
{
|
||||||
return "archiva.redback.usermanager.cached";
|
return "archiva.redback.usermanager.cached";
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class ConfigurableUserManager
|
||||||
private UserManager userManagerImpl;
|
private UserManager userManagerImpl;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
|
@ -66,40 +67,47 @@ public class ConfigurableUserManager
|
||||||
userManagerImpl = applicationContext.getBean( "userManager#" + userManagerRole, UserManager.class );
|
userManagerImpl = applicationContext.getBean( "userManager#" + userManagerRole, UserManager.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User addUser( User user )
|
public User addUser( User user )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.addUser( user );
|
return userManagerImpl.addUser( user );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addUserUnchecked( User user )
|
public void addUserUnchecked( User user )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
userManagerImpl.addUserUnchecked( user );
|
userManagerImpl.addUserUnchecked( user );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User createUser( String username, String fullName, String emailAddress )
|
public User createUser( String username, String fullName, String emailAddress )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.createUser( username, fullName, emailAddress );
|
return userManagerImpl.createUser( username, fullName, emailAddress );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UserQuery createUserQuery()
|
public UserQuery createUserQuery()
|
||||||
{
|
{
|
||||||
return userManagerImpl.createUserQuery();
|
return userManagerImpl.createUserQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteUser( String username )
|
public void deleteUser( String username )
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
userManagerImpl.deleteUser( username );
|
userManagerImpl.deleteUser( username );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void eraseDatabase()
|
public void eraseDatabase()
|
||||||
{
|
{
|
||||||
userManagerImpl.eraseDatabase();
|
userManagerImpl.eraseDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User findUser( String username )
|
public User findUser( String username )
|
||||||
throws UserManagerException, UserNotFoundException
|
throws UserManagerException, UserNotFoundException
|
||||||
{
|
{
|
||||||
|
@ -120,64 +128,75 @@ public class ConfigurableUserManager
|
||||||
return userManagerImpl.getGuestUser();
|
return userManagerImpl.getGuestUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.findUsersByEmailKey( emailKey, orderAscending );
|
return userManagerImpl.findUsersByEmailKey( emailKey, orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.findUsersByFullNameKey( fullNameKey, orderAscending );
|
return userManagerImpl.findUsersByFullNameKey( fullNameKey, orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findUsersByQuery( UserQuery query )
|
@Override
|
||||||
|
public List<? extends User> findUsersByQuery( UserQuery query )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.findUsersByQuery( query );
|
return userManagerImpl.findUsersByQuery( query );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.findUsersByUsernameKey( usernameKey, orderAscending );
|
return userManagerImpl.findUsersByUsernameKey( usernameKey, orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return "configurable";
|
return "configurable";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getUsers()
|
@Override
|
||||||
|
public List<? extends User> getUsers()
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.getUsers();
|
return userManagerImpl.getUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getUsers( boolean orderAscending )
|
@Override
|
||||||
|
public List<? extends User> getUsers( boolean orderAscending )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.getUsers( orderAscending );
|
return userManagerImpl.getUsers( orderAscending );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isReadOnly()
|
public boolean isReadOnly()
|
||||||
{
|
{
|
||||||
return userManagerImpl.isReadOnly();
|
return userManagerImpl.isReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User updateUser( User user )
|
public User updateUser( User user )
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
return updateUser( user, false );
|
return updateUser( user, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public User updateUser( User user, boolean passwordChangeRequired )
|
public User updateUser( User user, boolean passwordChangeRequired )
|
||||||
throws UserNotFoundException, UserManagerException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerImpl.updateUser( user, passwordChangeRequired );
|
return userManagerImpl.updateUser( user, passwordChangeRequired );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean userExists( String userName )
|
public boolean userExists( String userName )
|
||||||
throws UserManagerException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
|
@ -189,6 +208,7 @@ public class ConfigurableUserManager
|
||||||
this.userManagerImpl = userManagerImpl;
|
this.userManagerImpl = userManagerImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDescriptionKey()
|
public String getDescriptionKey()
|
||||||
{
|
{
|
||||||
return "archiva.redback.usermanager.configurable";
|
return "archiva.redback.usermanager.configurable";
|
||||||
|
|
|
@ -20,17 +20,24 @@ package org.apache.archiva.redback.users.jpa;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.redback.policy.UserSecurityPolicy;
|
import org.apache.archiva.redback.policy.UserSecurityPolicy;
|
||||||
import org.apache.archiva.redback.users.*;
|
import org.apache.archiva.redback.users.AbstractUserManager;
|
||||||
|
import org.apache.archiva.redback.users.Messages;
|
||||||
|
import org.apache.archiva.redback.users.PermanentUserException;
|
||||||
|
import org.apache.archiva.redback.users.User;
|
||||||
|
import org.apache.archiva.redback.users.UserManagerException;
|
||||||
|
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||||
|
import org.apache.archiva.redback.users.UserQuery;
|
||||||
import org.apache.archiva.redback.users.jpa.model.JpaUser;
|
import org.apache.archiva.redback.users.jpa.model.JpaUser;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.*;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.NoResultException;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.PersistenceContext;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import javax.persistence.TypedQuery;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
@ -91,17 +98,17 @@ public class JpaUserManager extends AbstractUserManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUsers() throws UserManagerException {
|
public List<? extends User> getUsers() throws UserManagerException {
|
||||||
final EntityManager em = getEm();
|
final EntityManager em = getEm();
|
||||||
Query q= em.createQuery("SELECT x from JpaUser x");
|
TypedQuery<JpaUser> q= em.createQuery("SELECT x from JpaUser x", JpaUser.class);
|
||||||
return q.getResultList();
|
return q.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUsers(boolean orderAscending) throws UserManagerException {
|
public List<? extends User> getUsers(boolean orderAscending) throws UserManagerException {
|
||||||
final EntityManager em = getEm();
|
final EntityManager em = getEm();
|
||||||
final String orderFlag = orderAscending ? "ASC" : "DESC";
|
final String orderFlag = orderAscending ? "ASC" : "DESC";
|
||||||
Query q = em.createQuery("SELECT u FROM JpaUser u ORDER BY u.username "+orderFlag);
|
TypedQuery<JpaUser> q = em.createQuery("SELECT u FROM JpaUser u ORDER BY u.username "+orderFlag, JpaUser.class);
|
||||||
return q.getResultList();
|
return q.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,18 +147,18 @@ public class JpaUserManager extends AbstractUserManager {
|
||||||
if (user.getLastPasswordChange()==null) {
|
if (user.getLastPasswordChange()==null) {
|
||||||
user.setLastPasswordChange(new Date());
|
user.setLastPasswordChange(new Date());
|
||||||
}
|
}
|
||||||
em.persist((JpaUser)user);
|
em.persist( user );
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public User updateUser(User user) throws UserNotFoundException, UserManagerException {
|
public User updateUser(User user) throws UserManagerException {
|
||||||
return updateUser(user, false);
|
return updateUser(user, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User findUser(String username) throws UserNotFoundException, UserManagerException {
|
public User findUser(String username) throws UserManagerException {
|
||||||
if (username==null) {
|
if (username==null) {
|
||||||
throw new UserNotFoundException("Username was <null>");
|
throw new UserNotFoundException("Username was <null>");
|
||||||
}
|
}
|
||||||
|
@ -168,30 +175,30 @@ public class JpaUserManager extends AbstractUserManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User findUser(String username, boolean useCache) throws UserNotFoundException, UserManagerException {
|
public User findUser(String username, boolean useCache) throws UserManagerException {
|
||||||
return findUser(username);
|
return findUser(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByUsernameKey(String usernameKey, boolean orderAscending) throws UserManagerException {
|
public List<? extends User> findUsersByUsernameKey(String usernameKey, boolean orderAscending) throws UserManagerException {
|
||||||
return findUsers("username",usernameKey,"username",orderAscending);
|
return findUsers("username",usernameKey,"username",orderAscending);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByFullNameKey(String fullNameKey, boolean orderAscending) throws UserManagerException {
|
public List<? extends User> findUsersByFullNameKey(String fullNameKey, boolean orderAscending) throws UserManagerException {
|
||||||
return findUsers("fullName",fullNameKey,"username",orderAscending);
|
return findUsers("fullName",fullNameKey,"username",orderAscending);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByEmailKey(String emailKey, boolean orderAscending) throws UserManagerException {
|
public List<? extends User> findUsersByEmailKey(String emailKey, boolean orderAscending) throws UserManagerException {
|
||||||
return findUsers("email",emailKey,"username", orderAscending);
|
return findUsers("email",emailKey,"username", orderAscending);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByQuery(final UserQuery queryParam) throws UserManagerException {
|
public List<? extends User> findUsersByQuery(final UserQuery queryParam) throws UserManagerException {
|
||||||
final EntityManager em = getEm();
|
final EntityManager em = getEm();
|
||||||
final JpaUserQuery query = (JpaUserQuery)queryParam;
|
final JpaUserQuery query = (JpaUserQuery)queryParam;
|
||||||
String orderByAttribute = "";
|
String orderByAttribute;
|
||||||
if (UserQuery.ORDER_BY_EMAIL.equals(query.getOrderBy())) {
|
if (UserQuery.ORDER_BY_EMAIL.equals(query.getOrderBy())) {
|
||||||
orderByAttribute="email";
|
orderByAttribute="email";
|
||||||
} else if (UserQuery.ORDER_BY_FULLNAME.equals(query.getOrderBy())) {
|
} else if (UserQuery.ORDER_BY_FULLNAME.equals(query.getOrderBy())) {
|
||||||
|
@ -240,7 +247,7 @@ public class JpaUserManager extends AbstractUserManager {
|
||||||
return q.getResultList();
|
return q.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<User> findUsers(final String attribute, final String pattern,
|
private List<? extends User> findUsers(final String attribute, final String pattern,
|
||||||
final String orderAttribute, final boolean orderAscending) {
|
final String orderAttribute, final boolean orderAscending) {
|
||||||
final EntityManager em = getEm();
|
final EntityManager em = getEm();
|
||||||
StringBuilder sb = new StringBuilder("SELECT u FROM JpaUser u WHERE LOWER(u.");
|
StringBuilder sb = new StringBuilder("SELECT u FROM JpaUser u WHERE LOWER(u.");
|
||||||
|
@ -262,7 +269,7 @@ public class JpaUserManager extends AbstractUserManager {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteUser(String username) throws UserNotFoundException, UserManagerException {
|
public void deleteUser(String username) throws UserManagerException {
|
||||||
final EntityManager em = getEm();
|
final EntityManager em = getEm();
|
||||||
User u = findUser(username);
|
User u = findUser(username);
|
||||||
if (u.isPermanent()) {
|
if (u.isPermanent()) {
|
||||||
|
@ -293,7 +300,7 @@ public class JpaUserManager extends AbstractUserManager {
|
||||||
log.info("USER FOUND: "+u.getUsername());
|
log.info("USER FOUND: "+u.getUsername());
|
||||||
}
|
}
|
||||||
log.info("NEW USER "+user.getUsername());
|
log.info("NEW USER "+user.getUsername());
|
||||||
em.persist((JpaUser)user);
|
em.persist( user );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +321,7 @@ public class JpaUserManager extends AbstractUserManager {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public User updateUser(User user, boolean passwordChangeRequired) throws UserNotFoundException, UserManagerException {
|
public User updateUser(User user, boolean passwordChangeRequired) throws UserManagerException {
|
||||||
if ( !( user instanceof JpaUser ) )
|
if ( !( user instanceof JpaUser ) )
|
||||||
{
|
{
|
||||||
throw new UserManagerException( "Unable to update user. User object " + user.getClass().getName() +
|
throw new UserManagerException( "Unable to update user. User object " + user.getClass().getName() +
|
||||||
|
|
|
@ -19,34 +19,16 @@ package org.apache.archiva.redback.users.jpa;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.redback.policy.UserSecurityPolicy;
|
|
||||||
import org.apache.archiva.redback.users.User;
|
|
||||||
import org.apache.archiva.redback.users.UserManager;
|
import org.apache.archiva.redback.users.UserManager;
|
||||||
import org.apache.archiva.redback.users.UserManagerException;
|
|
||||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
|
||||||
import org.apache.archiva.redback.users.jpa.model.JpaUser;
|
|
||||||
import org.apache.archiva.redback.users.provider.test.AbstractUserManagerTestCase;
|
import org.apache.archiva.redback.users.provider.test.AbstractUserManagerTestCase;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
import org.springframework.test.context.transaction.TransactionConfiguration;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.persistence.EntityManagerFactory;
|
|
||||||
import javax.persistence.Persistence;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -63,12 +45,6 @@ public class JpaUserManagerTest extends AbstractUserManagerTestCase {
|
||||||
@Named("userManager#jpa")
|
@Named("userManager#jpa")
|
||||||
UserManager jpaUserManager;
|
UserManager jpaUserManager;
|
||||||
|
|
||||||
@Inject
|
|
||||||
EntityManagerFactory entityManagerFactory;
|
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private UserSecurityPolicy securityPolicy;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,14 +19,21 @@ package org.apache.archiva.redback.users.ldap.ctl;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Collection;
|
import org.apache.archiva.redback.common.ldap.MappingException;
|
||||||
import java.util.HashMap;
|
import org.apache.archiva.redback.common.ldap.user.LdapUser;
|
||||||
import java.util.HashSet;
|
import org.apache.archiva.redback.common.ldap.user.LdapUserMapper;
|
||||||
import java.util.LinkedHashSet;
|
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
||||||
import java.util.LinkedList;
|
import org.apache.archiva.redback.configuration.UserConfiguration;
|
||||||
import java.util.List;
|
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
|
||||||
import java.util.Map;
|
import org.apache.archiva.redback.policy.PasswordEncoder;
|
||||||
import java.util.Set;
|
import org.apache.archiva.redback.policy.encoders.SHA1PasswordEncoder;
|
||||||
|
import org.apache.archiva.redback.users.User;
|
||||||
|
import org.apache.archiva.redback.users.UserManager;
|
||||||
|
import org.apache.archiva.redback.users.ldap.LdapUserQuery;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -40,22 +47,14 @@ import javax.naming.directory.BasicAttributes;
|
||||||
import javax.naming.directory.DirContext;
|
import javax.naming.directory.DirContext;
|
||||||
import javax.naming.directory.SearchControls;
|
import javax.naming.directory.SearchControls;
|
||||||
import javax.naming.directory.SearchResult;
|
import javax.naming.directory.SearchResult;
|
||||||
|
import java.util.Collection;
|
||||||
import org.apache.archiva.redback.common.ldap.user.LdapUser;
|
import java.util.HashMap;
|
||||||
import org.apache.archiva.redback.common.ldap.user.LdapUserMapper;
|
import java.util.HashSet;
|
||||||
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
import java.util.LinkedHashSet;
|
||||||
import org.apache.archiva.redback.configuration.UserConfiguration;
|
import java.util.LinkedList;
|
||||||
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
|
import java.util.List;
|
||||||
import org.apache.archiva.redback.policy.PasswordEncoder;
|
import java.util.Map;
|
||||||
import org.apache.archiva.redback.policy.encoders.SHA1PasswordEncoder;
|
import java.util.Set;
|
||||||
import org.apache.archiva.redback.users.User;
|
|
||||||
import org.apache.archiva.redback.users.UserManager;
|
|
||||||
import org.apache.archiva.redback.common.ldap.MappingException;
|
|
||||||
import org.apache.archiva.redback.users.ldap.LdapUserQuery;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jesse
|
* @author jesse
|
||||||
|
@ -420,10 +419,10 @@ public class DefaultLdapController
|
||||||
|
|
||||||
if ( uniqueMemberAttr != null )
|
if ( uniqueMemberAttr != null )
|
||||||
{
|
{
|
||||||
NamingEnumeration<String> allMembersEnum = (NamingEnumeration<String>) uniqueMemberAttr.getAll();
|
NamingEnumeration<?> allMembersEnum = uniqueMemberAttr.getAll();
|
||||||
while ( allMembersEnum.hasMore() )
|
while ( allMembersEnum.hasMore() )
|
||||||
{
|
{
|
||||||
String userName = allMembersEnum.next();
|
String userName = allMembersEnum.next().toString();
|
||||||
// uid=blabla we only want bla bla
|
// uid=blabla we only want bla bla
|
||||||
userName = StringUtils.substringAfter( userName, "=" );
|
userName = StringUtils.substringAfter( userName, "=" );
|
||||||
userName = StringUtils.substringBefore( userName, "," );
|
userName = StringUtils.substringBefore( userName, "," );
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class LdapUserManagerTest
|
||||||
|
|
||||||
//assertNotNull( ldapCacheService.getUser( "jesse" ) );
|
//assertNotNull( ldapCacheService.getUser( "jesse" ) );
|
||||||
|
|
||||||
List<User> users = userManager.getUsers();
|
List<? extends User> users = userManager.getUsers();
|
||||||
|
|
||||||
assertNotNull( users );
|
assertNotNull( users );
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ public class LdapUserManagerTest
|
||||||
|
|
||||||
assertTrue( userManager.userExists( "user10" ) );
|
assertTrue( userManager.userExists( "user10" ) );
|
||||||
|
|
||||||
List<User> users = userManager.getUsers();
|
List<? extends User> users = userManager.getUsers();
|
||||||
|
|
||||||
assertNotNull( users );
|
assertNotNull( users );
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ public class AbstractUserManagerTestCase
|
||||||
// Query with default ordering ascending
|
// Query with default ordering ascending
|
||||||
query = um.createUserQuery();
|
query = um.createUserQuery();
|
||||||
query.setOrderBy( UserQuery.ORDER_BY_EMAIL );
|
query.setOrderBy( UserQuery.ORDER_BY_EMAIL );
|
||||||
List<User> users = um.findUsersByQuery( query );
|
List<? extends User> users = um.findUsersByQuery( query );
|
||||||
assertEquals( 3, users.size() );
|
assertEquals( 3, users.size() );
|
||||||
assertEquals( "admin@somedomain.com", ( (User) users.get( 0 ) ).getEmail() );
|
assertEquals( "admin@somedomain.com", ( (User) users.get( 0 ) ).getEmail() );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue