aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java25
-rw-r--r--archiva-modules/metadata/metadata-repository-api/pom.xml4
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java7
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java44
4 files changed, 78 insertions, 2 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
index 293e230e5..6132dfe01 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
@@ -527,6 +527,28 @@ public class ArchivaDavResourceFactory
return path;
}
+ private String evaluatePathWithVersion( ArchivaDavResourceLocator archivaLocator, ManagedRepositoryContent managedRepositoryContent )
+ throws DavException
+ {
+ String layout = managedRepositoryContent.getRepository() == null ? new ManagedRepository( ).getLayout() : managedRepositoryContent.getRepository().getLayout();
+ RepositoryStorage repositoryStorage =
+ this.applicationContext.getBean( "repositoryStorage#" + layout, RepositoryStorage.class );
+ try
+ {
+ return repositoryStorage.getFilePathWithVersion( archivaLocator.getResourcePath(), managedRepositoryContent );
+ }
+ catch ( LayoutException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
+ }
+ catch ( XMLException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
+ }
+ }
+
private DavResource processRepository( final DavServletRequest request, ArchivaDavResourceLocator archivaLocator,
String activePrincipal, ManagedRepositoryContent managedRepositoryContent,
ManagedRepository managedRepository )
@@ -535,7 +557,8 @@ public class ArchivaDavResourceFactory
DavResource resource = null;
if ( isAuthorized( request, managedRepositoryContent.getId() ) )
{
- String path = getLogicalResource( archivaLocator, managedRepository, false );
+ // Maven Centric part ask evaluation if -SNAPSHOT
+ String path = evaluatePathWithVersion(archivaLocator, managedRepositoryContent);
if ( path.startsWith( "/" ) )
{
path = path.substring( 1 );
diff --git a/archiva-modules/metadata/metadata-repository-api/pom.xml b/archiva-modules/metadata/metadata-repository-api/pom.xml
index 4b8e36834..0b508762c 100644
--- a/archiva-modules/metadata/metadata-repository-api/pom.xml
+++ b/archiva-modules/metadata/metadata-repository-api/pom.xml
@@ -91,7 +91,9 @@
org.apache.archiva.model,
org.apache.archiva.policies,
org.apache.archiva.repository,
- org.apache.archiva.admin.model.beans
+ org.apache.archiva.admin.model.beans,
+ org.apache.archiva.repository.layout,
+ org.apache.archiva.xml
</Import-Package>
</instructions>
</configuration>
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java
index d5b203778..fee01b775 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java
@@ -27,6 +27,8 @@ import org.apache.archiva.metadata.repository.filter.Filter;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.ProxyDownloadException;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.layout.LayoutException;
+import org.apache.archiva.xml.XMLException;
import java.util.Collection;
@@ -70,4 +72,9 @@ public interface RepositoryStorage
* @since 2.0.0
*/
String getFilePath( String requestPath, ManagedRepository managedRepository );
+
+ String getFilePathWithVersion( final String requestPath, ManagedRepositoryContent managedRepositoryContent )
+ throws LayoutException, XMLException;
+
+
}
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
index 699f41bfc..30cc56958 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
@@ -35,6 +35,7 @@ import org.apache.archiva.maven2.metadata.MavenMetadataReader;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.metadata.repository.filter.Filter;
import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
@@ -50,6 +51,8 @@ import org.apache.archiva.proxy.common.WagonFactory;
import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
import org.apache.archiva.reports.RepositoryProblemFacet;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.content.PathParser;
+import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.xml.XMLException;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@@ -131,6 +134,10 @@ public class Maven2RepositoryStorage
@Inject
private ApplicationContext applicationContext;
+ @Inject
+ @Named ( value = "pathParser#default")
+ private PathParser pathParser;
+
private static final Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class );
private static final String METADATA_FILENAME_START = "maven-metadata";
@@ -757,6 +764,34 @@ public class Maven2RepositoryStorage
}
+ public String getFilePathWithVersion( final String requestPath, ManagedRepositoryContent managedRepositoryContent )
+ throws LayoutException, XMLException
+ {
+ String requestPathNoRepository = removePrefix( requestPath );
+ ArtifactReference artifactReference = pathParser.toArtifactReference( requestPathNoRepository );
+
+ String filePath = getFilePath( requestPath, managedRepositoryContent.getRepository() );
+
+ if (StringUtils.endsWith( artifactReference.getVersion(), "SNAPSHOT" ))
+ {
+ // read maven metadata to get last timestamp
+ File metadataDir = new File( managedRepositoryContent.getRepoRoot(), filePath).getParentFile();
+ ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( new File(metadataDir, METADATA_FILENAME ) );
+ int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
+ String timestamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
+
+ // org/apache/archiva/archiva-checksum/1.4-M4-SNAPSHOT/archiva-checksum-1.4-M4-SNAPSHOT.jar
+ // -> archiva-checksum-1.4-M4-20130425.081822-1.jar
+
+ filePath = StringUtils.replace( filePath, artifactReference.getArtifactId() + "-" + artifactReference.getVersion(),
+ artifactReference.getArtifactId() + "-" + StringUtils.remove( artifactReference.getVersion(), "-SNAPSHOT")
+ + "-" + timestamp + "-" + buildNumber );
+
+ }
+
+ return filePath;
+ }
+
//-----------------------------
@@ -1002,4 +1037,13 @@ public class Maven2RepositoryStorage
}
+ public PathParser getPathParser()
+ {
+ return pathParser;
+ }
+
+ public void setPathParser( PathParser pathParser )
+ {
+ this.pathParser = pathParser;
+ }
}