adapt to last changes in spring-jdo2 component

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1417087 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-04 18:20:19 +00:00
parent 7878eec5cb
commit b890cd1b97
3 changed files with 33 additions and 34 deletions

View File

@ -392,7 +392,7 @@
<dependency> <dependency>
<groupId>org.apache.archiva.redback.components</groupId> <groupId>org.apache.archiva.redback.components</groupId>
<artifactId>spring-jdo2</artifactId> <artifactId>spring-jdo2</artifactId>
<version>2.0</version> <version>2.1-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>xerces</groupId> <groupId>xerces</groupId>

View File

@ -20,9 +20,9 @@
*/ */
import org.apache.archiva.redback.components.jdo.JdoFactory; import org.apache.archiva.redback.components.jdo.JdoFactory;
import org.apache.archiva.redback.components.jdo.PlexusJdoUtils; import org.apache.archiva.redback.components.jdo.RedbackJdoUtils;
import org.apache.archiva.redback.components.jdo.PlexusObjectNotFoundException; import org.apache.archiva.redback.components.jdo.RedbackObjectNotFoundException;
import org.apache.archiva.redback.components.jdo.PlexusStoreException; import org.apache.archiva.redback.components.jdo.RedbackStoreException;
import org.apache.archiva.redback.keys.AuthenticationKey; import org.apache.archiva.redback.keys.AuthenticationKey;
import org.apache.archiva.redback.keys.AbstractKeyManager; import org.apache.archiva.redback.keys.AbstractKeyManager;
import org.apache.archiva.redback.keys.KeyManagerException; import org.apache.archiva.redback.keys.KeyManagerException;
@ -78,13 +78,13 @@ public AuthenticationKey createKey( String principal, String purpose, int expira
public AuthenticationKey addKey( AuthenticationKey key ) public AuthenticationKey addKey( AuthenticationKey key )
{ {
return (AuthenticationKey) PlexusJdoUtils.addObject( getPersistenceManager(), key ); return (AuthenticationKey) RedbackJdoUtils.addObject( getPersistenceManager(), key );
} }
public void eraseDatabase() public void eraseDatabase()
{ {
PlexusJdoUtils.removeAll( getPersistenceManager(), JdoAuthenticationKey.class ); RedbackJdoUtils.removeAll( getPersistenceManager(), JdoAuthenticationKey.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), RedbackKeyManagementJdoModelloMetadata.class ); RedbackJdoUtils.removeAll( getPersistenceManager(), RedbackKeyManagementJdoModelloMetadata.class );
} }
public AuthenticationKey findKey( String key ) public AuthenticationKey findKey( String key )
@ -97,9 +97,8 @@ public AuthenticationKey findKey( String key )
try try
{ {
JdoAuthenticationKey authkey = (JdoAuthenticationKey) PlexusJdoUtils.getObjectById( getPersistenceManager(), JdoAuthenticationKey authkey = (JdoAuthenticationKey) RedbackJdoUtils.getObjectById(
JdoAuthenticationKey.class, getPersistenceManager(), JdoAuthenticationKey.class, key );
key );
if ( authkey == null ) if ( authkey == null )
{ {
@ -109,11 +108,11 @@ public AuthenticationKey findKey( String key )
return authkey; return authkey;
} }
catch ( PlexusObjectNotFoundException e ) catch ( RedbackObjectNotFoundException e )
{ {
throw new KeyNotFoundException( e.getMessage() ); throw new KeyNotFoundException( e.getMessage() );
} }
catch ( PlexusStoreException e ) catch ( RedbackStoreException e )
{ {
throw new KeyManagerException( throw new KeyManagerException(
"Unable to get " + JdoAuthenticationKey.class.getName() + "', key '" + key + "' from jdo store." ); "Unable to get " + JdoAuthenticationKey.class.getName() + "', key '" + key + "' from jdo store." );
@ -123,7 +122,7 @@ public AuthenticationKey findKey( String key )
public void deleteKey( AuthenticationKey authkey ) public void deleteKey( AuthenticationKey authkey )
throws KeyManagerException throws KeyManagerException
{ {
PlexusJdoUtils.removeObject( getPersistenceManager(), authkey ); RedbackJdoUtils.removeObject( getPersistenceManager(), authkey );
} }
public void deleteKey( String key ) public void deleteKey( String key )
@ -132,7 +131,7 @@ public void deleteKey( String key )
try try
{ {
AuthenticationKey authkey = findKey( key ); AuthenticationKey authkey = findKey( key );
PlexusJdoUtils.removeObject( getPersistenceManager(), authkey ); RedbackJdoUtils.removeObject( getPersistenceManager(), authkey );
} }
catch ( KeyNotFoundException e ) catch ( KeyNotFoundException e )
{ {
@ -143,7 +142,7 @@ public void deleteKey( String key )
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
public List<AuthenticationKey> getAllKeys() public List<AuthenticationKey> getAllKeys()
{ {
return PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), JdoAuthenticationKey.class ); return RedbackJdoUtils.getAllObjectsDetached( getPersistenceManager(), JdoAuthenticationKey.class );
} }
@PostConstruct @PostConstruct

View File

@ -20,9 +20,9 @@
*/ */
import org.apache.archiva.redback.components.jdo.JdoFactory; import org.apache.archiva.redback.components.jdo.JdoFactory;
import org.apache.archiva.redback.components.jdo.PlexusJdoUtils; import org.apache.archiva.redback.components.jdo.RedbackJdoUtils;
import org.apache.archiva.redback.components.jdo.PlexusObjectNotFoundException; import org.apache.archiva.redback.components.jdo.RedbackObjectNotFoundException;
import org.apache.archiva.redback.components.jdo.PlexusStoreException; import org.apache.archiva.redback.components.jdo.RedbackStoreException;
import org.apache.archiva.redback.policy.UserSecurityPolicy; import org.apache.archiva.redback.policy.UserSecurityPolicy;
import org.apache.archiva.redback.users.AbstractUserManager; import org.apache.archiva.redback.users.AbstractUserManager;
import org.apache.archiva.redback.users.PermanentUserException; import org.apache.archiva.redback.users.PermanentUserException;
@ -107,7 +107,7 @@ public List<User> getUsers( boolean orderAscending )
@SuppressWarnings ("unchecked") @SuppressWarnings ("unchecked")
private List<User> getAllObjectsDetached( String ordering ) private List<User> getAllObjectsDetached( String ordering )
{ {
return PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), JdoUser.class, ordering, (String) null ); return RedbackJdoUtils.getAllObjectsDetached( getPersistenceManager(), JdoUser.class, ordering, (String) null );
} }
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending ) public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
@ -276,7 +276,7 @@ public void deleteUser( String username )
fireUserManagerUserRemoved( user ); fireUserManagerUserRemoved( user );
PlexusJdoUtils.removeObject( getPersistenceManager(), user ); RedbackJdoUtils.removeObject( getPersistenceManager(), user );
} }
catch ( UserNotFoundException e ) catch ( UserNotFoundException e )
{ {
@ -303,8 +303,8 @@ public void addUserUnchecked( User user )
public void eraseDatabase() public void eraseDatabase()
{ {
PlexusJdoUtils.removeAll( getPersistenceManager(), JdoUser.class ); RedbackJdoUtils.removeAll( getPersistenceManager(), JdoUser.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), UsersManagementModelloMetadata.class ); RedbackJdoUtils.removeAll( getPersistenceManager(), UsersManagementModelloMetadata.class );
} }
public User findUser( Object principal ) public User findUser( Object principal )
@ -317,14 +317,14 @@ public User findUser( Object principal )
try try
{ {
return (User) PlexusJdoUtils.getObjectById( getPersistenceManager(), JdoUser.class, principal.toString(), return (User) RedbackJdoUtils.getObjectById( getPersistenceManager(), JdoUser.class, principal.toString(),
null ); null );
} }
catch ( PlexusObjectNotFoundException e ) catch ( RedbackObjectNotFoundException e )
{ {
throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e ); throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e );
} }
catch ( PlexusStoreException e ) catch ( RedbackStoreException e )
{ {
throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e ); throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e );
} }
@ -407,7 +407,7 @@ public PersistenceManager getPersistenceManager()
private Object addObject( Object object ) private Object addObject( Object object )
{ {
return PlexusJdoUtils.addObject( getPersistenceManager(), object ); return RedbackJdoUtils.addObject( getPersistenceManager(), object );
} }
private Object getObjectById( String id, String fetchGroup ) private Object getObjectById( String id, String fetchGroup )
@ -415,13 +415,13 @@ private Object getObjectById( String id, String fetchGroup )
{ {
try try
{ {
return PlexusJdoUtils.getObjectById( getPersistenceManager(), JdoUser.class, id, fetchGroup ); return RedbackJdoUtils.getObjectById( getPersistenceManager(), JdoUser.class, id, fetchGroup );
} }
catch ( PlexusObjectNotFoundException e ) catch ( RedbackObjectNotFoundException e )
{ {
throw new UserNotFoundException( e.getMessage() ); throw new UserNotFoundException( e.getMessage() );
} }
catch ( PlexusStoreException e ) catch ( RedbackStoreException e )
{ {
throw new UserManagerException( "Unable to get object '" + JdoUser.class.getName() + "', id '" + id + throw new UserManagerException( "Unable to get object '" + JdoUser.class.getName() + "', id '" + id +
"', fetch-group '" + fetchGroup + "' from jdo store.", e ); "', fetch-group '" + fetchGroup + "' from jdo store.", e );
@ -435,7 +435,7 @@ private Object removeObject( Object o )
throw new UserManagerException( "Unable to remove null object" ); throw new UserManagerException( "Unable to remove null object" );
} }
PlexusJdoUtils.removeObject( getPersistenceManager(), o ); RedbackJdoUtils.removeObject( getPersistenceManager(), o );
return o; return o;
} }
@ -444,9 +444,9 @@ private Object updateObject( Object object )
{ {
try try
{ {
return PlexusJdoUtils.updateObject( getPersistenceManager(), object ); return RedbackJdoUtils.updateObject( getPersistenceManager(), object );
} }
catch ( PlexusStoreException e ) catch ( RedbackStoreException e )
{ {
throw new UserManagerException( throw new UserManagerException(
"Unable to update the '" + object.getClass().getName() + "' object in the jdo database.", e ); "Unable to update the '" + object.getClass().getName() + "' object in the jdo database.", e );
@ -455,7 +455,7 @@ private Object updateObject( Object object )
private void rollback( Transaction tx ) private void rollback( Transaction tx )
{ {
PlexusJdoUtils.rollbackIfActive( tx ); RedbackJdoUtils.rollbackIfActive( tx );
} }
private boolean hasTriggeredInit = false; private boolean hasTriggeredInit = false;