From cba6c6685880d26a39e27df988ad544f77b69f0d Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 17 Mar 2009 16:13:38 +0000 Subject: [PATCH] warnings in repository layer and some bugs found due to non-generic lists git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755296 13f79535-47bb-0310-9956-ffa450edef68 --- .../repository/content/LegacyPathParser.java | 10 +- .../events/RepositoryListenerFactoryBean.java | 4 +- .../metadata/RepositoryMetadataMerge.java | 27 +-- .../repository/project/ProjectModelMerge.java | 198 ++++++++---------- .../filters/ProjectModelExpressionFilter.java | 1 + .../readers/ProjectModel300Reader.java | 5 + .../readers/ProjectModel400Reader.java | 1 + .../resolvers/ProjectModelResolverStack.java | 40 ++-- .../writers/ProjectModel400Writer.java | 1 + .../scanner/DefaultRepositoryScanner.java | 4 - .../scanner/RepositoryContentConsumers.java | 6 +- .../ManagedDefaultRepositoryContentTest.java | 2 +- .../metadata/MetadataToolsTest.java | 6 - .../scanner/InvalidScanConsumer.java | 4 +- .../repository/scanner/KnownScanConsumer.java | 6 +- .../RepositoryContentConsumersTest.java | 17 +- .../scanner/RepositoryScannerTest.java | 46 ++-- .../scanner/SampleKnownConsumer.java | 4 +- 18 files changed, 182 insertions(+), 200 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java index 0b17ecc63..53b9e145c 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java @@ -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 legacy = configuration.getConfiguration().getLegacyArtifactPaths(); + for ( LegacyArtifactPath legacyPath : legacy ) { - LegacyArtifactPath legacyPath = (LegacyArtifactPath) iterator.next(); if ( legacyPath.match( path ) ) { artifact.setGroupId( legacyPath.getGroupId() ); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java index b4d16b16d..cfd48c317 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java @@ -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 getObjectType() { return List.class; } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataMerge.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataMerge.java index 47d4fadd3..5d53a7d96 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataMerge.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataMerge.java @@ -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 mergePlugins(List mainPlugins, List sourcePlugins) { if ( sourcePlugins == null ) { @@ -182,12 +181,10 @@ public class RepositoryMetadataMerge return clonePlugins( sourcePlugins ); } - List merged = clonePlugins( mainPlugins ); + List 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 result = new ArrayList(); for (Plugin plugin : plugins) { @@ -227,7 +224,7 @@ public class RepositoryMetadataMerge return result; } - private static List mergeAvailableVersions( List mainAvailableVersions, List sourceAvailableVersions ) + private static List mergeAvailableVersions( List mainAvailableVersions, List sourceAvailableVersions ) { if ( sourceAvailableVersions == null ) { @@ -239,12 +236,10 @@ public class RepositoryMetadataMerge return ArchivaModelCloner.cloneAvailableVersions( sourceAvailableVersions ); } - List merged = ArchivaModelCloner.cloneAvailableVersions( mainAvailableVersions ); + List 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 ); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java index 84b874564..f84d9f48f 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java @@ -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 createArtifactReferenceMap( List artifactReferences ) { - Map ret = new HashMap(); + Map ret = new HashMap(); - 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 createDependencyMap( List dependencies ) { - Map ret = new HashMap(); + Map ret = new HashMap(); - Iterator it = dependencies.iterator(); + Iterator 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 createExclusionMap( List exclusions ) { - Map ret = new HashMap(); + Map ret = new HashMap(); - Iterator it = exclusions.iterator(); + Iterator 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 createLicensesMap( List licenses ) { - Map ret = new HashMap(); + Map ret = new HashMap(); - 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 createRepositoriesMap( List repositories ) { - Map ret = new HashMap(); + Map ret = new HashMap(); - 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 keys = (Enumeration) 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 mergeArtifactReferences( List mainArtifactReferences, List 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 merged = new ArrayList(); - Map mainArtifactReferenceMap = createArtifactReferenceMap( mainArtifactReferences ); - Map parentArtifactReferenceMap = createArtifactReferenceMap( parentArtifactReferences ); + Map mainArtifactReferenceMap = createArtifactReferenceMap( mainArtifactReferences ); + Map parentArtifactReferenceMap = createArtifactReferenceMap( parentArtifactReferences ); - Iterator it = mainArtifactReferenceMap.entrySet().iterator(); - while ( it.hasNext() ) + for ( Map.Entry 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 mergeDependencies( List mainDependencies, List parentDependencies ) { if ( parentDependencies == null ) { @@ -425,30 +417,30 @@ public class ProjectModelMerge if ( mainDependencies == null ) { - List merged = ArchivaModelCloner.cloneDependencies( parentDependencies ); - Iterator it = merged.iterator(); + List merged = ArchivaModelCloner.cloneDependencies( parentDependencies ); + Iterator 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 merged = new ArrayList(); - Map mainDepMap = createDependencyMap( mainDependencies ); - Map parentDepMap = createDependencyMap( parentDependencies ); - Set uniqueKeys = new HashSet(); + Map mainDepMap = createDependencyMap( mainDependencies ); + Map parentDepMap = createDependencyMap( parentDependencies ); + Set uniqueKeys = new HashSet(); uniqueKeys.addAll( mainDepMap.keySet() ); uniqueKeys.addAll( parentDepMap.keySet() ); - Iterator it = uniqueKeys.iterator(); + Iterator 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 mergeDependencyManagement( List mainDepMgmt, List parentDepMgmt ) { if ( parentDepMgmt == null ) { @@ -475,30 +467,30 @@ public class ProjectModelMerge if ( mainDepMgmt == null ) { - List merged = ArchivaModelCloner.cloneDependencies( parentDepMgmt ); - Iterator it = merged.iterator(); + List merged = ArchivaModelCloner.cloneDependencies( parentDepMgmt ); + Iterator 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 merged = new ArrayList(); - Map mainDepMap = createDependencyMap( mainDepMgmt ); - Map parentDepMap = createDependencyMap( parentDepMgmt ); - Set uniqueKeys = new HashSet(); + Map mainDepMap = createDependencyMap( mainDepMgmt ); + Map parentDepMap = createDependencyMap( parentDepMgmt ); + Set uniqueKeys = new HashSet(); uniqueKeys.addAll( mainDepMap.keySet() ); uniqueKeys.addAll( parentDepMap.keySet() ); - Iterator it = uniqueKeys.iterator(); + Iterator 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 mergeExclusions( List mainExclusions, List parentExclusions ) { if ( parentExclusions == null ) { @@ -528,18 +520,16 @@ public class ProjectModelMerge return ArchivaModelCloner.cloneExclusions( parentExclusions ); } - List merged = new ArrayList(); + List merged = new ArrayList(); - Map mainExclusionMap = createExclusionMap( mainExclusions ); - Map parentExclusionMap = createExclusionMap( parentExclusions ); + Map mainExclusionMap = createExclusionMap( mainExclusions ); + Map parentExclusionMap = createExclusionMap( parentExclusions ); - Iterator it = mainExclusionMap.entrySet().iterator(); - while ( it.hasNext() ) + for ( Map.Entry 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 mergeIndividuals( List mainIndividuals, List parentIndividuals ) { if ( parentIndividuals == null ) { @@ -566,12 +556,12 @@ public class ProjectModelMerge return ArchivaModelCloner.cloneIndividuals( parentIndividuals ); } - List merged = ArchivaModelCloner.cloneIndividuals( mainIndividuals ); + List merged = ArchivaModelCloner.cloneIndividuals( mainIndividuals ); - Iterator it = parentIndividuals.iterator(); + Iterator 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 mergeLicenses( List mainLicenses, List parentLicenses ) { if ( parentLicenses == null ) { @@ -594,18 +584,16 @@ public class ProjectModelMerge return ArchivaModelCloner.cloneLicenses( parentLicenses ); } - List merged = new ArrayList(); + List merged = new ArrayList(); - Map mainLicensesMap = createLicensesMap( mainLicenses ); - Map parentLicensesMap = createLicensesMap( parentLicenses ); + Map mainLicensesMap = createLicensesMap( mainLicenses ); + Map parentLicensesMap = createLicensesMap( parentLicenses ); - Iterator it = mainLicensesMap.entrySet().iterator(); - while ( it.hasNext() ) + for ( Map.Entry 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 mergePlugins( List mainPlugins, List parentPlugins ) { return mergeArtifactReferences( mainPlugins, parentPlugins ); } - private static List mergeReports( List mainReports, List parentReports ) + private static List mergeReports( List mainReports, List parentReports ) { return mergeArtifactReferences( mainReports, parentReports ); } - private static List mergeRepositories( List mainRepositories, List parentRepositories ) + private static List mergeRepositories( List mainRepositories, List 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 merged = new ArrayList(); - Map mainRepositoriesMap = createRepositoriesMap( mainRepositories ); - Map parentRepositoriesMap = createRepositoriesMap( parentRepositories ); + Map mainRepositoriesMap = createRepositoriesMap( mainRepositories ); + Map parentRepositoriesMap = createRepositoriesMap( parentRepositories ); - Iterator it = mainRepositoriesMap.entrySet().iterator(); - while ( it.hasNext() ) + for ( Map.Entry 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 ) { diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java index f502e4649..02c3b4157 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java @@ -68,6 +68,7 @@ public class ProjectModelExpressionFilter * * @param model the model to correct. */ + @SuppressWarnings("unchecked") public ArchivaProjectModel filter( final ArchivaProjectModel model ) throws ProjectModelException { diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java index 600f738ae..74ebf1be8 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java @@ -139,6 +139,7 @@ public class ProjectModel300Reader return getDependencyList( xml, new String[] { "dependencies" } ); } + @SuppressWarnings("unchecked") private List getDependencyList( XMLReader xml, String parts[] ) throws XMLException { @@ -200,6 +201,7 @@ public class ProjectModel300Reader return individuals; } + @SuppressWarnings("unchecked") private List getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr ) throws XMLException { @@ -270,6 +272,7 @@ public class ProjectModel300Reader return issueMgmt; } + @SuppressWarnings("unchecked") private List getLicenses( XMLReader xml ) throws XMLException { @@ -297,6 +300,7 @@ public class ProjectModel300Reader return licenses; } + @SuppressWarnings("unchecked") private List getMailingLists( XMLReader xml ) throws XMLException { @@ -351,6 +355,7 @@ public class ProjectModel300Reader return null; } + @SuppressWarnings("unchecked") private Properties getProperties( Element elemProperties ) { if ( elemProperties == null ) diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java index 16f8225a1..d946ef317 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java @@ -50,6 +50,7 @@ import org.dom4j.Element; * * @version $Id$ */ +@SuppressWarnings("unchecked") public class ProjectModel400Reader implements ProjectModelReader { diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java index ff86ecb4b..534342392 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java @@ -37,14 +37,14 @@ import org.apache.maven.archiva.repository.project.ProjectModelResolver; */ public class ProjectModelResolverStack { - private List resolvers; + private List resolvers; - private List listeners; + private List listeners; public ProjectModelResolverStack() { - this.resolvers = new ArrayList(); - this.listeners = new ArrayList(); + this.resolvers = new ArrayList(); + this.listeners = new ArrayList(); } public void addListener( ProjectModelResolutionListener listener ) @@ -81,11 +81,11 @@ public class ProjectModelResolverStack triggerResolutionStart( projectRef, this.resolvers ); - Iterator it = this.resolvers.iterator(); + Iterator 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 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 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 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 resolvers ) { - Iterator it = this.listeners.iterator(); + Iterator 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 resolvers ) { - Iterator it = this.listeners.iterator(); + Iterator 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 it = this.listeners.iterator(); while ( it.hasNext() ) { - ProjectModelResolutionListener listener = (ProjectModelResolutionListener) it.next(); + ProjectModelResolutionListener listener = it.next(); try { diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java index 64de8f959..1141eba27 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java @@ -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() ); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java index 7422b79d3..f5784509c 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java @@ -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 */ diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java index 8e95d793c..119165b0b 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java @@ -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 getAvailableKnownConsumers() { - return new ArrayList( applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class ).values() ); + return new ArrayList( 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 getAvailableInvalidConsumers() { - return new ArrayList( applicationContext.getBeansOfType( InvalidRepositoryContentConsumer.class ).values() ); + return new ArrayList( applicationContext.getBeansOfType( InvalidRepositoryContentConsumer.class ).values() ); } /** diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContentTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContentTest.java index 798d78c9b..c525d9424 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContentTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContentTest.java @@ -50,7 +50,7 @@ public class ManagedDefaultRepositoryContentTest public void testGetVersionsBadArtifact() throws Exception { - assertGetVersions( "bad_artifact", Collections.EMPTY_LIST ); + assertGetVersions( "bad_artifact", Collections.emptyList() ); } public void testGetVersionsMissingMultipleVersions() diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java index 92dbaefdd..468a6b3e1 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java @@ -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 diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java index 65cebae74..29e50a589 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java @@ -54,12 +54,12 @@ public class InvalidScanConsumer /* do nothing */ } - public List getExcludes() + public List getExcludes() { return null; } - public List getIncludes() + public List getIncludes() { return null; } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java index f8d7fd70a..0ab62fe46 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java @@ -40,11 +40,11 @@ public class KnownScanConsumer { private int processCount = 0; - private List includes = new ArrayList(); + private List includes = new ArrayList(); private boolean processUnmodified = false; - public List getExcludes() + public List getExcludes() { return null; } @@ -55,7 +55,7 @@ public class KnownScanConsumer this.includes.addAll( Arrays.asList( includesArray ) ); } - public List getIncludes() + public List getIncludes() { return includes; } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java index 5717b2de7..5906c7641 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java @@ -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; private List invalidRepositoryContentConsumers; diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java index 0ae9d0828..22cd183b0 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java @@ -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 getIgnoreList() { - List ignores = new ArrayList(); + List ignores = new ArrayList(); ignores.addAll( Arrays.asList( RepositoryScanner.IGNORABLE_CONTENT ) ); return ignores; } @@ -121,12 +123,12 @@ public class RepositoryScannerTest { ManagedRepositoryConfiguration repository = createSimpleRepository(); - List knownConsumers = new ArrayList(); + List knownConsumers = new ArrayList(); KnownScanConsumer consumer = new KnownScanConsumer(); consumer.setIncludes( ARTIFACT_PATTERNS ); knownConsumers.add( consumer ); - List invalidConsumers = new ArrayList(); + List invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); @@ -147,12 +149,12 @@ public class RepositoryScannerTest { ManagedRepositoryConfiguration repository = createSimpleRepository(); - List knownConsumers = new ArrayList(); + List knownConsumers = new ArrayList(); KnownScanConsumer consumer = new KnownScanConsumer(); consumer.setIncludes( ARTIFACT_PATTERNS ); knownConsumers.add( consumer ); - List invalidConsumers = new ArrayList(); + List invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); @@ -172,13 +174,13 @@ public class RepositoryScannerTest { ManagedRepositoryConfiguration repository = createSimpleRepository(); - List knownConsumers = new ArrayList(); + List knownConsumers = new ArrayList(); KnownScanConsumer consumer = new KnownScanConsumer(); consumer.setProcessUnmodified( true ); consumer.setIncludes( ARTIFACT_PATTERNS ); knownConsumers.add( consumer ); - List invalidConsumers = new ArrayList(); + List invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); @@ -198,13 +200,13 @@ public class RepositoryScannerTest { ManagedRepositoryConfiguration repository = createDefaultRepository(); - List knownConsumers = new ArrayList(); + List knownConsumers = new ArrayList(); 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 invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); @@ -221,7 +223,7 @@ public class RepositoryScannerTest public void testDefaultRepositoryArtifactScanner() throws Exception { - List actualArtifactPaths = new ArrayList(); + List actualArtifactPaths = new ArrayList(); 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 knownConsumers = new ArrayList(); KnownScanConsumer consumer = new KnownScanConsumer(); consumer.setIncludes( ARTIFACT_PATTERNS ); knownConsumers.add( consumer ); - List invalidConsumers = new ArrayList(); + List invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); @@ -278,7 +280,7 @@ public class RepositoryScannerTest public void testDefaultRepositoryMetadataScanner() throws Exception { - List actualMetadataPaths = new ArrayList(); + List actualMetadataPaths = new ArrayList(); 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 knownConsumers = new ArrayList(); KnownScanConsumer knownConsumer = new KnownScanConsumer(); knownConsumer.setIncludes( new String[]{"**/maven-metadata*.xml"} ); knownConsumers.add( knownConsumer ); - List invalidConsumers = new ArrayList(); + List invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); @@ -314,7 +316,7 @@ public class RepositoryScannerTest public void testDefaultRepositoryProjectScanner() throws Exception { - List actualProjectPaths = new ArrayList(); + List actualProjectPaths = new ArrayList(); 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 knownConsumers = new ArrayList(); KnownScanConsumer consumer = new KnownScanConsumer(); consumer.setIncludes( new String[]{"**/*.pom"} ); knownConsumers.add( consumer ); - List invalidConsumers = new ArrayList(); + List invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); @@ -350,7 +352,7 @@ public class RepositoryScannerTest public void testLegacyRepositoryArtifactScanner() throws Exception { - List actualArtifactPaths = new ArrayList(); + List actualArtifactPaths = new ArrayList(); 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 knownConsumers = new ArrayList(); KnownScanConsumer consumer = new KnownScanConsumer(); consumer.setIncludes( ARTIFACT_PATTERNS ); knownConsumers.add( consumer ); - List invalidConsumers = new ArrayList(); + List invalidConsumers = new ArrayList(); InvalidScanConsumer badconsumer = new InvalidScanConsumer(); invalidConsumers.add( badconsumer ); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java index 94c3128b5..c2358d702 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java @@ -55,12 +55,12 @@ public class SampleKnownConsumer /* nothing to do */ } - public List getExcludes() + public List getExcludes() { return null; } - public List getIncludes() + public List getIncludes() { return null; } -- 2.39.5