You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by mi...@apache.org on 2003/05/02 11:03:53 UTC

cvs commit: maven-new/core/src/java/org/apache/maven/artifact DefaultArtifactFactory.java DefaultArtifactVerifier.java ArtifactFactory.java ArtifactVerifier.java ArtifactListProcessor.java DefaultArtifactListProcessor.java

michal      2003/05/02 02:03:53

  Modified:    core/src/java/org/apache/maven/artifact/handlers
                        NOPHandler.java JarHandler.java
               core/src/java/org/apache/maven/artifact
                        DefaultArtifactFactory.java
                        DefaultArtifactVerifier.java ArtifactFactory.java
                        ArtifactVerifier.java
  Removed:     core/src/java/org/apache/maven/artifact
                        ArtifactListProcessor.java
                        DefaultArtifactListProcessor.java
  Log:
  Improved javadocs
  
  Revision  Changes    Path
  1.2       +2 -2      maven-new/core/src/java/org/apache/maven/artifact/handlers/NOPHandler.java
  
  Index: NOPHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/NOPHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NOPHandler.java	30 Apr 2003 12:40:43 -0000	1.1
  +++ NOPHandler.java	2 May 2003 09:03:53 -0000	1.2
  @@ -53,7 +53,7 @@
    *
    * ====================================================================
    */
  - package org.apache.maven.artifact.handlers;
  +package org.apache.maven.artifact.handlers;
   
   import org.apache.maven.artifact.Artifact;
   import org.apache.maven.artifact.ArtifactHandler;
  
  
  
  1.2       +2 -2      maven-new/core/src/java/org/apache/maven/artifact/handlers/JarHandler.java
  
  Index: JarHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/JarHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JarHandler.java	30 Apr 2003 08:29:39 -0000	1.1
  +++ JarHandler.java	2 May 2003 09:03:53 -0000	1.2
  @@ -77,7 +77,7 @@
        */
       public void process(Artifact artifact, Project project)
       {
  -        project.setDependencyPath(artifact.getName(), artifact.getPath());
  +        project.setDependencyPath(artifact.getId(), artifact.getPath());
       }
   
   }
  
  
  
  1.2       +2 -2      maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifactFactory.java
  
  Index: DefaultArtifactFactory.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifactFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultArtifactFactory.java	30 Apr 2003 08:29:40 -0000	1.1
  +++ DefaultArtifactFactory.java	2 May 2003 09:03:53 -0000	1.2
  @@ -101,7 +101,7 @@
               }
               Artifact artifact = new DefaultArtifact();
               artifact.setDependency(dependency);
  -            artifact.setId(dependency.getArtifactId());
  +            artifact.setArtifactId(dependency.getArtifactId());
               artifact.setGroupId(dependency.getArtifactDirectory());
               artifact.setType(dependency.getType());
   
  
  
  
  1.3       +108 -77   maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifactVerifier.java
  
  Index: DefaultArtifactVerifier.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifactVerifier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultArtifactVerifier.java	1 May 2003 17:28:40 -0000	1.2
  +++ DefaultArtifactVerifier.java	2 May 2003 09:03:53 -0000	1.3
  @@ -60,7 +60,13 @@
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.util.Iterator;
  +import java.util.List;
   
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.maven.project.Project;
   import org.apache.maven.util.I18NUtils;
   import org.apache.maven.util.MD5Sum;
   import org.apache.maven.verifier.ChecksumVerificationException;
  @@ -76,83 +82,108 @@
    * @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a> 
    * @version $Id$
    */
  -public class DefaultArtifactVerifier
  +public class DefaultArtifactVerifier implements Configurable, ArtifactVerifier
   {
  +   /** Control verification of dependencies. */
  +   private boolean verifyDependencies;
   
  -    // ----------------------------------------------------------------------
  -    // C H E C K S U M  V E R I F I C A T I O N
  -    // ----------------------------------------------------------------------
  -
  -    public void verify(Artifact artifact) throws ChecksumVerificationException
  -    {
  -
  -        File artifactFile = artifact.getFile();
  -        File checksumFile = new File(artifactFile.getName() + ".md5");
  -
  -        // The central repository is not fully populated with md5
  -        // checksum files yet so we'll be a little lax right now but
  -        // hopefully in the future we can differentiate or specify
  -        // repositories whose artifacts must undergo verification.
  -        if (checksumFile.exists() == false)
  -        {
  -            return;
  -        }
  -
  -        String actualChecksum = null;
  -        MD5Sum md5 = null;
  -        try
  -        {
  -            md5 = new MD5Sum();
  -            md5.setFile(artifactFile);
  -            md5.execute();
  -
  -            actualChecksum = fileRead(checksumFile);
  -            actualChecksum =
  -                actualChecksum.substring(0, actualChecksum.length() - 1);
  -        }
  -        catch (Exception e)
  -        {
  -            return;
  -        }
  -        System.out.println("'" + actualChecksum + "'");
  -        System.out.println("'" + md5.getChecksum() + "'");
  -        if (actualChecksum.equals(md5.getChecksum()) == false)
  -        {
  -            throw new ChecksumVerificationException(
  -                I18NUtils.getMessage(
  -                    "checksum.verification.error",
  -                    artifact.getPath()));
  -        }
  -    }
  -
  -    /**
  -     * Reads the contents of a file.
  -     *
  -     * @param file The name of the file to read.
  -     * @return The file contents or null if read failed.
  -     */
  -    private String fileRead(File file) throws IOException
  -    {
  -        InputStream in = null;
  -        try
  -        {
  -            StringBuffer buf = new StringBuffer();
  -            in = new BufferedInputStream(new FileInputStream(file));
  -            int count;
  -            byte[] b = new byte[512];
  -            while ((count = in.read(b)) > 0) // blocking read
  -            {
  -                buf.append(new String(b, 0, count));
  -            }
  -            return buf.toString();
  -        }
  -        finally
  -        {
  -            if (in != null)
  -            {
  -                in.close();
  -            }
  -        }
  -    }
  +   //	----------------------------------------------------------------------
  +   // Lifecylce Management
  +   // ----------------------------------------------------------------------
  +
  +   public void configure(Configuration configuration)
  +      throws ConfigurationException
  +   {
  +      verifyDependencies =
  +         configuration.getChild("verifyDependencies").getValueAsBoolean(false);
  +   }
  +   /**
  +    * @see org.apache.maven.artifact.ArtifactVerifier#verify(org.apache.maven.project.Project)
  +    */
  +   public void verify(Project project) throws ChecksumVerificationException
  +   {
  +      List artifacts = project.getArtifacts();
  +      for (Iterator iter = artifacts.iterator(); iter.hasNext();)
  +      {
  +         Artifact artifact = (Artifact) iter.next();
  +         verify(artifact);
  +      }
  +   }
  +
  +   // ----------------------------------------------------------------------
  +   // C H E C K S U M  V E R I F I C A T I O N
  +   // ----------------------------------------------------------------------
  +
  +   private void verify(Artifact artifact) throws ChecksumVerificationException
  +   {
  +
  +      File artifactFile = artifact.getFile();
  +      File checksumFile = new File(artifactFile.getName() + ".md5");
  +
  +      // The central repository is not fully populated with md5
  +      // checksum files yet so we'll be a little lax right now but
  +      // hopefully in the future we can differentiate or specify
  +      // repositories whose artifacts must undergo verification.
  +      if (checksumFile.exists() == false)
  +      {
  +         return;
  +      }
  +
  +      String actualChecksum = null;
  +      MD5Sum md5 = null;
  +      try
  +      {
  +         md5 = new MD5Sum();
  +         md5.setFile(artifactFile);
  +         md5.execute();
  +
  +         actualChecksum = fileRead(checksumFile);
  +         actualChecksum =
  +            actualChecksum.substring(0, actualChecksum.length() - 1);
  +      }
  +      catch (Exception e)
  +      {
  +         return;
  +      }
  +      System.out.println("'" + actualChecksum + "'");
  +      System.out.println("'" + md5.getChecksum() + "'");
  +      if (actualChecksum.equals(md5.getChecksum()) == false)
  +      {
  +         throw new ChecksumVerificationException(
  +            I18NUtils.getMessage(
  +               "checksum.verification.error",
  +               artifact.getPath()));
  +      }
  +   }
  +
  +   /**
  +    * Reads the contents of a file.
  +    *
  +    * @param file The name of the file to read.
  +    * @return The file contents or null if read failed.
  +    */
  +   private String fileRead(File file) throws IOException
  +   {
  +      InputStream in = null;
  +      try
  +      {
  +         StringBuffer buf = new StringBuffer();
  +         in = new BufferedInputStream(new FileInputStream(file));
  +         int count;
  +         byte[] b = new byte[512];
  +         while ((count = in.read(b)) > 0) // blocking read
  +         {
  +            buf.append(new String(b, 0, count));
  +         }
  +         return buf.toString();
  +      }
  +      finally
  +      {
  +         if (in != null)
  +         {
  +            in.close();
  +         }
  +      }
  +   }
   
   }
  
  
  
  1.3       +2 -2      maven-new/core/src/java/org/apache/maven/artifact/ArtifactFactory.java
  
  Index: ArtifactFactory.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/ArtifactFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArtifactFactory.java	1 May 2003 17:28:40 -0000	1.2
  +++ ArtifactFactory.java	2 May 2003 09:03:53 -0000	1.3
  @@ -83,7 +83,7 @@
   public interface ArtifactFactory
   {
   
  -   /** The role played in Avalon container*/
  +   /** Component role name*/
      public static final String ROLE = ArtifactFactory.class.getName();
   
      /**
  
  
  
  1.3       +14 -18    maven-new/core/src/java/org/apache/maven/artifact/ArtifactVerifier.java
  
  Index: ArtifactVerifier.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/ArtifactVerifier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArtifactVerifier.java	1 May 2003 17:28:40 -0000	1.2
  +++ ArtifactVerifier.java	2 May 2003 09:03:53 -0000	1.3
  @@ -53,33 +53,29 @@
    *
    * ====================================================================
    */
  -package org.apache.maven.artifact; 
  +package org.apache.maven.artifact;
   
  +import org.apache.maven.project.Project;
   import org.apache.maven.verifier.ChecksumVerificationException;
   
   /**
    * The interface defining an interface for classes 
  - * which will verify if given artifact is "valid".
  - * <br/>
  - * "The validation" can be type sensitive
  - * and can mean (just examples):
  - * <ol>
  - *   <li>MD5 sum checking</li>
  - *   <li>
  - *      XML validation (sytaxtic & agaist XML schema) 
  - *      - in case when artifact is XML file
  - *   </li>
  - *   <li>Checking if war archive contains valid web.xml file</li>
  - *   <li>...</i>
  - * <ol>
  + * which will verify all project <code>Artifact</code>s.
    * 
  - * @todo This code was extracted from artifact class. 
  - * Find all the places which were affected. 
    * 
    * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
    * @version $Id$
    */
   public interface ArtifactVerifier
   {
  -   void verify(Artifact artifact) throws ChecksumVerificationException;
  +   /** Component role name  */
  +   public static final String ROLE = ArtifactVerifier.class.getName();
  +
  +   
  +    /**
  +     * 
  +     * @param artifact the <code>Artifact</code> which will be verified
  +     * @throws ChecksumVerificationException
  +     */
  +   void verify(Project project) throws ChecksumVerificationException;
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org