diff options
author | Brett Porter <brett@apache.org> | 2006-09-08 05:16:51 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2006-09-08 05:16:51 +0000 |
commit | 90f0dddc4363000f1b854f4fd8f9f3282433f21d (patch) | |
tree | 864a65b55815fb4b2aa9738d92fe4cafc8299195 /archiva-converter | |
parent | 2ae0f74fec8ef399c913b584cbba87b7bf8df053 (diff) | |
download | archiva-90f0dddc4363000f1b854f4fd8f9f3282433f21d.tar.gz archiva-90f0dddc4363000f1b854f4fd8f9f3282433f21d.zip |
[MRM-161] introduce a model for storing reports in the repository, and wire them up on the back of the indexer.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441377 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-converter')
3 files changed, 23 insertions, 27 deletions
diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java index 747767f93..74e9bac4e 100644 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java +++ b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java @@ -19,7 +19,7 @@ package org.apache.maven.archiva.converter; import org.apache.maven.archiva.converter.transaction.FileTransaction; import org.apache.maven.archiva.digest.Digester; import org.apache.maven.archiva.digest.DigesterException; -import org.apache.maven.archiva.reporting.ArtifactReporter; +import org.apache.maven.archiva.reporting.ReportingDatabase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -105,7 +105,7 @@ public class DefaultRepositoryConverter */ private I18N i18n; - public void convert( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter ) + public void convert( Artifact artifact, ArtifactRepository targetRepository, ReportingDatabase reporter ) throws RepositoryConversionException { if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) ) @@ -150,7 +150,6 @@ public class DefaultRepositoryConverter { transaction.commit(); } - reporter.addSuccess( artifact ); } } } @@ -239,7 +238,7 @@ public class DefaultRepositoryConverter return metadata; } - private boolean validateMetadata( Artifact artifact, ArtifactReporter reporter ) + private boolean validateMetadata( Artifact artifact, ReportingDatabase reporter ) throws RepositoryConversionException { ArtifactRepository repository = artifact.getRepository(); @@ -267,7 +266,7 @@ public class DefaultRepositoryConverter } private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact, - ArtifactReporter reporter ) + ReportingDatabase reporter ) { String groupIdKey; String artifactIdKey = null; @@ -368,7 +367,7 @@ public class DefaultRepositoryConverter return result; } - private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter, + private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, ReportingDatabase reporter, FileTransaction transaction ) throws RepositoryConversionException { @@ -572,7 +571,7 @@ public class DefaultRepositoryConverter return i18n.getString( getClass().getName(), Locale.getDefault(), key ); } - private boolean testChecksums( Artifact artifact, File file, ArtifactReporter reporter ) + private boolean testChecksums( Artifact artifact, File file, ReportingDatabase reporter ) throws IOException { @@ -583,7 +582,7 @@ public class DefaultRepositoryConverter return result; } - private boolean verifyChecksum( File file, String fileName, Digester digester, ArtifactReporter reporter, + private boolean verifyChecksum( File file, String fileName, Digester digester, ReportingDatabase reporter, Artifact artifact, String key ) throws IOException { @@ -606,7 +605,7 @@ public class DefaultRepositoryConverter return result; } - private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter, + private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, ReportingDatabase reporter, FileTransaction transaction ) throws RepositoryConversionException { @@ -649,7 +648,7 @@ public class DefaultRepositoryConverter return result; } - public void convert( List artifacts, ArtifactRepository targetRepository, ArtifactReporter reporter ) + public void convert( List artifacts, ArtifactRepository targetRepository, ReportingDatabase reporter ) throws RepositoryConversionException { for ( Iterator i = artifacts.iterator(); i.hasNext(); ) diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java index be3de802a..fdc9c248e 100644 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java +++ b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java @@ -16,7 +16,7 @@ package org.apache.maven.archiva.converter; * limitations under the License. */ -import org.apache.maven.archiva.reporting.ArtifactReporter; +import org.apache.maven.archiva.reporting.ReportingDatabase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -38,7 +38,7 @@ public interface RepositoryConverter * @param targetRepository the target repository * @param reporter reporter to track the results of the conversion */ - void convert( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter ) + void convert( Artifact artifact, ArtifactRepository targetRepository, ReportingDatabase reporter ) throws RepositoryConversionException; /** @@ -48,6 +48,6 @@ public interface RepositoryConverter * @param targetRepository the target repository * @param reporter reporter to track the results of the conversions */ - void convert( List artifacts, ArtifactRepository targetRepository, ArtifactReporter reporter ) + void convert( List artifacts, ArtifactRepository targetRepository, ReportingDatabase reporter ) throws RepositoryConversionException; } diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java index fd957e46a..759748d89 100644 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java +++ b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java @@ -16,9 +16,9 @@ package org.apache.maven.archiva.converter; * limitations under the License. */ -import org.apache.maven.archiva.reporting.ArtifactReporter; -import org.apache.maven.archiva.reporting.ArtifactResult; -import org.apache.maven.archiva.reporting.DefaultArtifactReporter; +import org.apache.maven.archiva.reporting.ReportingDatabase; +import org.apache.maven.archiva.reporting.model.ArtifactResults; +import org.apache.maven.archiva.reporting.model.Result; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; @@ -61,7 +61,7 @@ public class RepositoryConverterTest private ArtifactFactory artifactFactory; - private ArtifactReporter reporter; + private ReportingDatabase reporter; private static final int SLEEP_MILLIS = 100; @@ -94,7 +94,7 @@ public class RepositoryConverterTest i18n = (I18N) lookup( I18N.ROLE ); - reporter = new DefaultArtifactReporter(); + reporter = new ReportingDatabase(); } private void copyDirectoryStructure( File sourceDirectory, File destinationDirectory ) @@ -284,7 +284,6 @@ public class RepositoryConverterTest repositoryConverter.convert( artifact, targetRepository, reporter ); assertEquals( "check no errors", 0, reporter.getNumFailures() ); assertEquals( "check number of warnings", 2, reporter.getNumWarnings() ); - assertEquals( "check success", 1, reporter.getNumSuccesses() ); File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); assertTrue( "Check artifact created", artifactFile.exists() ); @@ -455,7 +454,6 @@ public class RepositoryConverterTest repositoryConverter.convert( artifact, targetRepository, reporter ); assertEquals( "check no errors", 0, reporter.getNumFailures() ); assertEquals( "check no warnings", 1, reporter.getNumWarnings() ); - assertEquals( "check success", 1, reporter.getNumSuccesses() ); assertEquals( "check warning message", getI18nString( "warning.missing.pom" ), getWarning().getReason() ); File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); @@ -735,7 +733,6 @@ public class RepositoryConverterTest repositoryConverter.convert( artifacts, targetRepository, reporter ); assertEquals( "check no errors", 0, reporter.getNumFailures() ); assertEquals( "check no warnings", 0, reporter.getNumWarnings() ); - assertEquals( "check successes", 3, reporter.getNumSuccesses() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { @@ -908,14 +905,12 @@ public class RepositoryConverterTest { assertEquals( "check no errors", 0, reporter.getNumFailures() ); assertEquals( "check no warnings", 0, reporter.getNumWarnings() ); - assertEquals( "check success", 1, reporter.getNumSuccesses() ); } private void checkFailure() { assertEquals( "check num errors", 1, reporter.getNumFailures() ); assertEquals( "check no warnings", 0, reporter.getNumWarnings() ); - assertEquals( "check no success", 0, reporter.getNumSuccesses() ); } private String getI18nString( String key ) @@ -923,14 +918,16 @@ public class RepositoryConverterTest return i18n.getString( repositoryConverter.getClass().getName(), Locale.getDefault(), key ); } - private ArtifactResult getFailure() + private Result getFailure() { - return (ArtifactResult) reporter.getArtifactFailureIterator().next(); + ArtifactResults artifact = (ArtifactResults) reporter.getArtifactIterator().next(); + return (Result) artifact.getFailures().get( 0 ); } - private ArtifactResult getWarning() + private Result getWarning() { - return (ArtifactResult) reporter.getArtifactWarningIterator().next(); + ArtifactResults artifact = (ArtifactResults) reporter.getArtifactIterator().next(); + return (Result) artifact.getWarnings().get( 0 ); } private void createModernSourceRepository() |