From 75e9f6fe7afeb3bc3c0e4cc2f919026ff52cffd2 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 17 Mar 2009 14:28:40 +0000 Subject: [PATCH] clear warnings for archiva-database git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755266 13f79535-47bb-0310-9956-ffa450edef68 --- .../ProjectModelResolutionListener.java | 4 +- .../maven/archiva/database/ArchivaDAO.java | 2 +- .../RepositoryContentStatisticsDAO.java | 2 +- .../archiva/database/SimpleConstraint.java | 2 +- .../browsing/DefaultRepositoryBrowsing.java | 19 +++++--- .../MostRecentRepositoryScanStatistics.java | 2 +- .../UniqueArtifactIdConstraint.java | 2 +- .../constraints/UniqueFieldConstraint.java | 2 +- .../maven/archiva/database/jdo/JdoAccess.java | 48 +++++++++---------- .../archiva/database/jdo/JdoArchivaDAO.java | 2 +- .../archiva/database/jdo/JdoArtifactDAO.java | 22 ++++----- .../database/jdo/JdoProjectModelDAO.java | 3 +- .../JdoRepositoryContentStatisticsDAO.java | 7 ++- .../database/jdo/JdoRepositoryProblemDAO.java | 5 +- .../ProjectModelToDatabaseListener.java | 4 +- .../database/updater/DatabaseConsumers.java | 36 +++++++------- .../database/updater/JdoDatabaseUpdater.java | 30 ++++++------ .../RepositoryDatabaseEventListenerTest.java | 1 + .../browsing/RepositoryBrowsingTest.java | 2 +- .../ArtifactsByChecksumConstraintTest.java | 2 +- .../ArtifactsByRepositoryConstraintTest.java | 2 +- .../ArtifactsProcessedConstraintTest.java | 21 ++++---- .../ArtifactsRelatedConstraintTest.java | 2 +- ...ostRecentRepositoryScanStatisticsTest.java | 6 ++- .../OlderArtifactsByAgeConstraintTest.java | 2 +- ...rSnapshotArtifactsByAgeConstraintTest.java | 2 +- ...ProjectsByArtifactUsageConstraintTest.java | 2 +- .../constraints/RangeConstraintTest.java | 2 +- .../RecentArtifactsByAgeConstraintTest.java | 2 +- ...tStatisticsByRepositoryConstraintTest.java | 4 +- ...ositoryProblemByGroupIdConstraintTest.java | 6 +-- ...ryProblemByRepositoryIdConstraintTest.java | 2 +- .../RepositoryProblemConstraintTest.java | 2 +- .../UniqueArtifactIdConstraintTest.java | 6 ++- .../UniqueFieldConstraintTest.java | 2 +- .../UniqueGroupIdConstraintTest.java | 3 +- .../UniqueVersionConstraintTest.java | 3 +- .../database/jdo/JdoArtifactDAOTest.java | 14 +++--- .../database/jdo/JdoProjectModelDAOTest.java | 23 ++++----- ...JdoRepositoryContentStatisticsDAOTest.java | 2 +- .../updater/DatabaseConsumersTest.java | 8 ++-- .../DefaultArchivaTaskScheduler.java | 6 ++- ...ArchivaRepositoryScanningTaskExecutor.java | 11 +++-- .../archiva/web/action/SearchAction.java | 24 +++++----- .../repositories/RepositoriesAction.java | 3 +- .../action/reports/GenerateReportAction.java | 7 +-- 46 files changed, 188 insertions(+), 176 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolutionListener.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolutionListener.java index ba84ea580..2587429df 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolutionListener.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolutionListener.java @@ -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 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 resolverList ); } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java index 49e6025fd..76566b4d7 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java @@ -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. diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryContentStatisticsDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryContentStatisticsDAO.java index 64689e917..b607eccf0 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryContentStatisticsDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryContentStatisticsDAO.java @@ -30,7 +30,7 @@ import org.apache.maven.archiva.model.RepositoryContentStatistics; */ public interface RepositoryContentStatisticsDAO { - public List queryRepositoryContentStatistics( Constraint constraint ) + public List queryRepositoryContentStatistics( Constraint constraint ) throws ObjectNotFoundException, ArchivaDatabaseException; public RepositoryContentStatistics saveRepositoryContentStatistics( RepositoryContentStatistics stats ); diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/SimpleConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/SimpleConstraint.java index ad75e7808..bdfb09926 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/SimpleConstraint.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/SimpleConstraint.java @@ -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, diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java index 9fd8b0182..dfe6c74bf 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java @@ -68,13 +68,14 @@ public class DefaultRepositoryBrowsing /** * @see RepositoryBrowsing#getRoot(String, List) */ + @SuppressWarnings("unchecked") public BrowsingResults getRoot( final String principal, final List observableRepositoryIds ) { final BrowsingResults results = new BrowsingResults(); if ( !observableRepositoryIds.isEmpty() ) { - final List groups = dao.query( new UniqueGroupIdConstraint( observableRepositoryIds ) ); + final List groups = (List) 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 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 versions = - dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) ); + (List) 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 observableRepositoryIds, final String groupId ) { @@ -111,9 +114,9 @@ public class DefaultRepositoryBrowsing if ( !observableRepositoryIds.isEmpty() ) { - final List groups = dao.query( new UniqueGroupIdConstraint( observableRepositoryIds, groupId ) ); + final List groups = (List) dao.query( new UniqueGroupIdConstraint( observableRepositoryIds, groupId ) ); final List artifacts = - dao.query( new UniqueArtifactIdConstraint( observableRepositoryIds, groupId ) ); + (List) 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 getOtherSnapshotVersions( List observableRepositoryIds, String groupId, String artifactId, String version ) throws ObjectNotFoundException, ArchivaDatabaseException @@ -188,7 +192,7 @@ public class DefaultRepositoryBrowsing if ( VersionUtil.isSnapshot( version ) ) { List versions = - dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) ); + (List) 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 versions = dao.query( new UniqueVersionConstraint( groupId, artifactId ) ); + final List versions = (List) dao.query( new UniqueVersionConstraint( groupId, artifactId ) ); Collections.sort( versions ); Collections.reverse( versions ); diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatistics.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatistics.java index 9b7c054b3..a01de2164 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatistics.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatistics.java @@ -40,7 +40,7 @@ public class MostRecentRepositoryScanStatistics super.params = new Object[]{repoId}; } - public Class getResultClass() + public Class getResultClass() { return RepositoryContentStatistics.class; } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java index ac0c850d1..1449352af 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java @@ -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. diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java index 8e22ac255..9cdbda9d7 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java @@ -45,7 +45,7 @@ public class UniqueFieldConstraint super.params = new Object[]{fieldNamePrefix}; } - public Class getResultClass() + public Class getResultClass() { return String.class; } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java index f75fc6431..27c39bf52 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java @@ -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 copiedResults = new ArrayList(); 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(); diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java index 420e044a2..54d30af86 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java @@ -65,7 +65,7 @@ public class JdoArchivaDAO private RepositoryContentStatisticsDAO repositoryContentStatisticsDAO; - public List query( SimpleConstraint constraint ) + public List query( SimpleConstraint constraint ) { return jdo.queryObjects( constraint ); } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAO.java index 38e13ea41..8380d9e1d 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAO.java @@ -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 queryArtifacts( Constraint constraint ) throws ObjectNotFoundException, ArchivaDatabaseException { - List results = jdo.queryObjects( ArchivaArtifactModel.class, constraint ); - if ( ( results == null ) || results.isEmpty() ) + List results = (List) jdo.queryObjects( ArchivaArtifactModel.class, constraint ); + if ( results == null ) { - return results; + return null; } - List ret = new ArrayList(); - Iterator it = results.iterator(); - while ( it.hasNext() ) + List ret = new ArrayList(); + for ( ArchivaArtifactModel model : results ) { - ArchivaArtifactModel model = (ArchivaArtifactModel) it.next(); ret.add( new ArchivaArtifact( model ) ); } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java index 614868993..12c223018 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java @@ -73,10 +73,11 @@ public class JdoProjectModelDAO return (ArchivaProjectModel) jdo.getObjectById( ArchivaProjectModel.class, key, null ); } + @SuppressWarnings("unchecked") public List queryProjectModels( Constraint constraint ) throws ObjectNotFoundException, ArchivaDatabaseException { - return jdo.queryObjects( ArchivaProjectModel.class, constraint ); + return (List) jdo.queryObjects( ArchivaProjectModel.class, constraint ); } public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model ) diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java index 21936fac2..23be22b2b 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java @@ -48,12 +48,11 @@ public class JdoRepositoryContentStatisticsDAO jdo.removeObject( stats ); } - public List queryRepositoryContentStatistics( Constraint constraint ) + @SuppressWarnings("unchecked") + public List queryRepositoryContentStatistics( Constraint constraint ) throws ObjectNotFoundException, ArchivaDatabaseException { - List results = jdo.queryObjects( RepositoryContentStatistics.class, constraint ); - - return results; + return (List) jdo.queryObjects( RepositoryContentStatistics.class, constraint ); } public RepositoryContentStatistics saveRepositoryContentStatistics( RepositoryContentStatistics stats ) diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java index 5f4fd1675..3179bd238 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java @@ -42,10 +42,11 @@ public class JdoRepositoryProblemDAO */ private JdoAccess jdo; - public List queryRepositoryProblems( Constraint constraint ) + @SuppressWarnings("unchecked") + public List queryRepositoryProblems( Constraint constraint ) throws ObjectNotFoundException, ArchivaDatabaseException { - return jdo.queryObjects( RepositoryProblem.class, constraint ); + return (List) jdo.queryObjects( RepositoryProblem.class, constraint ); } public RepositoryProblem saveRepositoryProblem( RepositoryProblem problem ) diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java index 5529d3849..edba43335 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java @@ -116,12 +116,12 @@ public class ProjectModelToDatabaseListener /* do nothing */ } - public void resolutionNotFound( VersionedReference projectRef, List resolverList ) + public void resolutionNotFound( VersionedReference projectRef, List resolverList ) { /* do nothing */ } - public void resolutionStart( VersionedReference projectRef, List resolverList ) + public void resolutionStart( VersionedReference projectRef, List resolverList ) { /* do nothing */ } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java index e79e51b50..af6d12b97 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java @@ -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 getSelectedUnprocessedConsumers() { - List ret = new ArrayList(); + List ret = new ArrayList(); 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 getSelectedCleanupConsumers() { - List ret = new ArrayList(); + List ret = new ArrayList(); 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 getAvailableUnprocessedConsumers() { - return new ArrayList( applicationContext.getBeansOfType( DatabaseUnprocessedArtifactConsumer.class ).values() ); + return new ArrayList( 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 getAvailableCleanupConsumers() { - return new ArrayList( applicationContext.getBeansOfType( DatabaseCleanupConsumer.class ).values() ); + return new ArrayList( 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 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(); } } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java index 41bd5bf52..613c40349 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java @@ -67,10 +67,11 @@ public class JdoDatabaseUpdater updateAllProcessed(); } + @SuppressWarnings("unchecked") public void updateAllUnprocessed() throws ArchivaDatabaseException { - List unprocessedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + List 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 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 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 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 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 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 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 consumers = dbConsumers.getSelectedCleanupConsumers(); if ( CollectionUtils.isEmpty( consumers ) ) { diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListenerTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListenerTest.java index e566ec629..b5c09d87d 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListenerTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListenerTest.java @@ -42,6 +42,7 @@ public class RepositoryDatabaseEventListenerTest listener = (RepositoryListener) lookup( RepositoryListener.class.getName(), "database" ); } + @SuppressWarnings("unchecked") public void testWiring() { List listeners = diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java index 8ec1d5f2c..77d80ed7a 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java @@ -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 actualGroupIds, String[] expectedGroupIds ) { assertEquals( msg + ": groupIds.length", expectedGroupIds.length, actualGroupIds.size() ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByChecksumConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByChecksumConstraintTest.java index 61078f1d0..0b5fa0da2 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByChecksumConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByChecksumConstraintTest.java @@ -193,7 +193,7 @@ public class ArtifactsByChecksumConstraintTest private void assertConstraint( String msg, int count, ArtifactsByChecksumConstraint constraint ) throws Exception { - List results = artifactDao.queryArtifacts( constraint ); + List results = artifactDao.queryArtifacts( constraint ); assertNotNull( msg + ": Not Null", results ); assertEquals( msg + ": Results.size", count, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java index 5751c26e2..8b2841f0a 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java @@ -167,7 +167,7 @@ public class ArtifactsByRepositoryConstraintTest private void assertConstraint( String msg, int count, ArtifactsByRepositoryConstraint constraint ) throws Exception { - List results = artifactDao.queryArtifacts( constraint ); + List results = artifactDao.queryArtifacts( constraint ); assertNotNull( msg + ": Not Null", results ); assertEquals( msg + ": Results.size", count, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java index c1da3c42f..65719df90 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java @@ -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 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 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 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 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 results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) ); assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } ); } } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsRelatedConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsRelatedConstraintTest.java index 94a99af06..fc4de5b26 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsRelatedConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsRelatedConstraintTest.java @@ -82,7 +82,7 @@ public class ArtifactsRelatedConstraintTest private void assertConstraint( int expectedHits, Constraint constraint ) throws Exception { - List results = artifactDao.queryArtifacts( constraint ); + List results = artifactDao.queryArtifacts( constraint ); assertNotNull( "Related Artifacts: Not Null", results ); assertEquals( "Related Artifacts: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatisticsTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatisticsTest.java index 5214faa34..070a24769 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatisticsTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/MostRecentRepositoryScanStatisticsTest.java @@ -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 results = (List) 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 results = (List) dao.query( new MostRecentRepositoryScanStatistics( "internal" ) ); assertNotNull( "Stats: results (not null)", results ); assertEquals( "Stats: results.size", 1, results.size() ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java index 2b2dc7a74..c4936d274 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java @@ -95,7 +95,7 @@ public class OlderArtifactsByAgeConstraintTest private void assertConstraint( int expectedHits, Constraint constraint ) throws Exception { - List results = artifactDao.queryArtifacts( constraint ); + List results = artifactDao.queryArtifacts( constraint ); assertNotNull( "Older Artifacts By Age: Not Null", results ); assertEquals( "Older Artifacts By Age: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java index 13659dc6f..1cf8a6c91 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java @@ -110,7 +110,7 @@ public class OlderSnapshotArtifactsByAgeConstraintTest private void assertConstraint( int expectedHits, Constraint constraint ) throws Exception { - List results = artifactDao.queryArtifacts( constraint ); + List results = artifactDao.queryArtifacts( constraint ); assertNotNull( "Older Snapshot Artifacts By Age: Not Null", results ); assertEquals( "Older Snapshot Artifacts By Age: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java index 646c6381d..7795b3a9a 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java @@ -108,7 +108,7 @@ public class ProjectsByArtifactUsageConstraintTest private void assertConstraint( int expectedHits, DeclarativeConstraint constraint ) throws Exception { - List results = dao.getProjectModelDAO().queryProjectModels( constraint ); + List results = dao.getProjectModelDAO().queryProjectModels( constraint ); assertNotNull( "Projects By Artifact Usage: Not Null", results ); assertEquals( "Projects By Artifact Usage: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java index aa0618955..8f627983d 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java @@ -81,7 +81,7 @@ public class RangeConstraintTest private void assertConstraint( int expectedHits, Constraint constraint ) throws Exception { - List results = repoProblemDao.queryRepositoryProblems( constraint ); + List results = repoProblemDao.queryRepositoryProblems( constraint ); assertNotNull( "Range Constraint: Not Null", results ); assertEquals( "Range Constraint: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java index 3b4827884..da59b761b 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java @@ -97,7 +97,7 @@ public class RecentArtifactsByAgeConstraintTest private void assertConstraint( int expectedHits, Constraint constraint ) throws Exception { - List results = artifactDao.queryArtifacts( constraint ); + List results = artifactDao.queryArtifacts( constraint ); assertNotNull( "Recent Artifacts By Age: Not Null", results ); assertEquals( "Recent Artifacts By Age: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java index 71f10a735..2f500d77f 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java @@ -67,7 +67,7 @@ public class RepositoryContentStatisticsByRepositoryConstraintTest throws Exception { Constraint constraint = new RepositoryContentStatisticsByRepositoryConstraint( "internal" ); - List results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint ); + List 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 results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint ); assertNotNull( "Stats: results (not null)", results ); assertEquals( "Stats: results.size", 3, results.size() ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java index cc8b3f42b..14f66f412 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java @@ -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 results = repoProblemDao.queryRepositoryProblems( constraint ); assertNotNull( "Repository Problems by Group Id: Not Null", results ); assertEquals( "Repository Problems by Group Id: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java index 425fc0e8d..59d8016cd 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java @@ -86,7 +86,7 @@ public class RepositoryProblemByRepositoryIdConstraintTest private void assertConstraint( int expectedHits, Constraint constraint ) throws Exception { - List results = repoProblemDao.queryRepositoryProblems( constraint ); + List results = repoProblemDao.queryRepositoryProblems( constraint ); assertNotNull( "Repository Problems by Repository Id: Not Null", results ); assertEquals( "Repository Problems by Repository Id: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java index a593281ac..cc8dd55fa 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java @@ -122,7 +122,7 @@ public class RepositoryProblemConstraintTest private void assertConstraint( int expectedHits, Constraint constraint ) throws Exception { - List results = repoProblemDao.queryRepositoryProblems( constraint ); + List results = repoProblemDao.queryRepositoryProblems( constraint ); assertNotNull( "Repository Problems: Not Null", results ); assertEquals( "Repository Problems: Results.size", expectedHits, results.size() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java index 85535ab69..45a0316b4 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java @@ -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 results = dao.query( constraint ); + List results = (List) 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 results = dao.query( constraint ); + List results = (List) dao.query( constraint ); assertNotNull( prefix + "Not Null", results ); assertEquals( prefix + "Results.size", artifactIds.length, results.size() ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java index 36724d182..0edc344b6 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java @@ -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() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java index 8439d532a..9eaf7a4bc 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java @@ -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 results = dao.query( constraint ); + List results = (List) dao.query( constraint ); assertNotNull( prefix + "Not Null", results ); assertEquals( prefix + "Results.size", expectedGroupIds.length, results.size() ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueVersionConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueVersionConstraintTest.java index f94b65c4f..4d12bf49c 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueVersionConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueVersionConstraintTest.java @@ -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 results = dao.query( constraint ); + List results = (List) dao.query( constraint ); assertNotNull( prefix + "Not Null", results ); assertEquals( prefix + "Results.size", versions.length, results.size() ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java index 2fab7ade0..a21e3ecb2 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java @@ -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 artifacts = artiDao.queryArtifacts( null ); assertNotNull( artifacts ); assertEquals( 1, artifacts.size() ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java index bc5f63e2f..c51168468 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java @@ -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 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 exprs = new ArrayList(); 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 ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAOTest.java index 9dd7921e0..0034e3853 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAOTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAOTest.java @@ -51,7 +51,7 @@ public class JdoRepositoryContentStatisticsDAOTest assertEquals( "1[OID]org.apache.maven.archiva.model.RepositoryContentStatistics", savedKeyId ); // query - List results = + List results = repoContentStatisticsDAO.queryRepositoryContentStatistics( new RepositoryContentStatisticsByRepositoryConstraint( "internal" ) ); assertNotNull( results ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java index d13e86d14..b66fb4cc3 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java @@ -44,7 +44,7 @@ public class DatabaseConsumersTest throws Exception { DatabaseConsumers dbconsumers = lookupDbConsumers(); - List available = dbconsumers.getAvailableCleanupConsumers(); + List 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 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 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 available = dbconsumers.getSelectedUnprocessedConsumers(); assertNotNull( "Selected Unprocessed Consumers should never be null.", available ); assertTrue( "Selected Unprocessed Consumers should have entries.", CollectionUtils.isNotEmpty( available ) ); diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java index 1a468d8b2..599de9736 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java @@ -151,10 +151,11 @@ public class DefaultArchivaTaskScheduler } } + @SuppressWarnings("unchecked") private boolean isPreviouslyScanned( ManagedRepositoryConfiguration repoConfig ) { List results = - dao.query( new MostRecentRepositoryScanStatistics( repoConfig.getId() ) ); + (List) 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 { diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java index 08187c989..6163ed4f5 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java @@ -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 results = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) ); + List results = (List) 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 results, @@ -145,7 +148,7 @@ public class ArchivaRepositoryScanningTaskExecutor // total artifact count try { - List artifacts = dao.getArtifactDAO().queryArtifacts( + List artifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsByRepositoryConstraint( arepo.getId(), stats.getWhenGathered(), "groupId", true ) ); dbstats.setTotalArtifactCount( artifacts.size() ); } @@ -166,10 +169,10 @@ public class ArchivaRepositoryScanningTaskExecutor List repos = new ArrayList(); repos.add( arepo.getId() ); - List groupIds = dao.query( new UniqueGroupIdConstraint( repos ) ); + List groupIds = (List) dao.query( new UniqueGroupIdConstraint( repos ) ); dbstats.setTotalGroupCount( groupIds.size() ); - List artifactIds = dao.query( new UniqueArtifactIdConstraint( arepo.getId(), true ) ); + List artifactIds = (List) dao.query( new UniqueArtifactIdConstraint( arepo.getId(), true ) ); dbstats.setTotalProjectCount( artifactIds.size() ); return dbstats; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java index dab1bf0eb..493121c90 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java @@ -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 managedRepositories; - private String q; /** @@ -97,7 +96,7 @@ public class SearchAction private static final String ARTIFACT = "artifact"; - private List databaseResults; + private List 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 versions = - dao.query( new UniqueVersionConstraint( getObservableRepos(), resultHit.getGroupId(), - resultHit.getArtifactId() ) ); + (List) 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 getDatabaseResults() { return databaseResults; } @@ -543,7 +544,6 @@ public class SearchAction public void setManagedRepositories( Map managedRepositories ) { - this.managedRepositories = managedRepositories; } public String getGroupId() diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java index ec349b9af..c36cc1ab8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java @@ -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 results = - dao.query( new MostRecentRepositoryScanStatistics( repo.getId() ) ); + (List) dao.query( new MostRecentRepositoryScanStatistics( repo.getId() ) ); if ( !results.isEmpty() ) { repositoryStatistics.put( repo.getId(), results.get( 0 ) ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java index 94c9f5eea..f38012909 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java @@ -152,12 +152,13 @@ public class GenerateReportAction private InputStream inputStream; + @SuppressWarnings("unchecked") public void prepare() { repositoryIds = new ArrayList(); 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) dao.query( new UniqueFieldConstraint( RepositoryProblem.class.getName(), + "repositoryId" ) ) ); availableRepositories = new ArrayList(); @@ -449,7 +450,7 @@ public class GenerateReportAction { try { - List contentStats = repoContentStatsDao.queryRepositoryContentStatistics( + List contentStats = repoContentStatsDao.queryRepositoryContentStatistics( new RepositoryContentStatisticsByRepositoryConstraint( repo, startDateInDF, endDateInDF ) ); if ( contentStats == null || contentStats.isEmpty() ) -- 2.39.5