| Method from org.apache.maven.artifact.manager.DefaultWagonManager Detail: |
public void addAuthenticationInfo(String repositoryId,
String username,
String password,
String privateKey,
String passphrase) {
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName( username );
authInfo.setPassword( password );
authInfo.setPrivateKey( privateKey );
authInfo.setPassphrase( passphrase );
authenticationInfoMap.put( repositoryId, authInfo );
}
|
public void addConfiguration(String repositoryId,
Xpp3Dom configuration) {
if ( repositoryId == null || configuration == null )
{
throw new IllegalArgumentException( "arguments can't be null" );
}
final XmlPlexusConfiguration xmlConf = new XmlPlexusConfiguration( configuration );
serverConfigurationMap.put( repositoryId, xmlConf );
}
|
public void addMirror(String id,
String mirrorOf,
String url) {
ArtifactRepository mirror = new DefaultArtifactRepository( id, url, null );
mirrors.put( mirrorOf, mirror );
}
|
public void addPermissionInfo(String repositoryId,
String filePermissions,
String directoryPermissions) {
RepositoryPermissions permissions = new RepositoryPermissions();
boolean addPermissions = false;
if ( filePermissions != null )
{
permissions.setFileMode( filePermissions );
addPermissions = true;
}
if ( directoryPermissions != null )
{
permissions.setDirectoryMode( directoryPermissions );
addPermissions = true;
}
if ( addPermissions )
{
serverPermissionsMap.put( repositoryId, permissions );
}
}
|
public void addProxy(String protocol,
String host,
int port,
String username,
String password,
String nonProxyHosts) {
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost( host );
proxyInfo.setType( protocol );
proxyInfo.setPort( port );
proxyInfo.setNonProxyHosts( nonProxyHosts );
proxyInfo.setUserName( username );
proxyInfo.setPassword( password );
proxies.put( protocol, proxyInfo );
}
Set the proxy used for a particular protocol. |
public void contextualize(Context context) throws ContextException {
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
|
public void getArtifact(Artifact artifact,
List remoteRepositories) throws TransferFailedException, ResourceDoesNotExistException {
// TODO [BP]: The exception handling here needs some work
boolean successful = false;
for ( Iterator iter = remoteRepositories.iterator(); iter.hasNext() && !successful; )
{
ArtifactRepository repository = (ArtifactRepository) iter.next();
try
{
getArtifact( artifact, repository );
successful = artifact.isResolved();
}
catch ( ResourceDoesNotExistException e )
{
// This one we will eat when looking through remote repositories
// because we want to cycle through them all before squawking.
getLogger().debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
repository.getId() + " (" + repository.getUrl() + ")" );
}
catch ( TransferFailedException e )
{
getLogger().debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
repository.getId() + " (" + repository.getUrl() + ")" );
}
}
// if it already exists locally we were just trying to force it - ignore the update
if ( !successful && !artifact.getFile().exists() )
{
throw new ResourceDoesNotExistException( "Unable to download the artifact from any repository" );
}
}
|
public void getArtifact(Artifact artifact,
ArtifactRepository repository) throws TransferFailedException, ResourceDoesNotExistException {
String remotePath = repository.pathOf( artifact );
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
if ( !policy.isEnabled() )
{
getLogger().debug( "Skipping disabled repository " + repository.getId() );
}
else if ( repository.isBlacklisted() )
{
getLogger().debug( "Skipping blacklisted repository " + repository.getId() );
}
else
{
getLogger().debug( "Trying repository " + repository.getId() );
getRemoteFile( getMirrorRepository( repository ), artifact.getFile(), remotePath, downloadMonitor,
policy.getChecksumPolicy(), false );
getLogger().debug( " Artifact resolved" );
artifact.setResolved( true );
}
}
|
public void getArtifactMetadata(ArtifactMetadata metadata,
ArtifactRepository repository,
File destination,
String checksumPolicy) throws TransferFailedException, ResourceDoesNotExistException {
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
getRemoteFile( getMirrorRepository( repository ), destination, remotePath, null, checksumPolicy, true );
}
|
public void getArtifactMetadataFromDeploymentRepository(ArtifactMetadata metadata,
ArtifactRepository repository,
File destination,
String checksumPolicy) throws TransferFailedException, ResourceDoesNotExistException {
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
}
|
public AuthenticationInfo getAuthenticationInfo(String id) {
return (AuthenticationInfo) authenticationInfoMap.get( id );
}
|
public ArtifactRepository getMirror(ArtifactRepository originalRepository) {
ArtifactRepository selectedMirror = (ArtifactRepository) mirrors.get( originalRepository.getId() );
if ( null == selectedMirror )
{
// Process the patterns in order. First one that matches wins.
Set keySet = mirrors.keySet();
if ( keySet != null )
{
Iterator iter = keySet.iterator();
while ( iter.hasNext() )
{
String pattern = (String) iter.next();
if ( matchPattern( originalRepository, pattern ) )
{
selectedMirror = (ArtifactRepository) mirrors.get( pattern );
}
}
}
}
return selectedMirror;
}
This method finds a matching mirror for the selected repository. If there is an exact match, this will be used.
If there is no exact match, then the list of mirrors is examined to see if a pattern applies. |
public ArtifactRepository getMirrorRepository(ArtifactRepository repository) {
ArtifactRepository mirror = getMirror( repository );
if ( mirror != null )
{
String id = mirror.getId();
if ( id == null )
{
// TODO: this should be illegal in settings.xml
id = repository.getId();
}
repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(),
repository.getLayout(), repository.getSnapshots(),
repository.getReleases() );
}
return repository;
}
|
public ProxyInfo getProxy(String protocol) {
return (ProxyInfo) proxies.get( protocol );
}
|
public Wagon getWagon(Repository repository) throws WagonConfigurationException, UnsupportedProtocolException {
// TODO: this leaks the component in the public api - it is never released back to the container
String protocol = repository.getProtocol();
if ( protocol == null )
{
throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" );
}
Wagon wagon = getWagon( protocol );
configureWagon( wagon, repository.getId() );
return wagon;
}
|
public Wagon getWagon(String protocol) throws UnsupportedProtocolException {
PlexusContainer container = getWagonContainer( protocol );
Wagon wagon;
try
{
wagon = (Wagon) container.lookup( Wagon.ROLE, protocol );
}
catch ( ComponentLookupException e1 )
{
throw new UnsupportedProtocolException(
"Cannot find wagon which supports the requested protocol: " + protocol, e1 );
}
wagon.setInteractive( interactive );
return wagon;
}
|
public boolean isExternalRepo(ArtifactRepository originalRepository) {
try
{
URL url = new URL( originalRepository.getUrl() );
return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals(
"file" ) );
}
catch ( MalformedURLException e )
{
// bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it
return false;
}
}
Checks the URL to see if this repository refers to an external repository |
public boolean isOnline() {
return online;
}
|
public boolean matchPattern(ArtifactRepository originalRepository,
String pattern) {
boolean result = false;
String originalId = originalRepository.getId();
// simple checks first to short circuit processing below.
if ( WILDCARD.equals( pattern ) || pattern.equals( originalId ) )
{
result = true;
}
else
{
// process the list
String[] repos = pattern.split( "," );
for ( int i = 0; i < repos.length; i++ )
{
String repo = repos[i];
// see if this is a negative match
if ( repo.length() > 1 && repo.startsWith( "!" ) )
{
if ( originalId.equals( repo.substring( 1 ) ) )
{
// explicitly exclude. Set result and stop processing.
result = false;
break;
}
}
// check for exact match
else if ( originalId.equals( repo ) )
{
result = true;
break;
}
// check for external:*
else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository ) )
{
result = true;
// don't stop processing in case a future segment explicitly excludes this repo
}
else if ( WILDCARD.equals( repo ) )
{
result = true;
// don't stop processing in case a future segment explicitly excludes this repo
}
}
}
return result;
}
This method checks if the pattern matches the originalRepository.
Valid patterns:
* = everything
external:* = everything not on the localhost and not file based.
repo,repo1 = repo or repo1
*,!repo1 = everything except repo1 |
public void putArtifact(File source,
Artifact artifact,
ArtifactRepository deploymentRepository) throws TransferFailedException {
putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor );
}
|
public void putArtifactMetadata(File source,
ArtifactMetadata artifactMetadata,
ArtifactRepository repository) throws TransferFailedException {
getLogger().info( "Uploading " + artifactMetadata );
putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null );
}
|
public void registerWagons(Collection wagons,
PlexusContainer extensionContainer) {
for ( Iterator i = wagons.iterator(); i.hasNext(); )
{
availableWagons.put( i.next(), extensionContainer );
}
}
|
public void setDefaultRepositoryPermissions(RepositoryPermissions defaultRepositoryPermissions) {
this.defaultRepositoryPermissions = defaultRepositoryPermissions;
}
|
public void setDownloadMonitor(TransferListener downloadMonitor) {
this.downloadMonitor = downloadMonitor;
}
|
public void setInteractive(boolean interactive) {
this.interactive = interactive;
}
|
public void setOnline(boolean online) {
this.online = online;
}
|