You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/01/08 03:31:13 UTC

svn commit: r732592 [1/2] - in /maven/mercury/trunk: mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/ mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/re...

Author: ogusakov
Date: Wed Jan  7 18:31:13 2009
New Revision: 732592

URL: http://svn.apache.org/viewvc?rev=732592&view=rev
Log:
[MERCURY-72] fixed swallowed exception in virtual repository, minor massage to remove unused methods, streamline creation of artifact metadata

Modified:
    maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java
    maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactMetadata.java
    maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
    maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml
    maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
    maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryM2.java
    maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Util.java

Modified: maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java?rev=732592&r1=732591&r2=732592&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java (original)
+++ maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java Wed Jan  7 18:31:13 2009
@@ -141,12 +141,12 @@
    * empty string to specify missing component - for instance query for common-1.3.zip
    * can be specified as ":common:1.3::zip" - note missing groupId and classifier. 
    */
-  public ArtifactBasicMetadata( String query )
+  public ArtifactBasicMetadata( String gavQuery )
   {
-    if( query == null )
+    if( gavQuery == null )
       return;
     
-    String [] tokens = query.split(":");
+    String [] tokens = gavQuery.split(":");
     
     if( tokens == null || tokens.length < 1 )
       return;
@@ -322,6 +322,11 @@
   {
     this.type = type;
   }
+  
+  public Map<String, String> getAttributes()
+  {
+      return attributes;
+  }
 
   public String getScope()
   {

Modified: maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactMetadata.java?rev=732592&r1=732591&r2=732592&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactMetadata.java (original)
+++ maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactMetadata.java Wed Jan  7 18:31:13 2009
@@ -19,6 +19,7 @@
 package org.apache.maven.mercury.artifact;
 
 import java.util.List;
+import java.util.Map;
 
 
 
@@ -64,68 +65,19 @@
     {
     }
     //------------------------------------------------------------------
-    /**
-     * group:artifact:version:classifier:packaging
-     */
-    public ArtifactMetadata( String name )
-    {
-      if( name == null )
-        return;
-      
-      String [] tokens = name.split(":");
-      
-      if( tokens == null || tokens.length < 1 )
-        return;
- 
-      int count = tokens.length;
-      
-    this.groupId = nullify( tokens[0] );
-
-    if( count > 1 )
-      this.artifactId = nullify( tokens[1] );
-    
-    if( count > 2 )
-      this.version = nullify( tokens[2] );
-    
-    if( count > 3 )
-      this.classifier = nullify( tokens[3] );
-    
-    if( count > 4 )
-      this.type = nullify( tokens[4] );
-    }
-    private static final String nullify( String s )
-    {
-      if( s == null || s.length() < 1 )
-        return null;
-      return s;
-    }
-    public ArtifactMetadata( String groupId, String name, String version )
-    {
-        this( groupId, name, version, null );
-    }
-
-    public ArtifactMetadata( String groupId, String name, String version, String type )
-    {
-        this( groupId, name, version, type, null );
-    }
 
-    public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope )
-    {
-        this( groupId, name, version, type, artifactScope, null );
-    }
-
-    public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, String classifier )
-    {
-        this( groupId, name, version, type, artifactScope, classifier, null );
-    }
-
-    public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, String classifier, String artifactUri )
-    {
-        this( groupId, name, version, type, artifactScope, classifier, artifactUri, null, true, null );
-    }
-
-    public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, String classifier, String artifactUri, String why, boolean resolved,
-                             String error )
+    public ArtifactMetadata( String groupId
+                             , String name
+                             , String version
+                             , String type
+                             , ArtifactScopeEnum artifactScope
+                             , String classifier
+                             , String artifactUri
+                             , String why
+                             , boolean resolved
+                             , String error
+                             , Map<String, String> attributes
+                             )
     {
         this.groupId = groupId;
         this.artifactId = name;
@@ -137,20 +89,21 @@
         this.why = why;
         this.resolved = resolved;
         this.error = error;
+        this.attributes = attributes;
     }
 
     public ArtifactMetadata( ArtifactBasicMetadata bmd )
     {
-      this( bmd.getGroupId(), bmd.getArtifactId(), bmd.getVersion(), bmd.getType(), null, bmd.getClassifier() );
+      this( bmd.getGroupId(), bmd.getArtifactId(), bmd.getVersion(), bmd.getType(), null, bmd.getClassifier(), null, null, true, null, bmd.getAttributes() );
     }
 
-    public ArtifactMetadata( String groupId, String name, String version, String type, String scopeString, String classifier, String artifactUri, String why, boolean resolved, String error )
+    public ArtifactMetadata( Artifact af )
     {
-        this( groupId, name, version, type, scopeString == null ? ArtifactScopeEnum.DEFAULT_SCOPE : ArtifactScopeEnum.valueOf( scopeString ), classifier, artifactUri, why, resolved, error );
     }
 
-    public ArtifactMetadata( Artifact af )
+    public ArtifactMetadata( String gav )
     {
+        this( new ArtifactBasicMetadata(gav) );
     }
 
     public boolean isResolved()

Modified: maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java?rev=732592&r1=732591&r2=732592&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java (original)
+++ maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java Wed Jan  7 18:31:13 2009
@@ -216,8 +216,8 @@
     VirtualRepositoryReader vr = new VirtualRepositoryReader( repos );
     
     ArtifactResults ar = vr.readArtifacts( artifacts );
