add parameters. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1401896 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-1.4-M4
@@ -23,6 +23,7 @@ import com.google.common.io.Files; | |||
import org.apache.archiva.admin.model.RepositoryAdminException; | |||
import org.apache.archiva.admin.model.beans.NetworkProxy; | |||
import org.apache.archiva.admin.model.beans.ProxyConnectorRuleType; | |||
import org.apache.archiva.admin.model.beans.RemoteRepository; | |||
import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; | |||
import org.apache.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.archiva.configuration.Configuration; | |||
@@ -921,7 +922,7 @@ public class DefaultRepositoryProxyConnectors | |||
if ( !origFile.exists() ) | |||
{ | |||
log.debug( "Retrieving {} from {}", remotePath, remoteRepository.getRepository().getName() ); | |||
wagon.get( remotePath, destFile ); | |||
wagon.get( addParameters( remotePath, remoteRepository.getRepository() ), destFile ); | |||
success = true; | |||
// You wouldn't get here on failure, a WagonException would have been thrown. | |||
@@ -930,7 +931,8 @@ public class DefaultRepositoryProxyConnectors | |||
else | |||
{ | |||
log.debug( "Retrieving {} from {} if updated", remotePath, remoteRepository.getRepository().getName() ); | |||
success = wagon.getIfNewer( remotePath, destFile, origFile.lastModified() ); | |||
success = wagon.getIfNewer( addParameters( remotePath, remoteRepository.getRepository() ), destFile, | |||
origFile.lastModified() ); | |||
if ( !success ) | |||
{ | |||
throw new NotModifiedException( | |||
@@ -1249,6 +1251,29 @@ public class DefaultRepositoryProxyConnectors | |||
} | |||
} | |||
protected String addParameters( String path, RemoteRepository remoteRepository ) | |||
{ | |||
if ( remoteRepository.getExtraParameters().isEmpty() ) | |||
{ | |||
return path; | |||
} | |||
boolean question = false; | |||
StringBuilder res = new StringBuilder( path == null ? "" : path ); | |||
for ( Entry<String, String> entry : remoteRepository.getExtraParameters().entrySet() ) | |||
{ | |||
if ( !question ) | |||
{ | |||
res.append( '?' ).append( entry.getKey() ).append( '=' ).append( entry.getValue() ); | |||
} | |||
} | |||
return res.toString(); | |||
} | |||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) | |||
{ | |||
/* do nothing */ |
@@ -57,6 +57,7 @@ import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* @author Olivier Lamy | |||
@@ -168,7 +169,8 @@ public class DownloadRemoteIndexTask | |||
indexDirectory.mkdirs(); | |||
} | |||
ResourceFetcher resourceFetcher = new WagonResourceFetcher( log, tempIndexDirectory, wagon ); | |||
ResourceFetcher resourceFetcher = | |||
new WagonResourceFetcher( log, tempIndexDirectory, wagon, remoteRepository ); | |||
IndexUpdateRequest request = new IndexUpdateRequest( indexingContext, resourceFetcher ); | |||
request.setForceFullUpdate( this.fullDownload ); | |||
request.setLocalIndexCacheDir( indexCacheDirectory ); | |||
@@ -295,11 +297,15 @@ public class DownloadRemoteIndexTask | |||
Wagon wagon; | |||
private WagonResourceFetcher( Logger log, File tempIndexDirectory, Wagon wagon ) | |||
RemoteRepository remoteRepository; | |||
private WagonResourceFetcher( Logger log, File tempIndexDirectory, Wagon wagon, | |||
RemoteRepository remoteRepository ) | |||
{ | |||
this.log = log; | |||
this.tempIndexDirectory = tempIndexDirectory; | |||
this.wagon = wagon; | |||
this.remoteRepository = remoteRepository; | |||
} | |||
public void connect( String id, String url ) | |||
@@ -326,7 +332,7 @@ public class DownloadRemoteIndexTask | |||
file.delete(); | |||
} | |||
file.deleteOnExit(); | |||
wagon.get( name, file ); | |||
wagon.get( addParameters( name, this.remoteRepository ), file ); | |||
return new FileInputStream( file ); | |||
} | |||
catch ( AuthorizationException e ) | |||
@@ -342,7 +348,33 @@ public class DownloadRemoteIndexTask | |||
throw new FileNotFoundException( e.getMessage() ); | |||
} | |||
} | |||
// FIXME remove crappy copy/paste | |||
protected String addParameters( String path, RemoteRepository remoteRepository ) | |||
{ | |||
if ( remoteRepository.getExtraParameters().isEmpty() ) | |||
{ | |||
return path; | |||
} | |||
boolean question = false; | |||
StringBuilder res = new StringBuilder( path == null ? "" : path ); | |||
for ( Map.Entry<String, String> entry : remoteRepository.getExtraParameters().entrySet() ) | |||
{ | |||
if ( !question ) | |||
{ | |||
res.append( '?' ).append( entry.getKey() ).append( '=' ).append( entry.getValue() ); | |||
} | |||
} | |||
return res.toString(); | |||
} | |||
} | |||
} | |||
@@ -262,7 +262,7 @@ public class RepositoryModelResolver | |||
String metadataPath = | |||
StringUtils.substringBeforeLast( artifactPath, "/" ) + "/" + METADATA_FILENAME; | |||
wagon.get( metadataPath, tmpMetadataResource ); | |||
wagon.get( addParameters( metadataPath, remoteRepository ), tmpMetadataResource ); | |||
log.debug( "Successfully downloaded metadata." ); | |||
@@ -288,7 +288,7 @@ public class RepositoryModelResolver | |||
log.info( "Retrieving {} from {}", artifactPath, remoteRepository.getName() ); | |||
wagon.get( artifactPath, tmpResource ); | |||
wagon.get( addParameters( artifactPath, remoteRepository ), tmpResource ); | |||
log.debug( "Downloaded successfully." ); | |||
@@ -426,7 +426,7 @@ public class RepositoryModelResolver | |||
log.info( "Retrieving {} from {}", remotePath, remoteRepository.getName() ); | |||
wagon.get( remotePath, destFile ); | |||
wagon.get( addParameters( remotePath, remoteRepository ), destFile ); | |||
log.debug( "Downloaded successfully." ); | |||
@@ -485,4 +485,26 @@ public class RepositoryModelResolver | |||
} | |||
} | |||
} | |||
protected String addParameters( String path, RemoteRepository remoteRepository ) | |||
{ | |||
if ( remoteRepository.getExtraParameters().isEmpty() ) | |||
{ | |||
return path; | |||
} | |||
boolean question = false; | |||
StringBuilder res = new StringBuilder( path == null ? "" : path ); | |||
for ( Map.Entry<String, String> entry : remoteRepository.getExtraParameters().entrySet() ) | |||
{ | |||
if ( !question ) | |||
{ | |||
res.append( '?' ).append( entry.getKey() ).append( '=' ).append( entry.getValue() ); | |||
} | |||
} | |||
return res.toString(); | |||
} | |||
} |