]> source.dussan.org Git - archiva.git/commitdiff
warnings in repository layer and some bugs found due to non-generic lists
authorBrett Porter <brett@apache.org>
Tue, 17 Mar 2009 16:13:38 +0000 (16:13 +0000)
committerBrett Porter <brett@apache.org>
Tue, 17 Mar 2009 16:13:38 +0000 (16:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755296 13f79535-47bb-0310-9956-ffa450edef68

18 files changed:
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataMerge.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContentTest.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java

index 0b17ecc63221d6dacd0c9d7ef4d192641468d781..53b9e145c6903ca9ae1d919dbdf88aa77a7f19dc 100644 (file)
@@ -19,15 +19,14 @@ package org.apache.maven.archiva.repository.content;
  * under the License.
  */
 
+import java.util.Collection;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.LegacyArtifactPath;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 
-import java.util.Collection;
-import java.util.Iterator;
-
 /**
  * LegacyPathParser is a parser for maven 1 (legacy layout) paths to
  * ArtifactReference.
@@ -58,10 +57,9 @@ public class LegacyPathParser
         ArtifactReference artifact = new ArtifactReference();
 
         // First, look if a custom resolution rule has been set for this artifact
-        Collection legacy = configuration.getConfiguration().getLegacyArtifactPaths();
-        for ( Iterator iterator = legacy.iterator(); iterator.hasNext(); )
+        Collection<LegacyArtifactPath> legacy = configuration.getConfiguration().getLegacyArtifactPaths();
+        for ( LegacyArtifactPath legacyPath : legacy )
         {
-            LegacyArtifactPath legacyPath = (LegacyArtifactPath) iterator.next();
             if ( legacyPath.match( path ) )
             {                  
                            artifact.setGroupId( legacyPath.getGroupId() );
index b4d16b16d3a3d1b464ec6df524a175f2cbb25001..cfd48c31749e0f5428148ce3e10dba9723e4db26 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.maven.archiva.repository.events;
 
 import java.util.List;
 
-import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.FactoryBean;
 import org.springframework.context.ApplicationContext;
@@ -49,7 +48,8 @@ public class RepositoryListenerFactoryBean
         return applicationContext.getBeansOfType( RepositoryListener.class ).values();
     }
 
-    public Class getObjectType()
+    @SuppressWarnings("unchecked")
+    public Class<List> getObjectType()
     {
         return List.class;
     }
index 47d4fadd3fa292b64a96d47533076668bc363bcb..5d53a7d9653650491347135c18b540358f311e0f 100644 (file)
@@ -20,14 +20,13 @@ package org.apache.maven.archiva.repository.metadata;
  */
 
 import java.util.ArrayList;
-import org.apache.maven.archiva.model.ArchivaModelCloner;
-import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
-import org.apache.maven.archiva.model.SnapshotVersion;
-
-import java.util.Iterator;
 import java.util.List;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.model.ArchivaModelCloner;
+import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
 import org.apache.maven.archiva.model.Plugin;
+import org.apache.maven.archiva.model.SnapshotVersion;
 
 /**
  * RepositoryMetadataMerge 
@@ -170,7 +169,7 @@ public class RepositoryMetadataMerge
         return main;
     }
     
-    private static List mergePlugins(List mainPlugins, List sourcePlugins)
+    private static List<Plugin> mergePlugins(List<Plugin> mainPlugins, List<Plugin> sourcePlugins)
     {
         if ( sourcePlugins == null )
         {
@@ -182,12 +181,10 @@ public class RepositoryMetadataMerge
             return clonePlugins( sourcePlugins );
         }
         
-        List merged = clonePlugins( mainPlugins );
+        List<Plugin> merged = clonePlugins( mainPlugins );
         
-        Iterator it = sourcePlugins.iterator();
-        while ( it.hasNext() )
+        for ( Plugin plugin : sourcePlugins )
         {
-            Plugin plugin = (Plugin) it.next();
             if ( !merged.contains( plugin ) )
             {
                 merged.add( plugin );
@@ -213,7 +210,7 @@ public class RepositoryMetadataMerge
             return null;
         }
         
-        ArrayList result = new ArrayList();
+        List<Plugin> result = new ArrayList<Plugin>();
         
         for (Plugin plugin : plugins)
         {
@@ -227,7 +224,7 @@ public class RepositoryMetadataMerge
         return result;
     }
 
-    private static List mergeAvailableVersions( List mainAvailableVersions, List sourceAvailableVersions )
+    private static List<String> mergeAvailableVersions( List<String> mainAvailableVersions, List<String> sourceAvailableVersions )
     {
         if ( sourceAvailableVersions == null )
         {
@@ -239,12 +236,10 @@ public class RepositoryMetadataMerge
             return ArchivaModelCloner.cloneAvailableVersions( sourceAvailableVersions );
         }
 
-        List merged = ArchivaModelCloner.cloneAvailableVersions( mainAvailableVersions );
+        List<String> merged = ArchivaModelCloner.cloneAvailableVersions( mainAvailableVersions );
 
-        Iterator it = sourceAvailableVersions.iterator();
-        while ( it.hasNext() )
+        for ( String sourceVersion : sourceAvailableVersions )
         {
-            String sourceVersion = (String) it.next();
             if ( !merged.contains( sourceVersion ) )
             {
                 merged.add( sourceVersion );
index 84b8745645b91292f3b7d9924cf987e7b311df43..f84d9f48f68947a50924ddaac6ec810434b57ef7 100644 (file)
@@ -19,6 +19,16 @@ package org.apache.maven.archiva.repository.project;
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.model.ArchivaModelCloner;
 import org.apache.maven.archiva.model.ArchivaProjectModel;
@@ -33,17 +43,6 @@ import org.apache.maven.archiva.model.Organization;
 import org.apache.maven.archiva.model.ProjectRepository;
 import org.apache.maven.archiva.model.Scm;
 
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Map.Entry;
-
 /**
  * ProjectModelMerge
  *
@@ -107,14 +106,12 @@ public class ProjectModelMerge
         return merged;
     }
 
-    private static Map createArtifactReferenceMap( List artifactReferences )
+    private static Map<String, ArtifactReference> createArtifactReferenceMap( List<ArtifactReference> artifactReferences )
     {
-        Map ret = new HashMap();
+        Map<String, ArtifactReference> ret = new HashMap<String, ArtifactReference>();
 
-        Iterator it = artifactReferences.iterator();
-        while ( it.hasNext() )
+        for ( ArtifactReference artifactReference : artifactReferences )
         {
-            ArtifactReference artifactReference = (ArtifactReference) it.next();
             String key = toVersionlessArtifactKey( artifactReference );
             ret.put( key, artifactReference );
         }
@@ -122,14 +119,14 @@ public class ProjectModelMerge
         return ret;
     }
 
-    private static Map createDependencyMap( List dependencies )
+    private static Map<String, Dependency> createDependencyMap( List<Dependency> dependencies )
     {
-        Map ret = new HashMap();
+        Map<String, Dependency> ret = new HashMap<String, Dependency>();
 
-        Iterator it = dependencies.iterator();
+        Iterator<Dependency> it = dependencies.iterator();
         while ( it.hasNext() )
         {
-            Dependency dep = (Dependency) it.next();
+            Dependency dep = it.next();
             String key = toVersionlessDependencyKey( dep );
             ret.put( key, dep );
         }
@@ -137,14 +134,14 @@ public class ProjectModelMerge
         return ret;
     }
 
-    private static Map createExclusionMap( List exclusions )
+    private static Map<String, Exclusion> createExclusionMap( List<Exclusion> exclusions )
     {
-        Map ret = new HashMap();
+        Map<String, Exclusion> ret = new HashMap<String, Exclusion>();
 
-        Iterator it = exclusions.iterator();
+        Iterator<Exclusion> it = exclusions.iterator();
         while ( it.hasNext() )
         {
-            Exclusion exclusion = (Exclusion) it.next();
+            Exclusion exclusion = it.next();
             String key = exclusion.getGroupId() + ":" + exclusion.getArtifactId();
             ret.put( key, exclusion );
         }
@@ -152,14 +149,12 @@ public class ProjectModelMerge
         return ret;
     }
 
-    private static Map createLicensesMap( List licenses )
+    private static Map<String, License> createLicensesMap( List<License> licenses )
     {
-        Map ret = new HashMap();
+        Map<String, License> ret = new HashMap<String, License>();
 
-        Iterator it = licenses.iterator();
-        while ( it.hasNext() )
+        for ( License license : licenses )
         {
-            License license = (License) it.next();
             // TODO: Change to 'id' when LicenseTypeMapper is created.
             String key = license.getName();
             ret.put( key, license );
@@ -168,14 +163,12 @@ public class ProjectModelMerge
         return ret;
     }
 
-    private static Map createRepositoriesMap( List repositories )
+    private static Map<String, ProjectRepository> createRepositoriesMap( List<ProjectRepository> repositories )
     {
-        Map ret = new HashMap();
+        Map<String, ProjectRepository> ret = new HashMap<String, ProjectRepository>();
 
-        Iterator it = repositories.iterator();
-        while ( it.hasNext() )
+        for ( ProjectRepository repo : repositories )
         {
-            ProjectRepository repo = (ProjectRepository) it.next();
             // Should this really be using repo.id ?
             String key = repo.getUrl();
             ret.put( key, repo );
@@ -321,6 +314,7 @@ public class ProjectModelMerge
         return merged;
     }
 
+    @SuppressWarnings("unchecked")
     private static Properties merge( Properties mainProperties, Properties parentProperties )
     {
         if ( parentProperties == null )
@@ -336,7 +330,7 @@ public class ProjectModelMerge
         Properties merged = new Properties();
         merged.putAll(mainProperties);
 
-        Enumeration keys = parentProperties.propertyNames();
+        Enumeration<String> keys = (Enumeration<String>) parentProperties.propertyNames();
         while ( keys.hasMoreElements() )
         {
             String key = (String) keys.nextElement();
@@ -377,7 +371,7 @@ public class ProjectModelMerge
         return main;
     }
 
-    private static List mergeArtifactReferences( List mainArtifactReferences, List parentArtifactReferences )
+    private static List<ArtifactReference> mergeArtifactReferences( List<ArtifactReference> mainArtifactReferences, List<ArtifactReference> parentArtifactReferences )
     {
         if ( parentArtifactReferences == null )
         {
@@ -386,21 +380,19 @@ public class ProjectModelMerge
 
         if ( mainArtifactReferences == null )
         {
-            return ArchivaModelCloner.cloneLicenses( parentArtifactReferences );
+            return ArchivaModelCloner.cloneArtifactReferences( parentArtifactReferences );
         }
 
-        List merged = new ArrayList();
+        List<ArtifactReference> merged = new ArrayList<ArtifactReference>();
 
-        Map mainArtifactReferenceMap = createArtifactReferenceMap( mainArtifactReferences );
-        Map parentArtifactReferenceMap = createArtifactReferenceMap( parentArtifactReferences );
+        Map<String, ArtifactReference> mainArtifactReferenceMap = createArtifactReferenceMap( mainArtifactReferences );
+        Map<String, ArtifactReference> parentArtifactReferenceMap = createArtifactReferenceMap( parentArtifactReferences );
 
-        Iterator it = mainArtifactReferenceMap.entrySet().iterator();
-        while ( it.hasNext() )
+        for ( Map.Entry<String,ArtifactReference> entry : mainArtifactReferenceMap.entrySet() )
         {
-            Map.Entry entry = (Entry) it.next();
-            String key = (String) entry.getKey();
+            String key = entry.getKey();
             ArtifactReference mainArtifactReference = (ArtifactReference) entry.getValue();
-            ArtifactReference parentArtifactReference = (ArtifactReference) parentArtifactReferenceMap.get( key );
+            ArtifactReference parentArtifactReference = parentArtifactReferenceMap.get( key );
 
             if ( parentArtifactReference == null )
             {
@@ -416,7 +408,7 @@ public class ProjectModelMerge
         return merged;
     }
 
-    private static List mergeDependencies( List mainDependencies, List parentDependencies )
+    private static List<Dependency> mergeDependencies( List<Dependency> mainDependencies, List<Dependency> parentDependencies )
     {
         if ( parentDependencies == null )
         {
@@ -425,30 +417,30 @@ public class ProjectModelMerge
 
         if ( mainDependencies == null )
         {
-            List merged = ArchivaModelCloner.cloneDependencies( parentDependencies );
-            Iterator it = merged.iterator();
+            List<Dependency> merged = ArchivaModelCloner.cloneDependencies( parentDependencies );
+            Iterator<Dependency> it = merged.iterator();
             while ( it.hasNext() )
             {
-                Dependency dep = (Dependency) it.next();
+                Dependency dep = it.next();
                 dep.setFromParent( true );
             }
             return merged;
         }
 
-        List merged = new ArrayList();
+        List<Dependency> merged = new ArrayList<Dependency>();
 
-        Map mainDepMap = createDependencyMap( mainDependencies );
-        Map parentDepMap = createDependencyMap( parentDependencies );
-        Set uniqueKeys = new HashSet();
+        Map<String, Dependency> mainDepMap = createDependencyMap( mainDependencies );
+        Map<String, Dependency> parentDepMap = createDependencyMap( parentDependencies );
+        Set<String> uniqueKeys = new HashSet<String>();
         uniqueKeys.addAll( mainDepMap.keySet() );
         uniqueKeys.addAll( parentDepMap.keySet() );
 
-        Iterator it = uniqueKeys.iterator();
+        Iterator<String> it = uniqueKeys.iterator();
         while ( it.hasNext() )
         {
-            String key = (String) it.next();
-            Dependency parentDep = (Dependency) parentDepMap.get( key );
-            Dependency mainDep = (Dependency) mainDepMap.get( key );
+            String key = it.next();
+            Dependency parentDep = parentDepMap.get( key );
+            Dependency mainDep = mainDepMap.get( key );
 
             if ( parentDep == null )
             {
@@ -466,7 +458,7 @@ public class ProjectModelMerge
         return merged;
     }
 
-    private static List mergeDependencyManagement( List mainDepMgmt, List parentDepMgmt )
+    private static List<Dependency> mergeDependencyManagement( List<Dependency> mainDepMgmt, List<Dependency> parentDepMgmt )
     {
         if ( parentDepMgmt == null )
         {
@@ -475,30 +467,30 @@ public class ProjectModelMerge
 
         if ( mainDepMgmt == null )
         {
-            List merged = ArchivaModelCloner.cloneDependencies( parentDepMgmt );
-            Iterator it = merged.iterator();
+            List<Dependency> merged = ArchivaModelCloner.cloneDependencies( parentDepMgmt );
+            Iterator<Dependency> it = merged.iterator();
             while ( it.hasNext() )
             {
-                Dependency dep = (Dependency) it.next();
+                Dependency dep = it.next();
                 dep.setFromParent( true );
             }
             return merged;
         }
 
-        List merged = new ArrayList();
+        List<Dependency> merged = new ArrayList<Dependency>();
 
-        Map mainDepMap = createDependencyMap( mainDepMgmt );
-        Map parentDepMap = createDependencyMap( parentDepMgmt );
-        Set uniqueKeys = new HashSet();
+        Map<String, Dependency> mainDepMap = createDependencyMap( mainDepMgmt );
+        Map<String, Dependency> parentDepMap = createDependencyMap( parentDepMgmt );
+        Set<String> uniqueKeys = new HashSet<String>();
         uniqueKeys.addAll( mainDepMap.keySet() );
         uniqueKeys.addAll( parentDepMap.keySet() );
 
-        Iterator it = uniqueKeys.iterator();
+        Iterator<String> it = uniqueKeys.iterator();
         while ( it.hasNext() )
         {
-            String key = (String) it.next();
-            Dependency parentDep = (Dependency) parentDepMap.get( key );
-            Dependency mainDep = (Dependency) mainDepMap.get( key );
+            String key = it.next();
+            Dependency parentDep = parentDepMap.get( key );
+            Dependency mainDep = mainDepMap.get( key );
 
             if ( parentDep == null )
             {
@@ -516,7 +508,7 @@ public class ProjectModelMerge
         return merged;
     }
 
-    public static List mergeExclusions( List mainExclusions, List parentExclusions )
+    public static List<Exclusion> mergeExclusions( List<Exclusion> mainExclusions, List<Exclusion> parentExclusions )
     {
         if ( parentExclusions == null )
         {
@@ -528,18 +520,16 @@ public class ProjectModelMerge
             return ArchivaModelCloner.cloneExclusions( parentExclusions );
         }
 
-        List merged = new ArrayList();
+        List<Exclusion> merged = new ArrayList<Exclusion>();
 
-        Map mainExclusionMap = createExclusionMap( mainExclusions );
-        Map parentExclusionMap = createExclusionMap( parentExclusions );
+        Map<String, Exclusion> mainExclusionMap = createExclusionMap( mainExclusions );
+        Map<String, Exclusion> parentExclusionMap = createExclusionMap( parentExclusions );
 
-        Iterator it = mainExclusionMap.entrySet().iterator();
-        while ( it.hasNext() )
+        for ( Map.Entry<String, Exclusion> entry : mainExclusionMap.entrySet() )
         {
-            Map.Entry entry = (Entry) it.next();
-            String key = (String) entry.getKey();
-            Exclusion mainExclusion = (Exclusion) entry.getValue();
-            Exclusion parentExclusion = (Exclusion) parentExclusionMap.get( key );
+            String key = entry.getKey();
+            Exclusion mainExclusion = entry.getValue();
+            Exclusion parentExclusion = parentExclusionMap.get( key );
 
             if ( parentExclusion == null )
             {
@@ -554,7 +544,7 @@ public class ProjectModelMerge
         return merged;
     }
 
-    private static List mergeIndividuals( List mainIndividuals, List parentIndividuals )
+    private static List<Individual> mergeIndividuals( List<Individual> mainIndividuals, List<Individual> parentIndividuals )
     {
         if ( parentIndividuals == null )
         {
@@ -566,12 +556,12 @@ public class ProjectModelMerge
             return ArchivaModelCloner.cloneIndividuals( parentIndividuals );
         }
 
-        List merged = ArchivaModelCloner.cloneIndividuals( mainIndividuals );
+        List<Individual> merged = ArchivaModelCloner.cloneIndividuals( mainIndividuals );
 
-        Iterator it = parentIndividuals.iterator();
+        Iterator<Individual> it = parentIndividuals.iterator();
         while ( it.hasNext() )
         {
-            Individual parentIndividual = (Individual) it.next();
+            Individual parentIndividual = it.next();
 
             if ( !mainIndividuals.contains( parentIndividual ) )
             {
@@ -582,7 +572,7 @@ public class ProjectModelMerge
         return merged;
     }
 
-    private static List mergeLicenses( List mainLicenses, List parentLicenses )
+    private static List<License> mergeLicenses( List<License> mainLicenses, List<License> parentLicenses )
     {
         if ( parentLicenses == null )
         {
@@ -594,18 +584,16 @@ public class ProjectModelMerge
             return ArchivaModelCloner.cloneLicenses( parentLicenses );
         }
 
-        List merged = new ArrayList();
+        List<License> merged = new ArrayList<License>();
 
-        Map mainLicensesMap = createLicensesMap( mainLicenses );
-        Map parentLicensesMap = createLicensesMap( parentLicenses );
+        Map<String, License> mainLicensesMap = createLicensesMap( mainLicenses );
+        Map<String, License> parentLicensesMap = createLicensesMap( parentLicenses );
 
-        Iterator it = mainLicensesMap.entrySet().iterator();
-        while ( it.hasNext() )
+        for ( Map.Entry<String, License> entry : mainLicensesMap.entrySet() )
         {
-            Map.Entry entry = (Entry) it.next();
-            String key = (String) entry.getKey();
-            License mainLicense = (License) entry.getValue();
-            License parentLicense = (License) parentLicensesMap.get( key );
+            String key = entry.getKey();
+            License mainLicense = entry.getValue();
+            License parentLicense = parentLicensesMap.get( key );
 
             if ( parentLicense == null )
             {
@@ -621,17 +609,17 @@ public class ProjectModelMerge
         return merged;
     }
 
-    private static List mergePlugins( List mainPlugins, List parentPlugins )
+    private static List<ArtifactReference> mergePlugins( List<ArtifactReference> mainPlugins, List<ArtifactReference> parentPlugins )
     {
         return mergeArtifactReferences( mainPlugins, parentPlugins );
     }
 
-    private static List mergeReports( List mainReports, List parentReports )
+    private static List<ArtifactReference> mergeReports( List<ArtifactReference> mainReports, List<ArtifactReference> parentReports )
     {
         return mergeArtifactReferences( mainReports, parentReports );
     }
 
-    private static List mergeRepositories( List mainRepositories, List parentRepositories )
+    private static List<ProjectRepository> mergeRepositories( List<ProjectRepository> mainRepositories, List<ProjectRepository> parentRepositories )
     {
         if ( parentRepositories == null )
         {
@@ -640,21 +628,19 @@ public class ProjectModelMerge
 
         if ( mainRepositories == null )
         {
-            return ArchivaModelCloner.cloneLicenses( parentRepositories );
+            return ArchivaModelCloner.cloneRepositories( parentRepositories );
         }
 
-        List merged = new ArrayList();
+        List<ProjectRepository> merged = new ArrayList<ProjectRepository>();
 
-        Map mainRepositoriesMap = createRepositoriesMap( mainRepositories );
-        Map parentRepositoriesMap = createRepositoriesMap( parentRepositories );
+        Map<String, ProjectRepository> mainRepositoriesMap = createRepositoriesMap( mainRepositories );
+        Map<String, ProjectRepository> parentRepositoriesMap = createRepositoriesMap( parentRepositories );
 
-        Iterator it = mainRepositoriesMap.entrySet().iterator();
-        while ( it.hasNext() )
+        for ( Map.Entry<String, ProjectRepository> entry : mainRepositoriesMap.entrySet() )
         {
-            Map.Entry entry = (Entry) it.next();
-            String key = (String) entry.getKey();
-            ProjectRepository mainProjectRepository = (ProjectRepository) entry.getValue();
-            ProjectRepository parentProjectRepository = (ProjectRepository) parentRepositoriesMap.get( key );
+            String key = entry.getKey();
+            ProjectRepository mainProjectRepository = entry.getValue();
+            ProjectRepository parentProjectRepository = parentRepositoriesMap.get( key );
 
             if ( parentProjectRepository == null )
             {
index f502e464915b0be4e9602163f76d6cd30a2be560..02c3b41574fb89986890bae83d75b827bb2a433b 100644 (file)
@@ -68,6 +68,7 @@ public class ProjectModelExpressionFilter
      * 
      * @param model the model to correct.
      */
+    @SuppressWarnings("unchecked")
     public ArchivaProjectModel filter( final ArchivaProjectModel model )
         throws ProjectModelException
     {
index 600f738ae2c1a44902965fb4d953a376f2750515..74ebf1be86f9f02f6c0d94dfd0e4dfd05b0a5cf6 100644 (file)
@@ -139,6 +139,7 @@ public class ProjectModel300Reader
         return getDependencyList( xml, new String[] { "dependencies" } );
     }
 
+    @SuppressWarnings("unchecked")
     private List<Dependency> getDependencyList( XMLReader xml, String parts[] )
         throws XMLException
     {
@@ -200,6 +201,7 @@ public class ProjectModel300Reader
         return individuals;
     }
 
+    @SuppressWarnings("unchecked")
     private List<Individual> getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr )
         throws XMLException
     {
@@ -270,6 +272,7 @@ public class ProjectModel300Reader
         return issueMgmt;
     }
 
