@Service(value="repositoryProxyConnectors#default") public class DefaultRepositoryProxyConnectors extends Object implements RepositoryProxyConnectors, org.apache.archiva.redback.components.registry.RegistryListener
| Modifier and Type | Field and Description |
|---|---|
private ArchivaConfiguration |
archivaConfiguration |
private Map<String,DownloadErrorPolicy> |
downloadErrorPolicies |
private FileLockManager |
fileLockManager |
private org.slf4j.Logger |
log |
private MetadataTools |
metadataTools |
private NetworkProxyAdmin |
networkProxyAdmin |
private ConcurrentMap<String,org.apache.maven.wagon.proxy.ProxyInfo> |
networkProxyMap |
private Map<String,PostDownloadPolicy> |
postDownloadPolicies |
private Map<String,PreDownloadPolicy> |
preDownloadPolicies |
private ConcurrentMap<String,List<ProxyConnector>> |
proxyConnectorMap |
private RepositoryContentFactory |
repositoryFactory |
private RepositoryRegistry |
repositoryRegistry |
private ArchivaTaskScheduler<RepositoryTask> |
scheduler |
private UrlFailureCache |
urlFailureCache |
private WagonFactory |
wagonFactory |
| Constructor and Description |
|---|
DefaultRepositoryProxyConnectors() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
addParameters(String path,
RemoteRepository remoteRepository) |
void |
afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
String propertyName,
Object propertyValue) |
void |
beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
String propertyName,
Object propertyValue) |
private boolean |
connectToRepository(ProxyConnector connector,
org.apache.maven.wagon.Wagon wagon,
RemoteRepositoryContent remoteRepository)
Using wagon, connect to the remote repository.
|
private Path |
createWorkingDirectory(ManagedRepositoryContent repository)
Creates a working directory
|
Path |
fetchFromProxies(ManagedRepositoryContent repository,
ArtifactReference artifact)
Performs the artifact fetch operation against the target repositories
of the provided source repository.
|
Path |
fetchFromProxies(ManagedRepositoryContent repository,
String path)
Performs the fetch operation against the target repositories
of the provided source repository.
|
ProxyFetchResult |
fetchMetadataFromProxies(ManagedRepositoryContent repository,
String logicalPath)
Performs the metadata fetch operation against the target repositories
of the provided source repository.
|
private boolean |
fileExists(Path file)
Simple method to test if the file exists on the local disk.
|
private List<ProxyConnectorRuleConfiguration> |
findProxyConnectorRules(String sourceRepository,
String targetRepository,
List<ProxyConnectorRuleConfiguration> all) |
ArchivaConfiguration |
getArchivaConfiguration() |
Map<String,DownloadErrorPolicy> |
getDownloadErrorPolicies() |
private long |
getLastModified(Path file) |
MetadataTools |
getMetadataTools() |
Map<String,PostDownloadPolicy> |
getPostDownloadPolicies() |
Map<String,PreDownloadPolicy> |
getPreDownloadPolicies() |
List<ProxyConnector> |
getProxyConnectors(ManagedRepositoryContent repository)
TODO: Ensure that list is correctly ordered based on configuration.
|
RepositoryContentFactory |
getRepositoryFactory() |
UrlFailureCache |
getUrlFailureCache() |
WagonFactory |
getWagonFactory() |
private boolean |
hasBeenUpdated(Path file,
long originalLastModified) |
boolean |
hasProxies(ManagedRepositoryContent repository)
Test if the provided ManagedRepositoryContent has any proxies configured for it.
|
private void |
initConnectorsAndNetworkProxies() |
void |
initialize() |
private boolean |
matchesPattern(String path,
List<String> patterns)
Tests whitelist and blacklist patterns against path.
|
private void |
moveFileIfExists(Path fileToMove,
Path directory)
Moves the file into repository location if it exists
|
private void |
moveTempToTarget(Path temp,
Path target)
Used to move the temporary file to its real destination.
|
private void |
queueRepositoryTask(String repositoryId,
Path localFile) |
void |
setArchivaConfiguration(ArchivaConfiguration archivaConfiguration) |
void |
setDownloadErrorPolicies(Map<String,DownloadErrorPolicy> downloadErrorPolicies) |
void |
setMetadataTools(MetadataTools metadataTools) |
void |
setPostDownloadPolicies(Map<String,PostDownloadPolicy> postDownloadPolicies) |
void |
setPreDownloadPolicies(Map<String,PreDownloadPolicy> preDownloadPolicies) |
void |
setRepositoryFactory(RepositoryContentFactory repositoryFactory) |
void |
setUrlFailureCache(UrlFailureCache urlFailureCache) |
void |
setWagonFactory(WagonFactory wagonFactory) |
private Path |
toLocalFile(ManagedRepositoryContent repository,
ArtifactReference artifact) |
private Path |
toLocalRepoFile(ManagedRepositoryContent repository,
RemoteRepositoryContent targetRepository,
String targetPath) |
private void |
transferArtifact(org.apache.maven.wagon.Wagon wagon,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
Path resource,
Path tmpDirectory,
Path destFile) |
private void |
transferChecksum(org.apache.maven.wagon.Wagon wagon,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
Path resource,
Path tmpDirectory,
String ext,
Path destFile)
Quietly transfer the checksum file from the remote repository to the local file.
|
private Path |
transferFile(ProxyConnector connector,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
Path resource,
Properties requestProperties,
boolean executeConsumers)
Perform the transfer of the file.
|
protected void |
transferResources(ProxyConnector connector,
RemoteRepositoryContent remoteRepository,
Path tmpMd5,
Path tmpSha1,
Path tmpResource,
String url,
String remotePath,
Path resource,
Path workingDirectory,
ManagedRepositoryContent repository) |
private void |
transferSimpleFile(org.apache.maven.wagon.Wagon wagon,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
Path origFile,
Path destFile)
Perform the transfer of the remote file to the local file specified.
|
private void |
validatePolicies(Map<String,? extends DownloadPolicy> policies,
Map<String,String> settings,
Properties request,
Path localFile)
Apply the policies.
|
private void |
validatePolicies(Map<String,DownloadErrorPolicy> policies,
Map<String,String> settings,
Properties request,
ArtifactReference artifact,
RemoteRepositoryContent content,
Path localFile,
Exception exception,
Map<String,Exception> previousExceptions) |
private org.slf4j.Logger log
@Inject @Named(value="archivaConfiguration#default") private ArchivaConfiguration archivaConfiguration
@Inject @Named(value="repositoryContentFactory#default") private RepositoryContentFactory repositoryFactory
@Inject @Named(value="metadataTools#default") private MetadataTools metadataTools
@Inject private Map<String,PreDownloadPolicy> preDownloadPolicies
@Inject private Map<String,PostDownloadPolicy> postDownloadPolicies
@Inject private Map<String,DownloadErrorPolicy> downloadErrorPolicies
@Inject private UrlFailureCache urlFailureCache
private ConcurrentMap<String,List<ProxyConnector>> proxyConnectorMap
private ConcurrentMap<String,org.apache.maven.wagon.proxy.ProxyInfo> networkProxyMap
@Inject private WagonFactory wagonFactory
@Inject @Named(value="archivaTaskScheduler#repository") private ArchivaTaskScheduler<RepositoryTask> scheduler
@Inject private RepositoryRegistry repositoryRegistry
@Inject private NetworkProxyAdmin networkProxyAdmin
@Inject @Named(value="fileLockManager#default") private FileLockManager fileLockManager
public DefaultRepositoryProxyConnectors()
@PostConstruct public void initialize()
private void initConnectorsAndNetworkProxies()
private List<ProxyConnectorRuleConfiguration> findProxyConnectorRules(String sourceRepository, String targetRepository, List<ProxyConnectorRuleConfiguration> all)
public Path fetchFromProxies(ManagedRepositoryContent repository, ArtifactReference artifact) throws ProxyDownloadException
RepositoryProxyConnectorsfetchFromProxies in interface RepositoryProxyConnectorsrepository - the source repository to use. (must be a managed repository)artifact - the artifact to fetch.ProxyDownloadException - if there was a problem fetching the content from the target repositories.public Path fetchFromProxies(ManagedRepositoryContent repository, String path)
RepositoryProxyConnectorsfetchFromProxies in interface RepositoryProxyConnectorsrepository - the source repository to use. (must be a managed repository)path - the path of the resource to fetchpublic ProxyFetchResult fetchMetadataFromProxies(ManagedRepositoryContent repository, String logicalPath)
RepositoryProxyConnectorsfetchMetadataFromProxies in interface RepositoryProxyConnectorsrepository - the source repository to use. (must be a managed repository)logicalPath - the metadata to fetch.protected void transferResources(ProxyConnector connector, RemoteRepositoryContent remoteRepository, Path tmpMd5, Path tmpSha1, Path tmpResource, String url, String remotePath, Path resource, Path workingDirectory, ManagedRepositoryContent repository) throws ProxyException, NotModifiedException, RepositoryAdminException
connector - remoteRepository - tmpMd5 - tmpSha1 - tmpResource - url - remotePath - resource - workingDirectory - repository - ProxyExceptionNotModifiedExceptionRepositoryAdminExceptionprivate void transferArtifact(org.apache.maven.wagon.Wagon wagon, RemoteRepositoryContent remoteRepository, String remotePath, ManagedRepositoryContent repository, Path resource, Path tmpDirectory, Path destFile) throws ProxyException
ProxyExceptionprivate long getLastModified(Path file)
private boolean hasBeenUpdated(Path file, long originalLastModified)
private Path toLocalRepoFile(ManagedRepositoryContent repository, RemoteRepositoryContent targetRepository, String targetPath)
public boolean hasProxies(ManagedRepositoryContent repository)
hasProxies in interface RepositoryProxyConnectorsrepository - the source repository to look for.private Path toLocalFile(ManagedRepositoryContent repository, ArtifactReference artifact)
private boolean fileExists(Path file)
file - the file to test. (may be null)private Path transferFile(ProxyConnector connector, RemoteRepositoryContent remoteRepository, String remotePath, ManagedRepositoryContent repository, Path resource, Properties requestProperties, boolean executeConsumers) throws ProxyException, NotModifiedException, RepositoryAdminException
connector - the connector configuration to use.remoteRepository - the remote repository get the resource from.remotePath - the path in the remote repository to the resource to get.repository - the managed repository that will hold the fileresource - the local file to place the downloaded resource intorequestProperties - the request properties to utilize for policy handling.executeConsumers - whether to execute the consumers after proxyingNotFoundException - if the file was not found on the remote repository.NotModifiedException - if the localFile was present, and the resource was present on remote repository, but
the remote resource is not newer than the local File.ProxyException - if transfer was unsuccessful.RepositoryAdminExceptionprivate void queueRepositoryTask(String repositoryId, Path localFile)
private void moveFileIfExists(Path fileToMove, Path directory) throws ProxyException
fileToMove - this could be either the main artifact, sha1 or md5 checksum file.directory - directory to write files toProxyExceptionprivate void transferChecksum(org.apache.maven.wagon.Wagon wagon, RemoteRepositoryContent remoteRepository, String remotePath, ManagedRepositoryContent repository, Path resource, Path tmpDirectory, String ext, Path destFile) throws ProxyException
Quietly transfer the checksum file from the remote repository to the local file.
wagon - the wagon instance (should already be connected) to use.remoteRepository - the remote repository to transfer from.remotePath - the remote path to the resource to get.repository - the managed repository that will hold the fileresource - the local file that should contain the downloaded contentstmpDirectory - the temporary directory to download toext - the type of checksum to transfer (example: ".md5" or ".sha1")ProxyException - if copying the downloaded file into place did not succeed.private void transferSimpleFile(org.apache.maven.wagon.Wagon wagon, RemoteRepositoryContent remoteRepository, String remotePath, ManagedRepositoryContent repository, Path origFile, Path destFile) throws ProxyException
wagon - the wagon instance to use.remoteRepository - the remote repository to useremotePath - the remote path to attempt to getrepository - the managed repository that will hold the fileorigFile - the local file to save toProxyException - if there was a problem moving the downloaded file into place.private void validatePolicies(Map<String,? extends DownloadPolicy> policies, Map<String,String> settings, Properties request, Path localFile) throws PolicyViolationException
policies - the map of policies to execute. (Map of String policy keys, to DownloadPolicy objects)settings - the map of settings for the policies to execute. (Map of String policy keys, to String policy
setting)request - the request properties (utilized by the DownloadPolicy.applyPolicy(String, Properties, Path)
)localFile - the local file (utilized by the DownloadPolicy.applyPolicy(String, Properties, Path))PolicyViolationExceptionprivate void validatePolicies(Map<String,DownloadErrorPolicy> policies, Map<String,String> settings, Properties request, ArtifactReference artifact, RemoteRepositoryContent content, Path localFile, Exception exception, Map<String,Exception> previousExceptions) throws ProxyDownloadException
ProxyDownloadExceptionprivate Path createWorkingDirectory(ManagedRepositoryContent repository)
repository - private void moveTempToTarget(Path temp, Path target) throws ProxyException
temp - The completed download filetarget - The final location of the downloaded fileProxyException - when the temp file cannot replace the target fileprivate boolean connectToRepository(ProxyConnector connector, org.apache.maven.wagon.Wagon wagon, RemoteRepositoryContent remoteRepository)
connector - the connector configuration to utilize (for obtaining network proxy configuration from)wagon - the wagon instance to establish the connection on.remoteRepository - the remote repository to connect to.private boolean matchesPattern(String path, List<String> patterns)
path - the path to test.patterns - the list of patterns to check.public List<ProxyConnector> getProxyConnectors(ManagedRepositoryContent repository)
getProxyConnectors in interface RepositoryProxyConnectorsrepository - the source repository to look for.ProxyConnector objects.public void afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
afterConfigurationChange in interface org.apache.archiva.redback.components.registry.RegistryListenerprotected String addParameters(String path, RemoteRepository remoteRepository)
public void beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
beforeConfigurationChange in interface org.apache.archiva.redback.components.registry.RegistryListenerpublic ArchivaConfiguration getArchivaConfiguration()
public void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration)
public RepositoryContentFactory getRepositoryFactory()
public void setRepositoryFactory(RepositoryContentFactory repositoryFactory)
public MetadataTools getMetadataTools()
public void setMetadataTools(MetadataTools metadataTools)
public UrlFailureCache getUrlFailureCache()
public void setUrlFailureCache(UrlFailureCache urlFailureCache)
public WagonFactory getWagonFactory()
public void setWagonFactory(WagonFactory wagonFactory)
public Map<String,PreDownloadPolicy> getPreDownloadPolicies()
public void setPreDownloadPolicies(Map<String,PreDownloadPolicy> preDownloadPolicies)
public Map<String,PostDownloadPolicy> getPostDownloadPolicies()
public void setPostDownloadPolicies(Map<String,PostDownloadPolicy> postDownloadPolicies)
public Map<String,DownloadErrorPolicy> getDownloadErrorPolicies()
public void setDownloadErrorPolicies(Map<String,DownloadErrorPolicy> downloadErrorPolicies)
Copyright © 2006–2018 The Apache Software Foundation. All rights reserved.