maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject cvs commit: maven-components/maven-repository-tools/src/main/java/org/apache/maven/repository ChecksumValidator.java
Date Thu, 17 Mar 2005 14:47:15 GMT
carlos      2005/03/17 06:47:15

  Modified:    maven-repository-tools/src/main/java/org/apache/maven/repository
                        ChecksumValidator.java
  Log:
  Trying to use ChecksumObserver to validate the checksum
  
  Revision  Changes    Path
  1.2       +53 -2     maven-components/maven-repository-tools/src/main/java/org/apache/maven/repository/ChecksumValidator.java
  
  Index: ChecksumValidator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-repository-tools/src/main/java/org/apache/maven/repository/ChecksumValidator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChecksumValidator.java	23 Feb 2005 20:57:34 -0000	1.1
  +++ ChecksumValidator.java	17 Mar 2005 14:47:15 -0000	1.2
  @@ -17,17 +17,24 @@
    */
   
   import java.io.File;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Set;
   
   import org.apache.maven.artifact.Artifact;
  +import org.apache.maven.artifact.manager.DefaultWagonManager;
  +import org.apache.maven.artifact.manager.WagonManager;
   import org.apache.maven.artifact.repository.ArtifactRepository;
  +import org.apache.maven.wagon.TransferFailedException;
  +import org.apache.maven.wagon.UnsupportedProtocolException;
  +import org.apache.maven.wagon.Wagon;
  +import org.apache.maven.wagon.observers.ChecksumObserver;
   
   /**
    * Prints all artifacts without checksum file
    * 
    * @todo generate checksums for those files without it
  - * 
    * @author <a href="mailto:carlos@apache.org">Carlos Sanchez </a>
    * @version $Id$
    */
  @@ -35,6 +42,50 @@
   public class ChecksumValidator
   {
   
  +    private ChecksumObserver checksumObserver;
  +
  +    private ArtifactRepository tempRepository;
  +
  +    public ChecksumValidator()
  +    {
  +
  +        checksumObserver = new ChecksumObserver();
  +
  +        tempRepository = new ArtifactRepository();
  +
  +        File f = new File( "target/test-classes/temp/" );
  +
  +        tempRepository.setUrl( "file://" + f.getPath() );
  +
  +    }
  +
  +    public boolean isValidChecksum( Artifact artifact, ArtifactRepository localRepository
)
  +        throws TransferFailedException, UnsupportedProtocolException
  +    {
  +        WagonManager wagonManager = new DefaultWagonManager();
  +
  +        Set set = new HashSet();
  +
  +        set.add( localRepository );
  +
  +        Wagon wagon = wagonManager.getWagon( "file://" );
  +
  +        wagon.addTransferListener( checksumObserver );
  +
  +        wagonManager.get( artifact, set, tempRepository );
  +
  +        // File file = artifact.getFile();
  +        //
  +        // TransferEvent transferEvent = new TransferEvent( wagon, new
  +        // Resource(), TransferEvent.TRANSFER_COMPLETED,
  +        // TransferEvent.REQUEST_GET );
  +        //
  +        // checksumObserver.transferStarted( transferEvent );
  +        // checksumObserver.transferProgress(transferEvent, file);
  +
  +        return true;
  +    }
  +
       public static void main( String[] args )
       {
           if ( args.length != 1 )
  
  
  

Mime
View raw message