From 4e69773c410797160f793e2849c547dece668e34 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 29 Oct 2012 23:12:08 +0000 Subject: [PATCH] remove code which has been migrated to an other module git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1403573 13f79535-47bb-0310-9956-ffa450edef68 --- .../webdav/ArchivaDavResourceFactory.java | 103 ++---------------- .../maven2/Maven2RepositoryStorage.java | 8 ++ 2 files changed, 17 insertions(+), 94 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 5c200275e..c3ce0deb6 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 @@ -36,6 +36,7 @@ import org.apache.archiva.indexer.merger.IndexMergerException; import org.apache.archiva.indexer.merger.TemporaryGroupIndex; import org.apache.archiva.indexer.search.RepositorySearch; import org.apache.archiva.maven2.metadata.MavenMetadataReader; +import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.model.ArchivaRepositoryMetadata; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.policies.ProxyDownloadException; @@ -81,14 +82,10 @@ import org.apache.jackrabbit.webdav.DavSession; import org.apache.jackrabbit.webdav.lock.LockManager; import org.apache.jackrabbit.webdav.lock.SimpleLockManager; import org.apache.maven.index.context.IndexingContext; -import org.apache.maven.model.DistributionManagement; -import org.apache.maven.model.Model; -import org.apache.maven.model.Relocation; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.plexus.digest.ChecksumFile; import org.codehaus.plexus.digest.Digester; import org.codehaus.plexus.digest.DigesterException; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; @@ -100,8 +97,6 @@ import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Date; @@ -733,7 +728,14 @@ public class ArchivaDavResourceFactory if ( artifact != null ) { - applyServerSideRelocation( managedRepository, artifact ); + String repositoryLayout = managedRepository.getRepository().getLayout(); + if ( StringUtils.equalsIgnoreCase( "default", repositoryLayout ) ) + { + repositoryLayout = "maven2"; + } + RepositoryStorage repositoryStorage = + this.applicationContext.getBean( repositoryLayout, RepositoryStorage.class ); + repositoryStorage.applyServerSideRelocation( managedRepository, artifact ); File proxiedFile = connectors.fetchFromProxies( managedRepository, artifact ); @@ -758,93 +760,6 @@ public class ArchivaDavResourceFactory return false; } - /** - * A relocation capable client will request the POM prior to the artifact, and will then read meta-data and do - * client side relocation. A simplier client (like maven 1) will only request the artifact and not use the - * metadatas. - *

- * For such clients, archiva does server-side relocation by reading itself the <relocation> element in - * metadatas and serving the expected artifact. - */ - protected void applyServerSideRelocation( ManagedRepositoryContent managedRepository, ArtifactReference artifact ) - throws ProxyDownloadException - { - if ( "pom".equals( artifact.getType() ) ) - { - return; - } - - // Build the artifact POM reference - ArtifactReference pomReference = new ArtifactReference(); - pomReference.setGroupId( artifact.getGroupId() ); - pomReference.setArtifactId( artifact.getArtifactId() ); - pomReference.setVersion( artifact.getVersion() ); - pomReference.setType( "pom" ); - - // Get the artifact POM from proxied repositories if needed - connectors.fetchFromProxies( managedRepository, pomReference ); - - // Open and read the POM from the managed repo - File pom = managedRepository.toFile( pomReference ); - - if ( !pom.exists() ) - { - return; - } - - try - { - // MavenXpp3Reader leaves the file open, so we need to close it ourselves. - FileReader reader = new FileReader( pom ); - Model model = null; - try - { - model = MAVEN_XPP_3_READER.read( reader ); - } - finally - { - if ( reader != null ) - { - reader.close(); - } - } - - DistributionManagement dist = model.getDistributionManagement(); - if ( dist != null ) - { - Relocation relocation = dist.getRelocation(); - if ( relocation != null ) - { - // artifact is relocated : update the repositoryPath - if ( relocation.getGroupId() != null ) - { - artifact.setGroupId( relocation.getGroupId() ); - } - if ( relocation.getArtifactId() != null ) - { - artifact.setArtifactId( relocation.getArtifactId() ); - } - if ( relocation.getVersion() != null ) - { - artifact.setVersion( relocation.getVersion() ); - } - } - } - } - catch ( FileNotFoundException e ) - { - // Artifact has no POM in repo : ignore - } - catch ( IOException e ) - { - // Unable to read POM : ignore. - } - catch ( XmlPullParserException e ) - { - // Invalid POM : ignore - } - } - // TODO: remove? private void triggerAuditEvent( String remoteIP, String repositoryId, String resource, String action, 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 cb2171c70..803809afb 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 @@ -629,6 +629,14 @@ public class Maven2RepositoryStorage return metadata; } + /** + * A relocation capable client will request the POM prior to the artifact, and will then read meta-data and do + * client side relocation. A simplier client (like maven 1) will only request the artifact and not use the + * metadatas. + *

+ * For such clients, archiva does server-side relocation by reading itself the <relocation> element in + * metadatas and serving the expected artifact. + */ public void applyServerSideRelocation( ManagedRepositoryContent managedRepository, ArtifactReference artifact ) throws ProxyDownloadException { -- 2.39.5