mirror of https://github.com/apache/archiva.git
[MRM-161] rename some classes
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@440577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ba2e4dc2d
commit
1b940da867
|
@ -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
|
||||
|
|
|
@ -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 )
|
||||
{
|
|
@ -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." );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
{
|
||||
/**
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
}
|
Loading…
Reference in New Issue