git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755266 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-1.2
@@ -40,7 +40,7 @@ public interface ProjectModelResolutionListener | |||
* @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 | |||
@@ -92,5 +92,5 @@ public interface ProjectModelResolutionListener | |||
* @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 ); | |||
} |
@@ -37,7 +37,7 @@ public interface ArchivaDAO | |||
* @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. |
@@ -30,7 +30,7 @@ import org.apache.maven.archiva.model.RepositoryContentStatistics; | |||
*/ | |||
public interface RepositoryContentStatisticsDAO | |||
{ | |||
public List queryRepositoryContentStatistics( Constraint constraint ) | |||
public List<RepositoryContentStatistics> queryRepositoryContentStatistics( Constraint constraint ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException; | |||
public RepositoryContentStatistics saveRepositoryContentStatistics( RepositoryContentStatistics stats ); |
@@ -47,7 +47,7 @@ public interface SimpleConstraint extends Constraint | |||
* | |||
* @return the result class. | |||
*/ | |||
public Class getResultClass(); | |||
public Class<?> getResultClass(); | |||
/** | |||
* When working with result classes that are not persistable, |
@@ -68,13 +68,14 @@ public class DefaultRepositoryBrowsing | |||
/** | |||
* @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 ) ); | |||
} | |||
@@ -84,6 +85,7 @@ public class DefaultRepositoryBrowsing | |||
/** | |||
* @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 ) | |||
{ | |||
@@ -93,7 +95,7 @@ public class DefaultRepositoryBrowsing | |||
{ | |||
// 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 ) ); | |||
@@ -104,6 +106,7 @@ public class DefaultRepositoryBrowsing | |||
/** | |||
* @see RepositoryBrowsing#selectGroupId(String, List, String) | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public BrowsingResults selectGroupId( final String principal, final List<String> observableRepositoryIds, | |||
final String groupId ) | |||
{ | |||
@@ -111,9 +114,9 @@ public class DefaultRepositoryBrowsing | |||
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. | |||
@@ -179,6 +182,7 @@ public class DefaultRepositoryBrowsing | |||
/** | |||
* @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 | |||
@@ -188,7 +192,7 @@ public class DefaultRepositoryBrowsing | |||
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 ) | |||
{ | |||
@@ -259,7 +263,7 @@ public class DefaultRepositoryBrowsing | |||
if ( results == null ) | |||
{ | |||
// defensive. to honor contract as specified. never null. | |||
return Collections.EMPTY_LIST; | |||
return Collections.emptyList(); | |||
} | |||
return results; | |||
@@ -312,6 +316,7 @@ public class DefaultRepositoryBrowsing | |||
* @param pomArtifact | |||
* @throws ArchivaDatabaseException | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
private ArchivaArtifact handleGenericSnapshots( final String groupId, final String artifactId, | |||
final String version, final String repositoryId ) | |||
throws ArchivaDatabaseException | |||
@@ -320,7 +325,7 @@ public class DefaultRepositoryBrowsing | |||
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 ); | |||
@@ -40,7 +40,7 @@ public class MostRecentRepositoryScanStatistics | |||
super.params = new Object[]{repoId}; | |||
} | |||
public Class getResultClass() | |||
public Class<?> getResultClass() | |||
{ | |||
return RepositoryContentStatistics.class; | |||
} |
@@ -35,7 +35,7 @@ public class UniqueArtifactIdConstraint | |||
{ | |||
private StringBuffer sql = new StringBuffer(); | |||
private Class resultClass; | |||
private Class<?> resultClass; | |||
/** | |||
* Obtain a set of unique ArtifactIds for the specified groupId. |
@@ -45,7 +45,7 @@ public class UniqueFieldConstraint | |||
super.params = new Object[]{fieldNamePrefix}; | |||
} | |||
public Class getResultClass() | |||
public Class<?> getResultClass() | |||
{ | |||
return String.class; | |||
} |
@@ -151,7 +151,7 @@ public class JdoAccess | |||
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 | |||
@@ -200,12 +200,12 @@ public class JdoAccess | |||
} | |||
} | |||
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(); | |||
@@ -214,7 +214,7 @@ public class JdoAccess | |||
{ | |||
tx.begin(); | |||
List result = null; | |||
List<?> result = null; | |||
if ( constraint != null ) | |||
{ | |||
@@ -236,7 +236,7 @@ public class JdoAccess | |||
result = processUnconstrained( pm, clazz ); | |||
} | |||
result = (List) pm.detachCopyAll( result ); | |||
result = (List<?>) pm.detachCopyAll( result ); | |||
tx.commit(); | |||
@@ -248,7 +248,7 @@ public class JdoAccess | |||
} | |||
} | |||
public List queryObjects( SimpleConstraint constraint ) | |||
public List<?> queryObjects( SimpleConstraint constraint ) | |||
{ | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); | |||
@@ -257,16 +257,16 @@ public class JdoAccess | |||
{ | |||
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; | |||
} | |||
@@ -281,14 +281,14 @@ public class JdoAccess | |||
} | |||
} | |||
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() ); | |||
@@ -309,10 +309,10 @@ public class JdoAccess | |||
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 ); | |||
@@ -380,26 +380,26 @@ public class JdoAccess | |||
} | |||
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 ) | |||
@@ -456,7 +456,7 @@ public class JdoAccess | |||
} | |||
} | |||
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 ) ) | |||
@@ -473,7 +473,7 @@ public class JdoAccess | |||
return ( JDOHelper.getObjectId( object ) != null ); | |||
} | |||
public boolean objectExistsById( Class clazz, String id ) | |||
public boolean objectExistsById( Class<?> clazz, String id ) | |||
throws ArchivaDatabaseException | |||
{ | |||
try | |||
@@ -492,7 +492,7 @@ public class JdoAccess | |||
{ | |||
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(); | |||
@@ -570,7 +570,7 @@ public class JdoAccess | |||
// ignore | |||
} | |||
public void removeAll( Class aClass ) | |||
public void removeAll( Class<?> aClass ) | |||
{ | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); |
@@ -65,7 +65,7 @@ public class JdoArchivaDAO | |||
private RepositoryContentStatisticsDAO repositoryContentStatisticsDAO; | |||
public List query( SimpleConstraint constraint ) | |||
public List<?> query( SimpleConstraint constraint ) | |||
{ | |||
return jdo.queryObjects( constraint ); | |||
} |
@@ -19,6 +19,9 @@ package org.apache.maven.archiva.database.jdo; | |||
* 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; | |||
@@ -27,10 +30,6 @@ 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.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
/** | |||
* JdoArtifactDAO | |||
* | |||
@@ -82,20 +81,19 @@ public class 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 ) ); | |||
} | |||
@@ -73,10 +73,11 @@ public class JdoProjectModelDAO | |||
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 ) |
@@ -48,12 +48,11 @@ public class JdoRepositoryContentStatisticsDAO | |||
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 ) |
@@ -42,10 +42,11 @@ public class JdoRepositoryProblemDAO | |||
*/ | |||
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 ) |
@@ -116,12 +116,12 @@ public class ProjectModelToDatabaseListener | |||
/* 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 */ | |||
} |
@@ -19,6 +19,9 @@ package org.apache.maven.archiva.database.updater; | |||
* 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; | |||
@@ -32,10 +35,6 @@ import org.springframework.beans.BeansException; | |||
import org.springframework.context.ApplicationContext; | |||
import org.springframework.context.ApplicationContextAware; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
/** | |||
* DatabaseConsumers | |||
* | |||
@@ -114,9 +113,10 @@ public class 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; | |||
} | |||
@@ -127,9 +127,10 @@ public class DatabaseConsumers | |||
* | |||
* @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; | |||
} | |||
@@ -140,9 +141,10 @@ public class DatabaseConsumers | |||
* | |||
* @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() ); | |||
} | |||
/** | |||
@@ -151,9 +153,10 @@ public class DatabaseConsumers | |||
* | |||
* @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() ); | |||
} | |||
/** | |||
@@ -163,11 +166,9 @@ public class DatabaseConsumers | |||
*/ | |||
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(); | |||
} | |||
@@ -182,9 +183,8 @@ public class DatabaseConsumers | |||
CollectionUtils.forAllDo( consumers, processArtifactClosure ); | |||
while ( it.hasNext() ) | |||
for ( ArchivaArtifactConsumer consumer : consumers ) | |||
{ | |||
ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) it.next(); | |||
consumer.completeScan(); | |||
} | |||
} |
@@ -67,10 +67,11 @@ public class JdoDatabaseUpdater | |||
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() ); | |||
@@ -79,10 +80,10 @@ public class JdoDatabaseUpdater | |||
// 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 ); | |||
} | |||
} | |||
@@ -92,10 +93,11 @@ public class JdoDatabaseUpdater | |||
} | |||
} | |||
@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() ); | |||
@@ -104,10 +106,10 @@ public class JdoDatabaseUpdater | |||
// 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 ); | |||
} | |||
} | |||
@@ -117,22 +119,18 @@ public class JdoDatabaseUpdater | |||
} | |||
} | |||
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(); | |||
} | |||
} | |||
@@ -140,7 +138,7 @@ public class JdoDatabaseUpdater | |||
public void updateUnprocessed( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException | |||
{ | |||
List consumers = dbConsumers.getSelectedUnprocessedConsumers(); | |||
List<ArchivaArtifactConsumer> consumers = dbConsumers.getSelectedUnprocessedConsumers(); | |||
if ( CollectionUtils.isEmpty( consumers ) ) | |||
{ | |||
@@ -158,7 +156,7 @@ public class JdoDatabaseUpdater | |||
public void updateProcessed( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException | |||
{ | |||
List consumers = dbConsumers.getSelectedCleanupConsumers(); | |||
List<ArchivaArtifactConsumer> consumers = dbConsumers.getSelectedCleanupConsumers(); | |||
if ( CollectionUtils.isEmpty( consumers ) ) | |||
{ |
@@ -42,6 +42,7 @@ public class RepositoryDatabaseEventListenerTest | |||
listener = (RepositoryListener) lookup( RepositoryListener.class.getName(), "database" ); | |||
} | |||
@SuppressWarnings("unchecked") | |||
public void testWiring() | |||
{ | |||
List<RepositoryListener> listeners = |
@@ -195,7 +195,7 @@ public class RepositoryBrowsingTest | |||
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() ); | |||
@@ -193,7 +193,7 @@ public class ArtifactsByChecksumConstraintTest | |||
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() ); | |||
} |
@@ -167,7 +167,7 @@ public class ArtifactsByRepositoryConstraintTest | |||
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() ); | |||
} |
@@ -19,14 +19,13 @@ package org.apache.maven.archiva.database.constraints; | |||
* 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 | |||
* | |||
@@ -55,7 +54,7 @@ public class 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() ); | |||
@@ -65,10 +64,8 @@ public class ArtifactsProcessedConstraintTest | |||
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++; | |||
@@ -107,14 +104,14 @@ public class ArtifactsProcessedConstraintTest | |||
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" } ); | |||
} | |||
@@ -122,7 +119,7 @@ public class ArtifactsProcessedConstraintTest | |||
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" } ); | |||
} | |||
@@ -130,7 +127,7 @@ public class ArtifactsProcessedConstraintTest | |||
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" } ); | |||
} | |||
} |
@@ -82,7 +82,7 @@ public class ArtifactsRelatedConstraintTest | |||
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() ); | |||
} |
@@ -58,18 +58,20 @@ public class MostRecentRepositoryScanStatisticsTest | |||
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() ); | |||
@@ -95,7 +95,7 @@ public class OlderArtifactsByAgeConstraintTest | |||
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() ); | |||
} |
@@ -110,7 +110,7 @@ public class OlderSnapshotArtifactsByAgeConstraintTest | |||
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() ); | |||
} |
@@ -108,7 +108,7 @@ public class ProjectsByArtifactUsageConstraintTest | |||
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() ); | |||
} |
@@ -81,7 +81,7 @@ public class RangeConstraintTest | |||
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() ); | |||
} |
@@ -97,7 +97,7 @@ public class RecentArtifactsByAgeConstraintTest | |||
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() ); | |||
} |
@@ -67,7 +67,7 @@ public class RepositoryContentStatisticsByRepositoryConstraintTest | |||
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() ); | |||
@@ -83,7 +83,7 @@ public class RepositoryContentStatisticsByRepositoryConstraintTest | |||
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() ); | |||
@@ -19,14 +19,14 @@ package org.apache.maven.archiva.database.constraints; | |||
* 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 | |||
*/ | |||
@@ -89,7 +89,7 @@ public class 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() ); | |||
} |
@@ -86,7 +86,7 @@ public class RepositoryProblemByRepositoryIdConstraintTest | |||
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() ); | |||
} |
@@ -122,7 +122,7 @@ public class RepositoryProblemConstraintTest | |||
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() ); | |||
} |
@@ -112,12 +112,13 @@ public class UniqueArtifactIdConstraintTest | |||
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() ); | |||
@@ -134,11 +135,12 @@ public class UniqueArtifactIdConstraintTest | |||
} | |||
} | |||
@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() ); | |||
@@ -110,7 +110,7 @@ public class UniqueFieldConstraintTest | |||
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() ); | |||
} |
@@ -231,12 +231,13 @@ public class UniqueGroupIdConstraintTest | |||
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() ); | |||
@@ -108,11 +108,12 @@ public class UniqueVersionConstraintTest | |||
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() ); | |||
@@ -19,18 +19,18 @@ package org.apache.maven.archiva.database.jdo; | |||
* 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 | |||
* | |||
@@ -76,7 +76,7 @@ public class 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() ); | |||
@@ -19,6 +19,13 @@ package org.apache.maven.archiva.database.jdo; | |||
* 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; | |||
@@ -27,14 +34,6 @@ import org.apache.maven.archiva.model.ArchivaProjectModel; | |||
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 | |||
* | |||
@@ -65,7 +64,7 @@ public class 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() ); | |||
@@ -133,7 +132,7 @@ public class JdoProjectModelDAOTest | |||
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" ); | |||
@@ -149,10 +148,8 @@ public class JdoProjectModelDAOTest | |||
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 ); |
@@ -51,7 +51,7 @@ public class JdoRepositoryContentStatisticsDAOTest | |||
assertEquals( "1[OID]org.apache.maven.archiva.model.RepositoryContentStatistics", savedKeyId ); | |||
// query | |||
List results = | |||
List<RepositoryContentStatistics> results = | |||
repoContentStatisticsDAO.queryRepositoryContentStatistics( new RepositoryContentStatisticsByRepositoryConstraint( | |||
"internal" ) ); | |||
assertNotNull( results ); |
@@ -44,7 +44,7 @@ public class DatabaseConsumersTest | |||
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 ) ); | |||
@@ -54,7 +54,7 @@ public class DatabaseConsumersTest | |||
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 ) ); | |||
@@ -64,7 +64,7 @@ public class DatabaseConsumersTest | |||
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 ) ); | |||
@@ -74,7 +74,7 @@ public class DatabaseConsumersTest | |||
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 ) ); |
@@ -151,10 +151,11 @@ public class DefaultArchivaTaskScheduler | |||
} | |||
} | |||
@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() ) | |||
{ | |||
@@ -320,6 +321,7 @@ public class DefaultArchivaTaskScheduler | |||
} | |||
} | |||
@SuppressWarnings("unchecked") | |||
public boolean isProcessingAnyRepositoryTask() | |||
throws ArchivaException | |||
{ | |||
@@ -337,6 +339,7 @@ public class DefaultArchivaTaskScheduler | |||
return !queue.isEmpty(); | |||
} | |||
@SuppressWarnings("unchecked") | |||
public boolean isProcessingRepositoryTask( String repositoryId ) | |||
throws ArchivaException | |||
{ | |||
@@ -354,6 +357,7 @@ public class DefaultArchivaTaskScheduler | |||
return CollectionUtils.exists( queue, new RepositoryTaskSelectionPredicate( repositoryId ) ); | |||
} | |||
@SuppressWarnings("unchecked") | |||
public boolean isProcessingDatabaseTask() | |||
throws ArchivaException | |||
{ |
@@ -31,6 +31,7 @@ import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstr | |||
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; | |||
@@ -85,6 +86,7 @@ public class ArchivaRepositoryScanningTaskExecutor | |||
log.info( "Initialized " + this.getClass().getName() ); | |||
} | |||
@SuppressWarnings("unchecked") | |||
public void executeTask( Task task ) | |||
throws TaskExecutionException | |||
{ | |||
@@ -107,7 +109,7 @@ public class ArchivaRepositoryScanningTaskExecutor | |||
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 ) ) | |||
{ | |||
@@ -129,6 +131,7 @@ public class ArchivaRepositoryScanningTaskExecutor | |||
} | |||
} | |||
@SuppressWarnings("unchecked") | |||
private RepositoryContentStatistics constructRepositoryStatistics( ManagedRepositoryConfiguration arepo, | |||
long sinceWhen, | |||
List<RepositoryContentStatistics> results, | |||
@@ -145,7 +148,7 @@ public class ArchivaRepositoryScanningTaskExecutor | |||
// 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() ); | |||
} | |||
@@ -166,10 +169,10 @@ public class ArchivaRepositoryScanningTaskExecutor | |||
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; |
@@ -34,26 +34,27 @@ import org.apache.archiva.indexer.search.SearchResultLimits; | |||
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. | |||
* | |||
@@ -69,8 +70,6 @@ public class SearchAction | |||
private ArchivaConfiguration archivaConfiguration; | |||
private Map<String, ManagedRepositoryConfiguration> managedRepositories; | |||
private String q; | |||
/** | |||
@@ -97,7 +96,7 @@ public class SearchAction | |||
private static final String ARTIFACT = "artifact"; | |||
private List databaseResults; | |||
private List<ArchivaArtifact> databaseResults; | |||
private int currentPage = 0; | |||
@@ -262,6 +261,7 @@ public class SearchAction | |||
return SUCCESS; | |||
} | |||
@SuppressWarnings("unchecked") | |||
public String quickSearch() | |||
throws MalformedURLException | |||
{ | |||
@@ -335,8 +335,8 @@ public class SearchAction | |||
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 ); | |||
@@ -400,6 +400,7 @@ public class SearchAction | |||
return INPUT; | |||
} | |||
@SuppressWarnings("unchecked") | |||
private String getPrincipal() | |||
{ | |||
return archivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() ); | |||
@@ -481,7 +482,7 @@ public class SearchAction | |||
return results; | |||
} | |||
public List getDatabaseResults() | |||
public List<ArchivaArtifact> getDatabaseResults() | |||
{ | |||
return databaseResults; | |||
} | |||
@@ -543,7 +544,6 @@ public class SearchAction | |||
public void setManagedRepositories( Map<String, ManagedRepositoryConfiguration> managedRepositories ) | |||
{ | |||
this.managedRepositories = managedRepositories; | |||
} | |||
public String getGroupId() |
@@ -94,6 +94,7 @@ public class RepositoriesAction | |||
return bundle; | |||
} | |||
@SuppressWarnings("unchecked") | |||
public void prepare() | |||
{ | |||
Configuration config = archivaConfiguration.getConfiguration(); | |||
@@ -109,7 +110,7 @@ public class RepositoriesAction | |||
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 ) ); |
@@ -152,12 +152,13 @@ public class GenerateReportAction | |||
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>(); | |||
@@ -449,7 +450,7 @@ public class GenerateReportAction | |||
{ | |||
try | |||
{ | |||
List contentStats = repoContentStatsDao.queryRepositoryContentStatistics( | |||
List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics( | |||
new RepositoryContentStatisticsByRepositoryConstraint( repo, startDateInDF, endDateInDF ) ); | |||
if ( contentStats == null || contentStats.isEmpty() ) |