diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-04-20 20:55:14 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-04-20 20:55:14 +0000 |
commit | d9e4b87d608b07d5f74b58f19cc74d8540a5e2af (patch) | |
tree | 8973c849f5248245b6fe758076d11cd48c238b66 /archiva-base/archiva-proxy/src | |
parent | 32f1b4afd229747be65b14fe10f0194b081159fc (diff) | |
download | archiva-d9e4b87d608b07d5f74b58f19cc74d8540a5e2af.tar.gz archiva-d9e4b87d608b07d5f74b58f19cc74d8540a5e2af.zip |
Adding VersionedReference metadata to .fetchFromProxies()
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@530916 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-base/archiva-proxy/src')
2 files changed, 72 insertions, 4 deletions
diff --git a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java index ed85005a8..a2521ef37 100644 --- a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -27,6 +27,7 @@ import org.apache.maven.archiva.configuration.RepositoryConfiguration; import org.apache.maven.archiva.model.ArchivaRepository; import org.apache.maven.archiva.model.ArtifactReference; import org.apache.maven.archiva.model.ProjectReference; +import org.apache.maven.archiva.model.VersionedReference; import org.apache.maven.archiva.policies.DownloadPolicy; import org.apache.maven.archiva.policies.urlcache.UrlFailureCache; import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; @@ -70,8 +71,6 @@ public class DefaultRepositoryProxyConnectors extends AbstractLogEnabled implements RepositoryProxyConnectors, RegistryListener, Initializable { - private static final String FILENAME_MAVEN_METADATA = "maven-metadata.xml"; - /** * @plexus.requirement */ @@ -166,6 +165,59 @@ public class DefaultRepositoryProxyConnectors return null; } + + public File fetchFromProxies( ArchivaRepository repository, VersionedReference metadata ) + throws ProxyException + { + if ( !repository.isManaged() ) + { + throw new ProxyException( "Can only proxy managed repositories." ); + } + + File localFile; + try + { + BidirectionalRepositoryLayout sourceLayout = layoutFactory.getLayout( repository.getLayoutType() ); + String sourcePath = sourceLayout.toPath( metadata ); + localFile = new File( repository.getUrl().getPath(), sourcePath ); + } + catch ( LayoutException e ) + { + throw new ProxyException( "Unable to proxy due to bad source repository layout definition: " + + e.getMessage(), e ); + } + + Properties requestProperties = new Properties(); + + List connectors = getProxyConnectors( repository ); + Iterator it = connectors.iterator(); + while ( it.hasNext() ) + { + ProxyConnector connector = (ProxyConnector) it.next(); + ArchivaRepository targetRepository = connector.getTargetRepository(); + try + { + BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() ); + String targetPath = targetLayout.toPath( metadata ); + + File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile, + requestProperties ); + + if ( fileExists( downloadedFile ) ) + { + getLogger().info( "Successfully transfered: " + downloadedFile.getAbsolutePath() ); + return downloadedFile; + } + } + catch ( LayoutException e ) + { + getLogger().error( "Unable to proxy due to bad layout definition: " + e.getMessage(), e ); + return null; + } + } + + return null; + } public File fetchFromProxies( ArchivaRepository repository, ProjectReference metadata ) throws ProxyException @@ -179,7 +231,7 @@ public class DefaultRepositoryProxyConnectors try { BidirectionalRepositoryLayout sourceLayout = layoutFactory.getLayout( repository.getLayoutType() ); - String sourcePath = sourceLayout.toPath( metadata ) + FILENAME_MAVEN_METADATA; + String sourcePath = sourceLayout.toPath( metadata ); localFile = new File( repository.getUrl().getPath(), sourcePath ); } catch ( LayoutException e ) @@ -199,7 +251,7 @@ public class DefaultRepositoryProxyConnectors try { BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() ); - String targetPath = targetLayout.toPath( metadata ) + FILENAME_MAVEN_METADATA; + String targetPath = targetLayout.toPath( metadata ); File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile, requestProperties ); diff --git a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/RepositoryProxyConnectors.java b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/RepositoryProxyConnectors.java index 622360754..182b219ed 100644 --- a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/RepositoryProxyConnectors.java +++ b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/RepositoryProxyConnectors.java @@ -22,6 +22,7 @@ package org.apache.maven.archiva.proxy; import org.apache.maven.archiva.model.ArchivaRepository; import org.apache.maven.archiva.model.ArtifactReference; import org.apache.maven.archiva.model.ProjectReference; +import org.apache.maven.archiva.model.VersionedReference; import java.io.File; import java.util.List; @@ -61,6 +62,21 @@ public interface RepositoryProxyConnectors * @return true if the fetch operation succeeded in obtaining content, false if no content was obtained. * @throws ProxyException if there was a problem fetching the content from the target repositories. */ + public File fetchFromProxies( ArchivaRepository repository, VersionedReference metadata ) + throws ProxyException; + + /** + * Performs the metadata fetch operation against the target repositories + * of the provided source repository. + * + * If the metadata is found, it is downloaded and placed into the source repository + * filesystem. + * + * @param repository the source repository to use. (must be a managed repository) + * @param metadata the metadata to fetch. + * @return true if the fetch operation succeeded in obtaining content, false if no content was obtained. + * @throws ProxyException if there was a problem fetching the content from the target repositories. + */ public File fetchFromProxies( ArchivaRepository repository, ProjectReference metadata ) throws ProxyException; |