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 2008/10/13 19:48:24 UTC

svn commit: r704182 - in /maven/mercury/trunk: mercury-repo/ mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/ mercury-repo/mercury-repo-cache-fs/ mercury-repo/mercury-repo-cache-fs/src/ mercury-repo/mercury-repo-cach...

Author: ogusakov
Date: Mon Oct 13 10:48:23 2008
New Revision: 704182

URL: http://svn.apache.org/viewvc?rev=704182&view=rev
Log:
added FS based metadata cache implementation

Added:
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/   (with props)
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAMetadata.java
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVMetadata.java
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedMetadata.java
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/Messages.properties
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/MetadataCacheFs.java
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/mdo/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/mdo/cached-metadata.mdo
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGATest.java
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVTest.java
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/ga-metadata.xml
    maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/gav-metadata.xml
Modified:
    maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java
    maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java
    maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryMetadataCache.java
    maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java
    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/RemoteRepositoryReaderM2.java
    maven/mercury/trunk/mercury-repo/pom.xml
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java?rev=704182&r1=704181&r2=704182&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java Mon Oct 13 10:48:23 2008
@@ -26,14 +26,18 @@
 {
   private static final Language _lang = new DefaultLanguage( RepositoryGAVMetadata.class );
   
-  ArtifactCoordinates ga;
+  protected ArtifactCoordinates ga;
 
   /** a list of last discovered versions, ordered ascending */
-  protected TreeSet<String> versions;
+  protected TreeSet<String> versions = new TreeSet<String>( new VersionComparator() );
   
   /** GMT timestamp of the last metadata check */
   protected long lastCheck;
 
+  protected RepositoryGAMetadata()
+  {
+  }
+
   /**
    * @param versions
    * @param lastCheck
@@ -41,7 +45,6 @@
   public RepositoryGAMetadata( ArtifactCoordinates ga, Collection<String> versions )
   {
     this.ga = ga;
-    this.versions = new TreeSet<String>( new VersionComparator() );
     
     if( ! Util.isEmpty( versions ) )
       this.versions.addAll( versions );
@@ -64,8 +67,6 @@
     
     this.ga = new ArtifactCoordinates( md.getGroupId(), md.getArtifactId(), md.getVersion() );
 
-    this.versions = new TreeSet<String>( new VersionComparator() );
-    
     List<String> vers = null;
     
     if( md.getVersioning() != null )

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java?rev=704182&r1=704181&r2=704182&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java Mon Oct 13 10:48:23 2008
@@ -26,16 +26,20 @@
 {
   private static final Language _lang = new DefaultLanguage( RepositoryGAVMetadata.class );
   
-  ArtifactCoordinates gav;
+  protected ArtifactCoordinates gav;
   
   /** a list of last discovered snapshots, ordered descending */
-  protected TreeSet<String> snapshots;
+  protected TreeSet<String> snapshots = new TreeSet<String>( new VersionComparator() );
 
   /** a list of last discovered versions, ordered ascending */
   protected Collection<String> classifiers;
   
   /** GMT timestamp of the last metadata check */
   protected long lastCheck;
+  
+  protected RepositoryGAVMetadata()
+  {
+  }
 
   /**
    * initialization of md object from scratch
@@ -47,8 +51,6 @@
   {
     this.gav = gav;
 
-    this.snapshots = new TreeSet<String>( new VersionComparator() );
-    
     if( !Util.isEmpty( snapshots ) )
       this.snapshots.addAll( snapshots );
     
@@ -72,8 +74,6 @@
     
     this.gav = new ArtifactCoordinates( md.getGroupId(), md.getArtifactId(), md.getVersion() );
 
-    this.snapshots = new TreeSet<String>( new VersionComparator() );
-    
     List<String> versions = null;
     
     if( md.getVersioning() != null )

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryMetadataCache.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryMetadataCache.java?rev=704182&r1=704181&r2=704182&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryMetadataCache.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/RepositoryMetadataCache.java Mon Oct 13 10:48:23 2008
@@ -1,9 +1,6 @@
 package org.apache.maven.mercury.repository.api;
 
-import java.util.Collection;
-
 import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
-import org.apache.maven.mercury.repository.metadata.Metadata;
 
 /**
  * this object abstracts the existence of multiple repositories and repository
@@ -18,26 +15,18 @@
 public interface RepositoryMetadataCache
 {
   /**
-   * initialize cache implementor with a collection of remote repositories. Order 
-   * does not matter here because access is defined by repository policy.
-   * 
-   * @param repos
-   */
-  public void init( Collection<RemoteRepository> repos );
-  
-  /**
-   * check if GA level metadata exists in this cache
+   * check if GA level metadata exists in this cache for the given repo. Read from repo, if does not exists
    * 
    * @param bmd - bare GA coordinates of the requisted metadata
    * @return 
    */
-  public RepositoryGAMetadata findGA( ArtifactBasicMetadata bmd );
+  public RepositoryGAMetadata findGA( RemoteRepository repo, ArtifactBasicMetadata bmd );
   
   /**
-   * check if GAV level metadata exists in this cache
+   * check if GAV level metadata exists in this cache for the given repo. Read from repo, if does not exists
    * 
    * @param bmd - bare GAV coordinates of the requisted metadata
    * @return 
    */
-  public RepositoryGAMetadata findGAV( ArtifactBasicMetadata bmd );
+  public RepositoryGAMetadata findGAV( RemoteRepository repo, ArtifactBasicMetadata bmd );
 }