-    if( ar.hasExceptions() )
-      throw new RepositoryException( ar.getExceptions().toString() );
+    if( ar == null || ar.hasExceptions() )
+      throw new RepositoryException( ar == null ? "null result" : ar.getExceptions().toString() );
     
     if( !ar.hasResults() )
       return null;

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java?rev=732592&r1=732591&r2=732592&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java Wed Jan  7 18:31:13 2009
@@ -22,53 +22,65 @@
 import java.util.Map;
 
 import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+
 /**
  * generic repository operation result. Represents a Map of query object to AbstractRepositoryOperationResult
- *
+ * 
  * @author Oleg Gusakov
  * @version $Id$
- *
  */
 public abstract class AbstractRepOpResult
 {
-  private Map<ArtifactBasicMetadata,Exception> _exceptions;
-  
-  public AbstractRepOpResult()
-  {
-  }
-  
-  public Map<ArtifactBasicMetadata,Exception> getExceptions()
-  {
-      return _exceptions;
-  }
-  
-  public abstract boolean hasResults();
-  
-  public abstract boolean hasResults( ArtifactBasicMetadata key );
-  
-  public boolean hasExceptions()
-  {
-    return _exceptions != null && ! _exceptions.isEmpty();
-  }
-  
-  public void addError( ArtifactBasicMetadata key, Exception error )
-  {
-    if( _exceptions == null )
-      _exceptions = new HashMap<ArtifactBasicMetadata, Exception>(8);
-
-    _exceptions.put( key, error );
-  }
-  
-  public Exception getError( ArtifactBasicMetadata key )
-  {
-    if( _exceptions == null )
-      return null;
-
-    return _exceptions.get( key );
-  }
-
-  public String toString()
-  {
-      return _exceptions.toString();
-  }
+    private Map<ArtifactBasicMetadata, Exception> _exceptions;
+
+    public AbstractRepOpResult()
+    {
+    }
+
+    public Map<ArtifactBasicMetadata, Exception> getExceptions()
+    {
+        return _exceptions;
+    }
+
+    public abstract boolean hasResults();
+
+    public abstract boolean hasResults( ArtifactBasicMetadata key );
+
+    public boolean hasExceptions()
+    {
+        return _exceptions != null && !_exceptions.isEmpty();
+    }
+
+    public void addError( ArtifactBasicMetadata key, Exception error )
+    {
+        if ( _exceptions == null )
+            _exceptions = new HashMap<ArtifactBasicMetadata, Exception>( 8 );
+
+        _exceptions.put( key, error );
+    }
+
+    public void addError( ArtifactResults res )
+    {
+        if ( res == null || !res.hasExceptions() )
+            return;
+
+        if ( _exceptions == null )
+            _exceptions = new HashMap<ArtifactBasicMetadata, Exception>( 8 );
+        
+        for( ArtifactBasicMetadata bmd : res.getExceptions().keySet() )
+           _exceptions.put( bmd, res.getError( bmd ) );
+    }
+
+    public Exception getError( ArtifactBasicMetadata key )
+    {
+        if ( _exceptions == null )
+            return null;
+
+        return _exceptions.get( key );
+    }
+
+    public String toString()
+    {
+        return _exceptions.toString();
+    }
 }

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml?rev=732592&r1=732591&r2=732592&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml Wed Jan  7 18:31:13 2009
@@ -31,6 +31,35 @@
 
   <name>Mercury Repository FS Cache</name>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
+        <!--
+        <version>1.0-alpha-17</version>
+        -->
+        <configuration>
+          <version>1.0.0</version>
+          <models>
+            <model>src/main/mdo/cached-metadata.mdo</model>
+          </models>
+        </configuration>
+        <executions>
+          <execution>
+            <id>standard</id>
+            <goals>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+              <goal>xpp3-writer</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  
+
   <dependencies>
     <dependency>
       <groupId>org.apache.maven.mercury</groupId>

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java?rev=732592&r1=732591&r2=732592&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java Wed Jan  7 18:31:13 2009
@@ -57,548 +57,580 @@
 import org.codehaus.plexus.lang.Language;
 
 public class LocalRepositoryReaderM2
