mirror of https://github.com/apache/archiva.git
MRM-153 : when used as a maven1 proxy, Archiva should handle relocation from maven2 poms
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-0.9@537022 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
31341e38ec
commit
8f310d58d4
|
@ -104,32 +104,32 @@ public class DefaultProxyRequestHandler
|
|||
|
||||
private static final TimeZone UTC_TIMEZONE = TimeZone.getTimeZone( "UTC" );
|
||||
|
||||
public File get( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
public ProxiedArtifact get( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
throws ProxyException, ResourceDoesNotExistException
|
||||
{
|
||||
return get( path, proxiedRepositories, managedRepository, null );
|
||||
}
|
||||
|
||||
public File get( String path, List proxiedRepositories, ArtifactRepository managedRepository, ProxyInfo wagonProxy )
|
||||
public ProxiedArtifact get( String path, List proxiedRepositories, ArtifactRepository managedRepository, ProxyInfo wagonProxy )
|
||||
throws ProxyException, ResourceDoesNotExistException
|
||||
{
|
||||
return get( managedRepository, path, proxiedRepositories, wagonProxy, false );
|
||||
}
|
||||
|
||||
public File getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
public ProxiedArtifact getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
throws ProxyException, ResourceDoesNotExistException
|
||||
{
|
||||
return getAlways( path, proxiedRepositories, managedRepository, null );
|
||||
}
|
||||
|
||||
public File getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository,
|
||||
public ProxiedArtifact getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository,
|
||||
ProxyInfo wagonProxy )
|
||||
throws ResourceDoesNotExistException, ProxyException
|
||||
{
|
||||
return get( managedRepository, path, proxiedRepositories, wagonProxy, true );
|
||||
}
|
||||
|
||||
private File get( ArtifactRepository managedRepository, String path, List proxiedRepositories, ProxyInfo wagonProxy,
|
||||
private ProxiedArtifact get( ArtifactRepository managedRepository, String path, List proxiedRepositories, ProxyInfo wagonProxy,
|
||||
boolean force )
|
||||
throws ProxyException, ResourceDoesNotExistException
|
||||
{
|
||||
|
@ -173,6 +173,10 @@ public class DefaultProxyRequestHandler
|
|||
{
|
||||
artifact = legacyArtifactBuilder.build( artifactPath );
|
||||
getLogger().debug( "Artifact requested is: " + artifact );
|
||||
|
||||
// This is a maven1 request (legacy format)
|
||||
// as Maven1 can't handle relocation, do it internally.
|
||||
applyRelocation( managedRepository, artifact, proxiedRepositories, wagonProxy, force );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
|
@ -182,12 +186,11 @@ public class DefaultProxyRequestHandler
|
|||
|
||||
if ( artifact != null )
|
||||
{
|
||||
applyRelocation( managedRepository, artifact, proxiedRepositories, wagonProxy, force );
|
||||
|
||||
if ( !checksum )
|
||||
{
|
||||
path = managedRepository.pathOf( artifact );
|
||||
// Build the target file name
|
||||
target = new File( managedRepository.getBasedir(), managedRepository.pathOf( artifact ) );
|
||||
target = new File( managedRepository.getBasedir(), path );
|
||||
|
||||
// Get the requested artifact from proxiedRepositories
|
||||
getArtifactFromRepository( managedRepository, target, artifact, proxiedRepositories, wagonProxy,
|
||||
|
@ -195,9 +198,9 @@ public class DefaultProxyRequestHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
path = managedRepository.pathOf( artifact ) + "." + checksumExtension;
|
||||
// Just adjust the filename for relocation, don't actualy get it
|
||||
target = new File( managedRepository.getBasedir(),
|
||||
managedRepository.pathOf( artifact ) + "." + checksumExtension );
|
||||
target = new File( managedRepository.getBasedir(), path );
|
||||
}
|
||||
}
|
||||
else if ( !checksum )
|
||||
|
@ -215,7 +218,7 @@ public class DefaultProxyRequestHandler
|
|||
throw new ResourceDoesNotExistException( "Could not find " + path + " in any of the repositories." );
|
||||
}
|
||||
|
||||
return target;
|
||||
return new ProxiedArtifact( target, path );
|
||||
}
|
||||
|
||||
private void getFileFromRepository( ArtifactRepository managedRepository, File target, String path,
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package org.apache.maven.archiva.proxy;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Composite object for describing an artifact as result of a proxy-request.
|
||||
*
|
||||
* @author @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
|
||||
*/
|
||||
public class ProxiedArtifact
|
||||
{
|
||||
/**
|
||||
* The artifact as a file in the managed repository
|
||||
*/
|
||||
private File file;
|
||||
|
||||
/**
|
||||
* The artifact Path in the managed repository
|
||||
*/
|
||||
private String path;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ProxiedArtifact( File file, String path )
|
||||
{
|
||||
super();
|
||||
this.file = file;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the file
|
||||
*/
|
||||
public File getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
|
@ -23,7 +23,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.apache.maven.wagon.proxy.ProxyInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +49,7 @@ public interface ProxyRequestHandler
|
|||
* when the requested object can't be found in any of the
|
||||
* configured repositories
|
||||
*/
|
||||
File get( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
ProxiedArtifact get( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
throws ProxyException, ResourceDoesNotExistException;
|
||||
|
||||
/**
|
||||
|
@ -66,7 +65,7 @@ public interface ProxyRequestHandler
|
|||
* when the requested object can't be found in any of the
|
||||
* configured repositories
|
||||
*/
|
||||
File get( String path, List proxiedRepositories, ArtifactRepository managedRepository, ProxyInfo wagonProxy )
|
||||
ProxiedArtifact get( String path, List proxiedRepositories, ArtifactRepository managedRepository, ProxyInfo wagonProxy )
|
||||
throws ProxyException, ResourceDoesNotExistException;
|
||||
|
||||
/**
|
||||
|
@ -82,7 +81,7 @@ public interface ProxyRequestHandler
|
|||
* when the requested object can't be found in any of the
|
||||
* configured repositories
|
||||
*/
|
||||
File getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
ProxiedArtifact getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository )
|
||||
throws ProxyException, ResourceDoesNotExistException;
|
||||
|
||||
/**
|
||||
|
@ -99,6 +98,6 @@ public interface ProxyRequestHandler
|
|||
* when the requested object can't be found in any of the
|
||||
* configured repositories
|
||||
*/
|
||||
File getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository, ProxyInfo wagonProxy )
|
||||
ProxiedArtifact getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository, ProxyInfo wagonProxy )
|
||||
throws ProxyException, ResourceDoesNotExistException;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,7 @@ import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
|
|||
import org.apache.maven.archiva.configuration.ProxiedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Proxy;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.proxy.ProxiedArtifact;
|
||||
import org.apache.maven.archiva.proxy.ProxyException;
|
||||
import org.apache.maven.archiva.proxy.ProxyRequestHandler;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
@ -160,8 +161,9 @@ public class ProxiedDavServer
|
|||
{
|
||||
try
|
||||
{
|
||||
proxyRequestHandler.get( request.getLogicalResource(), this.proxiedRepositories, this.managedRepository,
|
||||
ProxiedArtifact proxied = proxyRequestHandler.get( request.getLogicalResource(), this.proxiedRepositories, this.managedRepository,
|
||||
this.wagonProxy );
|
||||
request.getRequest().setPathInfo( proxied.getPath() );
|
||||
}
|
||||
catch ( ProxyException e )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue