aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-reports-standard
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2006-09-06 02:38:02 +0000
committerBrett Porter <brett@apache.org>2006-09-06 02:38:02 +0000
commit1b940da8671bb5d0ee49fe4881edf86bcb95aaf4 (patch)
tree0ff3cf16b44ec788694f993c7d09097fd43e82a3 /archiva-reports-standard
parent6ba2e4dc2d27c8a4dc55ec4729be8bf50fb19b38 (diff)
downloadarchiva-1b940da8671bb5d0ee49fe4881edf86bcb95aaf4.tar.gz
archiva-1b940da8671bb5d0ee49fe4881edf86bcb95aaf4.zip
[MRM-161] rename some classes
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@440577 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-reports-standard')
-rw-r--r--archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java12
-rw-r--r--archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumArtifactReportProcessor.java (renamed from archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporter.java)10
-rw-r--r--archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReportProcessor.java95
-rw-r--r--archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReporter.java1
-rw-r--r--archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java (renamed from archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultArtifactReportProcessor.java)4
-rw-r--r--archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractChecksumArtifactReporterTestCase.java2
-rw-r--r--archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java6
-rw-r--r--archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java (renamed from archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReportProcessorTest.java)4
8 files changed, 109 insertions, 25 deletions
diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java
index 7ba79b61a..ec55ad6e5 100644
--- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java
+++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java
@@ -291,14 +291,12 @@ public class BadMetadataReportProcessor
return hasFailures;
}
- private Artifact createArtifact( RepositoryMetadata metadata, Snapshot snapshot )
- {
- String version = metadata.getBaseVersion();
- return artifactFactory.createProjectArtifact( metadata.getGroupId(), metadata.getArtifactId(), version );
- }
-
/**
- * Used to gather artifactIds from a groupId directory
+ * Used to gather artifactIds from a groupId directory.
+ *
+ * @param groupIdDir the directory of the group
+ * @return the list of artifact ID File objects for each directory
+ * @throws IOException if there was a failure to read the directories
*/
private List getArtifactIdFiles( File groupIdDir )
throws IOException
diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporter.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumArtifactReportProcessor.java
index ef23c9226..896fd35bd 100644
--- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporter.java
+++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumArtifactReportProcessor.java
@@ -32,7 +32,7 @@ import java.io.IOException;
*
* @plexus.component role="org.apache.maven.archiva.reporting.ArtifactReportProcessor" role-hint="checksum"
*/
-public class ChecksumArtifactReporter
+public class ChecksumArtifactReportProcessor
implements ArtifactReportProcessor
{
/**
@@ -45,14 +45,6 @@ public class ChecksumArtifactReporter
*/
private Digester md5Digester;
- /**
- * Validate the checksum of the specified artifact.
- *
- * @param model
- * @param artifact
- * @param reporter
- * @param repository
- */
public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter,
ArtifactRepository repository )
{
diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReportProcessor.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReportProcessor.java
new file mode 100644
index 000000000..18abad1ec
--- /dev/null
+++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReportProcessor.java
@@ -0,0 +1,95 @@
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.archiva.digest.Digester;
+import org.apache.maven.archiva.digest.DigesterException;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * This class reports invalid and mismatched checksums of artifacts and metadata files.
+ * It validates MD5 and SHA-1 checksums.
+ *
+ * @plexus.component role="org.apache.maven.archiva.reporting.MetadataReportProcessor" role-hint="checksum-metadata"
+ */
+public class ChecksumMetadataReportProcessor
+ implements MetadataReportProcessor
+{
+ /**
+ * @plexus.requirement role-hint="sha1"
+ */
+ private Digester sha1Digester;
+
+ /**
+ * @plexus.requirement role-hint="md5"
+ */
+ private Digester md5Digester;
+
+ /**
+ * Validate the checksums of the metadata. Get the metadata file from the
+ * repository then validate the checksum.
+ */
+ public void processMetadata( RepositoryMetadata metadata, ArtifactRepository repository, ArtifactReporter reporter )
+ {
+ if ( !"file".equals( repository.getProtocol() ) )
+ {
+ // We can't check other types of URLs yet. Need to use Wagon, with an exists() method.
+ throw new UnsupportedOperationException(
+ "Can't process repository '" + repository.getUrl() + "'. Only file based repositories are supported" );
+ }
+
+ //check if checksum files exist
+ String path = repository.pathOfRemoteRepositoryMetadata( metadata );
+ File file = new File( repository.getBasedir(), path );
+
+ verifyChecksum( repository, path + ".md5", file, md5Digester, reporter, metadata );
+ verifyChecksum( repository, path + ".sha1", file, sha1Digester, reporter, metadata );
+ }
+
+ private void verifyChecksum( ArtifactRepository repository, String path, File file, Digester digester,
+ ArtifactReporter reporter, RepositoryMetadata metadata )
+ {
+ File checksumFile = new File( repository.getBasedir(), path );
+ if ( checksumFile.exists() )
+ {
+ try
+ {
+ digester.verify( file, FileUtils.fileRead( checksumFile ) );
+
+ reporter.addSuccess( metadata );
+ }
+ catch ( DigesterException e )
+ {
+ reporter.addFailure( metadata, e.getMessage() );
+ }
+ catch ( IOException e )
+ {
+ reporter.addFailure( metadata, "Read file error: " + e.getMessage() );
+ }
+ }
+ else
+ {
+ reporter.addFailure( metadata, digester.getAlgorithm() + " checksum file does not exist." );
+ }
+ }
+
+}
diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReporter.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReporter.java
index 2e2f41a04..ef926c725 100644
--- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReporter.java
+++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ChecksumMetadataReporter.java
@@ -63,7 +63,6 @@ public class ChecksumMetadataReporter
verifyChecksum( repository, path + ".md5", file, md5Digester, reporter, metadata );
verifyChecksum( repository, path + ".sha1", file, sha1Digester, reporter, metadata );
-
}
private void verifyChecksum( ArtifactRepository repository, String path, File file, Digester digester,
diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultArtifactReportProcessor.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java
index b9fd36dd7..ded3d586d 100644
--- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultArtifactReportProcessor.java
+++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java
@@ -30,9 +30,9 @@ import java.util.Iterator;
import java.util.List;
/**
- * @plexus.component role="org.apache.maven.archiva.reporting.ArtifactReportProcessor" role-hint="default"
+ * @plexus.component role="org.apache.maven.archiva.reporting.ArtifactReportProcessor" role-hint="dependency"
*/
-public class DefaultArtifactReportProcessor
+public class DependencyArtifactReportProcessor
implements ArtifactReportProcessor
{
/**
diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractChecksumArtifactReporterTestCase.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractChecksumArtifactReporterTestCase.java
index a7e6a764f..bed4097ef 100644
--- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractChecksumArtifactReporterTestCase.java
+++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractChecksumArtifactReporterTestCase.java
@@ -33,7 +33,7 @@ import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
/**
- * This class creates the artifact and metadata files used for testing the ChecksumArtifactReporter.
+ * This class creates the artifact and metadata files used for testing the ChecksumArtifactReportProcessor.
* It is extended by ChecksumArtifactReporterTest class.
*/
public abstract class AbstractChecksumArtifactReporterTestCase
diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java
index 6132204db..2a4740399 100644
--- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java
+++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java
@@ -32,7 +32,7 @@ import java.io.IOException;
import java.util.Iterator;
/**
- * This class tests the ChecksumArtifactReporter.
+ * This class tests the ChecksumArtifactReportProcessor.
* It extends the AbstractChecksumArtifactReporterTestCase class.
*/
public class ChecksumArtifactReporterTest
@@ -53,7 +53,7 @@ public class ChecksumArtifactReporterTest
}
/**
- * Test the ChecksumArtifactReporter when the checksum files are valid.
+ * Test the ChecksumArtifactReportProcessor when the checksum files are valid.
*/
public void testChecksumArtifactReporterSuccess()
throws ReportProcessorException, IOException, DigesterException
@@ -71,7 +71,7 @@ public class ChecksumArtifactReporterTest
}
/**
- * Test the ChecksumArtifactReporter when the checksum files are invalid.
+ * Test the ChecksumArtifactReportProcessor when the checksum files are invalid.
*/
public void testChecksumArtifactReporterFailed()
throws ReportProcessorException
diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java
index 1b3d60759..6a30c51fa 100644
--- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReportProcessorTest.java
+++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java
@@ -26,7 +26,7 @@ import java.util.Iterator;
/**
*
*/
-public class ArtifactReportProcessorTest
+public class DependencyArtifactReportProcessorTest
extends AbstractRepositoryReportsTestCase
{
private static final String VALID_GROUP_ID = "groupId";
@@ -51,7 +51,7 @@ public class ArtifactReportProcessorTest
super.setUp();
reporter = (ArtifactReporter) lookup( ArtifactReporter.ROLE );
model = new Model();
- processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "default" );
+ processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "dependency" );
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
}