-extends AbstracRepositoryReader
-implements RepositoryReader, MetadataReader
+    extends AbstracRepositoryReader
+    implements RepositoryReader, MetadataReader
 {
-  private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( LocalRepositoryReaderM2.class ); 
-  private static final Language LANG = new DefaultLanguage( LocalRepositoryReaderM2.class );
-  //---------------------------------------------------------------------------------------------------------------
-  private static final String [] _protocols = new String [] { "file" };
-  
-  LocalRepository _repo;
-  File _repoDir;
-  //---------------------------------------------------------------------------------------------------------------
-  public LocalRepositoryReaderM2( LocalRepository repo, DependencyProcessor mdProcessor )
-  {
-    if( repo == null )
-      throw new IllegalArgumentException("localRepo cannot be null");
-    
-    _repoDir = repo.getDirectory();
-    if( _repoDir == null )
-      throw new IllegalArgumentException("localRepo directory cannot be null");
-    
-    if( !_repoDir.exists() )
-      throw new IllegalArgumentException("localRepo directory \""+_repoDir.getAbsolutePath()+"\" should exist");
-
-    _repo = repo;
-    
-    if( mdProcessor == null )
-      throw new IllegalArgumentException("MetadataProcessor cannot be null ");
-    
-    setDependencyProcessor(  mdProcessor );
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public Repository getRepository()
-  {
-    return _repo;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  private static ArtifactLocation calculateLocation( String root, ArtifactBasicMetadata bmd, AbstractRepOpResult res )
-  {
-    ArtifactLocation loc = new ArtifactLocation( root, bmd );
-
-    File   gaDir = new File( root, loc.getGaPath() );
-    
-    if( !gaDir.exists() )
-    {
-      res.addError( bmd, new RepositoryException( LANG.getMessage( "ga.not.found", bmd.toString(), loc.getGaPath() ) ) );
-      return null;
-    }
-    
-    Quality vq = new Quality( loc.getVersion() );
-    
-    // RELEASE = LATEST - SNAPSHOTs
-    if( Artifact.RELEASE_VERSION.equals( loc.getVersion() )
-        ||
-        Artifact.LATEST_VERSION.equals( loc.getVersion() ) 
-      )
-    {
-      boolean noSnapshots = Artifact.RELEASE_VERSION.equals( loc.getVersion() );
-      loc.setVersion( null );
-      DefaultArtifactVersion tempDav = null;
-      DefaultArtifactVersion tempDav2 = null;
-
-      File [] files = gaDir.listFiles();
-
-      // find latest
-      for( File vf : files )
-      {
-        if( vf.isFile() )
-          continue;
-        
-        String vn = vf.getName();
-        
-        // RELEASE?
-        if( noSnapshots && vn.endsWith( Artifact.SNAPSHOT_VERSION ))
-          continue;
-        
-        if( loc.getVersion() == null )
-        {
-          loc.setVersion( vn );
-          tempDav = new DefaultArtifactVersion( vn );
-          continue;
-        }
-        
-        tempDav2 = new DefaultArtifactVersion( vn );
-        if( tempDav2.compareTo( tempDav ) > 0 )
-        {
-          loc.setVersion( vn );
-          tempDav = tempDav2;
-        }
-        
-      }
-
-      if( loc.getVersion() == null )
-      {
-        res.addError( bmd, new RepositoryException( LANG.getMessage( "gav.not.found", bmd.toString(), loc.getGaPath() ) ) );
-        return null;
-      }
-      
-      // LATEST is a SNAPSHOT :(
-      if( loc.getVersion().endsWith( Artifact.SNAPSHOT_VERSION ) )
-      {
-        loc.setVersionDir( loc.getVersion() );
-
-        if( !findLatestSnapshot( bmd, loc, res ) )
-          return null;
-      }
-      else
-        // R or L found and actual captured in loc.version
-        loc.setVersionDir( loc.getVersion() );
-    }
-    // regular snapshot requested
-    else if( loc.getVersion().endsWith( Artifact.SNAPSHOT_VERSION ) )
-    {
-      File gavDir = new File( gaDir, loc.getVersion() );
-      if( !gavDir.exists() )
-      {
-        res.addError( bmd, new RepositoryException( LANG.getMessage( "gavdir.not.found", bmd.toString(), gavDir.getAbsolutePath() ) ) );
-        return null;
-      }
-      
-      if( !findLatestSnapshot( bmd, loc, res ) )
-        return null;
-        
-    }
-    // time stamped snapshot requested
-    else if( vq.equals( Quality.SNAPSHOT_TS_QUALITY ))
-    {
-      loc.setVersionDir( loc.getBaseVersion()+FileUtil.DASH+Artifact.SNAPSHOT_VERSION );
-    }
-    
-    return loc;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public ArtifactResults readArtifacts( Collection<ArtifactBasicMetadata> query )
-      throws RepositoryException,
-      IllegalArgumentException
-  {
-    if( query == null || query.isEmpty() )
-      throw new IllegalArgumentException( LANG.getMessage( "empty.query", query==null?"null":"empty" ) );
-    
-    ArtifactResults res = new ArtifactResults();
-    
-    Set<StreamVerifierFactory> vFacs = null;
-    
-    if( _repo.hasServer() && _repo.getServer().hasReaderStreamVerifierFactories() )
-      vFacs = _repo.getServer().getReaderStreamVerifierFactories();
-    
-    for( ArtifactBasicMetadata bmd : query )
-    {
-      DefaultArtifact da = bmd instanceof DefaultArtifact ? (DefaultArtifact)bmd : new DefaultArtifact( bmd );
-      
-      ArtifactLocation loc = calculateLocation( _repoDir.getAbsolutePath(), bmd, res );
-      
-      if( loc == null )
-        continue;
-      
-      File binary = new File( loc.getAbsPath() );
-      
-      // binary calculated 
-      if( ! binary.exists() )
-      {
-        res.addError( bmd, new RepositoryException( LANG.getMessage( "binary.not.found", bmd.toString(), binary.getAbsolutePath() ) ) );
-        continue;
-      }
-
-      try // reading pom if one exists
-      {
-        if( checkFile( binary, vFacs ) )
-        {
-          da.setFile( binary );
-          da.setTracker( this._repo );
-        }
-        
-
-        if( "pom".equals( bmd.getType() ) ) 
-        {
-            da.setPomBlob( FileUtil.readRawData( binary ) );
-        }
-        else
-        {
-          File pomFile = new File( loc.getAbsPomPath() );
-          if( pomFile.exists() )
-          {
-            if( checkFile( pomFile, vFacs ) )
-              da.setPomBlob( FileUtil.readRawData( pomFile ) );
-          }
-          else
-            LOG.warn( LANG.getMessage( "pom.not.found", bmd.toString()) );
-        }
-
-        da.setVersion( loc.getVersion() );
-        res.add( bmd, da );
-      }
-      catch( Exception e )
-      {
-        throw new RepositoryException( e );
-      }
-    }
-    return res;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  private static boolean checkFile( File f, Set<StreamVerifierFactory> vFacs )
-  throws RepositoryException, StreamVerifierException
-  {
-    if( vFacs != null )
-    {
-      String fileName = f.getAbsolutePath();
-      
-      HashSet<StreamVerifier> vs = new HashSet<StreamVerifier>( vFacs.size() );
-      
-      for( StreamVerifierFactory svf : vFacs )
-      {
-        StreamVerifier sv = svf.newInstance();
-        String ext = sv.getAttributes().getExtension();
-        String sigFileName = fileName+(ext.startsWith( "." )?"":".")+ext;
-        File sigFile = new File( sigFileName );
-        if( sigFile.exists() )
-        {
-          try
-          {
-            sv.initSignature( FileUtil.readRawDataAsString( sigFile ) );
-          }
-          catch( IOException e )
-          {
-            throw new RepositoryException( LANG.getMessage( "cannot.read.signature.file", sigFileName, e.getMessage() ) );
-          }
-          vs.add( sv );
-        }
-        else if( ! sv.getAttributes().isLenient() )
-        {
-          throw new RepositoryException( LANG.getMessage( "no.signature.file", ext, sigFileName ) );
-        }
-        // otherwise ignore absence of signature file, if verifier is lenient
-      }
-
-      FileInputStream fin = null;
-      try
-      {
-        fin = new FileInputStream( f );
-        byte [] buf = new byte[ 1024 ];
-        int n = -1;
-        while( (n = fin.read( buf )) != -1 )
+    private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( LocalRepositoryReaderM2.class );
+
+    private static final Language LANG = new DefaultLanguage( LocalRepositoryReaderM2.class );
+
+    // ---------------------------------------------------------------------------------------------------------------
+    private static final String[] _protocols = new String[] { "file" };
+
+    LocalRepository _repo;
+
+    File _repoDir;
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public LocalRepositoryReaderM2( LocalRepository repo, DependencyProcessor mdProcessor )
+    {
+        if ( repo == null )
+            throw new IllegalArgumentException( "localRepo cannot be null" );
+
+        _repoDir = repo.getDirectory();
+        if ( _repoDir == null )
+            throw new IllegalArgumentException( "localRepo directory cannot be null" );
+
+        if ( !_repoDir.exists() )
+            throw new IllegalArgumentException( "localRepo directory \"" + _repoDir.getAbsolutePath()
+                + "\" should exist" );
+
+        _repo = repo;
+
+        if ( mdProcessor == null )
+            throw new IllegalArgumentException( "MetadataProcessor cannot be null " );
+
+        setDependencyProcessor( mdProcessor );
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public Repository getRepository()
+    {
+        return _repo;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    private static ArtifactLocation calculateLocation( String root, ArtifactBasicMetadata bmd, AbstractRepOpResult res )
+    {
+        ArtifactLocation loc = new ArtifactLocation( root, bmd );
+
+        File gaDir = new File( root, loc.getGaPath() );
+
+        if ( !gaDir.exists() )
+        {
+            if ( LOG.isWarnEnabled() )
+                LOG.warn( LANG.getMessage( "ga.not.found", bmd.toString(), loc.getGaPath() ) );
+            return null;
+        }
+
+        Quality vq = new Quality( loc.getVersion() );
+
+        // RELEASE = LATEST - SNAPSHOTs
+        if ( Artifact.RELEASE_VERSION.equals( loc.getVersion() ) || Artifact.LATEST_VERSION.equals( loc.getVersion() ) )
         {
-          for( StreamVerifier sv : vs )
+            boolean noSnapshots = Artifact.RELEASE_VERSION.equals( loc.getVersion() );
+            loc.setVersion( null );
+            DefaultArtifactVersion tempDav = null;
+            DefaultArtifactVersion tempDav2 = null;
+
+            File[] files = gaDir.listFiles();
+
+            // find latest
+            for ( File vf : files )
+            {
+                if ( vf.isFile() )
+                    continue;
+
+                String vn = vf.getName();
+
+                // RELEASE?
+                if ( noSnapshots && vn.endsWith( Artifact.SNAPSHOT_VERSION ) )
+                    continue;
+
+                if ( loc.getVersion() == null )
+                {
+                    loc.setVersion( vn );
+                    tempDav = new DefaultArtifactVersion( vn );
+                    continue;
+                }
+
+                tempDav2 = new DefaultArtifactVersion( vn );
+                if ( tempDav2.compareTo( tempDav ) > 0 )
+                {
+                    loc.setVersion( vn );
+                    tempDav = tempDav2;
+                }
+
+            }
+
+            if ( loc.getVersion() == null )
+            {
+                res.addError( bmd, new RepositoryException( LANG.getMessage( "gav.not.found", bmd.toString(),
+                                                                             loc.getGaPath() ) ) );
+                return null;
+            }
+
+            // LATEST is a SNAPSHOT :(
+            if ( loc.getVersion().endsWith( Artifact.SNAPSHOT_VERSION ) )
+            {
+                loc.setVersionDir( loc.getVersion() );
+
+                if ( !findLatestSnapshot( bmd, loc, res ) )
+                    return null;
+            }
+            else
+                // R or L found and actual captured in loc.version
+                loc.setVersionDir( loc.getVersion() );
+        }
+        // regular snapshot requested
+        else if ( loc.getVersion().endsWith( Artifact.SNAPSHOT_VERSION ) )
+        {
+            File gavDir = new File( gaDir, loc.getVersion() );
+            if ( !gavDir.exists() )
+            {
+                res.addError( bmd, new RepositoryException( LANG.getMessage( "gavdir.not.found", bmd.toString(),
+                                                                             gavDir.getAbsolutePath() ) ) );
+                return null;
+            }
+
+            if ( !findLatestSnapshot( bmd, loc, res ) )
+                return null;
+
+        }
+        // time stamped snapshot requested
+        else if ( vq.equals( Quality.SNAPSHOT_TS_QUALITY ) )
+        {
+            loc.setVersionDir( loc.getBaseVersion() + FileUtil.DASH + Artifact.SNAPSHOT_VERSION );
+        }
+
+        return loc;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public ArtifactResults readArtifacts( Collection<ArtifactBasicMetadata> query )
+        throws RepositoryException, IllegalArgumentException
+    {
+        if ( query == null || query.isEmpty() )
+            throw new IllegalArgumentException( LANG.getMessage( "empty.query", query == null ? "null" : "empty" ) );
+
+        ArtifactResults res = new ArtifactResults();
+
+        Set<StreamVerifierFactory> vFacs = null;
+
+        if ( _repo.hasServer() && _repo.getServer().hasReaderStreamVerifierFactories() )
+            vFacs = _repo.getServer().getReaderStreamVerifierFactories();
+
+        for ( ArtifactBasicMetadata bmd : query )
+        {
+            DefaultArtifact da = bmd instanceof DefaultArtifact ? (DefaultArtifact) bmd : new DefaultArtifact( bmd );
+
+            ArtifactLocation loc = calculateLocation( _repoDir.getAbsolutePath(), bmd, res );
+
+            if ( loc == null )
+                continue;
+
+            File binary = new File( loc.getAbsPath() );
+
+            // binary calculated
+            if ( !binary.exists() )
+            {
+                res.addError( bmd, new RepositoryException( LANG.getMessage( "binary.not.found", bmd.toString(),
+                                                                             binary.getAbsolutePath() ) ) );
+                continue;
+            }
+
+            try
+            // reading pom if one exists
+            {
+                if ( checkFile( binary, vFacs ) )
+                {
+                    da.setFile( binary );
+                    da.setTracker( this._repo );
+                }
+
+                if ( "pom".equals( bmd.getType() ) )
+                {
+                    da.setPomBlob( FileUtil.readRawData( binary ) );
+                }
+                else
+                {
+                    File pomFile = new File( loc.getAbsPomPath() );
+                    if ( pomFile.exists() )
+                    {
+                        if ( checkFile( pomFile, vFacs ) )
+                            da.setPomBlob( FileUtil.readRawData( pomFile ) );
+                    }
+                    else
+                        LOG.warn( LANG.getMessage( "pom.not.found", bmd.toString() ) );
+                }
+
+                da.setVersion( loc.getVersion() );
+                res.add( bmd, da );
+            }
+            catch ( Exception e )
+            {
+                throw new RepositoryException( e );
+            }
+        }
+        return res;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    private static boolean checkFile( File f, Set<StreamVerifierFactory> vFacs )
+        throws RepositoryException, StreamVerifierException
+    {
+        if ( vFacs != null )
+        {
+            String fileName = f.getAbsolutePath();
+
+            HashSet<StreamVerifier> vs = new HashSet<StreamVerifier>( vFacs.size() );
+
+            for ( StreamVerifierFactory svf : vFacs )
+            {
+                StreamVerifier sv = svf.newInstance();
+                String ext = sv.getAttributes().getExtension();
+                String sigFileName = fileName + ( ext.startsWith( "." ) ? "" : "." ) + ext;
+                File sigFile = new File( sigFileName );
+                if ( sigFile.exists() )
+                {
+                    try
+                    {
+                        sv.initSignature( FileUtil.readRawDataAsString( sigFile ) );
+                    }
+                    catch ( IOException e )
+                    {
+                        throw new RepositoryException( LANG.getMessage( "cannot.read.signature.file", sigFileName,
+                                                                        e.getMessage() ) );
+                    }
+                    vs.add( sv );
+                }
+                else if ( !sv.getAttributes().isLenient() )
+                {
+                    throw new RepositoryException( LANG.getMessage( "no.signature.file", ext, sigFileName ) );
+                }
+                // otherwise ignore absence of signature file, if verifier is lenient
+            }
+
+            FileInputStream fin = null;
             try
             {
-              sv.bytesReady( buf, 0, n );
+                fin = new FileInputStream( f );
+                byte[] buf = new byte[1024];
+                int n = -1;
+                while ( ( n = fin.read( buf ) ) != -1 )
+                {
+                    for ( StreamVerifier sv : vs )
+                        try
+                        {
+                            sv.bytesReady( buf, 0, n );
+                        }
+                        catch ( StreamObserverException e )
+                        {
+                            if ( !sv.getAttributes().isLenient() )
+                                throw new RepositoryException( e );
+                        }
+                }
+
+                for ( StreamVerifier sv : vs )
+                {
+                    if ( sv.verifySignature() )
+                    {
+                        if ( sv.getAttributes().isSufficient() )
+                            break;
+                    }
+                    else
+                    {
+                        if ( !sv.getAttributes().isLenient() )
+                            throw new RepositoryException(
+                                                           LANG.getMessage( "signature.failed",
+                                                                            sv.getAttributes().getExtension(), fileName ) );
+                    }
+                }
+            }
+            catch ( IOException e )
+            {
+                throw new RepositoryException( e );
             }
-            catch( StreamObserverException e )
+            finally
             {
-              if( ! sv.getAttributes().isLenient() )
-                throw new RepositoryException(e);
+                if ( fin != null )
+                    try
+                    {
+                        fin.close();
+                    }
+                    catch ( Exception any )
+                    {
+                    }
             }
         }
-        
-        for( StreamVerifier sv : vs )
-        {
-          if( sv.verifySignature() )
-          {
-            if( sv.getAttributes().isSufficient() )
-              break;
-          }
-          else
-          {
-            if( !sv.getAttributes().isLenient() )
-              throw new RepositoryException( LANG.getMessage( "signature.failed", sv.getAttributes().getExtension(), fileName ) );
-          }
-        }
-      }
-      catch( IOException e )
-      {
-        throw new RepositoryException(e);
-      }
-      finally
-      {
-        if( fin != null ) try { fin.close(); } catch( Exception any ) {}
-      }
-    }
-    return true;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  /**
+        return true;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    /**
    * 
    */
-  public ArtifactBasicResults readDependencies( Collection<ArtifactBasicMetadata> query )
-      throws RepositoryException,
-      IllegalArgumentException
-  {
-    if( query == null || query.size() < 1 )
-      return null;
-
-    ArtifactBasicResults ror = null;
-    
-    File pomFile = null;
-    for( ArtifactBasicMetadata bmd : query )
-    {
-      String pomPath = bmd.getGroupId().replace( '.', '/' )
-                      + "/" + bmd.getArtifactId()
-                      + "/" + bmd.getVersion()
-                      + "/" + bmd.getArtifactId()+'-'+bmd.getVersion()
-                      + ".pom"
-                      ;
-      
-      pomFile = new File( _repoDir, pomPath );
-      if( ! pomFile.exists() )
-      {
-        LOG.warn( "file \""+pomPath+"\" does not exist in local repo" );
-        continue;
-      }
-      
-      // TODO HIGH og: delegate POM processing to maven-project
-      // for testing purpose - I plug in my test processor
-      try
-      {
-        List<ArtifactBasicMetadata> deps = _mdProcessor.getDependencies( bmd, _mdReader == null ? this : _mdReader
-                                                                       , System.getenv()
-                                                                       , System.getProperties()
-                                                                       );
-//for(ArtifactBasicMetadata d : deps )
-//{
-//  System.out.println("======> "+d.getScope() );
-//}
-        ror = ArtifactBasicResults.add( ror, bmd, deps );
-      }
-      catch( Exception e )
-      {
-        LOG.warn( "error reading "+bmd.toString()+" dependencies", e );
-        continue;
-      }
-      
-    }
-    
-    return ror;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  private static boolean findLatestSnapshot( ArtifactBasicMetadata bmd, ArtifactLocation loc, AbstractRepOpResult res )
-  {
-    File binary = new File( loc.getAbsPath() );
-    
-    if( binary.exists() )
-      return true;
-
-    // no real SNAPSHOT file, let's try to find one
-    File gavDir = new File( loc.getGavPath() );
-    File [] files = gavDir.listFiles();
-    loc.setVersion( null );
-    DefaultArtifactVersion tempDav = null;
-    DefaultArtifactVersion tempDav2 = null;
-    
-    int aLen = loc.getBaseName().length();
-    
-    // find latest
-    for( File vf : files )
-    {
-      if( vf.isFile() )
-        continue;
-      
-      String vn = vf.getName().substring( aLen+1 );
-      
-      // no snapshots
-      if( vn.endsWith( Artifact.SNAPSHOT_VERSION ))
-        continue;
-
-      if( loc.getVersion() == null )
-      {
-        loc.setVersion( vn );
-        tempDav = new DefaultArtifactVersion( vn );
-        continue;
-      }
-      
-      tempDav2 = new DefaultArtifactVersion( vn );
-      if( tempDav2.compareTo( tempDav ) > 0 )
-      {
-        loc.setVersion( vn );
-        tempDav = tempDav2;
-      }
-    
-    }
-
-    if( loc.getVersion() == null )
-    {
-      res.addError( bmd, new RepositoryException( LANG.getMessage( "snapshot.not.found", bmd.toString(), gavDir.getAbsolutePath() ) ) );
-      return false;
-    }
-    
-    return true;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  /**
-   * direct disk search, no redirects - I cannot process pom files :(
-   */
-  public ArtifactBasicResults readVersions( Collection<ArtifactBasicMetadata> query )
-  throws RepositoryException, IllegalArgumentException
-  {
-    if( query == null || query.size() < 1 )
-      return null;
-    
-    ArtifactBasicResults res = new ArtifactBasicResults( query.size() );
-    
-    File gaDir = null;
-    for( ArtifactBasicMetadata bmd : query )
-    {
-      gaDir = new File( _repoDir, bmd.getGroupId().replace( '.', '/' )+"/"+bmd.getArtifactId() );
-      if( ! gaDir.exists() )
-        continue;
-      
-      File [] versionFiles = gaDir.listFiles();
-      
-      VersionRange versionQuery;
-      try
-      {
-        versionQuery = VersionRangeFactory.create( bmd.getVersion(), _repo.getVersionRangeQualityRange() );
-      }
-      catch( VersionException e )
-      {
-        res = ArtifactBasicResults.add( res, bmd, new RepositoryException(e) );
-        continue;
-      }
-      
-      Quality vq = new Quality( bmd.getVersion() );
-      
-      if(    vq.equals( Quality.FIXED_RELEASE_QUALITY ) 
-          || vq.equals( Quality.FIXED_LATEST_QUALITY )
-          || vq.equals( Quality.SNAPSHOT_QUALITY     )
-      )
-      {
-        ArtifactLocation loc = calculateLocation( _repoDir.getAbsolutePath(), bmd, res );
-        
-        if( loc == null )
-          continue;
-          
-        ArtifactBasicMetadata vmd = new ArtifactBasicMetadata();
-        vmd.setGroupId( bmd.getGroupId() );
-        vmd.setArtifactId(  bmd.getArtifactId() );
-        vmd.setClassifier( bmd.getClassifier() );
-        vmd.setType( bmd.getType() );
-        vmd.setVersion( loc.getVersion() );
-          
-        res = ArtifactBasicResults.add( res, bmd, vmd );
-        
-        continue;
-
-      }
-      
-      for( File vf : versionFiles )
-      {
-        if( !vf.isDirectory() )
-          continue;
-        
-        String version = vf.getName();
-        
-        Quality q = new Quality( version );
-        if( ! _repo.isAcceptedQuality( q ) )
-          continue;
-        
-        if( !versionQuery.includes(  vf.getName() )  )
-          continue;
-        
-        ArtifactBasicMetadata vmd = new ArtifactBasicMetadata();
-        vmd.setGroupId( bmd.getGroupId() );
-        vmd.setArtifactId(  bmd.getArtifactId() );
-        vmd.setClassifier( bmd.getClassifier() );
-        vmd.setType( bmd.getType() );
-        vmd.setVersion( vf.getName() );
-        
-        res = ArtifactBasicResults.add( res, bmd, vmd );
-      }
-    }
-    return res;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public byte[] readRawData( ArtifactBasicMetadata bmd, String classifier, String type )
-  throws MetadataReaderException
-  {
-    return readRawData( relPathOf(bmd, classifier, type, null ) );
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  private static String relPathOf( ArtifactBasicMetadata bmd, String classifier, String type, DefaultArtifactVersion inDav )
-  {
-    DefaultArtifactVersion dav = inDav;
-    if( inDav == null )
-      dav = new DefaultArtifactVersion( bmd.getVersion() );
-    Quality aq = dav.getQuality();
-    boolean isSnapshot = aq.equals( Quality.SNAPSHOT_QUALITY ) || aq.equals( Quality.SNAPSHOT_TS_QUALITY );
-    
-    String bmdPath = bmd.getGroupId().replace( '.', '/' )+'/'+bmd.getArtifactId()
-                +'/' + ( isSnapshot ? dav.getBase()+'-'+Artifact.SNAPSHOT_VERSION : bmd.getVersion() );
-    
-    String path = bmdPath+'/'+bmd.getBaseName(classifier)+'.' + (type == null ? bmd.getType() : type );
-    
-    return path ;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public byte[] readRawData( String path )
-  throws MetadataReaderException
-  {
-    File file = new File( _repoDir, path );
-    
-    if( ! file.exists() )
-      return null;
-    
-    FileInputStream fis = null;
-    
-    try
-    {
-      fis = new FileInputStream( file );
-      int len = (int)file.length();
-      byte [] pom = new byte [ len ];
-      fis.read( pom );
-      return pom;
-    }
-    catch( IOException e )
-    {
-      throw new MetadataReaderException(e);
-    }
-    finally
-    {
-      if( fis != null ) try { fis.close(); } catch( Exception any ) {}
-    }
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public String readStringData( String path )
-  throws MetadataReaderException
-  {
-    byte [] data = readRawData( path );
-    if( data == null )
-      return null;
-
-    return new String( data );
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public boolean canHandle( String protocol )
-  {
-    return AbstractRepository.DEFAULT_LOCAL_READ_PROTOCOL.equals( protocol );
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public String[] getProtocols()
-  {
-    return _protocols;
-  }
-  //---------------------------------------------------------------------------------------------------------------
-  public void close()
-  {
-  }
-  //---------------------------------------------------------------------------------------------------------------
+    public ArtifactBasicResults readDependencies( Collection<ArtifactBasicMetadata> query )
+        throws RepositoryException, IllegalArgumentException
+    {
+        if ( query == null || query.size() < 1 )
+            return null;
+
+        ArtifactBasicResults ror = null;
+
+        File pomFile = null;
+        for ( ArtifactBasicMetadata bmd : query )
+        {
+            String pomPath =
+                bmd.getGroupId().replace( '.', '/' ) + "/" + bmd.getArtifactId() + "/" + bmd.getVersion() + "/"
+                    + bmd.getArtifactId() + '-' + bmd.getVersion() + ".pom";
+
+            pomFile = new File( _repoDir, pomPath );
+            if ( !pomFile.exists() )
+            {
+                LOG.warn( "file \"" + pomPath + "\" does not exist in local repo" );
+                continue;
+            }
+
+            // TODO HIGH og: delegate POM processing to maven-project
+            // for testing purpose - I plug in my test processor
+            try
+            {
+                List<ArtifactBasicMetadata> deps =
+                    _mdProcessor.getDependencies( bmd, _mdReader == null ? this : _mdReader, System.getenv(),
+                                                  System.getProperties() );
+                // for(ArtifactBasicMetadata d : deps )
+                // {
+                // System.out.println("======> "+d.getScope() );
+                // }
+                ror = ArtifactBasicResults.add( ror, bmd, deps );
+            }
+            catch ( Exception e )
+            {
+                LOG.warn( "error reading " + bmd.toString() + " dependencies", e );
+                continue;
+            }
+
+        }
+
+        return ror;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    private static boolean findLatestSnapshot( ArtifactBasicMetadata bmd, ArtifactLocation loc, AbstractRepOpResult res )
+    {
+        File binary = new File( loc.getAbsPath() );
+
+        if ( binary.exists() )
+            return true;
+
+        // no real SNAPSHOT file, let's try to find one
+        File gavDir = new File( loc.getGavPath() );
+        File[] files = gavDir.listFiles();
+        loc.setVersion( null );
+        DefaultArtifactVersion tempDav = null;
+        DefaultArtifactVersion tempDav2 = null;
+
+        int aLen = loc.getBaseName().length();
+
+        // find latest
+        for ( File vf : files )
+        {
+            if ( vf.isFile() )
+                continue;
+
+            String vn = vf.getName().substring( aLen + 1 );
+
+            // no snapshots
+            if ( vn.endsWith( Artifact.SNAPSHOT_VERSION ) )
+                continue;
+
+            if ( loc.getVersion() == null )
+            {
+                loc.setVersion( vn );
+                tempDav = new DefaultArtifactVersion( vn );
+                continue;
+            }
+
+            tempDav2 = new DefaultArtifactVersion( vn );
+            if ( tempDav2.compareTo( tempDav ) > 0 )
+            {
+                loc.setVersion( vn );
+                tempDav = tempDav2;
+            }
+
+        }
+
+        if ( loc.getVersion() == null )
+        {
+            res.addError( bmd, new RepositoryException( LANG.getMessage( "snapshot.not.found", bmd.toString(),
+                                                                         gavDir.getAbsolutePath() ) ) );
+            return false;
+        }
+
+        return true;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    /**
+     * direct disk search, no redirects - I cannot process pom files :(
+     */
+    public ArtifactBasicResults readVersions( Collection<ArtifactBasicMetadata> query )
+        throws RepositoryException, IllegalArgumentException
+    {
+        if ( query == null || query.size() < 1 )
+            return null;
+
+        ArtifactBasicResults res = new ArtifactBasicResults( query.size() );
+
+        File gaDir = null;
+        for ( ArtifactBasicMetadata bmd : query )
+        {
+            gaDir = new File( _repoDir, bmd.getGroupId().replace( '.', '/' ) + "/" + bmd.getArtifactId() );
+            if ( !gaDir.exists() )
+                continue;
+
+            File[] versionFiles = gaDir.listFiles();
+
+            VersionRange versionQuery;
+            try
+            {
+                versionQuery = VersionRangeFactory.create( bmd.getVersion(), _repo.getVersionRangeQualityRange() );
+            }
+            catch ( VersionException e )
+            {
+                res = ArtifactBasicResults.add( res, bmd, new RepositoryException( e ) );
+                continue;
+            }
+
+            Quality vq = new Quality( bmd.getVersion() );
+
+            if ( vq.equals( Quality.FIXED_RELEASE_QUALITY ) || vq.equals( Quality.FIXED_LATEST_QUALITY )
+                || vq.equals( Quality.SNAPSHOT_QUALITY ) )
+            {
+                ArtifactLocation loc = calculateLocation( _repoDir.getAbsolutePath(), bmd, res );
+
+                if ( loc == null )
+                    continue;
+
+                ArtifactBasicMetadata vmd = new ArtifactBasicMetadata();
+                vmd.setGroupId( bmd.getGroupId() );
+                vmd.setArtifactId( bmd.getArtifactId() );
+                vmd.setClassifier( bmd.getClassifier() );
+                vmd.setType( bmd.getType() );
+                vmd.setVersion( loc.getVersion() );
+
+                res = ArtifactBasicResults.add( res, bmd, vmd );
+
+                continue;
+
+            }
+
+            for ( File vf : versionFiles )
+            {
+                if ( !vf.isDirectory() )
+                    continue;
+
+                String version = vf.getName();
+
+                Quality q = new Quality( version );
+                if ( !_repo.isAcceptedQuality( q ) )
+                    continue;
+
+                if ( !versionQuery.includes( vf.getName() ) )
+                    continue;
+
+                ArtifactBasicMetadata vmd = new ArtifactBasicMetadata();
+                vmd.setGroupId( bmd.getGroupId() );
+                vmd.setArtifactId( bmd.getArtifactId() );
+                vmd.setClassifier( bmd.getClassifier() );
+                vmd.setType( bmd.getType() );
+                vmd.setVersion( vf.getName() );
+
+                res = ArtifactBasicResults.add( res, bmd, vmd );
+            }
+        }
+        return res;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public byte[] readRawData( ArtifactBasicMetadata bmd, String classifier, String type )
+        throws MetadataReaderException
+    {
+        return readRawData( relPathOf( bmd, classifier, type, null ) );
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    private static String relPathOf( ArtifactBasicMetadata bmd, String classifier, String type,
+                                     DefaultArtifactVersion inDav )
+    {
+        DefaultArtifactVersion dav = inDav;
+        if ( inDav == null )
+            dav = new DefaultArtifactVersion( bmd.getVersion() );
+        Quality aq = dav.getQuality();
+        boolean isSnapshot = aq.equals( Quality.SNAPSHOT_QUALITY ) || aq.equals( Quality.SNAPSHOT_TS_QUALITY );
+
+        String bmdPath =
+            bmd.getGroupId().replace( '.', '/' ) + '/' + bmd.getArtifactId() + '/'
+                + ( isSnapshot ? dav.getBase() + '-' + Artifact.SNAPSHOT_VERSION : bmd.getVersion() );
+
+        String path = bmdPath + '/' + bmd.getBaseName( classifier ) + '.' + ( type == null ? bmd.getType() : type );
+
+        return path;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public byte[] readRawData( String path )
+        throws MetadataReaderException
+    {
+        File file = new File( _repoDir, path );
+
+        if ( !file.exists() )
+            return null;
+
+        FileInputStream fis = null;
+
+        try
+        {
+            fis = new FileInputStream( file );
+            int len = (int) file.length();
+            byte[] pom = new byte[len];
+            fis.read( pom );
+            return pom;
+        }
+        catch ( IOException e )
+        {
+            throw new MetadataReaderException( e );
+        }
+        finally
+        {
+            if ( fis != null )
+                try
+                {
+                    fis.close();
+                }
+                catch ( Exception any )
+                {
+                }
+        }
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public String readStringData( String path )
+        throws MetadataReaderException
+    {
+        byte[] data = readRawData( path );
+        if ( data == null )
+            return null;
+
+        return new String( data );
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public boolean canHandle( String protocol )
+    {
+        return AbstractRepository.DEFAULT_LOCAL_READ_PROTOCOL.equals( protocol );
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public String[] getProtocols()
+    {
+        return _protocols;
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+    public void close()
+    {
+    }
+    // ---------------------------------------------------------------------------------------------------------------
 }

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryM2.java?rev=732592&r1=732591&r2=732592&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryM2.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryM2.java Wed Jan  7 18:31:13 2009
@@ -35,7 +35,7 @@
 implements RemoteRepository
 {
   public static final String METADATA_FILE_NAME = "maven-metadata.xml";
-
+  
   private Server _server;
     
     /** default update policy */