* @see #resolutionSuccess(VersionedReference, ProjectModelResolver, ArchivaProjectModel)
* @see #resolutionNotFound(VersionedReference, List)
*/
- public void resolutionStart( VersionedReference projectRef, List resolverList );
+ public void resolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolverList );
/**
* Indicates that a resolution against a specific resolver is about
* @param resolverList the {@link List} of {@link ProjectModelResolver}'s that was be searched.
* @see #resolutionStart(VersionedReference, List)
*/
- public void resolutionNotFound( VersionedReference projectRef, List resolverList );
+ public void resolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolverList );
}
* @param constraint the constraint to use.
* @return the List of results.
*/
- List query( SimpleConstraint constraint );
+ List<?> query( SimpleConstraint constraint );
/**
* Perform a simple save of a peristable object to the database.
*/
public interface RepositoryContentStatisticsDAO
{
- public List queryRepositoryContentStatistics( Constraint constraint )
+ public List<RepositoryContentStatistics> queryRepositoryContentStatistics( Constraint constraint )
throws ObjectNotFoundException, ArchivaDatabaseException;
public RepositoryContentStatistics saveRepositoryContentStatistics( RepositoryContentStatistics stats );
*
* @return the result class.
*/
- public Class getResultClass();
+ public Class<?> getResultClass();
/**
* When working with result classes that are not persistable,
/**
* @see RepositoryBrowsing#getRoot(String, List)
*/
+ @SuppressWarnings("unchecked")
public BrowsingResults getRoot( final String principal, final List<String> observableRepositoryIds )
{
final BrowsingResults results = new BrowsingResults();
if ( !observableRepositoryIds.isEmpty() )
{
- final List<String> groups = dao.query( new UniqueGroupIdConstraint( observableRepositoryIds ) );
+ final List<String> groups = (List<String>) dao.query( new UniqueGroupIdConstraint( observableRepositoryIds ) );
results.setSelectedRepositoryIds( observableRepositoryIds );
results.setGroupIds( GroupIdFilter.filterGroups( groups ) );
}
/**
* @see RepositoryBrowsing#selectArtifactId(String, List, String, String)
*/
+ @SuppressWarnings("unchecked")
public BrowsingResults selectArtifactId( final String principal, final List<String> observableRepositoryIds,
final String groupId, final String artifactId )
{
{
// NOTE: No group Id or artifact Id's should be returned here.
List<String> versions =
- dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) );
+ (List<String>) dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) );
results.setSelectedRepositoryIds( observableRepositoryIds );
results.setVersions( processSnapshots( versions ) );
/**
* @see RepositoryBrowsing#selectGroupId(String, List, String)
*/
+ @SuppressWarnings("unchecked")
public BrowsingResults selectGroupId( final String principal, final List<String> observableRepositoryIds,
final String groupId )
{
if ( !observableRepositoryIds.isEmpty() )
{
- final List<String> groups = dao.query( new UniqueGroupIdConstraint( observableRepositoryIds, groupId ) );
+ final List<String> groups = (List<String>) dao.query( new UniqueGroupIdConstraint( observableRepositoryIds, groupId ) );
final List<String> artifacts =
- dao.query( new UniqueArtifactIdConstraint( observableRepositoryIds, groupId ) );
+ (List<String>) dao.query( new UniqueArtifactIdConstraint( observableRepositoryIds, groupId ) );
// Remove searched for groupId from groups list.
// Easier to do this here, vs doing it in the SQL query.
/**
* @see RepositoryBrowsing#getOtherSnapshotVersions(List, String, String, String)
*/
+ @SuppressWarnings("unchecked")
public List<String> getOtherSnapshotVersions( List<String> observableRepositoryIds, String groupId,
String artifactId, String version )
throws ObjectNotFoundException, ArchivaDatabaseException
if ( VersionUtil.isSnapshot( version ) )
{
List<String> versions =
- dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) );
+ (List<String>) dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) );
for ( String uniqueVersion : versions )
{
if ( results == null )
{
// defensive. to honor contract as specified. never null.
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return results;
* @param pomArtifact
* @throws ArchivaDatabaseException
*/
+ @SuppressWarnings("unchecked")
private ArchivaArtifact handleGenericSnapshots( final String groupId, final String artifactId,
final String version, final String repositoryId )
throws ArchivaDatabaseException
if ( VersionUtil.isGenericSnapshot( version ) )
{
- final List<String> versions = dao.query( new UniqueVersionConstraint( groupId, artifactId ) );
+ final List<String> versions = (List<String>) dao.query( new UniqueVersionConstraint( groupId, artifactId ) );
Collections.sort( versions );
Collections.reverse( versions );
super.params = new Object[]{repoId};
}
- public Class getResultClass()
+ public Class<?> getResultClass()
{
return RepositoryContentStatistics.class;
}
{
private StringBuffer sql = new StringBuffer();
- private Class resultClass;
+ private Class<?> resultClass;
/**
* Obtain a set of unique ArtifactIds for the specified groupId.
super.params = new Object[]{fieldNamePrefix};
}
- public Class getResultClass()
+ public Class<?> getResultClass()
{
return String.class;
}
return pm;
}
- public void enableCache( Class clazz )
+ public void enableCache( Class<?> clazz )
{
DataStoreCache cache = pmf.getDataStoreCache();
cache.pinAll( clazz, false ); // Pin all objects of type clazz from now on
}
}
- public List getAllObjects( Class clazz )
+ public List<?> getAllObjects( Class<?> clazz )
{
return queryObjects( clazz, null );
}
- public List queryObjects( Class clazz, Constraint constraint )
+ public List<?> queryObjects( Class<?> clazz, Constraint constraint )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
{
tx.begin();
- List result = null;
+ List<?> result = null;
if ( constraint != null )
{
result = processUnconstrained( pm, clazz );
}
- result = (List) pm.detachCopyAll( result );
+ result = (List<?>) pm.detachCopyAll( result );
tx.commit();
}
}
- public List queryObjects( SimpleConstraint constraint )
+ public List<?> queryObjects( SimpleConstraint constraint )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
{
tx.begin();
- List result = processConstraint( pm, constraint );
+ List<?> result = processConstraint( pm, constraint );
// Only detach if results are known to be persistable.
if ( constraint.isResultsPersistable() )
{
- result = (List) pm.detachCopyAll( result );
+ result = (List<?>) pm.detachCopyAll( result );
}
else
{
- List copiedResults = new ArrayList();
+ List<Object> copiedResults = new ArrayList<Object>();
copiedResults.addAll( result );
result = copiedResults;
}
}
}
- private List processUnconstrained( PersistenceManager pm, Class clazz )
+ private List<?> processUnconstrained( PersistenceManager pm, Class<?> clazz )
{
Extent extent = pm.getExtent( clazz, true );
Query query = pm.newQuery( extent );
- return (List) query.execute();
+ return (List<?>) query.execute();
}
- private List processConstraint( PersistenceManager pm, SimpleConstraint constraint )
+ private List<?> processConstraint( PersistenceManager pm, SimpleConstraint constraint )
{
Query query = pm.newQuery( constraint.getSelectSql() );
return processParameterizedQuery( query, constraint.getParameters() );
}
- return (List) query.execute();
+ return (List<?>) query.execute();
}
- private List processConstraint( PersistenceManager pm, Class clazz, DeclarativeConstraint constraint )
+ private List<?> processConstraint( PersistenceManager pm, Class<?> clazz, DeclarativeConstraint constraint )
{
Extent extent = pm.getExtent( clazz, true );
Query query = pm.newQuery( extent );
}
else
{
- return (List) query.execute();
+ return (List<?>) query.execute();
}
}
- private List processParameterizedQuery( Query query, Object parameters[] )
+ private List<?> processParameterizedQuery( Query query, Object parameters[] )
{
switch ( parameters.length )
{
case 1:
- return (List) query.execute( parameters[0] );
+ return (List<?>) query.execute( parameters[0] );
case 2:
- return (List) query.execute( parameters[0], parameters[1] );
+ return (List<?>) query.execute( parameters[0], parameters[1] );
case 3:
- return (List) query.execute( parameters[0], parameters[1], parameters[2] );
+ return (List<?>) query.execute( parameters[0], parameters[1], parameters[2] );
default:
throw new JDOException( "Unable to use more than 3 parameters." );
}
}
- public Object getObjectById( Class clazz, Object id, String fetchGroup )
+ public Object getObjectById( Class<?> clazz, Object id, String fetchGroup )
throws ObjectNotFoundException, ArchivaDatabaseException
{
if ( id == null )
}
}
- public Object getObjectById( Class clazz, String id, String fetchGroup )
+ public Object getObjectById( Class<?> clazz, String id, String fetchGroup )
throws ObjectNotFoundException, ArchivaDatabaseException
{
if ( StringUtils.isEmpty( id ) )
return ( JDOHelper.getObjectId( object ) != null );
}
- public boolean objectExistsById( Class clazz, String id )
+ public boolean objectExistsById( Class<?> clazz, String id )
throws ArchivaDatabaseException
{
try
{
if ( o == null )
{
- throw new ArchivaDatabaseException( "Unable to remove null object '" + o.getClass().getName() + "'" );
+ throw new ArchivaDatabaseException( "Unable to remove null object" );
}
PersistenceManager pm = getPersistenceManager();
// ignore
}
- public void removeAll( Class aClass )
+ public void removeAll( Class<?> aClass )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
private RepositoryContentStatisticsDAO repositoryContentStatisticsDAO;
- public List query( SimpleConstraint constraint )
+ public List<?> query( SimpleConstraint constraint )
{
return jdo.queryObjects( constraint );
}
* under the License.
*/
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.maven.archiva.database.ArchivaDatabaseException;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.Constraint;
import org.apache.maven.archiva.model.ArchivaArtifactModel;
import org.apache.maven.archiva.model.jpox.ArchivaArtifactModelKey;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
/**
* JdoArtifactDAO
*
return new ArchivaArtifact( model );
}
- public List queryArtifacts( Constraint constraint )
+ @SuppressWarnings("unchecked")
+ public List<ArchivaArtifact> queryArtifacts( Constraint constraint )
throws ObjectNotFoundException, ArchivaDatabaseException
{
- List results = jdo.queryObjects( ArchivaArtifactModel.class, constraint );
- if ( ( results == null ) || results.isEmpty() )
+ List<ArchivaArtifactModel> results = (List<ArchivaArtifactModel>) jdo.queryObjects( ArchivaArtifactModel.class, constraint );
+ if ( results == null )
{
- return results;
+ return null;
}
- List ret = new ArrayList();
- Iterator it = results.iterator();
- while ( it.hasNext() )
+ List<ArchivaArtifact> ret = new ArrayList<ArchivaArtifact>();
+ for ( ArchivaArtifactModel model : results )
{
- ArchivaArtifactModel model = (ArchivaArtifactModel) it.next();
ret.add( new ArchivaArtifact( model ) );
}
return (ArchivaProjectModel) jdo.getObjectById( ArchivaProjectModel.class, key, null );
}
+ @SuppressWarnings("unchecked")
public List<ArchivaProjectModel> queryProjectModels( Constraint constraint )
throws ObjectNotFoundException, ArchivaDatabaseException
{
- return jdo.queryObjects( ArchivaProjectModel.class, constraint );
+ return (List<ArchivaProjectModel>) jdo.queryObjects( ArchivaProjectModel.class, constraint );
}
public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model )
jdo.removeObject( stats );
}
- public List queryRepositoryContentStatistics( Constraint constraint )
+ @SuppressWarnings("unchecked")
+ public List<RepositoryContentStatistics> queryRepositoryContentStatistics( Constraint constraint )
throws ObjectNotFoundException, ArchivaDatabaseException
{
- List results = jdo.queryObjects( RepositoryContentStatistics.class, constraint );
-
- return results;
+ return (List<RepositoryContentStatistics>) jdo.queryObjects( RepositoryContentStatistics.class, constraint );
}
public RepositoryContentStatistics saveRepositoryContentStatistics( RepositoryContentStatistics stats )
*/
private JdoAccess jdo;
- public List queryRepositoryProblems( Constraint constraint )
+ @SuppressWarnings("unchecked")
+ public List<RepositoryProblem> queryRepositoryProblems( Constraint constraint )
throws ObjectNotFoundException, ArchivaDatabaseException
{
- return jdo.queryObjects( RepositoryProblem.class, constraint );
+ return (List<RepositoryProblem>) jdo.queryObjects( RepositoryProblem.class, constraint );
}
public RepositoryProblem saveRepositoryProblem( RepositoryProblem problem )
/* do nothing */
}
- public void resolutionNotFound( VersionedReference projectRef, List resolverList )
+ public void resolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolverList )
{
/* do nothing */
}
- public void resolutionStart( VersionedReference projectRef, List resolverList )
+ public void resolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolverList )
{
/* do nothing */
}
* under the License.
*/
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.functors.OrPredicate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
/**
* DatabaseConsumers
*
*
* @return the list of selected {@link DatabaseUnprocessedArtifactConsumer} objects.
*/
- public List getSelectedUnprocessedConsumers()
+ @SuppressWarnings("unchecked")
+ public List<ArchivaArtifactConsumer> getSelectedUnprocessedConsumers()
{
- List ret = new ArrayList();
+ List<ArchivaArtifactConsumer> ret = new ArrayList<ArchivaArtifactConsumer>();
ret.addAll( CollectionUtils.select( getAvailableUnprocessedConsumers(), selectedUnprocessedConsumers ) );
return ret;
}
*
* @return the list of selected {@link DatabaseCleanupConsumer} objects.
*/
- public List getSelectedCleanupConsumers()
+ @SuppressWarnings("unchecked")
+ public List<ArchivaArtifactConsumer> getSelectedCleanupConsumers()
{
- List ret = new ArrayList();
+ List<ArchivaArtifactConsumer> ret = new ArrayList<ArchivaArtifactConsumer>();
ret.addAll( CollectionUtils.select( getAvailableCleanupConsumers(), selectedCleanupConsumers ) );
return ret;
}
*
* @return the list of all available {@link DatabaseUnprocessedArtifactConsumer} objects.
*/
- public List getAvailableUnprocessedConsumers()
+ @SuppressWarnings("unchecked")
+ public List<DatabaseUnprocessedArtifactConsumer> getAvailableUnprocessedConsumers()
{
- return new ArrayList( applicationContext.getBeansOfType( DatabaseUnprocessedArtifactConsumer.class ).values() );
+ return new ArrayList<DatabaseUnprocessedArtifactConsumer>( applicationContext.getBeansOfType( DatabaseUnprocessedArtifactConsumer.class ).values() );
}
/**
*
* @return the list of all available {@link DatabaseCleanupConsumer} objects.
*/
- public List getAvailableCleanupConsumers()
+ @SuppressWarnings("unchecked")
+ public List<DatabaseCleanupConsumer> getAvailableCleanupConsumers()
{
- return new ArrayList( applicationContext.getBeansOfType( DatabaseCleanupConsumer.class ).values() );
+ return new ArrayList<DatabaseCleanupConsumer>( applicationContext.getBeansOfType( DatabaseCleanupConsumer.class ).values() );
}
/**
*/
public void executeCleanupConsumer( ArchivaArtifact artifact )
{
- List consumers = getSelectedCleanupConsumers();
- Iterator it = consumers.iterator();
- while ( it.hasNext() )
+ List<ArchivaArtifactConsumer> consumers = getSelectedCleanupConsumers();
+ for ( ArchivaArtifactConsumer consumer : consumers )
{
- ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) it.next();
consumer.beginScan();
}
CollectionUtils.forAllDo( consumers, processArtifactClosure );
- while ( it.hasNext() )
+ for ( ArchivaArtifactConsumer consumer : consumers )
{
- ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) it.next();
consumer.completeScan();
}
}
updateAllProcessed();
}
+ @SuppressWarnings("unchecked")
public void updateAllUnprocessed()
throws ArchivaDatabaseException
{
- List unprocessedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) );
+ List<ArchivaArtifact> unprocessedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) );
beginConsumerLifecycle( dbConsumers.getSelectedUnprocessedConsumers() );
// Process each consumer.
Predicate predicate = UnprocessedArtifactPredicate.getInstance();
- Iterator it = IteratorUtils.filteredIterator( unprocessedArtifacts.iterator(), predicate );
+ Iterator<ArchivaArtifact> it = IteratorUtils.filteredIterator( unprocessedArtifacts.iterator(), predicate );
while ( it.hasNext() )
{
- ArchivaArtifact artifact = (ArchivaArtifact) it.next();
+ ArchivaArtifact artifact = it.next();
updateUnprocessed( artifact );
}
}
}
}
+ @SuppressWarnings("unchecked")
public void updateAllProcessed()
throws ArchivaDatabaseException
{
- List processedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( true ) );
+ List<ArchivaArtifact> processedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( true ) );
beginConsumerLifecycle( dbConsumers.getSelectedCleanupConsumers() );
// Process each consumer.
Predicate predicate = NotPredicate.getInstance( UnprocessedArtifactPredicate.getInstance() );
- Iterator it = IteratorUtils.filteredIterator( processedArtifacts.iterator(), predicate );
+ Iterator<ArchivaArtifact> it = IteratorUtils.filteredIterator( processedArtifacts.iterator(), predicate );
while ( it.hasNext() )
{
- ArchivaArtifact artifact = (ArchivaArtifact) it.next();
+ ArchivaArtifact artifact = it.next();
updateProcessed( artifact );
}
}
}
}
- private void endConsumerLifecycle( List consumers )
+ private void endConsumerLifecycle( List<ArchivaArtifactConsumer> consumers )
{
- Iterator it = consumers.iterator();
- while ( it.hasNext() )
+ for ( ArchivaArtifactConsumer consumer : consumers )
{
- ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) it.next();
consumer.completeScan();
}
}
- private void beginConsumerLifecycle( List consumers )
+ private void beginConsumerLifecycle( List<ArchivaArtifactConsumer> consumers )
{
- Iterator it = consumers.iterator();
- while ( it.hasNext() )
+ for ( ArchivaArtifactConsumer consumer : consumers )
{
- ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) it.next();
consumer.beginScan();
}
}
public void updateUnprocessed( ArchivaArtifact artifact )
throws ArchivaDatabaseException
{
- List consumers = dbConsumers.getSelectedUnprocessedConsumers();
+ List<ArchivaArtifactConsumer> consumers = dbConsumers.getSelectedUnprocessedConsumers();
if ( CollectionUtils.isEmpty( consumers ) )
{
public void updateProcessed( ArchivaArtifact artifact )
throws ArchivaDatabaseException
{
- List consumers = dbConsumers.getSelectedCleanupConsumers();
+ List<ArchivaArtifactConsumer> consumers = dbConsumers.getSelectedCleanupConsumers();
if ( CollectionUtils.isEmpty( consumers ) )
{
listener = (RepositoryListener) lookup( RepositoryListener.class.getName(), "database" );
}
+ @SuppressWarnings("unchecked")
public void testWiring()
{
List<RepositoryListener> listeners =
assertTrue( results.contains( "2.1-20070522.153141-2" ) );
}
- private void assertGroupIds( String msg, List actualGroupIds, String[] expectedGroupIds )
+ private void assertGroupIds( String msg, List<String> actualGroupIds, String[] expectedGroupIds )
{
assertEquals( msg + ": groupIds.length", expectedGroupIds.length, actualGroupIds.size() );
private void assertConstraint( String msg, int count, ArtifactsByChecksumConstraint constraint )
throws Exception
{
- List results = artifactDao.queryArtifacts( constraint );
+ List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint );
assertNotNull( msg + ": Not Null", results );
assertEquals( msg + ": Results.size", count, results.size() );
}
private void assertConstraint( String msg, int count, ArtifactsByRepositoryConstraint constraint )
throws Exception
{
- List results = artifactDao.queryArtifacts( constraint );
+ List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint );
assertNotNull( msg + ": Not Null", results );
assertEquals( msg + ": Results.size", count, results.size() );
}
* under the License.
*/
+import java.util.Date;
+import java.util.List;
+
import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.model.ArchivaArtifact;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
/**
* ArtifactsProcessedConstraintTest
*
return artifact;
}
- public void assertResults( String type, List results, String expectedArtifacts[] )
+ public void assertResults( String type, List<ArchivaArtifact> results, String expectedArtifacts[] )
{
assertNotNull( "Results[" + type + "] should not be null.", results );
assertEquals( "Results[" + type + "].size", expectedArtifacts.length, results.size() );
String artifactId = expectedArtifacts[i];
int found = 0;
- Iterator it = results.iterator();
- while ( it.hasNext() )
+ for ( ArchivaArtifact artifact : results )
{
- ArchivaArtifact artifact = (ArchivaArtifact) it.next();
if ( artifactId.equals( artifact.getArtifactId() ) )
{
found++;
public void testNotProcessed()
throws Exception
{
- List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) );
+ List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) );
assertResults( "not-processed", results, new String[] { "archiva-common", "archiva-database" } );
}
public void testProcessed()
throws Exception
{
- List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( true ) );
+ List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( true ) );
assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } );
}
throws Exception
{
Date since = toDate( "2006/01/01 12:00:00" );
- List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) );
+ List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) );
assertResults( "processed", results, new String[] { "archiva-utils" } );
}
throws Exception
{
Date since = toDate( "2001/01/01 12:00:00" );
- List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) );
+ List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) );
assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } );
}
}
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = artifactDao.queryArtifacts( constraint );
+ List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint );
assertNotNull( "Related Artifacts: Not Null", results );
assertEquals( "Related Artifacts: Results.size", expectedHits, results.size() );
}
dao.save( createStats( "internal", "2007/02/18 10:00:00", 20000, 11700, 320 ) );
}
+ @SuppressWarnings("unchecked")
public void testNotProcessedYet()
throws Exception
{
- List results = dao.query( new MostRecentRepositoryScanStatistics( "central" ) );
+ List<RepositoryContentStatistics> results = (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( "central" ) );
assertNotNull( "Not Processed Yet", results );
assertTrue( "Not Processed Yet", results.isEmpty() );
}
+ @SuppressWarnings("unchecked")
public void testStats()
throws Exception
{
- List results = dao.query( new MostRecentRepositoryScanStatistics( "internal" ) );
+ List<RepositoryContentStatistics> results = (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( "internal" ) );
assertNotNull( "Stats: results (not null)", results );
assertEquals( "Stats: results.size", 1, results.size() );
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = artifactDao.queryArtifacts( constraint );
+ List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint );
assertNotNull( "Older Artifacts By Age: Not Null", results );
assertEquals( "Older Artifacts By Age: Results.size", expectedHits, results.size() );
}
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = artifactDao.queryArtifacts( constraint );
+ List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint );
assertNotNull( "Older Snapshot Artifacts By Age: Not Null", results );
assertEquals( "Older Snapshot Artifacts By Age: Results.size", expectedHits, results.size() );
}
private void assertConstraint( int expectedHits, DeclarativeConstraint constraint )
throws Exception
{
- List results = dao.getProjectModelDAO().queryProjectModels( constraint );
+ List<ArchivaProjectModel> results = dao.getProjectModelDAO().queryProjectModels( constraint );
assertNotNull( "Projects By Artifact Usage: Not Null", results );
assertEquals( "Projects By Artifact Usage: Results.size", expectedHits, results.size() );
}
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = repoProblemDao.queryRepositoryProblems( constraint );
+ List<RepositoryProblem> results = repoProblemDao.queryRepositoryProblems( constraint );
assertNotNull( "Range Constraint: Not Null", results );
assertEquals( "Range Constraint: Results.size", expectedHits, results.size() );
}
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = artifactDao.queryArtifacts( constraint );
+ List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint );
assertNotNull( "Recent Artifacts By Age: Not Null", results );
assertEquals( "Recent Artifacts By Age: Results.size", expectedHits, results.size() );
}
throws Exception
{
Constraint constraint = new RepositoryContentStatisticsByRepositoryConstraint( "internal" );
- List results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint );
+ List<RepositoryContentStatistics> results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint );
assertNotNull( "Stats: results (not null)", results );
assertEquals( "Stats: results.size", 4, results.size() );
Constraint constraint =
new RepositoryContentStatisticsByRepositoryConstraint( "internal", toDate( "2007/10/18 8:00:00" ),
toDate( "2007/10/20 8:00:00" ) );
- List results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint );
+ List<RepositoryContentStatistics> results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint );
assertNotNull( "Stats: results (not null)", results );
assertEquals( "Stats: results.size", 3, results.size() );
* under the License.
*/
+import java.util.List;
+
import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.Constraint;
import org.apache.maven.archiva.database.RepositoryProblemDAO;
import org.apache.maven.archiva.model.RepositoryProblem;
-import java.util.List;
-
/**
* RepositoryProblemByGroupIdConstraintTest
*/
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = repoProblemDao.queryRepositoryProblems( constraint );
+ List<RepositoryProblem> results = repoProblemDao.queryRepositoryProblems( constraint );
assertNotNull( "Repository Problems by Group Id: Not Null", results );
assertEquals( "Repository Problems by Group Id: Results.size", expectedHits, results.size() );
}
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = repoProblemDao.queryRepositoryProblems( constraint );
+ List<RepositoryProblem> results = repoProblemDao.queryRepositoryProblems( constraint );
assertNotNull( "Repository Problems by Repository Id: Not Null", results );
assertEquals( "Repository Problems by Repository Id: Results.size", expectedHits, results.size() );
}
private void assertConstraint( int expectedHits, Constraint constraint )
throws Exception
{
- List results = repoProblemDao.queryRepositoryProblems( constraint );
+ List<RepositoryProblem> results = repoProblemDao.queryRepositoryProblems( constraint );
assertNotNull( "Repository Problems: Not Null", results );
assertEquals( "Repository Problems: Results.size", expectedHits, results.size() );
}
artifactDao.saveArtifact( artifact );
}
+ @SuppressWarnings("unchecked")
private void assertConstraintWithMultipleResultTypes( String[] artifactIds, SimpleConstraint constraint )
throws Exception
{
String prefix = "Unique Artifact IDs: ";
- List<Object[]> results = dao.query( constraint );
+ List<Object[]> results = (List<Object[]>) dao.query( constraint );
assertNotNull( prefix + "Not Null", results );
assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
}
}
+ @SuppressWarnings("unchecked")
private void assertConstraint( String[] artifactIds, SimpleConstraint constraint )
{
String prefix = "Unique Artifact IDs: ";
- List<String> results = dao.query( constraint );
+ List<String> results = (List<String>) dao.query( constraint );
assertNotNull( prefix + "Not Null", results );
assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
private void assertConstraint( int expectedHits, SimpleConstraint constraint )
throws Exception
{
- List results = archivaDao.query( constraint );
+ List<?> results = archivaDao.query( constraint );
assertNotNull( "Repository Problems: Not Null", results );
assertEquals( "Repository Problems: Results.size", expectedHits, results.size() );
}
new UniqueGroupIdConstraint( observableRepositories ) );
}
+ @SuppressWarnings("unchecked")
private void assertConstraint( String[] expectedGroupIds, SimpleConstraint constraint )
throws Exception
{
String prefix = "Unique Group IDs: ";
- List<String> results = dao.query( constraint );
+ List<String> results = (List<String>) dao.query( constraint );
assertNotNull( prefix + "Not Null", results );
assertEquals( prefix + "Results.size", expectedGroupIds.length, results.size() );
assertConstraint( new String[] { "3.0" }, new UniqueVersionConstraint( "org.codehaus.modello", "modellong" ) );
}
+ @SuppressWarnings("unchecked")
private void assertConstraint( String[] versions, SimpleConstraint constraint )
{
String prefix = "Unique Versions: ";
- List<String> results = dao.query( constraint );
+ List<String> results = (List<String>) dao.query( constraint );
assertNotNull( prefix + "Not Null", results );
assertEquals( prefix + "Results.size", versions.length, results.size() );
* under the License.
*/
-import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
-import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.model.ArchivaArtifact;
-import org.apache.maven.archiva.model.ArchivaArtifactModel;
-import org.apache.maven.archiva.model.jpox.ArchivaArtifactModelKey;
-
import java.util.Date;
import java.util.List;
import javax.jdo.JDOHelper;
import javax.jdo.spi.JDOImplHelper;
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaArtifactModel;
+import org.apache.maven.archiva.model.jpox.ArchivaArtifactModelKey;
+
/**
* JdoArtifactDAOTest
*
assertEquals( "org.apache.maven.archiva:archiva-test-module:1.0::jar:testrepo", savedKeyId );
// Test that something has been saved.
- List artifacts = artiDao.queryArtifacts( null );
+ List<ArchivaArtifact> artifacts = artiDao.queryArtifacts( null );
assertNotNull( artifacts );
assertEquals( 1, artifacts.size() );
* under the License.
*/
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.jdo.JDOHelper;
+
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
import org.apache.maven.archiva.repository.project.ProjectModelReader;
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jdo.JDOHelper;
-
/**
* JdoProjectModelDAOTest
*
assertEquals( "org.apache.maven.archiva:archiva-test-module:1.0", savedKeyId );
// Test that something has been saved.
- List projects = projectDao.queryProjectModels( null );
+ List<ArchivaProjectModel> projects = projectDao.queryProjectModels( null );
assertNotNull( projects );
assertEquals( 1, projects.size() );
assertNotNull( "Project model should not be null.", savedModel );
// Test proper detachment of sub-objects.
- List exprs = new ArrayList();
+ List<String> exprs = new ArrayList<String>();
exprs.add( "parentProject.groupId" );
exprs.add( "organization.name" );
exprs.add( "issueManagement.system" );
exprs.add( "licenses[0].url" );
exprs.add( "mailingLists[0].name" );
- Iterator it = exprs.iterator();
- while ( it.hasNext() )
+ for ( String expr : exprs )
{
- String expr = (String) it.next();
try
{
Object obj = PropertyUtils.getProperty( model, expr );
assertEquals( "1[OID]org.apache.maven.archiva.model.RepositoryContentStatistics", savedKeyId );
// query
- List results =
+ List<RepositoryContentStatistics> results =
repoContentStatisticsDAO.queryRepositoryContentStatistics( new RepositoryContentStatisticsByRepositoryConstraint(
"internal" ) );
assertNotNull( results );
throws Exception
{
DatabaseConsumers dbconsumers = lookupDbConsumers();
- List available = dbconsumers.getAvailableCleanupConsumers();
+ List<DatabaseCleanupConsumer> available = dbconsumers.getAvailableCleanupConsumers();
assertNotNull( "Available Cleanup Consumers should never be null.", available );
assertTrue( "Available Cleanup Consumers should have entries.", CollectionUtils.isNotEmpty( available ) );
throws Exception
{
DatabaseConsumers dbconsumers = lookupDbConsumers();
- List available = dbconsumers.getAvailableUnprocessedConsumers();
+ List<DatabaseUnprocessedArtifactConsumer> available = dbconsumers.getAvailableUnprocessedConsumers();
assertNotNull( "Available Unprocessed Consumers should never be null.", available );
assertTrue( "Available Unprocessed Consumers should have entries.", CollectionUtils.isNotEmpty( available ) );
throws Exception
{
DatabaseConsumers dbconsumers = lookupDbConsumers();
- List available = dbconsumers.getSelectedCleanupConsumers();
+ List<ArchivaArtifactConsumer> available = dbconsumers.getSelectedCleanupConsumers();
assertNotNull( "Selected Cleanup Consumers should never be null.", available );
assertTrue( "Selected Cleanup Consumers should have entries.", CollectionUtils.isNotEmpty( available ) );
throws Exception
{
DatabaseConsumers dbconsumers = lookupDbConsumers();
- List available = dbconsumers.getSelectedUnprocessedConsumers();
+ List<ArchivaArtifactConsumer> available = dbconsumers.getSelectedUnprocessedConsumers();
assertNotNull( "Selected Unprocessed Consumers should never be null.", available );
assertTrue( "Selected Unprocessed Consumers should have entries.", CollectionUtils.isNotEmpty( available ) );
}
}
+ @SuppressWarnings("unchecked")
private boolean isPreviouslyScanned( ManagedRepositoryConfiguration repoConfig )
{
List<RepositoryScanStatistics> results =
- dao.query( new MostRecentRepositoryScanStatistics( repoConfig.getId() ) );
+ (List<RepositoryScanStatistics>) dao.query( new MostRecentRepositoryScanStatistics( repoConfig.getId() ) );
if ( results != null && !results.isEmpty() )
{
}
}
+ @SuppressWarnings("unchecked")
public boolean isProcessingAnyRepositoryTask()
throws ArchivaException
{
return !queue.isEmpty();
}
+ @SuppressWarnings("unchecked")
public boolean isProcessingRepositoryTask( String repositoryId )
throws ArchivaException
{
return CollectionUtils.exists( queue, new RepositoryTaskSelectionPredicate( repositoryId ) );
}
+ @SuppressWarnings("unchecked")
public boolean isProcessingDatabaseTask()
throws ArchivaException
{
import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
import org.apache.maven.archiva.database.constraints.UniqueArtifactIdConstraint;
import org.apache.maven.archiva.database.constraints.UniqueGroupIdConstraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.RepositoryContentStatistics;
import org.apache.maven.archiva.repository.RepositoryException;
import org.apache.maven.archiva.repository.scanner.RepositoryScanStatistics;
log.info( "Initialized " + this.getClass().getName() );
}
+ @SuppressWarnings("unchecked")
public void executeTask( Task task )
throws TaskExecutionException
{
long sinceWhen = RepositoryScanner.FRESH_SCAN;
- List<RepositoryContentStatistics> results = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
+ List<RepositoryContentStatistics> results = (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
if ( CollectionUtils.isNotEmpty( results ) )
{
}
}
+ @SuppressWarnings("unchecked")
private RepositoryContentStatistics constructRepositoryStatistics( ManagedRepositoryConfiguration arepo,
long sinceWhen,
List<RepositoryContentStatistics> results,
// total artifact count
try
{
- List artifacts = dao.getArtifactDAO().queryArtifacts(
+ List<ArchivaArtifact> artifacts = dao.getArtifactDAO().queryArtifacts(
new ArtifactsByRepositoryConstraint( arepo.getId(), stats.getWhenGathered(), "groupId", true ) );
dbstats.setTotalArtifactCount( artifacts.size() );
}
List<String> repos = new ArrayList<String>();
repos.add( arepo.getId() );
- List<String> groupIds = dao.query( new UniqueGroupIdConstraint( repos ) );
+ List<String> groupIds = (List<String>) dao.query( new UniqueGroupIdConstraint( repos ) );
dbstats.setTotalGroupCount( groupIds.size() );
- List<Object[]> artifactIds = dao.query( new UniqueArtifactIdConstraint( arepo.getId(), true ) );
+ List<Object[]> artifactIds = (List<Object[]>) dao.query( new UniqueArtifactIdConstraint( arepo.getId(), true ) );
dbstats.setTotalProjectCount( artifactIds.size() );
return dbstats;
import org.apache.archiva.indexer.search.SearchResults;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.common.utils.VersionUtil;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.Constraint;
import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
+import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.security.AccessDeniedException;
import org.apache.maven.archiva.security.ArchivaSecurityException;
import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.security.PrincipalNotFoundException;
import org.apache.maven.archiva.security.UserRepositories;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.Preparable;
-import org.apache.maven.archiva.common.utils.VersionUtil;
-import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.Preparable;
+
/**
* Search all indexed fields by the given criteria.
*
private ArchivaConfiguration archivaConfiguration;
- private Map<String, ManagedRepositoryConfiguration> managedRepositories;
-
private String q;
/**
private static final String ARTIFACT = "artifact";
- private List databaseResults;
+ private List<ArchivaArtifact> databaseResults;
private int currentPage = 0;
return SUCCESS;
}
+ @SuppressWarnings("unchecked")
public String quickSearch()
throws MalformedURLException
{
for ( SearchResultHit resultHit : results.getHits() )
{
final List<String> versions =
- dao.query( new UniqueVersionConstraint( getObservableRepos(), resultHit.getGroupId(),
- resultHit.getArtifactId() ) );
+ (List<String>) dao.query( new UniqueVersionConstraint( getObservableRepos(), resultHit.getGroupId(),
+ resultHit.getArtifactId() ) );
if ( versions != null && !versions.isEmpty() )
{
resultHit.setVersion( null );
return INPUT;
}
+ @SuppressWarnings("unchecked")
private String getPrincipal()
{
return archivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );
return results;
}
- public List getDatabaseResults()
+ public List<ArchivaArtifact> getDatabaseResults()
{
return databaseResults;
}
public void setManagedRepositories( Map<String, ManagedRepositoryConfiguration> managedRepositories )
{
- this.managedRepositories = managedRepositories;
}
public String getGroupId()
return bundle;
}
+ @SuppressWarnings("unchecked")
public void prepare()
{
Configuration config = archivaConfiguration.getConfiguration();
for ( ManagedRepositoryConfiguration repo : managedRepositories )
{
List<RepositoryContentStatistics> results =
- dao.query( new MostRecentRepositoryScanStatistics( repo.getId() ) );
+ (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( repo.getId() ) );
if ( !results.isEmpty() )
{
repositoryStatistics.put( repo.getId(), results.get( 0 ) );
private InputStream inputStream;
+ @SuppressWarnings("unchecked")
public void prepare()
{
repositoryIds = new ArrayList<String>();
repositoryIds.add( ALL_REPOSITORIES ); // comes first to be first in the list
- repositoryIds.addAll(
- dao.query( new UniqueFieldConstraint( RepositoryProblem.class.getName(), "repositoryId" ) ) );
+ repositoryIds.addAll( (List<String>) dao.query( new UniqueFieldConstraint( RepositoryProblem.class.getName(),
+ "repositoryId" ) ) );
availableRepositories = new ArrayList<String>();
{
try
{
- List contentStats = repoContentStatsDao.queryRepositoryContentStatistics(
+ List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics(
new RepositoryContentStatisticsByRepositoryConstraint( repo, startDateInDF, endDateInDF ) );
if ( contentStats == null || contentStats.isEmpty() )