Propchange: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Oct 13 10:48:23 2008
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project

Added: 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=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/pom.xml Mon Oct 13 10:48:23 2008
@@ -0,0 +1,45 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.mercury</groupId>
+  <parent>
+  	<groupId>org.apache.maven.mercury</groupId>
+  	<artifactId>mercury-repo</artifactId>
+  	<version>1.0.0-alpha-2-SNAPSHOT</version>
+  </parent>
+  <artifactId>mercury-repo-cache-fs</artifactId>
+  <name>Mercury Repository FS Cahe:     ${project.version}</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>
+          <model>src/main/mdo/cached-metadata.mdo</model>
+        </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>
+  		<artifactId>mercury-repo-api</artifactId>
+  		<version>${project.version}</version>
+  	</dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAMetadata.java?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAMetadata.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAMetadata.java Mon Oct 13 10:48:23 2008
@@ -0,0 +1,88 @@
+package org.apache.maven.mercury.repository.cache.fs;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.maven.mercury.artifact.ArtifactCoordinates;
+import org.apache.maven.mercury.repository.api.MetadataCorruptionException;
+import org.apache.maven.mercury.repository.api.RepositoryGAMetadata;
+import org.apache.maven.mercury.repository.metadata.MetadataException;
+import org.apache.maven.mercury.util.Util;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class CachedGAMetadata
+extends RepositoryGAMetadata
+{
+  public static final String ELEM_COORDINATES = "coordinates";
+  public static final String ATTR_GROUP_ID = "groupId";
+  public static final String ATTR_ARTIFACT_ID = "artifactId";
+  public static final String ATTR_VERSION = "version";
+
+  public static final String ELEM_VERSIONS = "versions";
+
+  CachedMetadata cm;
+  
+  public CachedGAMetadata( File mdFile )
+  throws FileNotFoundException, IOException, XmlPullParserException, MetadataCorruptionException
+  {
+    cm = new CachedMetadata( mdFile );
+    fromXml();
+  }
+  
+  public CachedGAMetadata( byte [] mdBytes )
+  throws MetadataException
+  {
+    super( mdBytes );
+    
+    cm = new CachedMetadata();
+    
+    toXml();
+  }
+  
+  /**
+   * fill GA with data from cm
+   * 
+   * @throws MetadataCorruptionException 
+   */
+  private void fromXml()
+  throws MetadataCorruptionException
+  {
+    ga = new ArtifactCoordinates( 
+                    cm.getAttribute( ELEM_COORDINATES, ATTR_GROUP_ID, true ) 
+                  , cm.getAttribute( ELEM_COORDINATES, ATTR_ARTIFACT_ID, true ) 
+                  , null 
+                                );
+    
+    List<String> verList = cm.findAttributes( ELEM_VERSIONS, ATTR_VERSION );
+    
+    if( ! Util.isEmpty( verList ) )
+      this.versions.addAll( verList );
+
+    String lChk = cm.getLastUpdate();
+
+    lastCheck = Long.parseLong( lChk );
+  }
+  
+  private void toXml()
+  {
+    cm.clean();
+    
+    cm.setAttribute( ELEM_COORDINATES, ATTR_GROUP_ID, ga.getGroupId() );
+    cm.setAttribute( ELEM_COORDINATES, ATTR_ARTIFACT_ID, ga.getArtifactId() );
+    
+    if( !Util.isEmpty( versions ) )
+      cm.setAttribute( ELEM_VERSIONS, ATTR_VERSION, versions );
+    
+    cm.setLastUpdate( ""+lastCheck );
+  }
+  
+}

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVMetadata.java?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVMetadata.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVMetadata.java Mon Oct 13 10:48:23 2008
@@ -0,0 +1,95 @@
+package org.apache.maven.mercury.repository.cache.fs;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.maven.mercury.artifact.ArtifactCoordinates;
+import org.apache.maven.mercury.repository.api.MetadataCorruptionException;
+import org.apache.maven.mercury.repository.api.RepositoryGAMetadata;
+import org.apache.maven.mercury.repository.api.RepositoryGAVMetadata;
+import org.apache.maven.mercury.repository.metadata.Metadata;
+import org.apache.maven.mercury.repository.metadata.MetadataException;
+import org.apache.maven.mercury.util.Util;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class CachedGAVMetadata
+extends RepositoryGAVMetadata
+{
+  public static final String ELEM_SNAPSHOTS = "snapshots";
+  public static final String ATTR_SNAPSHOT = "snapshot";
+
+  public static final String ELEM_CLASSIFIERS = "classifiers";
+  public static final String ATTR_CLASSIFIER = "classifier";
+
+  CachedMetadata cm;
+  
+  public CachedGAVMetadata( File mdFile )
+  throws FileNotFoundException, IOException, XmlPullParserException, MetadataCorruptionException
+  {
+    cm = new CachedMetadata( mdFile );
+    fromXml();
+  }
+  
+  public CachedGAVMetadata( byte [] mdBytes )
+  throws MetadataException
+  {
+    super( mdBytes );
+    
+    cm = new CachedMetadata();
+    
+    toXml();
+  }
+  
+  /**
+   * fill GA with data from cm
+   * 
+   * @throws MetadataCorruptionException 
+   */
+  private void fromXml()
+  throws MetadataCorruptionException
+  {
+    gav = new ArtifactCoordinates( 
+                    cm.getAttribute( CachedGAMetadata.ELEM_COORDINATES, CachedGAMetadata.ATTR_GROUP_ID, true ) 
+                  , cm.getAttribute( CachedGAMetadata.ELEM_COORDINATES, CachedGAMetadata.ATTR_ARTIFACT_ID, true ) 
+                  , cm.getAttribute( CachedGAMetadata.ELEM_COORDINATES, CachedGAMetadata.ATTR_VERSION, true ) 
+                                );
+    
+    List<String> snList = cm.findAttributes( ELEM_SNAPSHOTS, ATTR_SNAPSHOT );
+    
+    if( ! Util.isEmpty( snList ) )
+      this.snapshots.addAll( snList );
+    
+    List<String> clList = cm.findAttributes( ELEM_CLASSIFIERS, ATTR_CLASSIFIER );
+    
+    if( ! Util.isEmpty( clList ) )
+      this.classifiers.addAll( clList );
+
+    String lChk = cm.getLastUpdate();
+
+    lastCheck = Long.parseLong( lChk );
+  }
+  
+  private void toXml()
+  {
+    cm.clean();
+    
+    cm.setAttribute( CachedGAMetadata.ELEM_COORDINATES, CachedGAMetadata.ATTR_GROUP_ID, gav.getGroupId() );
+    cm.setAttribute( CachedGAMetadata.ELEM_COORDINATES, CachedGAMetadata.ATTR_ARTIFACT_ID, gav.getArtifactId() );
+    cm.setAttribute( CachedGAMetadata.ELEM_COORDINATES, CachedGAMetadata.ATTR_VERSION, gav.getVersion() );
+    
+    if( !Util.isEmpty( snapshots ) )
+      cm.setAttribute( ELEM_SNAPSHOTS, ATTR_SNAPSHOT, snapshots );
+    
+    cm.setLastUpdate( ""+lastCheck );
+  }
+  
+}

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedMetadata.java?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedMetadata.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/CachedMetadata.java Mon Oct 13 10:48:23 2008
@@ -0,0 +1,212 @@
+package org.apache.maven.mercury.repository.cache.fs;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.mercury.repository.api.MetadataCorruptionException;
+import org.apache.maven.mercury.repository.api.RepositoryGAVMetadata;
+import org.apache.maven.mercury.repository.cache.md.Attribute;
+import org.apache.maven.mercury.repository.cache.md.CachedRawMetadata;
+import org.apache.maven.mercury.repository.cache.md.Element;
+import org.apache.maven.mercury.repository.cache.md.io.xpp3.CachedMetadataXpp3Reader;
+import org.apache.maven.mercury.repository.cache.md.io.xpp3.CachedMetadataXpp3Writer;
+import org.apache.maven.mercury.util.Util;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * metadata serialization helper - saves/restores element/attribute xml.
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+class CachedMetadata
+{
+  private static final Language _lang = new DefaultLanguage( CachedMetadata.class );
+  
+  private CachedRawMetadata crm;
+  
+  private File mdFile;
+  
+  private static CachedRawMetadata readRawMetadata( File mdFile )
+  throws FileNotFoundException, IOException, XmlPullParserException
+  {
+    CachedMetadataXpp3Reader reader = new CachedMetadataXpp3Reader();
+    return reader.read( new FileReader(mdFile) );
+  }
+  
+  private static void writeRawMetadata( CachedRawMetadata cmd, File mdFile )
+  throws FileNotFoundException, IOException, XmlPullParserException
+  {
+    CachedMetadataXpp3Writer writer = new CachedMetadataXpp3Writer();
+    writer.write( new FileWriter(mdFile), cmd );
+  }
+
+  protected CachedMetadata()
+  {
+    crm = new CachedRawMetadata();
+  }
+
+  protected CachedMetadata( File mdFile )
+  throws FileNotFoundException, IOException, XmlPullParserException
+  {
+    if( mdFile.exists() )
+      crm = readRawMetadata( mdFile );
+    else
+      crm = new CachedRawMetadata();
+    
+    this.mdFile = mdFile;
+  }
+
+  public void save( File mdFile )
+  throws FileNotFoundException, IOException, XmlPullParserException
+  {
+    writeRawMetadata( crm, mdFile );
+  }
+  
+  protected Element findElement( String elem )
+  {
+    List<Element> el = crm.getElements();
+    if( Util.isEmpty( el ) )
+    {
+      el = new ArrayList<Element>();
+      crm.setElements( el );
+    }
+    
+    Element e = null;
+    
+    for( Element le : el )
+      if( le.getName().equals( elem ) )
+      {
+        e = le;
+        break;
+      }
+    
+    if( e == null )
+    {
+      e = new Element();
+      e.setName( elem );
+      el.add( e );
+    }
+    
+    return e;
+  }
+
+  protected void cleanAttribute( Element e, String attr  )
+  {
+    List<Attribute> al = e.getAttributes();
+
+    if( Util.isEmpty( al ))
+      return;
+
+    int sz = al.size();
+    
+    for( int i= (sz-1); i >= 0; i-- )
+    {
+      Attribute a = al.get( i );
+      if( a.getName().equals( attr ) )
+        al.remove( i );
+    }
+  }
+  
+  protected List<String> findAttributes( Element e, String attr  )
+  {
+    List<Attribute> al = e.getAttributes();
+
+    if( Util.isEmpty( al ))
+    {
+      al = new ArrayList<Attribute>();
+      e.setAttributes( al );
+      return null;
+    }
+    
+    List<String> a = null;
+    
+    for( Attribute la : al )
+      if( la.getName().equals( attr ) )
+      {
+        if( a == null )
+          a = new ArrayList<String>();
+        a.add( la.getValue() );
+      }
+    
+    return a;
+  }
+  
+  protected List<String> findAttributes( String elem, String attr  )
+  {
+    Element e = findElement( elem );
+    return findAttributes( e, attr );
+  }
+  
+  protected String getAttribute( String elem, String attr, boolean mandatory  )
+  throws MetadataCorruptionException
+  {
+    Element e = findElement( elem );
+    
+    List<String> a = findAttributes( e, attr );
+    
+    if( Util.isEmpty( a ) )
+      if( mandatory )
+        throw new MetadataCorruptionException(  _lang.getMessage( "no.mandatory.attribute", elem, attr ) );
+      else 
+        return null;
+    
+    return a.get( 0 );
+  }
+  
+  protected void addAttribute( Element e, String attr, String val )
+  {
+    List<Attribute> al = e.getAttributes();
+    if( al == null )
+    {
+      al = new ArrayList<Attribute>();
+      e.setAttributes( al );
+    }
+    
+    Attribute a = new Attribute();
+    a.setName( attr );
+    a.setValue( val );
+    
+    al.add( a );
+  }
+  
+  protected void setAttribute( String elem, String attr, String val)
+  {
+    Element e = findElement( elem );
+    cleanAttribute( e, attr );
+    addAttribute( e, attr, val );
+  }
+
+  protected void setAttribute( String elem, String attr, Collection<String> vals )
+  {
+    Element e = findElement( elem );
+    cleanAttribute( e, attr );
+    for( String val : vals )
+      addAttribute( e, attr, val );
+  }
+  
+  protected void setLastUpdate( String lastUpdated )
+  {
+    crm.setLastUpdated( lastUpdated );
+  }
+  
+  protected String getLastUpdate()
+  {
+    return crm.getLastUpdated();
+  }
+  
+  protected void clean()
+  {
+    crm.setElements( null );
+  }
+
+}

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/Messages.properties
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/Messages.properties?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/Messages.properties (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/Messages.properties Mon Oct 13 10:48:23 2008
@@ -0,0 +1,2 @@
+bad.root.file=bad root folder {0}
+no.mandatory.attribute=for element {0} mandatory attribute {1} is missing
\ No newline at end of file

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/MetadataCacheFs.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/MetadataCacheFs.java?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/MetadataCacheFs.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/java/org/apache/maven/mercury/repository/cache/fs/MetadataCacheFs.java Mon Oct 13 10:48:23 2008
@@ -0,0 +1,121 @@
+package org.apache.maven.mercury.repository.cache.fs;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.Artifact;
+import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+import org.apache.maven.mercury.artifact.Quality;
+import org.apache.maven.mercury.repository.api.RemoteRepository;
+import org.apache.maven.mercury.repository.api.RepositoryGAMetadata;
+import org.apache.maven.mercury.repository.api.RepositoryGAVMetadata;
+import org.apache.maven.mercury.repository.api.RepositoryMetadataCache;
+import org.apache.maven.mercury.util.FileUtil;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class MetadataCacheFs
+implements RepositoryMetadataCache
+{
+  private static final Language _lang = new DefaultLanguage( RepositoryGAVMetadata.class );
+  
+  static volatile Map<String, MetadataCacheFs> fsCaches = Collections.synchronizedMap( new HashMap<String, MetadataCacheFs>(2) ); 
+  
+  volatile HashMap<String, RepositoryGAMetadata> gaCache;
+  volatile HashMap<String, RepositoryGAVMetadata> gavCache;
+  
+  private File root;
+  
+  /**
+   * access to all known FS caches
+   * 
+   * @param root
+   * @return
+   * @throws IOException 
+   */
+  public static MetadataCacheFs getCache( File root )
+  throws IOException
+  {
+    if( root == null 
+        || ( root.exists() && root.isFile() )
+    )
+      throw new IllegalArgumentException( _lang.getMessage( "bad.root.file", root == null ? "null" : root.getAbsolutePath() ) );
+    
+    String key = root.getCanonicalPath();
+    
+    MetadataCacheFs fsc = fsCaches.get(key);
+    
+    if( fsc == null )
+    {
+      fsc = new MetadataCacheFs( root );
+      fsCaches.put( key, fsc );
+    }
+    
+    return fsc;
+  }
+
+  /**
+   * 
+   */
+  private MetadataCacheFs( File root )
+  {
+    this.root = root;
+  }
+
+  public RepositoryGAMetadata findGA( RemoteRepository repo, ArtifactBasicMetadata bmd )
+  {
+    File gam = getGADir( bmd );
+    
+    return null;
+  }
+
+  public RepositoryGAMetadata findGAV( RemoteRepository repo, ArtifactBasicMetadata bmd )
+  {
+    return null;
+  }
+  
+  private File getGADir( ArtifactBasicMetadata bmd )
+  {
+    File dir = new File( root, bmd.getGroupId()+FileUtil.SEP+bmd.getArtifactId() );
+    
+    if( ! dir.exists() )
+      dir.mkdirs();
+    
+    return dir;
+  }
+  
+  private String getGAFileName( RemoteRepository repo )
+  {
+    return "";
+  }
+
+  private File getGAVDir( ArtifactBasicMetadata bmd )
+  {
+    String version = bmd.getVersion();
+    
+    Quality q = new Quality( version );
+    
+    if( q.compareTo( Quality.SNAPSHOT_TS_QUALITY ) == 0 )
+    {
+      version = Artifact.SNAPSHOT_VERSION;
+    }
+    
+    File dir = new File( getGADir( bmd ), bmd.getArtifactId()+FileUtil.DASH+version );
+    
+    if( ! dir.exists() )
+      dir.mkdirs();
+    
+    return dir;
+  }
+  
+}

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/mdo/cached-metadata.mdo
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/mdo/cached-metadata.mdo?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/mdo/cached-metadata.mdo (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/main/mdo/cached-metadata.mdo Mon Oct 13 10:48:23 2008
@@ -0,0 +1,106 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<model>
+  <id>cached-metadata</id>
+  
+  <name>CachedMetadata</name>
+  <description>Per-directory repository metadata.</description>
+  
+  <defaults>
+    <default>
+      <key>package</key>
+      <value>org.apache.maven.mercury.repository.cache.md</value>
+    </default>
+  </defaults>
+  
+  <classes>
+
+    <class rootElement="true">
+      <name>CachedRawMetadata</name>
+      <version>1.0.0</version>
+      <fields>
+        
+        <field>
+          <name>lastUpdated</name>
+          <version>1.0.0</version>
+          <type>String</type>
+          <description>When the metadata was last updated</description>
+        </field>
+        
+        <field>
+          <name>elements</name>
+          <version>1.0.0</version>
+          <description>group of metadata elements</description>
+          <association>
+            <type>Element</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
+     </class>
+
+    <class>
+      <name>Element</name>
+      <version>1.0.0</version>
+      <description>metadata element</description>
+      <fields>
+        <field>
+          <name>name</name>
+          <version>1.0.0</version>
+          <description>name of this element</description>
+          <type>String</type>
+        </field>
+        
+        <field>
+          <name>attributes</name>
+          <version>1.0.0</version>
+          <description>group of metadata element attributes</description>
+          <association>
+            <type>Attribute</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
+    </class>
+
+    <class>
+      <name>Attribute</name>
+      <version>1.0.0</version>
+      <description>generic attribute - name/value pair</description>
+      <fields>
+        <field>
+          <name>name</name>
+          <type>String</type>
+          <required>true</required>
+          <version>1.0.0</version>
+          <description>name of this attribute</description>
+        </field>
+        <field>
+          <name>value</name>
+          <type>String</type>
+          <required>true</required>
+          <version>1.0.0</version>
+          <description>value of this attribute</description>
+        </field>
+      </fields>
+    </class>
+    
+  </classes>
+</model>

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGATest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGATest.java?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGATest.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGATest.java Mon Oct 13 10:48:23 2008
@@ -0,0 +1,71 @@
+package org.apache.maven.mercury.repository.cache.fs;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.mercury.artifact.ArtifactCoordinates;
+import org.apache.maven.mercury.repository.api.RepositoryGAMetadata;
+import org.apache.maven.mercury.repository.metadata.Metadata;
+import org.apache.maven.mercury.repository.metadata.MetadataBuilder;
+import org.apache.maven.mercury.util.FileUtil;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class CachedGATest
+    extends TestCase
+{
+  
+  byte [] mdBytes;
+  
+  CachedGAMetadata gam;
+  
+  Metadata omd;
+
+  @Override
+  protected void setUp()
+  throws Exception
+  {
+    InputStream is = CachedGATest.class.getResourceAsStream( "/ga-metadata.xml" );
+    
+    mdBytes = FileUtil.readRawData( is );
+    
+    omd = MetadataBuilder.getMetadata( mdBytes );
+    
+    gam = new CachedGAMetadata( mdBytes );
+  }
+  
+  public void testData()
+  throws Exception
+  {
+    assertEquals( omd.getGroupId(), gam.getGA().getGroupId() );
+    assertEquals( omd.getArtifactId(), gam.getGA().getArtifactId() );
+    
+    assertEquals( omd.getVersioning().getVersions().size(), gam.getVersions().size() );
+  }
+  
+  public void testRead()
+  throws Exception
+  {
+    File mf = File.createTempFile( "test-ga-", ".xml", new File("./target") );
+    gam.cm.save( mf );
+    
+    CachedGAMetadata gam2 = new CachedGAMetadata( mf );
+
+    assertEquals( omd.getGroupId(), gam2.getGA().getGroupId() );
+    assertEquals( omd.getArtifactId(), gam2.getGA().getArtifactId() );
+    
+    assertEquals( omd.getVersioning().getVersions().size(), gam2.getVersions().size() );
+  }
+  
+  
+}

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVTest.java?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVTest.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/java/org/apache/maven/mercury/repository/cache/fs/CachedGAVTest.java Mon Oct 13 10:48:23 2008
@@ -0,0 +1,72 @@
+package org.apache.maven.mercury.repository.cache.fs;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.mercury.artifact.ArtifactCoordinates;
+import org.apache.maven.mercury.repository.api.RepositoryGAMetadata;
+import org.apache.maven.mercury.repository.metadata.Metadata;
+import org.apache.maven.mercury.repository.metadata.MetadataBuilder;
+import org.apache.maven.mercury.util.FileUtil;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class CachedGAVTest
+    extends TestCase
+{
+  
+  byte [] mdBytes;
+  
+  CachedGAVMetadata gam;
+  
+  Metadata omd;
+
+  @Override
+  protected void setUp()
+  throws Exception
+  {
+    InputStream is = CachedGAVTest.class.getResourceAsStream( "/gav-metadata.xml" );
+    
+    mdBytes = FileUtil.readRawData( is );
+    
+    omd = MetadataBuilder.getMetadata( mdBytes );
+    
+    gam = new CachedGAVMetadata( mdBytes );
+  }
+  
+  public void testData()
+  throws Exception
+  {
+    assertEquals( omd.getGroupId(), gam.getGAV().getGroupId() );
+    assertEquals( omd.getArtifactId(), gam.getGAV().getArtifactId() );
+    assertEquals( omd.getVersion(), gam.getGAV().getVersion() );
+    
+    assertEquals( omd.getVersioning().getVersions().size(), gam.getSnapshots().size() );
+  }
+  
+  public void testRead()
+  throws Exception
+  {
+    File mf = File.createTempFile( "test-ga-", ".xml", new File("./target") );
+    gam.cm.save( mf );
+    
+    CachedGAVMetadata gam2 = new CachedGAVMetadata( mf );
+
+    assertEquals( omd.getGroupId(), gam2.getGAV().getGroupId() );
+    assertEquals( omd.getArtifactId(), gam2.getGAV().getArtifactId() );
+    assertEquals( omd.getVersion(), gam2.getGAV().getVersion() );
+    
+    assertEquals( omd.getVersioning().getVersions().size(), gam2.getSnapshots().size() );
+  }
+  
+}

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/ga-metadata.xml
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/ga-metadata.xml?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/ga-metadata.xml (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/ga-metadata.xml Mon Oct 13 10:48:23 2008
@@ -0,0 +1,12 @@
+<metadata>
+  <groupId>activemq</groupId>
+  <artifactId>activemq-jaas</artifactId>
+  <version>4.0-M1</version>
+  <versioning>
+    <versions>
+      <version>4.0-M1</version>
+      <version>4.0-M2</version>
+      <version>4.0-M3</version>
+    </versions>
+  </versioning>
+</metadata>
\ No newline at end of file

Added: maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/gav-metadata.xml
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/gav-metadata.xml?rev=704182&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/gav-metadata.xml (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-cache-fs/src/test/resources/gav-metadata.xml Mon Oct 13 10:48:23 2008
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.maven.mercury</groupId>
+  <artifactId>mercury-transport-http</artifactId>
+  <version>1.0.0-alpha-2-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <localCopy>true</localCopy>
+    </snapshot>
+    <lastUpdated>20081009213718</lastUpdated>
+     <versions>
+        <version>1.0.0-alpha-2-20081006.174832-2</version>
+        <version>1.0.0-alpha-2-20081006.174832-9</version>
+        <version>1.0.0-alpha-2-20081006.174840-10</version>
+        <version>1.0.0-alpha-2-20081006.174840-11</version>
+     </versions>
+  </versioning>
+</metadata>

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.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/ArtifactLocation.java?rev=704182&r1=704181&r2=704182&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java Mon Oct 13 10:48:23 2008
@@ -2,6 +2,7 @@
 
 import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
 import org.apache.maven.mercury.artifact.version.DefaultArtifactVersion;
+import org.apache.maven.mercury.util.FileUtil;
 
 /**
  * artifact relative location data object - used by repositories to hold on to intermediate path calculations 
@@ -13,10 +14,6 @@
  */
 public class ArtifactLocation
 {
-  public static final String SEP = "/";
-  public static final char   SEP_CHAR = SEP.charAt( 0 );
-  public static final String DASH = "-";
-  public static final char   DASH_CHAR = DASH.charAt( 0 );
   public static final String POM_EXT = ".pom";
 
   private String prefix;
@@ -38,7 +35,7 @@
     this.bmd = bmd;
 
     this.prefix     = prefix;
-    this.gaPath     = bmd.getGroupId().replace( '.', SEP_CHAR ) + SEP + bmd.getArtifactId();
+    this.gaPath     = bmd.getGroupId().replace( '.', FileUtil.SEP_CHAR ) + FileUtil.SEP + bmd.getArtifactId();
     this.version    = bmd.getVersion();
     this.baseName   = bmd.getArtifactId();
     this.versionDir = this.version;
@@ -48,12 +45,12 @@
   
   public String getRelPath()
   {
-    return gaPath+SEP+versionDir+SEP+baseName+DASH+version+getDashedClassifier()+'.'+type;
+    return gaPath+FileUtil.SEP+versionDir+FileUtil.SEP+baseName+FileUtil.DASH+version+getDashedClassifier()+'.'+type;
   }
   
   public String getRelPomPath()
   {
-    return gaPath+SEP+versionDir+SEP+baseName+DASH+version+POM_EXT;
+    return gaPath+FileUtil.SEP+versionDir+FileUtil.SEP+baseName+FileUtil.DASH+version+POM_EXT;
   }
   
   public String getAbsPath()
@@ -74,7 +71,7 @@
   
   public String getGavPath()
   {
-    return getGaPath()+SEP+versionDir;
+    return getGaPath()+FileUtil.SEP+versionDir;
   }
   
   public String getBaseVersion()
@@ -125,7 +122,7 @@
   }
   public String getDashedClassifier()
   {
-    return (classifier == null||classifier.length()<1) ? "" : DASH+classifier;
+    return (classifier == null||classifier.length()<1) ? "" : FileUtil.DASH+classifier;
   }
   public void setClassifier( String classifier )
   {
@@ -148,7 +145,7 @@
     if( prefix == null )
       return null;
 
-    return prefix+(prefix.endsWith( SEP ) ? "" : SEP);
+    return prefix+(prefix.endsWith( FileUtil.SEP ) ? "" : FileUtil.SEP);
   }
   public void setPrefix( String prefix )
   {

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=704182&r1=704181&r2=704182&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 Mon Oct 13 10:48:23 2008
@@ -161,7 +161,7 @@
     // time stamped snapshot requested
     else if( vq.equals( Quality.SNAPSHOT_TS_QUALITY ))
     {
-      loc.setVersionDir( loc.getBaseVersion()+loc.DASH+Artifact.SNAPSHOT_VERSION );
+      loc.setVersionDir( loc.getBaseVersion()+FileUtil.DASH+Artifact.SNAPSHOT_VERSION );
     }
     
     return loc;

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.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/RemoteRepositoryReaderM2.java?rev=704182&r1=704181&r2=704182&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java Mon Oct 13 10:48:23 2008
@@ -142,7 +142,7 @@
   {
     ArtifactLocation loc = new ArtifactLocation( root, bmd );
 
-    byte [] mdBytes = readRawData( loc.getGaPath()+loc.SEP+ _repo.getMetadataName() );
+    byte [] mdBytes = readRawData( loc.getGaPath()+FileUtil.SEP+ _repo.getMetadataName() );
     if( mdBytes == null )
       throw new RepositoryException( _lang.getMessage( "no.group.md", _repo.getServer().getURL().toString(), loc.getGaPath() ) );
       
@@ -193,7 +193,7 @@
     // time stamped snapshot requested
     else if( vq.equals( Quality.SNAPSHOT_TS_QUALITY ))
     {
-      loc.setVersionDir( loc.getBaseVersion()+loc.DASH+Artifact.SNAPSHOT_VERSION );
+      loc.setVersionDir( loc.getBaseVersion()+FileUtil.DASH+Artifact.SNAPSHOT_VERSION );
     }
     
     return loc;
@@ -380,7 +380,7 @@
       byte[] mavenMetadata;
       try
       {
-        mavenMetadata = readRawData( loc.getGaPath()+loc.SEP+_repo.getMetadataName() );
+        mavenMetadata = readRawData( loc.getGaPath()+FileUtil.SEP+_repo.getMetadataName() );
       }
       catch( MetadataReaderException e )
       {
@@ -403,7 +403,7 @@
 
       if( mmd == null || mmd.getVersioning() == null )
       {
-        _log.warn( _lang.getMessage( "maven.bad.metadata", loc.getGaPath()+loc.SEP+_repo.getMetadataName(), _repo.getId() ) );
+        _log.warn( _lang.getMessage( "maven.bad.metadata", loc.getGaPath()+FileUtil.SEP+_repo.getMetadataName(), _repo.getId() ) );
         continue;
       }
       
@@ -411,7 +411,7 @@
 
       if( mmd == null || mmd.getVersioning() == null )
       {
-        _log.warn( _lang.getMessage( "maven.metadata.no.versions", loc.getGaPath()+loc.SEP+_repo.getMetadataName(), _repo.getId() ) );
+        _log.warn( _lang.getMessage( "maven.metadata.no.versions", loc.getGaPath()+FileUtil.SEP+_repo.getMetadataName(), _repo.getId() ) );
         continue;
       }
 

Modified: maven/mercury/trunk/mercury-repo/pom.xml
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/pom.xml?rev=704182&r1=704181&r2=704182&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/pom.xml (original)
+++ maven/mercury/trunk/mercury-repo/pom.xml Mon Oct 13 10:48:23 2008
@@ -15,6 +15,7 @@
     <module>mercury-repo-api</module>
     <module>mercury-repo-local-m2</module>
     <module>mercury-repo-remote-m2</module>
+    <module>mercury-repo-cache-fs</module>
   </modules>
 
 </project>
\ No newline at end of file

Modified: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java?rev=704182&r1=704181&r2=704182&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java (original)
+++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java Mon Oct 13 10:48:23 2008
@@ -5,7 +5,6 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -50,8 +49,15 @@
  */
 public class FileUtil
 {
+  public static final String SEP = "/";
+  public static final char   SEP_CHAR = SEP.charAt( 0 );
+
+  public static final String DASH = "-";
+  public static final char   DASH_CHAR = DASH.charAt( 0 );
+
   public static final String LOCK_FILE = ".lock";
   public static final String DEFAULT_CHARSET = "utf-8";
+  
   public static final int    K = 1024;
   public static final int    DEFAULT_BUFFER_SIZE = 10 * K;
   //---------------------------------------------------------------------------------------------------------------