From 3cdb8ce93405bb47b021482e798944c2f00bc557 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 17 Mar 2009 13:40:10 +0000 Subject: start adding Java5 features to modules git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755239 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/archiva/cli/ArtifactCountConsumer.java | 8 +-- .../maven/archiva/cli/ProjectReaderConsumer.java | 8 +-- .../converter/artifact/ArtifactConverter.java | 3 +- .../artifact/LegacyToDefaultConverter.java | 52 +++++++++---------- .../artifact/LegacyToDefaultConverterTest.java | 59 ++++++++++------------ .../apache/maven/archiva/database/ArtifactDAO.java | 2 +- .../archiva/database/RepositoryProblemDAO.java | 2 +- .../database/AbstractArchivaDatabaseTestCase.java | 25 ++++----- .../updater/TestDatabaseCleanupConsumer.java | 2 +- .../updater/TestDatabaseUnprocessedConsumer.java | 4 +- .../reporting/artifact/CorruptArtifactReport.java | 5 +- .../artifact/DuplicateArtifactReport.java | 5 +- .../artifact/LocationArtifactsConsumer.java | 37 +++++++------- .../artifact/LocationArtifactsReport.java | 5 +- .../reporting/artifact/OldArtifactReport.java | 9 ++-- .../artifact/OldSnapshotArtifactReport.java | 9 ++-- .../artifact/AbstractArtifactReportsTestCase.java | 19 +++---- .../artifact/DuplicateArtifactReportTest.java | 23 ++++----- .../maven/archiva/applet/ChecksumApplet.java | 11 ++-- .../web/startup/SecuritySynchronization.java | 6 --- 20 files changed, 138 insertions(+), 156 deletions(-) diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java index bb3a7146c..bfc5f6ebc 100644 --- a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java +++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java @@ -47,12 +47,12 @@ public class ArtifactCountConsumer */ private String description; - private List includes; + private List includes; public ArtifactCountConsumer() { // TODO: shouldn't this use filetypes? - includes = new ArrayList(); + includes = new ArrayList(); includes.add( "**/*.pom" ); includes.add( "**/*.jar" ); includes.add( "**/*.war" ); @@ -82,12 +82,12 @@ public class ArtifactCountConsumer return false; } - public List getExcludes() + public List getExcludes() { return null; } - public List getIncludes() + public List getIncludes() { return includes; } diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java index b0eb6edc0..be19a1a01 100644 --- a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java +++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java @@ -59,13 +59,13 @@ public class ProjectReaderConsumer private ManagedRepositoryConfiguration repo; - private List includes; + private List includes; public ProjectReaderConsumer() { reader = new ProjectModel400Reader(); - includes = new ArrayList(); + includes = new ArrayList(); includes.add( "**/*.pom" ); } @@ -84,12 +84,12 @@ public class ProjectReaderConsumer return false; } - public List getExcludes() + public List getExcludes() { return null; } - public List getIncludes() + public List getIncludes() { return includes; } diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/ArtifactConverter.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/ArtifactConverter.java index 1c67d8d2a..fc61d16a0 100644 --- a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/ArtifactConverter.java +++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/ArtifactConverter.java @@ -22,6 +22,7 @@ package org.apache.maven.archiva.converter.artifact; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import java.util.List; import java.util.Map; /** @@ -48,7 +49,7 @@ public interface ArtifactConverter * * @return the {@link Map}<{@link Artifact}, {@link String}> warning messages. */ - Map getWarnings(); + Map> getWarnings(); /** * Clear the list of warning messages. diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java index 8ce135b9f..f1f16601b 100644 --- a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java +++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java @@ -19,6 +19,19 @@ package org.apache.maven.archiva.converter.artifact; * under the License. */ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.maven.archiva.transaction.FileTransaction; @@ -45,20 +58,6 @@ import org.codehaus.plexus.digest.Digester; import org.codehaus.plexus.digest.DigesterException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.regex.Matcher; - /** * LegacyToDefaultConverter * @@ -75,7 +74,7 @@ public class LegacyToDefaultConverter * * @plexus.requirement role="org.codehaus.plexus.digest.Digester" */ - private List digesters; + private List digesters; /** * @plexus.requirement @@ -102,7 +101,7 @@ public class LegacyToDefaultConverter */ private boolean dryrun; - private Map warnings = new HashMap(); + private Map> warnings = new HashMap>(); public void convert( Artifact artifact, ArtifactRepository targetRepository ) throws ArtifactConversionException @@ -168,6 +167,7 @@ public class LegacyToDefaultConverter } } + @SuppressWarnings("unchecked") private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction ) throws ArtifactConversionException { @@ -250,11 +250,10 @@ public class LegacyToDefaultConverter transaction.createFile( writer.toString(), targetFile, digesters ); - List warnings = translator.getWarnings(); + List warnings = translator.getWarnings(); - for ( Iterator i = warnings.iterator(); i.hasNext(); ) + for ( String message : warnings ) { - String message = (String) i.next(); addWarning( artifact, message ); } } @@ -289,10 +288,8 @@ public class LegacyToDefaultConverter throws IOException { boolean result = true; - Iterator it = digesters.iterator(); - while ( it.hasNext() ) + for ( Digester digester : digesters ) { - Digester digester = (Digester) it.next(); result &= verifyChecksum( file, file.getName() + "." + getDigesterFileExtension( digester ), digester, //$NON-NLS-1$ artifact, "failure.incorrect." + getDigesterFileExtension( digester ) ); //$NON-NLS-1$ } @@ -441,6 +438,7 @@ public class LegacyToDefaultConverter return result; } + @SuppressWarnings("unchecked") private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact ) { String groupIdKey; @@ -488,12 +486,12 @@ public class LegacyToDefaultConverter boolean foundVersion = false; if ( metadata.getVersioning() != null ) { - for ( Iterator i = metadata.getVersioning().getVersions().iterator(); i.hasNext() && !foundVersion; ) + for ( String version : (List) metadata.getVersioning().getVersions() ) { - String version = (String) i.next(); if ( version.equals( artifact.getBaseVersion() ) ) { foundVersion = true; + break; } } } @@ -668,10 +666,10 @@ public class LegacyToDefaultConverter private void addWarning( Artifact artifact, String message ) { - List messages = (List) warnings.get( artifact ); + List messages = warnings.get( artifact ); if ( messages == null ) { - messages = new ArrayList(); + messages = new ArrayList(); } messages.add( message ); warnings.put( artifact, messages ); @@ -682,7 +680,7 @@ public class LegacyToDefaultConverter warnings.clear(); } - public Map getWarnings() + public Map> getWarnings() { return warnings; } diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java index a305f1349..8ce2f2c8a 100644 --- a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java +++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java @@ -19,6 +19,15 @@ package org.apache.maven.archiva.converter.artifact; * under the License. */ +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.regex.Matcher; + import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -30,17 +39,6 @@ import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.regex.Matcher; - /** * LegacyToDefaultConverterTest * @@ -736,19 +734,21 @@ public class LegacyToDefaultConverterTest boolean found = false; String pattern = "^" + Messages.getString( "invalid.source.pom" ).replaceFirst( "\\{0\\}", ".*" ) + "$"; - for ( Iterator it = artifactConverter.getWarnings().values().iterator(); it.hasNext() && !found; ) + for ( List messages : artifactConverter.getWarnings().values() ) { - List messages = (List) it.next(); - - for ( Iterator itmsgs = messages.iterator(); itmsgs.hasNext(); ) + for ( String message : messages ) { - String message = (String) itmsgs.next(); if ( message.matches( pattern ) ) { found = true; break; } } + + if ( found ) + { + break; + } } assertTrue( "Check failure message.", found ); @@ -763,22 +763,19 @@ public class LegacyToDefaultConverterTest { // test multiple artifacts are converted - List artifacts = new ArrayList(); + List artifacts = new ArrayList(); artifacts.add( createArtifact( "test", "artifact-one", "1.0.0" ) ); artifacts.add( createArtifact( "test", "artifact-two", "1.0.0" ) ); artifacts.add( createArtifact( "test", "artifact-three", "1.0.0" ) ); - for ( Iterator it = artifacts.iterator(); it.hasNext(); ) + for ( Artifact artifact : artifacts ) { - Artifact arti = (Artifact) it.next(); - artifactConverter.convert( arti, targetRepository ); + artifactConverter.convert( artifact, targetRepository ); checkSuccess( artifactConverter ); } - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) i.next(); - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); assertTrue( "Check artifact created", artifactFile.exists() ); assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); @@ -954,9 +951,8 @@ public class LegacyToDefaultConverterTest private int countWarningMessages( ArtifactConverter converter ) { int count = 0; - for ( Iterator it = converter.getWarnings().values().iterator(); it.hasNext(); ) + for ( List values : converter.getWarnings().values() ) { - List values = (List) it.next(); count += values.size(); } return count; @@ -967,28 +963,25 @@ public class LegacyToDefaultConverterTest assertNotNull( "Warnings should never be null.", converter.getWarnings() ); assertTrue( "Expecting 1 or more Warnings", countWarningMessages( converter ) > 0 ); - for ( Iterator it = converter.getWarnings().values().iterator(); it.hasNext(); ) + for ( List messages : converter.getWarnings().values() ) { - List messages = (List) it.next(); if ( messages.contains( reason ) ) { - /* No need to check any furthor */ + /* No need to check any further */ return; } } /* didn't find it. */ - for ( Iterator it = converter.getWarnings().entrySet().iterator(); it.hasNext(); ) + for ( Map.Entry> entry : converter.getWarnings().entrySet() ) { - Map.Entry entry = (Entry) it.next(); Artifact artifact = (Artifact) entry.getKey(); System.out.println( "-Artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() ); - List messages = (List) entry.getValue(); - for ( Iterator itmsgs = messages.iterator(); itmsgs.hasNext(); ) + List messages = entry.getValue(); + for ( String message : messages ) { - String message = (String) itmsgs.next(); System.out.println( " " + message ); } } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArtifactDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArtifactDAO.java index baca25660..2c8d901fe 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArtifactDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArtifactDAO.java @@ -58,7 +58,7 @@ public interface ArtifactDAO String type, String repositoryId ) throws ObjectNotFoundException, ArchivaDatabaseException; - public List /**/queryArtifacts( Constraint constraint ) + public List queryArtifacts( Constraint constraint ) throws ObjectNotFoundException, ArchivaDatabaseException; public ArchivaArtifact saveArtifact( ArchivaArtifact artifact ) diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java index b43a6d746..212a538a9 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java @@ -51,7 +51,7 @@ public interface RepositoryProblemDAO * This is the only list of options created in this DAO. */ - public List /**/queryRepositoryProblems( Constraint constraint ) + public List queryRepositoryProblems( Constraint constraint ) throws ObjectNotFoundException, ArchivaDatabaseException; public RepositoryProblem saveRepositoryProblem( RepositoryProblem problem ) diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java index 0cbc95f9c..6a3aaa8d4 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java @@ -19,6 +19,16 @@ package org.apache.maven.archiva.database; * under the License. */ +import java.io.File; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.database.updater.DatabaseCleanupConsumer; import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; @@ -31,17 +41,6 @@ import org.codehaus.plexus.jdo.JdoFactory; import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.jpox.SchemaTool; -import java.io.File; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; - -import javax.jdo.PersistenceManager; -import javax.jdo.PersistenceManagerFactory; - /** * AbstractArchivaDatabaseTestCase * @@ -103,10 +102,8 @@ public abstract class AbstractArchivaDatabaseTestCase Properties properties = jdoFactory.getProperties(); - for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); ) + for ( Map.Entry entry : properties.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java index 12cc9b6bd..4cc47a0df 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java @@ -55,7 +55,7 @@ public class TestDatabaseCleanupConsumer countComplete++; } - public List getIncludedTypes() + public List getIncludedTypes() { return null; } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java index d059a4a65..f35dd67d6 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java @@ -62,9 +62,9 @@ public class TestDatabaseUnprocessedConsumer countComplete++; } - public List getIncludedTypes() + public List getIncludedTypes() { - List types = new ArrayList(); + List types = new ArrayList(); types.add( "pom" ); types.add( "jar" ); return types; diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/CorruptArtifactReport.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/CorruptArtifactReport.java index 502489310..c9280e853 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/CorruptArtifactReport.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/CorruptArtifactReport.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.reporting.artifact; * under the License. */ +import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.reporting.DynamicReportSource; import org.apache.maven.archiva.reporting.DataLimits; import org.apache.maven.archiva.database.ArchivaDAO; @@ -56,13 +57,13 @@ public class CorruptArtifactReport constraint = new RepositoryProblemByTypeConstraint( PROBLEM_TYPE_CORRUPT_ARTIFACT ); } - public List getData() + public List getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); } - public List getData( DataLimits limits ) + public List getData( DataLimits limits ) throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java index 1e1d774b0..abf2ccb91 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java @@ -24,6 +24,7 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.Constraint; import org.apache.maven.archiva.database.ObjectNotFoundException; import org.apache.maven.archiva.database.constraints.RepositoryProblemByTypeConstraint; +import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.reporting.DataLimits; import org.apache.maven.archiva.reporting.DynamicReportSource; @@ -59,13 +60,13 @@ public class DuplicateArtifactReport constraint = new RepositoryProblemByTypeConstraint( PROBLEM_TYPE_DUPLICATE_ARTIFACTS ); } - public List getData() + public List getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); } - public List getData( DataLimits limits ) + public List getData( DataLimits limits ) throws ObjectNotFoundException, ArchivaDatabaseException { // TODO: implement limits. diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java index ac175ed27..2929abedf 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java @@ -98,7 +98,8 @@ public class LocationArtifactsConsumer */ private RepositoryContentFactory repositoryFactory; - private Map repositoryMap = new HashMap(); + private Map repositoryMap = + new HashMap(); // TODO: why is this not used? If it should be, what about excludes? private List includes = new ArrayList(); @@ -128,7 +129,7 @@ public class LocationArtifactsConsumer /* do nothing */ } - public List getIncludedTypes() + public List getIncludedTypes() { return null; } @@ -203,7 +204,7 @@ public class LocationArtifactsConsumer * indicate that the artifact is, indeed located in the wrong place. */ - List actualPomXmls = findJarEntryPattern( jar, "META-INF/maven/**/pom.xml" ); + List actualPomXmls = findJarEntryPattern( jar, "META-INF/maven/**/pom.xml" ); if ( actualPomXmls.isEmpty() ) { // No check needed. @@ -267,27 +268,27 @@ public class LocationArtifactsConsumer private ArchivaProjectModel readFilesystemModel( File artifactFile ) { - File pomFile = createPomFileReference( artifactFile ); +// File pomFile = createPomFileReference( artifactFile ); // TODO: read and resolve model here. return null; } - private File createPomFileReference( File artifactFile ) - { - String pomFilename = artifactFile.getAbsolutePath(); - - int pos = pomFilename.lastIndexOf( '.' ); - if ( pos <= 0 ) - { - // Invalid filename. - return null; - } - - pomFilename = pomFilename.substring( 0, pos ) + ".pom"; - return new File( pomFilename ); - } +// private File createPomFileReference( File artifactFile ) +// { +// String pomFilename = artifactFile.getAbsolutePath(); +// +// int pos = pomFilename.lastIndexOf( '.' ); +// if ( pos <= 0 ) +// { +// // Invalid filename. +// return null; +// } +// +// pomFilename = pomFilename.substring( 0, pos ) + ".pom"; +// return new File( pomFilename ); +// } private ManagedRepositoryConfiguration findRepository( ArchivaArtifact artifact ) { diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsReport.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsReport.java index d419bcafc..9a3f232ef 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsReport.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsReport.java @@ -24,6 +24,7 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.Constraint; import org.apache.maven.archiva.database.ObjectNotFoundException; import org.apache.maven.archiva.database.constraints.RepositoryProblemByTypeConstraint; +import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.reporting.DataLimits; import org.apache.maven.archiva.reporting.DynamicReportSource; @@ -59,13 +60,13 @@ public class LocationArtifactsReport constraint = new RepositoryProblemByTypeConstraint( PROBLEM_TYPE_BAD_ARTIFACT_LOCATION ); } - public List getData() + public List getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); } - public List getData( DataLimits limits ) + public List getData( DataLimits limits ) throws ObjectNotFoundException, ArchivaDatabaseException { // TODO: implement limits. diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldArtifactReport.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldArtifactReport.java index 6cf545d1d..4a40c80bd 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldArtifactReport.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldArtifactReport.java @@ -19,15 +19,16 @@ package org.apache.maven.archiva.reporting.artifact; * under the License. */ +import java.util.List; + import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.ObjectNotFoundException; import org.apache.maven.archiva.database.constraints.OlderArtifactsByAgeConstraint; +import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.reporting.DataLimits; import org.apache.maven.archiva.reporting.DynamicReportSource; -import java.util.List; - /** * OldArtifactReport * @@ -56,13 +57,13 @@ public class OldArtifactReport */ private int cutoffDays; - public List getData() + public List getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getArtifactDAO().queryArtifacts( new OlderArtifactsByAgeConstraint( cutoffDays ) ); } - public List getData( DataLimits limits ) + public List getData( DataLimits limits ) throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getArtifactDAO().queryArtifacts( new OlderArtifactsByAgeConstraint( cutoffDays ) ); diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldSnapshotArtifactReport.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldSnapshotArtifactReport.java index 82d4160eb..b3c217d03 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldSnapshotArtifactReport.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldSnapshotArtifactReport.java @@ -19,15 +19,16 @@ package org.apache.maven.archiva.reporting.artifact; * under the License. */ +import java.util.List; + import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.ObjectNotFoundException; import org.apache.maven.archiva.database.constraints.OlderSnapshotArtifactsByAgeConstraint; +import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.reporting.DataLimits; import org.apache.maven.archiva.reporting.DynamicReportSource; -import java.util.List; - /** * OldSnapshotArtifactReport * @@ -56,13 +57,13 @@ public class OldSnapshotArtifactReport */ private int cutoffDays; - public List getData() + public List getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getArtifactDAO().queryArtifacts( new OlderSnapshotArtifactsByAgeConstraint( cutoffDays ) ); } - public List getData( DataLimits limits ) + public List getData( DataLimits limits ) throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getArtifactDAO().queryArtifacts( new OlderSnapshotArtifactsByAgeConstraint( cutoffDays ) ); diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/AbstractArtifactReportsTestCase.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/AbstractArtifactReportsTestCase.java index a28eb073e..2ff436a08 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/AbstractArtifactReportsTestCase.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/AbstractArtifactReportsTestCase.java @@ -19,21 +19,20 @@ package org.apache.maven.archiva.reporting.artifact; * under the License. */ -import org.apache.maven.archiva.database.ArchivaDAO; -import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; -import org.codehaus.plexus.jdo.JdoFactory; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import org.jpox.SchemaTool; - import java.io.File; import java.net.URL; -import java.util.Iterator; -import java.util.Map; import java.util.Properties; +import java.util.Map.Entry; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; +import org.codehaus.plexus.jdo.JdoFactory; +import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.jpox.SchemaTool; + /** * AbstractArtifactReportsTestCase * @@ -92,10 +91,8 @@ public abstract class AbstractArtifactReportsTestCase Properties properties = jdoFactory.getProperties(); - for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); ) + for ( Entry entry : properties.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); } diff --git a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java index 96dddd5c8..4f44f7311 100644 --- a/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java +++ b/archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java @@ -19,6 +19,10 @@ package org.apache.maven.archiva.reporting.artifact; * under the License. */ +import java.io.File; +import java.util.Date; +import java.util.List; + import org.apache.commons.io.FileUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -28,11 +32,6 @@ import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.reporting.DynamicReportSource; -import java.io.File; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - /** * DuplicateArtifactReportTest * @@ -115,20 +114,18 @@ public class DuplicateArtifactReportTest // Setup entries for bad/duplicate in problem DB. pretendToRunDuplicateArtifactsConsumer(); - List allArtifacts = artifactDao.queryArtifacts( null ); + List allArtifacts = artifactDao.queryArtifacts( null ); assertEquals( "Total Artifact Count", 7, allArtifacts.size() ); DuplicateArtifactReport report = (DuplicateArtifactReport) lookup( DynamicReportSource.class.getName(), "duplicate-artifacts" ); - List results = report.getData(); + List results = report.getData(); System.out.println( "Results.size: " + results.size() ); int i = 0; - Iterator it = results.iterator(); - while ( it.hasNext() ) + for ( RepositoryProblem problem : results ) { - RepositoryProblem problem = (RepositoryProblem) it.next(); System.out.println( "[" + ( i++ ) + "] " + problem.getMessage() ); } @@ -144,16 +141,14 @@ public class DuplicateArtifactReportTest private void pretendToRunDuplicateArtifactsConsumer() throws Exception { - List artifacts = dao.getArtifactDAO().queryArtifacts( null ); + List artifacts = dao.getArtifactDAO().queryArtifacts( null ); ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) lookup( ArchivaArtifactConsumer.class.getName(), "duplicate-artifacts" ); consumer.beginScan(); try { - Iterator it = artifacts.iterator(); - while ( it.hasNext() ) + for ( ArchivaArtifact artifact : artifacts ) { - ArchivaArtifact artifact = (ArchivaArtifact) it.next(); consumer.processArchivaArtifact( artifact ); } } diff --git a/archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/maven/archiva/applet/ChecksumApplet.java b/archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/maven/archiva/applet/ChecksumApplet.java index 03d8e33f1..5fb4752fd 100644 --- a/archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/maven/archiva/applet/ChecksumApplet.java +++ b/archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/maven/archiva/applet/ChecksumApplet.java @@ -19,9 +19,8 @@ package org.apache.maven.archiva.applet; * under the License. */ -import javax.swing.*; import java.applet.Applet; -import java.awt.*; +import java.awt.BorderLayout; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -32,6 +31,9 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.PrivilegedAction; +import javax.swing.JLabel; +import javax.swing.JProgressBar; + /** * Applet that takes a file on the local filesystem and checksums it for sending to the server. * @@ -58,9 +60,9 @@ public class ChecksumApplet public String generateMd5( final String file ) throws IOException, NoSuchAlgorithmException { - Object o = AccessController.doPrivileged( new PrivilegedAction() + return AccessController.doPrivileged( new PrivilegedAction() { - public Object run() + public String run() { try { @@ -80,7 +82,6 @@ public class ChecksumApplet } } } ); - return (String) o; } protected String checksumFile( String file ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java index 267c1b7de..346773abd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java @@ -30,7 +30,6 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationNames; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.security.ArchivaXworkUser; import org.codehaus.plexus.redback.rbac.RBACManager; import org.codehaus.plexus.redback.rbac.RbacManagerException; import org.codehaus.plexus.redback.rbac.UserAssignment; @@ -75,11 +74,6 @@ public class SecuritySynchronization */ private ArchivaConfiguration archivaConfiguration; - /** - * @plexus.requirement - */ - private ArchivaXworkUser archivaXworkUser; - public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) { if ( ConfigurationNames.isManagedRepositories( propertyName ) ) -- cgit v1.2.3