You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Brett Porter <br...@apache.org> on 2006/06/13 08:59:12 UTC

Re: svn commit: r413818 - in /maven/repository-manager/trunk: maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/ maven-repository-proxy/src/main/ja...

I don't really like when a map is used for a list of objects with two 
properties. Couldn't we have a little object for this?

- Brett

epunzalan@apache.org wrote:
> Author: epunzalan
> Date: Mon Jun 12 23:53:38 2006
> New Revision: 413818
> 
> URL: http://svn.apache.org/viewvc?rev=413818&view=rev
> Log:
> Added reason parameter in kickedOutPaths.  Also, added an interface with the kickedOutPaths which two other interfaces extends
> 
> Added:
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java   (with props)
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java   (with props)
> Modified:
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
>     maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
>     maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java Mon Jun 12 23:53:38 2006
> @@ -73,17 +73,19 @@
>          {
>              String path = artifactPaths[i];
>  
> -            Artifact artifact = buildArtifactFromPath( path, repository );
> -            if ( artifact != null )
> +            Artifact artifact = null;
> +            try
>              {
> +                artifact = buildArtifactFromPath( path, repository );
> +
>                  if ( includeSnapshots || !artifact.isSnapshot() )
>                  {
>                      artifacts.add( artifact );
>                  }
>              }
> -            else
> +            catch ( DiscovererException e )
>              {
> -                addKickedOutPath( path );
> +                addKickedOutPath( path, e.getMessage() );
>              }
>          }
>  
> @@ -103,14 +105,16 @@
>          {
>              String path = artifactPaths[i];
>  
> +            String filename = repositoryBase.getAbsolutePath() + "/" + path;
> +
>              if ( path.toLowerCase().endsWith( POM ) )
>              {
> -                Artifact pomArtifact = buildArtifactFromPath( path, repository );
> -
> -                MavenXpp3Reader mavenReader = new MavenXpp3Reader();
> -                String filename = repositoryBase.getAbsolutePath() + "/" + path;
>                  try
>                  {
> +                    Artifact pomArtifact = buildArtifactFromPath( path, repository );
> +
> +                    MavenXpp3Reader mavenReader = new MavenXpp3Reader();
> +
>                      Model model = mavenReader.read( new FileReader( filename ) );
>                      if ( pomArtifact != null && "pom".equals( model.getPackaging() ) )
>                      {
> @@ -134,6 +138,10 @@
>                      getLogger().error(
>                          "Parse error reading file during POM discovery: " + filename + ": " + e.getMessage() );
>                  }
> +                catch ( DiscovererException e )
> +                {
> +                    getLogger().error( e.getMessage() );
> +                }
>              }
>          }
>  
> @@ -141,6 +149,7 @@
>      }
>  
>      public Artifact buildArtifactFromPath( String path, ArtifactRepository repository )
> +        throws DiscovererException
>      {
>          Artifact artifact = buildArtifact( path );
>  
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java Mon Jun 12 23:53:38 2006
> @@ -26,6 +26,8 @@
>  import java.util.Arrays;
>  import java.util.Iterator;
>  import java.util.List;
> +import java.util.Map;
> +import java.util.HashMap;
>  
>  /**
>   * Base class for the artifact and metadata discoverers.
> @@ -34,8 +36,9 @@
>   */
>  public abstract class AbstractDiscoverer
>      extends AbstractLogEnabled
> +    implements Discoverer
>  {
> -    private List kickedOutPaths = new ArrayList();
> +    private Map kickedOutPaths = new HashMap();
>  
>      /**
>       * @plexus.requirement
> @@ -50,16 +53,16 @@
>       * Add a path to the list of files that were kicked out due to being invalid.
>       *
>       * @param path the path to add
> -     * @todo add a reason
> +     * @param reason the reason why the path is being kicked out
>       */
> -    protected void addKickedOutPath( String path )
> +    protected void addKickedOutPath( String path, String reason )
>      {
> -        kickedOutPaths.add( path );
> +        kickedOutPaths.put( path, reason );
>      }
>  
>      public Iterator getKickedOutPathsIterator()
>      {
> -        return kickedOutPaths.iterator();
> +        return kickedOutPaths.keySet().iterator();
>      }
>  
>      /**
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java Mon Jun 12 23:53:38 2006
> @@ -19,7 +19,6 @@
>  import org.apache.maven.artifact.Artifact;
>  import org.apache.maven.artifact.repository.ArtifactRepository;
>  
> -import java.util.Iterator;
>  import java.util.List;
>  
>  /**
> @@ -29,6 +28,7 @@
>   * @author Brett Porter
>   */
>  public interface ArtifactDiscoverer
> +    extends Discoverer
>  {
>      String ROLE = ArtifactDiscoverer.class.getName();
>  
> @@ -59,25 +59,12 @@
>      List discoverStandalonePoms( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots );
>  
>      /**
> -     * Get the list of paths kicked out during the discovery process.
> -     *
> -     * @return the paths as Strings.
> -     */
> -    Iterator getKickedOutPathsIterator();
> -
> -    /**
> -     * Get the list of paths excluded during the discovery process.
> -     *
> -     * @return the paths as Strings.
> -     */
> -    Iterator getExcludedPathsIterator();
> -
> -    /**
>       * Build an artifact from a path in the repository
>       *
>       * @param path the path
>       * @return the artifact
>       * @todo this should be in maven-artifact
>       */
> -    Artifact buildArtifact( String path );
> +    Artifact buildArtifact( String path )
> +        throws DiscovererException;
>  }
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java Mon Jun 12 23:53:38 2006
> @@ -35,6 +35,7 @@
>      extends AbstractArtifactDiscoverer
>  {
>      public Artifact buildArtifact( String path )
> +        throws DiscovererException
>      {
>          List pathParts = new ArrayList();
>          StringTokenizer st = new StringTokenizer( path, "/\\" );
> @@ -64,11 +65,7 @@
>              String groupId = StringUtils.join( pathParts.iterator(), "." );
>  
>              String remainingFilename = filename;
> -            if ( !remainingFilename.startsWith( artifactId + "-" ) )
> -            {
> -                return null;
> -            }
> -            else
> +            if ( remainingFilename.startsWith( artifactId + "-" ) )
>              {
>                  remainingFilename = remainingFilename.substring( artifactId.length() + 1 );
>  
> @@ -97,87 +94,92 @@
>                  else
>                  {
>                      int index = remainingFilename.lastIndexOf( "." );
> -                    if ( index < 0 )
> +                    if ( index >= 0 )
>                      {
> -                        return null;
> +                        type = remainingFilename.substring( index + 1 );
> +                        remainingFilename = remainingFilename.substring( 0, index );
>                      }
>                      else
>                      {
> -                        type = remainingFilename.substring( index + 1 );
> -                        remainingFilename = remainingFilename.substring( 0, index );
> +                        throw new DiscovererException( "Path filename does not have an extension" );
>                      }
>                  }
>  
> -                if ( type != null )
> +                Artifact result;
> +                if ( classifier == null )
>                  {
> -                    Artifact result;
> +                    result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
> +                                                             type );
> +                }
> +                else
> +                {
> +                    result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
> +                                                                           classifier );
> +                }
>  
> -                    if ( classifier == null )
> -                    {
> -                        result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
> -                                                                 type );
> +                if ( result.isSnapshot() )
> +                {
> +                    // version is *-SNAPSHOT, filename is *-yyyyMMdd.hhmmss-b
> +                    int classifierIndex = remainingFilename.indexOf( '-', version.length() + 8 );
> +                    if ( classifierIndex >= 0 )
> +                    {
> +                        classifier = remainingFilename.substring( classifierIndex + 1 );
> +                        remainingFilename = remainingFilename.substring( 0, classifierIndex );
> +                        result = artifactFactory.createArtifactWithClassifier( groupId, artifactId,
> +                                                                               remainingFilename, type,
> +                                                                               classifier );
>                      }
>                      else
>                      {
> -                        result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
> -                                                                               classifier );
> +                        result = artifactFactory.createArtifact( groupId, artifactId, remainingFilename,
> +                                                                 Artifact.SCOPE_RUNTIME, type );
>                      }
>  
> -                    if ( result.isSnapshot() )
> +                    // poor encapsulation requires we do this to populate base version
> +                    if ( !result.isSnapshot() )
> +                    {
> +                        throw new DiscovererException( "Failed to create a snapshot artifact" );
> +                    }
> +                    else if ( !result.getBaseVersion().equals( version ) )
>                      {
> -                        // version is *-SNAPSHOT, filename is *-yyyyMMdd.hhmmss-b
> -                        int classifierIndex = remainingFilename.indexOf( '-', version.length() + 8 );
> -                        if ( classifierIndex >= 0 )
> -                        {
> -                            classifier = remainingFilename.substring( classifierIndex + 1 );
> -                            remainingFilename = remainingFilename.substring( 0, classifierIndex );
> -                            result = artifactFactory.createArtifactWithClassifier( groupId, artifactId,
> -                                                                                   remainingFilename, type,
> -                                                                                   classifier );
> -                        }
> -                        else
> -                        {
> -                            result = artifactFactory.createArtifact( groupId, artifactId, remainingFilename,
> -                                                                     Artifact.SCOPE_RUNTIME, type );
> -                        }
> -
> -                        // poor encapsulation requires we do this to populate base version
> -                        if ( !result.isSnapshot() )
> -                        {
> -                            return null;
> -                        }
> -                        else if ( !result.getBaseVersion().equals( version ) )
> -                        {
> -                            return null;
> -                        }
> -                        else
> -                        {
> -                            artifact = result;
> -                        }
> -                    }
> -                    else if ( !remainingFilename.startsWith( version ) )
> -                    {
> -                        return null;
> -                    }
> -                    else if ( !remainingFilename.equals( version ) )
> -                    {
> -                        if ( remainingFilename.charAt( version.length() ) != '-' )
> -                        {
> -                            return null;
> -                        }
> -                        else
> -                        {
> -                            classifier = remainingFilename.substring( version.length() + 1 );
> -                            artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
> -                                                                                     classifier );
> -                        }
> +                        throw new DiscovererException( "Built snapshot artifact base version does not match " +
> +                                                       "path version" );
>                      }
>                      else
>                      {
>                          artifact = result;
>                      }
>                  }
> +                else if ( !remainingFilename.startsWith( version ) )
> +                {
> +                    throw new DiscovererException( "Built artifact version does not match path version" );
> +                }
> +                else if ( !remainingFilename.equals( version ) )
> +                {
> +                    if ( remainingFilename.charAt( version.length() ) == '-' )
> +                    {
> +                        classifier = remainingFilename.substring( version.length() + 1 );
> +                        artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
> +                                                                                 classifier );
> +                    }
> +                    else
> +                    {
> +                        throw new DiscovererException( "Path version does not corresspond to an artifact version" );
> +                    }
> +                }
> +                else
> +                {
> +                    artifact = result;
> +                }
> +            }
> +            else
> +            {
> +                throw new DiscovererException( "Path filename does not correspond to an artifact" );
>              }
> +        }
> +        else
> +        {
> +            throw new DiscovererException( "Path is too short to build an artifact from" );
>          }
>  
>          return artifact;
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java Mon Jun 12 23:53:38 2006
> @@ -24,6 +24,7 @@
>  import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
>  import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
>  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
> +import org.codehaus.plexus.util.StringUtils;
>  
>  import java.io.File;
>  import java.io.IOException;
> @@ -67,15 +68,14 @@
>  
>          for ( int i = 0; i < metadataPaths.length; i++ )
>          {
> -            RepositoryMetadata metadata = buildMetadata( repositoryBase.getPath(), metadataPaths[i] );
> -
> -            if ( metadata != null )
> +            try
>              {
> +                RepositoryMetadata metadata = buildMetadata( repositoryBase.getPath(), metadataPaths[i] );
>                  metadataFiles.add( metadata );
>              }
> -            else
> +            catch ( DiscovererException e )
>              {
> -                addKickedOutPath( metadataPaths[i] );
> +                addKickedOutPath( metadataPaths[i], e.getMessage() );
>              }
>          }
>  
> @@ -90,6 +90,7 @@
>       * @return the metadata
>       */
>      private RepositoryMetadata buildMetadata( String repo, String metadataPath )
> +        throws DiscovererException
>      {
>          Metadata m = null;
>          String repoPath = repo + "/" + metadataPath;
> @@ -104,23 +105,26 @@
>          }
>          catch ( XmlPullParserException e )
>          {
> -            getLogger().error( "Error parsing metadata file '" + repoPath + "': " + e.getMessage(), e );
> +            throw new DiscovererException( "Error parsing metadata file '" + repoPath + "': " + e.getMessage(), e );
>          }
>          catch ( MalformedURLException e )
>          {
>              // shouldn't happen
> -            getLogger().error( "Error constructing metadata file '" + repoPath + "': " + e.getMessage(), e );
> +            throw new DiscovererException( "Error constructing metadata file '" + repoPath + "': " +
> +                                           e.getMessage(), e );
>          }
>          catch ( IOException e )
>          {
> -            getLogger().error( "Error reading metadata file '" + repoPath + "': " + e.getMessage(), e );
> +            throw new DiscovererException( "Error reading metadata file '" + repoPath + "': " + e.getMessage(), e );
>          }
>  
> -        RepositoryMetadata repositoryMetadata = null;
> -        if ( m != null )
> +        RepositoryMetadata repositoryMetadata = buildMetadata( m, metadataPath );
> +
> +        if ( repositoryMetadata == null )
>          {
> -            repositoryMetadata = buildMetadata( m, metadataPath );
> +            throw new DiscovererException( "Unable to build a repository metadata from path" );
>          }
> +
>          return repositoryMetadata;
>      }
>  
> @@ -146,14 +150,8 @@
>          Iterator it = pathParts.iterator();
>          String tmpDir = (String) it.next();
>  
> -        //ArtifactHandler handler = new DefaultArtifactHandler( "jar" );
> -        //if( metaVersion != null && !metaVersion.equals( "" ) )
> -        //{
> -        //   VersionRange version = VersionRange.createFromVersion( metaVersion );
> -        //}
> -
>          Artifact artifact = null;
> -        if ( metaVersion != null && !"".equals( metaVersion ) )
> +        if ( !StringUtils.isEmpty( metaVersion ) )
>          {
>              artifact = artifactFactory.createBuildArtifact( metaGroupId, metaArtifactId, metaVersion, "jar" );
>          }
> 
> Added: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java?rev=413818&view=auto
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java (added)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java Mon Jun 12 23:53:38 2006
> @@ -0,0 +1,39 @@
> +package org.apache.maven.repository.discovery;
> +
> +import java.util.Iterator;
> +
> +/*
> + * 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.
> + */
> +
> +/**
> + * @author Edwin Punzalan
> + */
> +public interface Discoverer
> +{
> +    /**
> +     * Get the list of paths kicked out during the discovery process.
> +     *
> +     * @return the paths as Strings.
> +     */
> +    Iterator getKickedOutPathsIterator();
> +
> +    /**
> +     * Get the list of paths excluded during the discovery process.
> +     *
> +     * @return the paths as Strings.
> +     */
> +    Iterator getExcludedPathsIterator();
> +}
> 
> Propchange: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> Added: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java?rev=413818&view=auto
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java (added)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java Mon Jun 12 23:53:38 2006
> @@ -0,0 +1,39 @@
> +package org.apache.maven.repository.discovery;
> +
> +/*
> + * 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.
> + */
> +
> +/**
> + * @author Edwin Punzalan
> + */
> +public class DiscovererException
> +    extends Exception
> +{
> +    public DiscovererException( Throwable cause )
> +    {
> +        super( cause );
> +    }
> +
> +    public DiscovererException( String message )
> +    {
> +        super( message );
> +    }
> +
> +    public DiscovererException( String message, Throwable cause )
> +    {
> +        super( message, cause );
> +    }
> +}
> 
> Propchange: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java Mon Jun 12 23:53:38 2006
> @@ -38,10 +38,11 @@
>      extends AbstractArtifactDiscoverer
>  {
>      public Artifact buildArtifact( String path )
> +        throws DiscovererException
>      {
>          StringTokenizer tokens = new StringTokenizer( path, "/\\" );
>  
> -        Artifact result = null;
> +        Artifact result;
>  
>          int numberOfTokens = tokens.countTokens();
>  
> @@ -69,8 +70,6 @@
>  
>                  String lastAvceToken = (String) avceTokenList.removeLast();
>  
> -                boolean valid = true;
> -
>                  // TODO: share with other discoverer, use artifact handlers instead
>                  if ( lastAvceToken.endsWith( ".tar.gz" ) )
>                  {
> @@ -111,157 +110,168 @@
>                          }
>                          else
>                          {
> -                            //type does not match extension
> -                            valid = false;
> +                            throw new DiscovererException( "Path type does not match the extension" );
>                          }
>                      }
>                      else
>                      {
> -                        // no extension
> -                        valid = false;
> +                        throw new DiscovererException( "Path filename does not have an extension" );
>                      }
>                  }
>  
> -                if ( valid )
> -                {
> -                    // let's discover the version, and whatever's leftover will be either
> -                    // a classifier, or part of the artifactId, depending on position.
> -                    // Since version is at the end, we have to move in from the back.
> -                    Collections.reverse( avceTokenList );
> +                // let's discover the version, and whatever's leftover will be either
> +                // a classifier, or part of the artifactId, depending on position.
> +                // Since version is at the end, we have to move in from the back.
> +                Collections.reverse( avceTokenList );
>  
> -                    // TODO: this is obscene - surely a better way?
> -                    String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" +
> -                        "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" +
> -                        "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" +
> -                        "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" +
> -                        "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" +
> -                        "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" +
> -                        "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)";
> +                // TODO: this is obscene - surely a better way?
> +                String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" +
> +                    "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" +
> +                    "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" +
> +                    "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" +
> +                    "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" +
> +                    "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" +
> +                    "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)";
>  
> -                    StringBuffer classifierBuffer = new StringBuffer();
> -                    StringBuffer versionBuffer = new StringBuffer();
> +                StringBuffer classifierBuffer = new StringBuffer();
> +                StringBuffer versionBuffer = new StringBuffer();
>  
> -                    boolean firstVersionTokenEncountered = false;
> -                    boolean firstToken = true;
> +                boolean firstVersionTokenEncountered = false;
> +                boolean firstToken = true;
>  
> -                    int tokensIterated = 0;
> -                    for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
> -                    {
> -                        String token = (String) it.next();
> +                int tokensIterated = 0;
> +                for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
> +                {
> +                    String token = (String) it.next();
>  
> -                        boolean tokenIsVersionPart = token.matches( validVersionParts );
> +                    boolean tokenIsVersionPart = token.matches( validVersionParts );
>  
> -                        StringBuffer bufferToUpdate;
> +                    StringBuffer bufferToUpdate;
>  
> -                        // NOTE: logic in code is reversed, since we're peeling off the back
> -                        // Any token after the last versionPart will be in the classifier.
> -                        // Any token UP TO first non-versionPart is part of the version.
> -                        if ( !tokenIsVersionPart )
> -                        {
> -                            if ( firstVersionTokenEncountered )
> -                            {
> -                                //noinspection BreakStatement
> -                                break;
> -                            }
> -                            else
> -                            {
> -                                bufferToUpdate = classifierBuffer;
> -                            }
> -                        }
> -                        else
> -                        {
> -                            firstVersionTokenEncountered = true;
> -
> -                            bufferToUpdate = versionBuffer;
> -                        }
> -
> -                        if ( firstToken )
> +                    // NOTE: logic in code is reversed, since we're peeling off the back
> +                    // Any token after the last versionPart will be in the classifier.
> +                    // Any token UP TO first non-versionPart is part of the version.
> +                    if ( !tokenIsVersionPart )
> +                    {
> +                        if ( firstVersionTokenEncountered )
>                          {
> -                            firstToken = false;
> +                            //noinspection BreakStatement
> +                            break;
>                          }
>                          else
>                          {
> -                            bufferToUpdate.insert( 0, '-' );
> +                            bufferToUpdate = classifierBuffer;
>                          }
> +                    }
> +                    else
> +                    {
> +                        firstVersionTokenEncountered = true;
>  
> -                        bufferToUpdate.insert( 0, token );
> +                        bufferToUpdate = versionBuffer;
> +                    }
>  
> -                        tokensIterated++;
> +                    if ( firstToken )
> +                    {
> +                        firstToken = false;
>                      }
> +                    else
> +                    {
> +                        bufferToUpdate.insert( 0, '-' );
> +                    }
> +
> +                    bufferToUpdate.insert( 0, token );
> +
> +                    tokensIterated++;
> +                }
>  
> -                    // Now, restore the proper ordering so we can build the artifactId.
> -                    Collections.reverse( avceTokenList );
> +                // Now, restore the proper ordering so we can build the artifactId.
> +                Collections.reverse( avceTokenList );
>  
> -                    // if we didn't find a version, then punt. Use the last token
> -                    // as the version, and set the classifier empty.
> -                    if ( versionBuffer.length() < 1 )
> +                // if we didn't find a version, then punt. Use the last token
> +                // as the version, and set the classifier empty.
> +                if ( versionBuffer.length() < 1 )
> +                {
> +                    if ( avceTokenList.size() > 1 )
>                      {
> -                        if ( avceTokenList.size() > 1 )
> -                        {
> -                            int lastIdx = avceTokenList.size() - 1;
> +                        int lastIdx = avceTokenList.size() - 1;
>  
> -                            versionBuffer.append( avceTokenList.get( lastIdx ) );
> -                            avceTokenList.remove( lastIdx );
> -                        }
> +                        versionBuffer.append( avceTokenList.get( lastIdx ) );
> +                        avceTokenList.remove( lastIdx );
> +                    }
> +
> +                    classifierBuffer.setLength( 0 );
> +                }
> +                else
> +                {
> +                    // if everything is kosher, then pop off all the classifier and
> +                    // version tokens, leaving the naked artifact id in the list.
> +                    avceTokenList =
> +                        new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - tokensIterated ) );
> +                }
> +
> +                StringBuffer artifactIdBuffer = new StringBuffer();
>  
> -                        classifierBuffer.setLength( 0 );
> +                firstToken = true;
> +                for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
> +                {
> +                    String token = (String) it.next();
> +
> +                    if ( firstToken )
> +                    {
> +                        firstToken = false;
>                      }
>                      else
>                      {
> -                        // if everything is kosher, then pop off all the classifier and
> -                        // version tokens, leaving the naked artifact id in the list.
> -                        avceTokenList =
> -                            new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - tokensIterated ) );
> +                        artifactIdBuffer.append( '-' );
>                      }
>  
> -                    StringBuffer artifactIdBuffer = new StringBuffer();
> -
> -                    firstToken = true;
> -                    for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
> -                    {
> -                        String token = (String) it.next();
> +                    artifactIdBuffer.append( token );
> +                }
>  
> -                        if ( firstToken )
> -                        {
> -                            firstToken = false;
> -                        }
> -                        else
> -                        {
> -                            artifactIdBuffer.append( '-' );
> -                        }
> +                String artifactId = artifactIdBuffer.toString();
>  
> -                        artifactIdBuffer.append( token );
> +                if ( artifactId.length() > 0 )
> +                {
> +                    int lastVersionCharIdx = versionBuffer.length() - 1;
> +                    if ( lastVersionCharIdx > -1 && versionBuffer.charAt( lastVersionCharIdx ) == '-' )
> +                    {
> +                        versionBuffer.setLength( lastVersionCharIdx );
>                      }
>  
> -                    String artifactId = artifactIdBuffer.toString();
> +                    String version = versionBuffer.toString();
>  
> -                    if ( artifactId.length() > 0 )
> +                    if ( version.length() > 0 )
>                      {
> -                        int lastVersionCharIdx = versionBuffer.length() - 1;
> -                        if ( lastVersionCharIdx > -1 && versionBuffer.charAt( lastVersionCharIdx ) == '-' )
> +                        if ( classifierBuffer.length() > 0 )
>                          {
> -                            versionBuffer.setLength( lastVersionCharIdx );
> +                            result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version,
> +                                                                                   type,
> +                                                                                   classifierBuffer.toString() );
>                          }
> -
> -                        String version = versionBuffer.toString();
> -
> -                        if ( version.length() >= 1 )
> +                        else
>                          {
> -                            if ( classifierBuffer.length() > 0 )
> -                            {
> -                                result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version,
> -                                                                                       type,
> -                                                                                       classifierBuffer.toString() );
> -                            }
> -                            else
> -                            {
> -                                result = artifactFactory.createArtifact( groupId, artifactId, version,
> -                                                                         Artifact.SCOPE_RUNTIME, type );
> -                            }
> +                            result = artifactFactory.createArtifact( groupId, artifactId, version,
> +                                                                     Artifact.SCOPE_RUNTIME, type );
>                          }
>                      }
> +                    else
> +                    {
> +                        throw new DiscovererException( "Path filename version is empty" );
> +                    }
> +                }
> +                else
> +                {
> +                    throw new DiscovererException( "Path filename artifactId is empty" );
>                  }
>              }
> +            else
> +            {
> +                throw new DiscovererException( "Path artifact type does not corresspond to an artifact type" );
> +            }
> +        }
> +        else
> +        {
> +            throw new DiscovererException( "Path does not match a legacy repository path for an artifact" );
>          }
>  
>          return result;
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java Mon Jun 12 23:53:38 2006
> @@ -17,13 +17,13 @@
>   */
>  
>  import java.io.File;
> -import java.util.Iterator;
>  import java.util.List;
>  
>  /**
>   * Interface for discovering metadata files.
>   */
>  public interface MetadataDiscoverer
> +    extends Discoverer
>  {
>      String ROLE = MetadataDiscoverer.class.getName();
>  
> @@ -34,18 +34,4 @@
>       * @param blacklistedPatterns Patterns that are to be excluded from the discovery process.
>       */
>      List discoverMetadata( File repositoryBase, String blacklistedPatterns );
> -
> -    /**
> -     * Get the list of paths kicked out during the discovery process.
> -     *
> -     * @return the paths as Strings.
> -     */
> -    Iterator getKickedOutPathsIterator();
> -
> -    /**
> -     * Get the list of paths excluded during the discovery process.
> -     *
> -     * @return the paths as Strings.
> -     */
> -    Iterator getExcludedPathsIterator();
>  }
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java Mon Jun 12 23:53:38 2006
> @@ -565,7 +565,14 @@
>  
>      private Artifact getArtifactFromPath( String path )
>      {
> -        return discoverer.buildArtifact( path );
> +        try
> +        {
> +            return discoverer.buildArtifact( path );
> +        }
> +        catch ( DiscovererException e )
> +        {
> +            return null;
> +        }
>      }
>  
>      private Artifact createArtifact( String groupId, String artifactId, String version )
> 
> Modified: maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java (original)
> +++ maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java Mon Jun 12 23:53:38 2006
> @@ -406,7 +406,14 @@
>  
>      private Artifact getArtifactFromPath( String path )
>      {
> -        return discoverer.buildArtifact( path );
> +        try
> +        {
> +            return discoverer.buildArtifact( path );
> +        }
> +        catch ( DiscovererException e )
> +        {
> +            return null;
> +        }
>      }
>  
>      private Artifact createArtifact( String groupId, String artifactId, String version )
> 
> Modified: maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
> URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java?rev=413818&r1=413817&r2=413818&view=diff
> ==============================================================================
> --- maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java (original)
> +++ maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java Mon Jun 12 23:53:38 2006
> @@ -24,6 +24,7 @@
>  import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
>  import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
>  import org.apache.maven.repository.discovery.ArtifactDiscoverer;
> +import org.apache.maven.repository.discovery.DiscovererException;
>  import org.apache.maven.repository.proxy.configuration.ProxyConfiguration;
>  import org.apache.maven.repository.proxy.repository.ProxyRepository;
>  import org.apache.maven.wagon.ConnectionException;
> @@ -150,11 +151,26 @@
>          }
>          else
>          {
> -            Artifact artifact = defaultArtifactDiscoverer.buildArtifact( path );
> +            Artifact artifact = null;
> +            try
> +            {
> +                artifact = defaultArtifactDiscoverer.buildArtifact( path );
> +            }
> +            catch ( DiscovererException e )
> +            {
> +                getLogger().debug( "Failed to build artifact using default layout with message: " + e.getMessage() );
> +            }
>  
>              if ( artifact == null )
>              {
> -                artifact = legacyArtifactDiscoverer.buildArtifact( path );
> +                try
> +                {
> +                    artifact = legacyArtifactDiscoverer.buildArtifact( path );
> +                }
> +                catch ( DiscovererException e )
> +                {
> +                    getLogger().debug( "Failed to build artifact using legacy layout with message: " + e.getMessage() );
> +                }
>              }
>  
>              if ( artifact != null )
> 
> 


-- 
Brett Porter <br...@apache.org>
Apache Maven - http://maven.apache.org/
Better Builds with Maven - http://library.mergere.com/

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


Re: svn commit: r413818 - in /maven/repository-manager/trunk: maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/ maven-repository-proxy/src/main/ja...

Posted by Edwin Punzalan <ep...@exist.com>.
I was thinking about that... but thought that it was too little.  But 
since you brought it up, I'll change it. Thanks.

^_^




Brett Porter wrote:
> I don't really like when a map is used for a list of objects with two 
> properties. Couldn't we have a little object for this?
>
> - Brett
>
> epunzalan@apache.org wrote:
>> Author: epunzalan
>> Date: Mon Jun 12 23:53:38 2006
>> New Revision: 413818
>>
>> URL: http://svn.apache.org/viewvc?rev=413818&view=rev
>> Log:
>> Added reason parameter in kickedOutPaths.  Also, added an interface 
>> with the kickedOutPaths which two other interfaces extends
>>
>> Added:
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java   
>> (with props)
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java   
>> (with props)
>> Modified:
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java 
>>
>>     
>> maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java 
>>
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -73,17 +73,19 @@
>>          {
>>              String path = artifactPaths[i];
>>  
>> -            Artifact artifact = buildArtifactFromPath( path, 
>> repository );
>> -            if ( artifact != null )
>> +            Artifact artifact = null;
>> +            try
>>              {
>> +                artifact = buildArtifactFromPath( path, repository );
>> +
>>                  if ( includeSnapshots || !artifact.isSnapshot() )
>>                  {
>>                      artifacts.add( artifact );
>>                  }
>>              }
>> -            else
>> +            catch ( DiscovererException e )
>>              {
>> -                addKickedOutPath( path );
>> +                addKickedOutPath( path, e.getMessage() );
>>              }
>>          }
>>  
>> @@ -103,14 +105,16 @@
>>          {
>>              String path = artifactPaths[i];
>>  
>> +            String filename = repositoryBase.getAbsolutePath() + "/" 
>> + path;
>> +
>>              if ( path.toLowerCase().endsWith( POM ) )
>>              {
>> -                Artifact pomArtifact = buildArtifactFromPath( path, 
>> repository );
>> -
>> -                MavenXpp3Reader mavenReader = new MavenXpp3Reader();
>> -                String filename = repositoryBase.getAbsolutePath() + 
>> "/" + path;
>>                  try
>>                  {
>> +                    Artifact pomArtifact = buildArtifactFromPath( 
>> path, repository );
>> +
>> +                    MavenXpp3Reader mavenReader = new 
>> MavenXpp3Reader();
>> +
>>                      Model model = mavenReader.read( new FileReader( 
>> filename ) );
>>                      if ( pomArtifact != null && "pom".equals( 
>> model.getPackaging() ) )
>>                      {
>> @@ -134,6 +138,10 @@
>>                      getLogger().error(
>>                          "Parse error reading file during POM 
>> discovery: " + filename + ": " + e.getMessage() );
>>                  }
>> +                catch ( DiscovererException e )
>> +                {
>> +                    getLogger().error( e.getMessage() );
>> +                }
>>              }
>>          }
>>  
>> @@ -141,6 +149,7 @@
>>      }
>>  
>>      public Artifact buildArtifactFromPath( String path, 
>> ArtifactRepository repository )
>> +        throws DiscovererException
>>      {
>>          Artifact artifact = buildArtifact( path );
>>  
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -26,6 +26,8 @@
>>  import java.util.Arrays;
>>  import java.util.Iterator;
>>  import java.util.List;
>> +import java.util.Map;
>> +import java.util.HashMap;
>>  
>>  /**
>>   * Base class for the artifact and metadata discoverers.
>> @@ -34,8 +36,9 @@
>>   */
>>  public abstract class AbstractDiscoverer
>>      extends AbstractLogEnabled
>> +    implements Discoverer
>>  {
>> -    private List kickedOutPaths = new ArrayList();
>> +    private Map kickedOutPaths = new HashMap();
>>  
>>      /**
>>       * @plexus.requirement
>> @@ -50,16 +53,16 @@
>>       * Add a path to the list of files that were kicked out due to 
>> being invalid.
>>       *
>>       * @param path the path to add
>> -     * @todo add a reason
>> +     * @param reason the reason why the path is being kicked out
>>       */
>> -    protected void addKickedOutPath( String path )
>> +    protected void addKickedOutPath( String path, String reason )
>>      {
>> -        kickedOutPaths.add( path );
>> +        kickedOutPaths.put( path, reason );
>>      }
>>  
>>      public Iterator getKickedOutPathsIterator()
>>      {
>> -        return kickedOutPaths.iterator();
>> +        return kickedOutPaths.keySet().iterator();
>>      }
>>  
>>      /**
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -19,7 +19,6 @@
>>  import org.apache.maven.artifact.Artifact;
>>  import org.apache.maven.artifact.repository.ArtifactRepository;
>>  
>> -import java.util.Iterator;
>>  import java.util.List;
>>  
>>  /**
>> @@ -29,6 +28,7 @@
>>   * @author Brett Porter
>>   */
>>  public interface ArtifactDiscoverer
>> +    extends Discoverer
>>  {
>>      String ROLE = ArtifactDiscoverer.class.getName();
>>  
>> @@ -59,25 +59,12 @@
>>      List discoverStandalonePoms( ArtifactRepository repository, 
>> String blacklistedPatterns, boolean includeSnapshots );
>>  
>>      /**
>> -     * Get the list of paths kicked out during the discovery process.
>> -     *
>> -     * @return the paths as Strings.
>> -     */
>> -    Iterator getKickedOutPathsIterator();
>> -
>> -    /**
>> -     * Get the list of paths excluded during the discovery process.
>> -     *
>> -     * @return the paths as Strings.
>> -     */
>> -    Iterator getExcludedPathsIterator();
>> -
>> -    /**
>>       * Build an artifact from a path in the repository
>>       *
>>       * @param path the path
>>       * @return the artifact
>>       * @todo this should be in maven-artifact
>>       */
>> -    Artifact buildArtifact( String path );
>> +    Artifact buildArtifact( String path )
>> +        throws DiscovererException;
>>  }
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -35,6 +35,7 @@
>>      extends AbstractArtifactDiscoverer
>>  {
>>      public Artifact buildArtifact( String path )
>> +        throws DiscovererException
>>      {
>>          List pathParts = new ArrayList();
>>          StringTokenizer st = new StringTokenizer( path, "/\\" );
>> @@ -64,11 +65,7 @@
>>              String groupId = StringUtils.join( pathParts.iterator(), 
>> "." );
>>  
>>              String remainingFilename = filename;
>> -            if ( !remainingFilename.startsWith( artifactId + "-" ) )
>> -            {
>> -                return null;
>> -            }
>> -            else
>> +            if ( remainingFilename.startsWith( artifactId + "-" ) )
>>              {
>>                  remainingFilename = remainingFilename.substring( 
>> artifactId.length() + 1 );
>>  
>> @@ -97,87 +94,92 @@
>>                  else
>>                  {
>>                      int index = remainingFilename.lastIndexOf( "." );
>> -                    if ( index < 0 )
>> +                    if ( index >= 0 )
>>                      {
>> -                        return null;
>> +                        type = remainingFilename.substring( index + 
>> 1 );
>> +                        remainingFilename = 
>> remainingFilename.substring( 0, index );
>>                      }
>>                      else
>>                      {
>> -                        type = remainingFilename.substring( index + 
>> 1 );
>> -                        remainingFilename = 
>> remainingFilename.substring( 0, index );
>> +                        throw new DiscovererException( "Path 
>> filename does not have an extension" );
>>                      }
>>                  }
>>  
>> -                if ( type != null )
>> +                Artifact result;
>> +                if ( classifier == null )
>>                  {
>> -                    Artifact result;
>> +                    result = artifactFactory.createArtifact( 
>> groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
>> +                                                             type );
>> +                }
>> +                else
>> +                {
>> +                    result = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
>> version, type,
>> +                                                                           
>> classifier );
>> +                }
>>  
>> -                    if ( classifier == null )
>> -                    {
>> -                        result = artifactFactory.createArtifact( 
>> groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
>> -                                                                 
>> type );
>> +                if ( result.isSnapshot() )
>> +                {
>> +                    // version is *-SNAPSHOT, filename is 
>> *-yyyyMMdd.hhmmss-b
>> +                    int classifierIndex = remainingFilename.indexOf( 
>> '-', version.length() + 8 );
>> +                    if ( classifierIndex >= 0 )
>> +                    {
>> +                        classifier = remainingFilename.substring( 
>> classifierIndex + 1 );
>> +                        remainingFilename = 
>> remainingFilename.substring( 0, classifierIndex );
>> +                        result = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId,
>> +                                                                               
>> remainingFilename, type,
>> +                                                                               
>> classifier );
>>                      }
>>                      else
>>                      {
>> -                        result = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
>> version, type,
>> -                                                                               
>> classifier );
>> +                        result = artifactFactory.createArtifact( 
>> groupId, artifactId, remainingFilename,
>> +                                                                 
>> Artifact.SCOPE_RUNTIME, type );
>>                      }
>>  
>> -                    if ( result.isSnapshot() )
>> +                    // poor encapsulation requires we do this to 
>> populate base version
>> +                    if ( !result.isSnapshot() )
>> +                    {
>> +                        throw new DiscovererException( "Failed to 
>> create a snapshot artifact" );
>> +                    }
>> +                    else if ( !result.getBaseVersion().equals( 
>> version ) )
>>                      {
>> -                        // version is *-SNAPSHOT, filename is 
>> *-yyyyMMdd.hhmmss-b
>> -                        int classifierIndex = 
>> remainingFilename.indexOf( '-', version.length() + 8 );
>> -                        if ( classifierIndex >= 0 )
>> -                        {
>> -                            classifier = 
>> remainingFilename.substring( classifierIndex + 1 );
>> -                            remainingFilename = 
>> remainingFilename.substring( 0, classifierIndex );
>> -                            result = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId,
>> -                                                                                   
>> remainingFilename, type,
>> -                                                                                   
>> classifier );
>> -                        }
>> -                        else
>> -                        {
>> -                            result = artifactFactory.createArtifact( 
>> groupId, artifactId, remainingFilename,
>> -                                                                     
>> Artifact.SCOPE_RUNTIME, type );
>> -                        }
>> -
>> -                        // poor encapsulation requires we do this to 
>> populate base version
>> -                        if ( !result.isSnapshot() )
>> -                        {
>> -                            return null;
>> -                        }
>> -                        else if ( !result.getBaseVersion().equals( 
>> version ) )
>> -                        {
>> -                            return null;
>> -                        }
>> -                        else
>> -                        {
>> -                            artifact = result;
>> -                        }
>> -                    }
>> -                    else if ( !remainingFilename.startsWith( version 
>> ) )
>> -                    {
>> -                        return null;
>> -                    }
>> -                    else if ( !remainingFilename.equals( version ) )
>> -                    {
>> -                        if ( remainingFilename.charAt( 
>> version.length() ) != '-' )
>> -                        {
>> -                            return null;
>> -                        }
>> -                        else
>> -                        {
>> -                            classifier = 
>> remainingFilename.substring( version.length() + 1 );
>> -                            artifact = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
>> version, type,
>> -                                                                                     
>> classifier );
>> -                        }
>> +                        throw new DiscovererException( "Built 
>> snapshot artifact base version does not match " +
>> +                                                       "path 
>> version" );
>>                      }
>>                      else
>>                      {
>>                          artifact = result;
>>                      }
>>                  }
>> +                else if ( !remainingFilename.startsWith( version ) )
>> +                {
>> +                    throw new DiscovererException( "Built artifact 
>> version does not match path version" );
>> +                }
>> +                else if ( !remainingFilename.equals( version ) )
>> +                {
>> +                    if ( remainingFilename.charAt( version.length() 
>> ) == '-' )
>> +                    {
>> +                        classifier = remainingFilename.substring( 
>> version.length() + 1 );
>> +                        artifact = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
>> version, type,
>> +                                                                                 
>> classifier );
>> +                    }
>> +                    else
>> +                    {
>> +                        throw new DiscovererException( "Path version 
>> does not corresspond to an artifact version" );
>> +                    }
>> +                }
>> +                else
>> +                {
>> +                    artifact = result;
>> +                }
>> +            }
>> +            else
>> +            {
>> +                throw new DiscovererException( "Path filename does 
>> not correspond to an artifact" );
>>              }
>> +        }
>> +        else
>> +        {
>> +            throw new DiscovererException( "Path is too short to 
>> build an artifact from" );
>>          }
>>  
>>          return artifact;
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -24,6 +24,7 @@
>>  import 
>> org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; 
>>
>>  import 
>> org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; 
>>
>>  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
>> +import org.codehaus.plexus.util.StringUtils;
>>  
>>  import java.io.File;
>>  import java.io.IOException;
>> @@ -67,15 +68,14 @@
>>  
>>          for ( int i = 0; i < metadataPaths.length; i++ )
>>          {
>> -            RepositoryMetadata metadata = buildMetadata( 
>> repositoryBase.getPath(), metadataPaths[i] );
>> -
>> -            if ( metadata != null )
>> +            try
>>              {
>> +                RepositoryMetadata metadata = buildMetadata( 
>> repositoryBase.getPath(), metadataPaths[i] );
>>                  metadataFiles.add( metadata );
>>              }
>> -            else
>> +            catch ( DiscovererException e )
>>              {
>> -                addKickedOutPath( metadataPaths[i] );
>> +                addKickedOutPath( metadataPaths[i], e.getMessage() );
>>              }
>>          }
>>  
>> @@ -90,6 +90,7 @@
>>       * @return the metadata
>>       */
>>      private RepositoryMetadata buildMetadata( String repo, String 
>> metadataPath )
>> +        throws DiscovererException
>>      {
>>          Metadata m = null;
>>          String repoPath = repo + "/" + metadataPath;
>> @@ -104,23 +105,26 @@
>>          }
>>          catch ( XmlPullParserException e )
>>          {
>> -            getLogger().error( "Error parsing metadata file '" + 
>> repoPath + "': " + e.getMessage(), e );
>> +            throw new DiscovererException( "Error parsing metadata 
>> file '" + repoPath + "': " + e.getMessage(), e );
>>          }
>>          catch ( MalformedURLException e )
>>          {
>>              // shouldn't happen
>> -            getLogger().error( "Error constructing metadata file '" 
>> + repoPath + "': " + e.getMessage(), e );
>> +            throw new DiscovererException( "Error constructing 
>> metadata file '" + repoPath + "': " +
>> +                                           e.getMessage(), e );
>>          }
>>          catch ( IOException e )
>>          {
>> -            getLogger().error( "Error reading metadata file '" + 
>> repoPath + "': " + e.getMessage(), e );
>> +            throw new DiscovererException( "Error reading metadata 
>> file '" + repoPath + "': " + e.getMessage(), e );
>>          }
>>  
>> -        RepositoryMetadata repositoryMetadata = null;
>> -        if ( m != null )
>> +        RepositoryMetadata repositoryMetadata = buildMetadata( m, 
>> metadataPath );
>> +
>> +        if ( repositoryMetadata == null )
>>          {
>> -            repositoryMetadata = buildMetadata( m, metadataPath );
>> +            throw new DiscovererException( "Unable to build a 
>> repository metadata from path" );
>>          }
>> +
>>          return repositoryMetadata;
>>      }
>>  
>> @@ -146,14 +150,8 @@
>>          Iterator it = pathParts.iterator();
>>          String tmpDir = (String) it.next();
>>  
>> -        //ArtifactHandler handler = new DefaultArtifactHandler( 
>> "jar" );
>> -        //if( metaVersion != null && !metaVersion.equals( "" ) )
>> -        //{
>> -        //   VersionRange version = VersionRange.createFromVersion( 
>> metaVersion );
>> -        //}
>> -
>>          Artifact artifact = null;
>> -        if ( metaVersion != null && !"".equals( metaVersion ) )
>> +        if ( !StringUtils.isEmpty( metaVersion ) )
>>          {
>>              artifact = artifactFactory.createBuildArtifact( 
>> metaGroupId, metaArtifactId, metaVersion, "jar" );
>>          }
>>
>> Added: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java?rev=413818&view=auto 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java 
>> (added)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -0,0 +1,39 @@
>> +package org.apache.maven.repository.discovery;
>> +
>> +import java.util.Iterator;
>> +
>> +/*
>> + * 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.
>> + */
>> +
>> +/**
>> + * @author Edwin Punzalan
>> + */
>> +public interface Discoverer
>> +{
>> +    /**
>> +     * Get the list of paths kicked out during the discovery process.
>> +     *
>> +     * @return the paths as Strings.
>> +     */
>> +    Iterator getKickedOutPathsIterator();
>> +
>> +    /**
>> +     * Get the list of paths excluded during the discovery process.
>> +     *
>> +     * @return the paths as Strings.
>> +     */
>> +    Iterator getExcludedPathsIterator();
>> +}
>>
>> Propchange: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/Discoverer.java 
>>
>> ------------------------------------------------------------------------------ 
>>
>>     svn:eol-style = native
>>
>> Added: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java?rev=413818&view=auto 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java 
>> (added)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -0,0 +1,39 @@
>> +package org.apache.maven.repository.discovery;
>> +
>> +/*
>> + * 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.
>> + */
>> +
>> +/**
>> + * @author Edwin Punzalan
>> + */
>> +public class DiscovererException
>> +    extends Exception
>> +{
>> +    public DiscovererException( Throwable cause )
>> +    {
>> +        super( cause );
>> +    }
>> +
>> +    public DiscovererException( String message )
>> +    {
>> +        super( message );
>> +    }
>> +
>> +    public DiscovererException( String message, Throwable cause )
>> +    {
>> +        super( message, cause );
>> +    }
>> +}
>>
>> Propchange: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java 
>>
>> ------------------------------------------------------------------------------ 
>>
>>     svn:eol-style = native
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -38,10 +38,11 @@
>>      extends AbstractArtifactDiscoverer
>>  {
>>      public Artifact buildArtifact( String path )
>> +        throws DiscovererException
>>      {
>>          StringTokenizer tokens = new StringTokenizer( path, "/\\" );
>>  
>> -        Artifact result = null;
>> +        Artifact result;
>>  
>>          int numberOfTokens = tokens.countTokens();
>>  
>> @@ -69,8 +70,6 @@
>>  
>>                  String lastAvceToken = (String) 
>> avceTokenList.removeLast();
>>  
>> -                boolean valid = true;
>> -
>>                  // TODO: share with other discoverer, use artifact 
>> handlers instead
>>                  if ( lastAvceToken.endsWith( ".tar.gz" ) )
>>                  {
>> @@ -111,157 +110,168 @@
>>                          }
>>                          else
>>                          {
>> -                            //type does not match extension
>> -                            valid = false;
>> +                            throw new DiscovererException( "Path 
>> type does not match the extension" );
>>                          }
>>                      }
>>                      else
>>                      {
>> -                        // no extension
>> -                        valid = false;
>> +                        throw new DiscovererException( "Path 
>> filename does not have an extension" );
>>                      }
>>                  }
>>  
>> -                if ( valid )
>> -                {
>> -                    // let's discover the version, and whatever's 
>> leftover will be either
>> -                    // a classifier, or part of the artifactId, 
>> depending on position.
>> -                    // Since version is at the end, we have to move 
>> in from the back.
>> -                    Collections.reverse( avceTokenList );
>> +                // let's discover the version, and whatever's 
>> leftover will be either
>> +                // a classifier, or part of the artifactId, 
>> depending on position.
>> +                // Since version is at the end, we have to move in 
>> from the back.
>> +                Collections.reverse( avceTokenList );
>>  
>> -                    // TODO: this is obscene - surely a better way?
>> -                    String validVersionParts = 
>> "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" +
>> -                        "([0-9][_.0-9a-zA-Z]*)|" + 
>> "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" +
>> -                        "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + 
>> "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" +
>> -                        "([Tt][Ee][Ss][Tt][_.0-9]*)|" + 
>> "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" +
>> -                        
>> "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + 
>> "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" +
>> -                        "([Ll][Aa][Tt][Ee][Ss][Tt])|" + 
>> "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" +
>> -                        "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + 
>> "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)";
>> +                // TODO: this is obscene - surely a better way?
>> +                String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" 
>> + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" +
>> +                    "([0-9][_.0-9a-zA-Z]*)|" + 
>> "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" +
>> +                    "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + 
>> "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" +
>> +                    "([Tt][Ee][Ss][Tt][_.0-9]*)|" + 
>> "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" +
>> +                    
>> "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + 
>> "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" +
>> +                    "([Ll][Aa][Tt][Ee][Ss][Tt])|" + 
>> "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" +
>> +                    "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + 
>> "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)";
>>  
>> -                    StringBuffer classifierBuffer = new StringBuffer();
>> -                    StringBuffer versionBuffer = new StringBuffer();
>> +                StringBuffer classifierBuffer = new StringBuffer();
>> +                StringBuffer versionBuffer = new StringBuffer();
>>  
>> -                    boolean firstVersionTokenEncountered = false;
>> -                    boolean firstToken = true;
>> +                boolean firstVersionTokenEncountered = false;
>> +                boolean firstToken = true;
>>  
>> -                    int tokensIterated = 0;
>> -                    for ( Iterator it = avceTokenList.iterator(); 
>> it.hasNext(); )
>> -                    {
>> -                        String token = (String) it.next();
>> +                int tokensIterated = 0;
>> +                for ( Iterator it = avceTokenList.iterator(); 
>> it.hasNext(); )
>> +                {
>> +                    String token = (String) it.next();
>>  
>> -                        boolean tokenIsVersionPart = token.matches( 
>> validVersionParts );
>> +                    boolean tokenIsVersionPart = token.matches( 
>> validVersionParts );
>>  
>> -                        StringBuffer bufferToUpdate;
>> +                    StringBuffer bufferToUpdate;
>>  
>> -                        // NOTE: logic in code is reversed, since 
>> we're peeling off the back
>> -                        // Any token after the last versionPart will 
>> be in the classifier.
>> -                        // Any token UP TO first non-versionPart is 
>> part of the version.
>> -                        if ( !tokenIsVersionPart )
>> -                        {
>> -                            if ( firstVersionTokenEncountered )
>> -                            {
>> -                                //noinspection BreakStatement
>> -                                break;
>> -                            }
>> -                            else
>> -                            {
>> -                                bufferToUpdate = classifierBuffer;
>> -                            }
>> -                        }
>> -                        else
>> -                        {
>> -                            firstVersionTokenEncountered = true;
>> -
>> -                            bufferToUpdate = versionBuffer;
>> -                        }
>> -
>> -                        if ( firstToken )
>> +                    // NOTE: logic in code is reversed, since we're 
>> peeling off the back
>> +                    // Any token after the last versionPart will be 
>> in the classifier.
>> +                    // Any token UP TO first non-versionPart is part 
>> of the version.
>> +                    if ( !tokenIsVersionPart )
>> +                    {
>> +                        if ( firstVersionTokenEncountered )
>>                          {
>> -                            firstToken = false;
>> +                            //noinspection BreakStatement
>> +                            break;
>>                          }
>>                          else
>>                          {
>> -                            bufferToUpdate.insert( 0, '-' );
>> +                            bufferToUpdate = classifierBuffer;
>>                          }
>> +                    }
>> +                    else
>> +                    {
>> +                        firstVersionTokenEncountered = true;
>>  
>> -                        bufferToUpdate.insert( 0, token );
>> +                        bufferToUpdate = versionBuffer;
>> +                    }
>>  
>> -                        tokensIterated++;
>> +                    if ( firstToken )
>> +                    {
>> +                        firstToken = false;
>>                      }
>> +                    else
>> +                    {
>> +                        bufferToUpdate.insert( 0, '-' );
>> +                    }
>> +
>> +                    bufferToUpdate.insert( 0, token );
>> +
>> +                    tokensIterated++;
>> +                }
>>  
>> -                    // Now, restore the proper ordering so we can 
>> build the artifactId.
>> -                    Collections.reverse( avceTokenList );
>> +                // Now, restore the proper ordering so we can build 
>> the artifactId.
>> +                Collections.reverse( avceTokenList );
>>  
>> -                    // if we didn't find a version, then punt. Use 
>> the last token
>> -                    // as the version, and set the classifier empty.
>> -                    if ( versionBuffer.length() < 1 )
>> +                // if we didn't find a version, then punt. Use the 
>> last token
>> +                // as the version, and set the classifier empty.
>> +                if ( versionBuffer.length() < 1 )
>> +                {
>> +                    if ( avceTokenList.size() > 1 )
>>                      {
>> -                        if ( avceTokenList.size() > 1 )
>> -                        {
>> -                            int lastIdx = avceTokenList.size() - 1;
>> +                        int lastIdx = avceTokenList.size() - 1;
>>  
>> -                            versionBuffer.append( avceTokenList.get( 
>> lastIdx ) );
>> -                            avceTokenList.remove( lastIdx );
>> -                        }
>> +                        versionBuffer.append( avceTokenList.get( 
>> lastIdx ) );
>> +                        avceTokenList.remove( lastIdx );
>> +                    }
>> +
>> +                    classifierBuffer.setLength( 0 );
>> +                }
>> +                else
>> +                {
>> +                    // if everything is kosher, then pop off all the 
>> classifier and
>> +                    // version tokens, leaving the naked artifact id 
>> in the list.
>> +                    avceTokenList =
>> +                        new LinkedList( avceTokenList.subList( 0, 
>> avceTokenList.size() - tokensIterated ) );
>> +                }
>> +
>> +                StringBuffer artifactIdBuffer = new StringBuffer();
>>  
>> -                        classifierBuffer.setLength( 0 );
>> +                firstToken = true;
>> +                for ( Iterator it = avceTokenList.iterator(); 
>> it.hasNext(); )
>> +                {
>> +                    String token = (String) it.next();
>> +
>> +                    if ( firstToken )
>> +                    {
>> +                        firstToken = false;
>>                      }
>>                      else
>>                      {
>> -                        // if everything is kosher, then pop off all 
>> the classifier and
>> -                        // version tokens, leaving the naked 
>> artifact id in the list.
>> -                        avceTokenList =
>> -                            new LinkedList( avceTokenList.subList( 
>> 0, avceTokenList.size() - tokensIterated ) );
>> +                        artifactIdBuffer.append( '-' );
>>                      }
>>  
>> -                    StringBuffer artifactIdBuffer = new StringBuffer();
>> -
>> -                    firstToken = true;
>> -                    for ( Iterator it = avceTokenList.iterator(); 
>> it.hasNext(); )
>> -                    {
>> -                        String token = (String) it.next();
>> +                    artifactIdBuffer.append( token );
>> +                }
>>  
>> -                        if ( firstToken )
>> -                        {
>> -                            firstToken = false;
>> -                        }
>> -                        else
>> -                        {
>> -                            artifactIdBuffer.append( '-' );
>> -                        }
>> +                String artifactId = artifactIdBuffer.toString();
>>  
>> -                        artifactIdBuffer.append( token );
>> +                if ( artifactId.length() > 0 )
>> +                {
>> +                    int lastVersionCharIdx = versionBuffer.length() 
>> - 1;
>> +                    if ( lastVersionCharIdx > -1 && 
>> versionBuffer.charAt( lastVersionCharIdx ) == '-' )
>> +                    {
>> +                        versionBuffer.setLength( lastVersionCharIdx );
>>                      }
>>  
>> -                    String artifactId = artifactIdBuffer.toString();
>> +                    String version = versionBuffer.toString();
>>  
>> -                    if ( artifactId.length() > 0 )
>> +                    if ( version.length() > 0 )
>>                      {
>> -                        int lastVersionCharIdx = 
>> versionBuffer.length() - 1;
>> -                        if ( lastVersionCharIdx > -1 && 
>> versionBuffer.charAt( lastVersionCharIdx ) == '-' )
>> +                        if ( classifierBuffer.length() > 0 )
>>                          {
>> -                            versionBuffer.setLength( 
>> lastVersionCharIdx );
>> +                            result = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
>> version,
>> +                                                                                   
>> type,
>> +                                                                                   
>> classifierBuffer.toString() );
>>                          }
>> -
>> -                        String version = versionBuffer.toString();
>> -
>> -                        if ( version.length() >= 1 )
>> +                        else
>>                          {
>> -                            if ( classifierBuffer.length() > 0 )
>> -                            {
>> -                                result = 
>> artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
>> version,
>> -                                                                                       
>> type,
>> -                                                                                       
>> classifierBuffer.toString() );
>> -                            }
>> -                            else
>> -                            {
>> -                                result = 
>> artifactFactory.createArtifact( groupId, artifactId, version,
>> -                                                                         
>> Artifact.SCOPE_RUNTIME, type );
>> -                            }
>> +                            result = artifactFactory.createArtifact( 
>> groupId, artifactId, version,
>> +                                                                     
>> Artifact.SCOPE_RUNTIME, type );
>>                          }
>>                      }
>> +                    else
>> +                    {
>> +                        throw new DiscovererException( "Path 
>> filename version is empty" );
>> +                    }
>> +                }
>> +                else
>> +                {
>> +                    throw new DiscovererException( "Path filename 
>> artifactId is empty" );
>>                  }
>>              }
>> +            else
>> +            {
>> +                throw new DiscovererException( "Path artifact type 
>> does not corresspond to an artifact type" );
>> +            }
>> +        }
>> +        else
>> +        {
>> +            throw new DiscovererException( "Path does not match a 
>> legacy repository path for an artifact" );
>>          }
>>  
>>          return result;
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -17,13 +17,13 @@
>>   */
>>  
>>  import java.io.File;
>> -import java.util.Iterator;
>>  import java.util.List;
>>  
>>  /**
>>   * Interface for discovering metadata files.
>>   */
>>  public interface MetadataDiscoverer
>> +    extends Discoverer
>>  {
>>      String ROLE = MetadataDiscoverer.class.getName();
>>  
>> @@ -34,18 +34,4 @@
>>       * @param blacklistedPatterns Patterns that are to be excluded 
>> from the discovery process.
>>       */
>>      List discoverMetadata( File repositoryBase, String 
>> blacklistedPatterns );
>> -
>> -    /**
>> -     * Get the list of paths kicked out during the discovery process.
>> -     *
>> -     * @return the paths as Strings.
>> -     */
>> -    Iterator getKickedOutPathsIterator();
>> -
>> -    /**
>> -     * Get the list of paths excluded during the discovery process.
>> -     *
>> -     * @return the paths as Strings.
>> -     */
>> -    Iterator getExcludedPathsIterator();
>>  }
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -565,7 +565,14 @@
>>  
>>      private Artifact getArtifactFromPath( String path )
>>      {
>> -        return discoverer.buildArtifact( path );
>> +        try
>> +        {
>> +            return discoverer.buildArtifact( path );
>> +        }
>> +        catch ( DiscovererException e )
>> +        {
>> +            return null;
>> +        }
>>      }
>>  
>>      private Artifact createArtifact( String groupId, String 
>> artifactId, String version )
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -406,7 +406,14 @@
>>  
>>      private Artifact getArtifactFromPath( String path )
>>      {
>> -        return discoverer.buildArtifact( path );
>> +        try
>> +        {
>> +            return discoverer.buildArtifact( path );
>> +        }
>> +        catch ( DiscovererException e )
>> +        {
>> +            return null;
>> +        }
>>      }
>>  
>>      private Artifact createArtifact( String groupId, String 
>> artifactId, String version )
>>
>> Modified: 
>> maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java?rev=413818&r1=413817&r2=413818&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java 
>> (original)
>> +++ 
>> maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java 
>> Mon Jun 12 23:53:38 2006
>> @@ -24,6 +24,7 @@
>>  import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
>>  import 
>> org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
>>  import org.apache.maven.repository.discovery.ArtifactDiscoverer;
>> +import org.apache.maven.repository.discovery.DiscovererException;
>>  import 
>> org.apache.maven.repository.proxy.configuration.ProxyConfiguration;
>>  import org.apache.maven.repository.proxy.repository.ProxyRepository;
>>  import org.apache.maven.wagon.ConnectionException;
>> @@ -150,11 +151,26 @@
>>          }
>>          else
>>          {
>> -            Artifact artifact = 
>> defaultArtifactDiscoverer.buildArtifact( path );
>> +            Artifact artifact = null;
>> +            try
>> +            {
>> +                artifact = defaultArtifactDiscoverer.buildArtifact( 
>> path );
>> +            }
>> +            catch ( DiscovererException e )
>> +            {
>> +                getLogger().debug( "Failed to build artifact using 
>> default layout with message: " + e.getMessage() );
>> +            }
>>  
>>              if ( artifact == null )
>>              {
>> -                artifact = legacyArtifactDiscoverer.buildArtifact( 
>> path );
>> +                try
>> +                {
>> +                    artifact = 
>> legacyArtifactDiscoverer.buildArtifact( path );
>> +                }
>> +                catch ( DiscovererException e )
>> +                {
>> +                    getLogger().debug( "Failed to build artifact 
>> using legacy layout with message: " + e.getMessage() );
>> +                }
>>              }
>>  
>>              if ( artifact != null )
>>
>>
>
>

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