+    @SuppressWarnings("unchecked")
     private List<License> getLicenses( XMLReader xml )
         throws XMLException
     {
@@ -297,6 +300,7 @@ public class ProjectModel300Reader
         return licenses;
     }
 
+    @SuppressWarnings("unchecked")
     private List<MailingList> getMailingLists( XMLReader xml )
         throws XMLException
     {
@@ -351,6 +355,7 @@ public class ProjectModel300Reader
         return null;
     }
 
+    @SuppressWarnings("unchecked")
     private Properties getProperties( Element elemProperties )
     {
         if ( elemProperties == null )
index ff86ecb4b105f42346c540209a5a5b4ccc7be178..534342392cf7d2b36c979bcd87b43fb5236074ef 100644 (file)
@@ -37,14 +37,14 @@ import org.apache.maven.archiva.repository.project.ProjectModelResolver;
  */
 public class ProjectModelResolverStack
 {
-    private List resolvers;
+    private List<ProjectModelResolver> resolvers;
 
-    private List listeners;
+    private List<ProjectModelResolutionListener> listeners;
 
     public ProjectModelResolverStack()
     {
-        this.resolvers = new ArrayList();
-        this.listeners = new ArrayList();
+        this.resolvers = new ArrayList<ProjectModelResolver>();
+        this.listeners = new ArrayList<ProjectModelResolutionListener>();
     }
 
     public void addListener( ProjectModelResolutionListener listener )
@@ -81,11 +81,11 @@ public class ProjectModelResolverStack
 
         triggerResolutionStart( projectRef, this.resolvers );
 
-        Iterator it = this.resolvers.iterator();
+        Iterator<ProjectModelResolver> it = this.resolvers.iterator();
 
         while ( it.hasNext() )
         {
-            ProjectModelResolver resolver = (ProjectModelResolver) it.next();
+            ProjectModelResolver resolver = it.next();
 
             try
             {
@@ -149,10 +149,10 @@ public class ProjectModelResolverStack
 
     private void triggerResolutionAttempting( VersionedReference projectRef, ProjectModelResolver resolver )
     {
-        Iterator it = this.listeners.iterator();
+        Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
         while ( it.hasNext() )
         {
-            ProjectModelResolutionListener listener = (ProjectModelResolutionListener) it.next();
+            ProjectModelResolutionListener listener = it.next();
 
             try
             {
@@ -167,10 +167,10 @@ public class ProjectModelResolverStack
 
     private void triggerResolutionError( VersionedReference projectRef, ProjectModelResolver resolver, Exception cause )
     {
-        Iterator it = this.listeners.iterator();
+        Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
         while ( it.hasNext() )
         {
-            ProjectModelResolutionListener listener = (ProjectModelResolutionListener) it.next();
+            ProjectModelResolutionListener listener = it.next();
 
             try
             {
@@ -185,10 +185,10 @@ public class ProjectModelResolverStack
 
     private void triggerResolutionMiss( VersionedReference projectRef, ProjectModelResolver resolver )
     {
-        Iterator it = this.listeners.iterator();
+        Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
         while ( it.hasNext() )
         {
-            ProjectModelResolutionListener listener = (ProjectModelResolutionListener) it.next();
+            ProjectModelResolutionListener listener = it.next();
 
             try
             {
@@ -201,12 +201,12 @@ public class ProjectModelResolverStack
         }
     }
 
-    private void triggerResolutionNotFound( VersionedReference projectRef, List resolvers )
+    private void triggerResolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolvers )
     {
-        Iterator it = this.listeners.iterator();
+        Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
         while ( it.hasNext() )
         {
-            ProjectModelResolutionListener listener = (ProjectModelResolutionListener) it.next();
+            ProjectModelResolutionListener listener = it.next();
 
             try
             {
@@ -219,12 +219,12 @@ public class ProjectModelResolverStack
         }
     }
 
-    private void triggerResolutionStart( VersionedReference projectRef, List resolvers )
+    private void triggerResolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolvers )
     {
-        Iterator it = this.listeners.iterator();
+        Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
         while ( it.hasNext() )
         {
-            ProjectModelResolutionListener listener = (ProjectModelResolutionListener) it.next();
+            ProjectModelResolutionListener listener = it.next();
 
             try
             {
@@ -240,10 +240,10 @@ public class ProjectModelResolverStack
     private void triggerResolutionSuccess( VersionedReference projectRef, ProjectModelResolver resolver,
                                            ArchivaProjectModel model )
     {
-        Iterator it = this.listeners.iterator();
+        Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
         while ( it.hasNext() )
         {
-            ProjectModelResolutionListener listener = (ProjectModelResolutionListener) it.next();
+            ProjectModelResolutionListener listener = it.next();
 
             try
             {
index 64de8f9599e4384f0f72d71d324db126f3b520c8..1141eba27090b48cbb2c70307122e41aeac6cdbc 100644 (file)
@@ -505,6 +505,7 @@ public class ProjectModel400Writer
     /**
      * Fix the default namespace on all elements recursively.
      */
+    @SuppressWarnings("unchecked")
     private void fixDefaultNamespace( Element elem )
     {
         elem.remove( elem.getNamespace() );
index 7422b79d3cce5f44adbdeaa15cab8694f15ec706..f5784509c23fd68c35d03bb73bea8fbde40249d2 100644 (file)
@@ -31,8 +31,6 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
 import org.apache.maven.archiva.repository.RepositoryException;
 import org.codehaus.plexus.util.DirectoryWalker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * DefaultRepositoryScanner
@@ -43,8 +41,6 @@ import org.slf4j.LoggerFactory;
 public class DefaultRepositoryScanner
     implements RepositoryScanner
 {
-    private Logger log = LoggerFactory.getLogger( DefaultRepositoryScanner.class );
-    
     /**
      * @plexus.requirement
      */
index 8e95d793c60d2880c7304113da1d7a904153e963..119165b0bf3b9060c64dccc93769fc5fa4df1447 100644 (file)
@@ -202,9 +202,10 @@ public class RepositoryContentConsumers
      * @return the list of all available {@link KnownRepositoryContentConsumer} present in the classpath and as a
      *         component in the IoC.
      */
+    @SuppressWarnings("unchecked")
     public List<KnownRepositoryContentConsumer> getAvailableKnownConsumers()
     {
-        return new ArrayList( applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class ).values() );
+        return new ArrayList<KnownRepositoryContentConsumer>( applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class ).values() );
     }
 
     /**
@@ -214,9 +215,10 @@ public class RepositoryContentConsumers
      * @return the list of all available {@link InvalidRepositoryContentConsumer} present in the classpath and as a
      *         component in the IoC.
      */
+    @SuppressWarnings("unchecked")
     public List<InvalidRepositoryContentConsumer> getAvailableInvalidConsumers()
     {
-        return new ArrayList( applicationContext.getBeansOfType( InvalidRepositoryContentConsumer.class ).values() );
+        return new ArrayList<InvalidRepositoryContentConsumer>( applicationContext.getBeansOfType( InvalidRepositoryContentConsumer.class ).values() );
     }
 
     /**
index 798d78c9bfea95d624ad43dfb2a5bb5157ff9b3f..c525d942418188791e8699ba3a7e897c3a2f024b 100644 (file)
@@ -50,7 +50,7 @@ public class ManagedDefaultRepositoryContentTest
     public void testGetVersionsBadArtifact()
         throws Exception
     {
-        assertGetVersions( "bad_artifact", Collections.EMPTY_LIST );
+        assertGetVersions( "bad_artifact", Collections.<String>emptyList() );
     }
 
     public void testGetVersionsMissingMultipleVersions()
index 92dbaefddb5123fbb6b997325540f958112c51db..468a6b3e157b850c685f9cedb8c60771202b9679 100644 (file)
@@ -378,12 +378,6 @@ public class MetadataToolsTest
         assertEquals( "Repository Specific Metadata Path", expected, actual );
     }
 
-    private void assertUpdatedProjectMetadata( String artifactId, String[] expectedVersions )
-        throws Exception
-    {
-        assertUpdatedProjectMetadata( artifactId, expectedVersions, null, null );
-    }
-
     private void assertUpdatedProjectMetadata( String artifactId, String[] expectedVersions, String latestVersion,
                                                String releaseVersion )
         throws Exception
index 65cebae74bada3511185401efd8f766306162a8e..29e50a58937a8f2510a820088b4c64179d02c073 100644 (file)
@@ -54,12 +54,12 @@ public class InvalidScanConsumer
         /* do nothing */
     }
 
-    public List getExcludes()
+    public List<String> getExcludes()
     {
         return null;
     }
 
-    public List getIncludes()
+    public List<String> getIncludes()
     {
         return null;
     }
index f8d7fd70a08daf2802909dc0e31da4a1cbda8966..0ab62fe4609dd5bf57cd3a04d45140cc6cb0d75c 100644 (file)
@@ -40,11 +40,11 @@ public class KnownScanConsumer
 {
     private int processCount = 0;
 
-    private List includes = new ArrayList();
+    private List<String> includes = new ArrayList<String>();
 
     private boolean processUnmodified = false;
 
-    public List getExcludes()
+    public List<String> getExcludes()
     {
         return null;
     }
@@ -55,7 +55,7 @@ public class KnownScanConsumer
         this.includes.addAll( Arrays.asList( includesArray ) );
     }
 
-    public List getIncludes()
+    public List<String> getIncludes()
     {
         return includes;
     }
index 5717b2de71973aedc0dda934d65877ac8645ce13..5906c764177593764108f40daa6f621d4c4f1a17 100644 (file)
@@ -321,18 +321,19 @@ public class RepositoryContentConsumersTest
         return path;
     }
 
-    private static Map convertToMap(List objects)
+    @SuppressWarnings("unchecked")
+    public class MockApplicationContext implements ApplicationContext
     {
-        HashMap map = new HashMap();
-        for (Object o : objects)
+        private Map convertToMap(List objects)
         {
-            map.put(o, o);
+            HashMap map = new HashMap();
+            for (Object o : objects)
+            {
+                map.put(o, o);
+            }
+            return map;
         }
-        return map;
-    }
 
-    public class MockApplicationContext implements ApplicationContext
-    {
         private List<KnownRepositoryContentConsumer> knownRepositoryContentConsumer;
 
         private List<InvalidRepositoryContentConsumer> invalidRepositoryContentConsumers;
index 0ae9d08284dfa5580d814d0b3c57a967c6bd1402..22cd183b0731cace52485da047789ff85599f521 100644 (file)
@@ -21,6 +21,8 @@ package org.apache.maven.archiva.repository.scanner;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.maven.archiva.model.RepositoryContentStatistics;
 import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
 
@@ -109,9 +111,9 @@ public class RepositoryScannerTest
         return (RepositoryScanner) lookup( RepositoryScanner.class );
     }
 
-    private List getIgnoreList()
+    private List<String> getIgnoreList()
     {
-        List ignores = new ArrayList();
+        List<String> ignores = new ArrayList<String>();
         ignores.addAll( Arrays.asList( RepositoryScanner.IGNORABLE_CONTENT ) );
         return ignores;
     }
@@ -121,12 +123,12 @@ public class RepositoryScannerTest
     {
         ManagedRepositoryConfiguration repository = createSimpleRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
         consumer.setIncludes( ARTIFACT_PATTERNS );
         knownConsumers.add( consumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
@@ -147,12 +149,12 @@ public class RepositoryScannerTest
     {
         ManagedRepositoryConfiguration repository = createSimpleRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
         consumer.setIncludes( ARTIFACT_PATTERNS );
         knownConsumers.add( consumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
@@ -172,13 +174,13 @@ public class RepositoryScannerTest
     {
         ManagedRepositoryConfiguration repository = createSimpleRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
         consumer.setProcessUnmodified( true );
         consumer.setIncludes( ARTIFACT_PATTERNS );
         knownConsumers.add( consumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
@@ -198,13 +200,13 @@ public class RepositoryScannerTest
     {
         ManagedRepositoryConfiguration repository = createDefaultRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
         consumer.setIncludes( new String[]{"**/*.jar", "**/*.war", "**/*.pom", "**/maven-metadata.xml", "**/*-site.xml",
             "**/*.zip", "**/*.tar.gz", "**/*.sha1", "**/*.md5"} );
         knownConsumers.add( consumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
@@ -221,7 +223,7 @@ public class RepositoryScannerTest
     public void testDefaultRepositoryArtifactScanner()
         throws Exception
     {
-        List actualArtifactPaths = new ArrayList();
+        List<String> actualArtifactPaths = new ArrayList<String>();
 
         actualArtifactPaths.add( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
         actualArtifactPaths.add( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" );
@@ -257,12 +259,12 @@ public class RepositoryScannerTest
 
         ManagedRepositoryConfiguration repository = createDefaultRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
         consumer.setIncludes( ARTIFACT_PATTERNS );
         knownConsumers.add( consumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
@@ -278,7 +280,7 @@ public class RepositoryScannerTest
     public void testDefaultRepositoryMetadataScanner()
         throws Exception
     {
-        List actualMetadataPaths = new ArrayList();
+        List<String> actualMetadataPaths = new ArrayList<String>();
 
         actualMetadataPaths.add( "org/apache/maven/some-ejb/1.0/maven-metadata.xml" );
         actualMetadataPaths.add( "org/apache/maven/update/test-not-updated/maven-metadata.xml" );
@@ -293,12 +295,12 @@ public class RepositoryScannerTest
 
         ManagedRepositoryConfiguration repository = createDefaultRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer knownConsumer = new KnownScanConsumer();
         knownConsumer.setIncludes( new String[]{"**/maven-metadata*.xml"} );
         knownConsumers.add( knownConsumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
@@ -314,7 +316,7 @@ public class RepositoryScannerTest
     public void testDefaultRepositoryProjectScanner()
         throws Exception
     {
-        List actualProjectPaths = new ArrayList();
+        List<String> actualProjectPaths = new ArrayList<String>();
 
         actualProjectPaths.add( "org/apache/maven/A/1.0/A-1.0.pom" );
         actualProjectPaths.add( "org/apache/maven/B/2.0/B-2.0.pom" );
@@ -329,12 +331,12 @@ public class RepositoryScannerTest
 
         ManagedRepositoryConfiguration repository = createDefaultRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
         consumer.setIncludes( new String[]{"**/*.pom"} );
         knownConsumers.add( consumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
@@ -350,7 +352,7 @@ public class RepositoryScannerTest
     public void testLegacyRepositoryArtifactScanner()
         throws Exception
     {
-        List actualArtifactPaths = new ArrayList();
+        List<String> actualArtifactPaths = new ArrayList<String>();
 
         actualArtifactPaths.add( "invalid/jars/1.0/invalid-1.0.jar" );
         actualArtifactPaths.add( "invalid/jars/invalid-1.0.rar" );
@@ -369,12 +371,12 @@ public class RepositoryScannerTest
 
         ManagedRepositoryConfiguration repository = createLegacyRepository();
 
-        List knownConsumers = new ArrayList();
+        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
         consumer.setIncludes( ARTIFACT_PATTERNS );
         knownConsumers.add( consumer );
 
-        List invalidConsumers = new ArrayList();
+        List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
         InvalidScanConsumer badconsumer = new InvalidScanConsumer();
         invalidConsumers.add( badconsumer );
 
index 94c3128b53fdb0cad52e71e7fa5536fbde34460a..c2358d702c63795d1961ce8081aa92951d79eb9e 100644 (file)
@@ -55,12 +55,12 @@ public class SampleKnownConsumer
         /* nothing to do */
     }
 
-    public List getExcludes()
+    public List<String> getExcludes()
     {
         return null;
     }
 
-    public List getIncludes()
+    public List<String> getIncludes()
     {
         return null;
     }