diff options
author | Brett Porter <brett@apache.org> | 2009-03-17 13:40:10 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-03-17 13:40:10 +0000 |
commit | 3cdb8ce93405bb47b021482e798944c2f00bc557 (patch) | |
tree | 23a4ca1d76b02cb7c192560607429e73745eece5 /archiva-modules/archiva-reporting | |
parent | 51ad4bdec94c15ff08d73032e3f9f580f8004aee (diff) | |
download | archiva-3cdb8ce93405bb47b021482e798944c2f00bc557.tar.gz archiva-3cdb8ce93405bb47b021482e798944c2f00bc557.zip |
start adding Java5 features to modules
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755239 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-reporting')
8 files changed, 55 insertions, 57 deletions
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<RepositoryProblem> getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); } - public List getData( DataLimits limits ) + public List<RepositoryProblem> 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<RepositoryProblem> getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); } - public List getData( DataLimits limits ) + public List<RepositoryProblem> 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<String, ManagedRepositoryConfiguration> repositoryMap = + new HashMap<String, ManagedRepositoryConfiguration>(); // TODO: why is this not used? If it should be, what about excludes? private List<String> includes = new ArrayList<String>(); @@ -128,7 +129,7 @@ public class LocationArtifactsConsumer /* do nothing */ } - public List getIncludedTypes() + public List<String> 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<JarEntry> 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<RepositoryProblem> getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); } - public List getData( DataLimits limits ) + public List<RepositoryProblem> 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<ArchivaArtifact> getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getArtifactDAO().queryArtifacts( new OlderArtifactsByAgeConstraint( cutoffDays ) ); } - public List getData( DataLimits limits ) + public List<ArchivaArtifact> 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<ArchivaArtifact> getData() throws ObjectNotFoundException, ArchivaDatabaseException { return dao.getArtifactDAO().queryArtifacts( new OlderSnapshotArtifactsByAgeConstraint( cutoffDays ) ); } - public List getData( DataLimits limits ) + public List<ArchivaArtifact> 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<Object, Object> 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<ArchivaArtifact> 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<RepositoryProblem> 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<ArchivaArtifact> 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 ); } } |