]> source.dussan.org Git - archiva.git/commitdiff
Adding ManagedRepositoryContent.toFile( ArchivaArtifact ) and ManagedRepositoryConten...
authorJoakim Erdfelt <joakime@apache.org>
Fri, 12 Oct 2007 17:53:59 +0000 (17:53 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Fri, 12 Oct 2007 17:53:59 +0000 (17:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@584215 13f79535-47bb-0310-9956-ffa450edef68

archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ManagedRepositoryContent.java
archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractDefaultRepositoryContent.java
archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractLegacyRepositoryContent.java
archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java
archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java

index 21a3b5fbcec859c3740c87080b267d94a8015f28..ef1ff8d805db78076f9873c75cbb7d294fb83130 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.repository;
  */
 
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.ProjectReference;
 import org.apache.maven.archiva.model.VersionedReference;
@@ -101,7 +102,7 @@ public interface ManagedRepositoryContent
     public ManagedRepositoryConfiguration getRepository();
 
     /**
-     * Given a specific ProjectReference, return the list of available versions for
+     * Given a specific {@link ProjectReference}, return the list of available versions for
      * that project reference.
      * 
      * @param reference the project reference to work off of.
@@ -114,7 +115,7 @@ public interface ManagedRepositoryContent
 
     /**
      * <p>
-     * Given a specific VersionedReference, return the list of available versions for that
+     * Given a specific {@link VersionedReference}, return the list of available versions for that
      * versioned reference.
      * </p>
      * 
@@ -174,15 +175,23 @@ public interface ManagedRepositoryContent
         throws LayoutException;
 
     /**
-     * Given an ArtifactReference, return the file reference to the artifact.
+     * Given an {@link ArtifactReference}, return the file reference to the artifact.
      *
      * @param reference the artifact reference to use.
      * @return the relative path to the artifact.
      */
     public File toFile( ArtifactReference reference );
+    
+    /**
+     * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
+     *
+     * @param reference the archiva artifact to use.
+     * @return the relative path to the artifact.
+     */
+    public File toFile( ArchivaArtifact reference );
 
     /**
-     * Given a project reference, return the path to the metadata for
+     * Given a {@link ProjectReference}, return the path to the metadata for
      * the project. 
      * 
      * @param reference the reference to use.
@@ -191,7 +200,7 @@ public interface ManagedRepositoryContent
     public String toMetadataPath( ProjectReference reference );
 
     /**
-     * Given a versioned reference, return the path to the metadata for
+     * Given a {@link VersionedReference}, return the path to the metadata for
      * the specific version of the project. 
      * 
      * @param reference the reference to use.
@@ -200,10 +209,18 @@ public interface ManagedRepositoryContent
     public String toMetadataPath( VersionedReference reference );
 
     /**
-     * Given an ArtifactReference, return the relative path to the artifact.
+     * Given an {@link ArtifactReference}, return the relative path to the artifact.
      *
      * @param reference the artifact reference to use.
      * @return the relative path to the artifact.
      */
     public String toPath( ArtifactReference reference );
+    
+    /**
+     * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
+     *
+     * @param reference the archiva artifact to use.
+     * @return the relative path to the artifact.
+     */
+    public String toPath( ArchivaArtifact reference );
 }
index 30d54ec85a6f7dbe9a76688b114fda67164eb629..a1b4d78e799bf9cbba9155c656c66233a888b58f 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.maven.archiva.repository.content;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.common.utils.VersionUtil;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.ProjectReference;
 import org.apache.maven.archiva.model.VersionedReference;
@@ -74,6 +75,18 @@ public abstract class AbstractDefaultRepositoryContent
     
         return path.toString();
     }
+    
+    public String toPath( ArchivaArtifact reference )
+    {
+        if ( reference == null )
+        {
+            throw new IllegalArgumentException( "ArchivaArtifact cannot be null" );
+        }
+
+        String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() );
+        return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion, reference.getVersion(),
+                       reference.getClassifier(), reference.getType() );
+    }
 
     public String toPath( ArtifactReference reference )
     {
index a9acaf2b939d029af90b22e6a08fa1ae4a23139b..33931a52775e5a3636e1f8c4ea7f1ecbf2436da7 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.repository.content;
  */
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 
@@ -55,6 +56,17 @@ public abstract class AbstractLegacyRepositoryContent
     {
         return LegacyPathParser.toArtifactReference( path );
     }
+    
+    public String toPath( ArchivaArtifact reference )
+    {
+        if ( reference == null )
+        {
+            throw new IllegalArgumentException( "Artifact reference cannot be null" );
+        }
+
+        return toPath( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), reference
+            .getClassifier(), reference.getType() );
+    }
 
     public String toPath( ArtifactReference reference )
     {
index 78ddfb2bdef42983c4e67cecd98782feef140396..9de5064e13abdab85e56e46d7b3b381b35d07e08 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.common.utils.PathUtil;
 import org.apache.maven.archiva.configuration.FileTypes;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.ProjectReference;
 import org.apache.maven.archiva.model.VersionedReference;
@@ -333,6 +334,11 @@ public class ManagedDefaultRepositoryContent
     {
         return new File( repository.getLocation(), toPath( reference ) );
     }
+    
+    public File toFile( ArchivaArtifact reference )
+    {
+        return new File( repository.getLocation(), toPath( reference ) );
+    }
 
     /**
      * Get the first Artifact found in the provided VersionedReference location.
index 212aeed8174a552283b96c90f61beb4e0a97d53a..c1817af4c34cc61ee91e86bd4b29fede769633c5 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.common.utils.PathUtil;
 import org.apache.maven.archiva.configuration.FileTypes;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.ProjectReference;
 import org.apache.maven.archiva.model.VersionedReference;
@@ -349,6 +350,11 @@ public class ManagedLegacyRepositoryContent
 
         return super.toArtifactReference( path );
     }
+    
+    public File toFile( ArchivaArtifact reference )
+    {
+        return new File( repository.getLocation(), toPath( reference ) );
+    }
 
     public File toFile( ArtifactReference reference )
     {