@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 ArchivaTaskScheduler |
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 File |
createWorkingDirectory(ManagedRepositoryContent repository)
Creates a working directory
|
File |
fetchFromProxies(ManagedRepositoryContent repository,
ArtifactReference artifact)
Performs the artifact fetch operation against the target repositories
of the provided source repository.
|
File |
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(File 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(File 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(File 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(File fileToMove,
File directory)
Moves the file into repository location if it exists
|
private void |
moveTempToTarget(File temp,
File target)
Used to move the temporary file to its real destination.
|
private void |
queueRepositoryTask(String repositoryId,
File 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 File |
toLocalFile(ManagedRepositoryContent repository,
ArtifactReference artifact) |
private File |
toLocalRepoFile(ManagedRepositoryContent repository,
RemoteRepositoryContent targetRepository,
String targetPath) |
private void |
transferArtifact(org.apache.maven.wagon.Wagon wagon,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
File resource,
File tmpDirectory,
File destFile) |
private void |
transferChecksum(org.apache.maven.wagon.Wagon wagon,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
File resource,
File tmpDirectory,
String ext,
File destFile)
Quietly transfer the checksum file from the remote repository to the local file.
|
private File |
transferFile(ProxyConnector connector,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
File resource,
Properties requestProperties,
boolean executeConsumers)
Perform the transfer of the file.
|
protected void |
transferResources(ProxyConnector connector,
RemoteRepositoryContent remoteRepository,
File tmpMd5,
File tmpSha1,
File tmpResource,
String url,
String remotePath,
File resource,
File workingDirectory,
ManagedRepositoryContent repository) |
private void |
transferSimpleFile(org.apache.maven.wagon.Wagon wagon,
RemoteRepositoryContent remoteRepository,
String remotePath,
ManagedRepositoryContent repository,
File origFile,
File 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,
File localFile)
Apply the policies.
|
private void |
validatePolicies(Map<String,DownloadErrorPolicy> policies,
Map<String,String> settings,
Properties request,
ArtifactReference artifact,
RemoteRepositoryContent content,
File 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 scheduler
@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 File fetchFromProxies(ManagedRepositoryContent repository, ArtifactReference artifact) throws ProxyDownloadException
RepositoryProxyConnectors
fetchFromProxies
in interface RepositoryProxyConnectors
repository
- 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 File fetchFromProxies(ManagedRepositoryContent repository, String path)
RepositoryProxyConnectors
fetchFromProxies
in interface RepositoryProxyConnectors
repository
- the source repository to use. (must be a managed repository)path
- the path of the resource to fetchpublic ProxyFetchResult fetchMetadataFromProxies(ManagedRepositoryContent repository, String logicalPath)
RepositoryProxyConnectors
fetchMetadataFromProxies
in interface RepositoryProxyConnectors
repository
- the source repository to use. (must be a managed repository)logicalPath
- the metadata to fetch.protected void transferResources(ProxyConnector connector, RemoteRepositoryContent remoteRepository, File tmpMd5, File tmpSha1, File tmpResource, String url, String remotePath, File resource, File workingDirectory, ManagedRepositoryContent repository) throws ProxyException, NotModifiedException, RepositoryAdminException
connector
- remoteRepository
- tmpMd5
- tmpSha1
- tmpResource
- url
- remotePath
- resource
- workingDirectory
- repository
- ProxyException
NotModifiedException
RepositoryAdminException
private void transferArtifact(org.apache.maven.wagon.Wagon wagon, RemoteRepositoryContent remoteRepository, String remotePath, ManagedRepositoryContent repository, File resource, File tmpDirectory, File destFile) throws ProxyException
ProxyException
private long getLastModified(File file)
private boolean hasBeenUpdated(File file, long originalLastModified)
private File toLocalRepoFile(ManagedRepositoryContent repository, RemoteRepositoryContent targetRepository, String targetPath)
public boolean hasProxies(ManagedRepositoryContent repository)
hasProxies
in interface RepositoryProxyConnectors
repository
- the source repository to look for.private File toLocalFile(ManagedRepositoryContent repository, ArtifactReference artifact)
private boolean fileExists(File file)
file
- the file to test. (may be null)private File transferFile(ProxyConnector connector, RemoteRepositoryContent remoteRepository, String remotePath, ManagedRepositoryContent repository, File 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.RepositoryAdminException
private void queueRepositoryTask(String repositoryId, File localFile)
private void moveFileIfExists(File fileToMove, File directory) throws ProxyException
fileToMove
- this could be either the main artifact, sha1 or md5 checksum file.directory
- directory to write files toProxyException
private void transferChecksum(org.apache.maven.wagon.Wagon wagon, RemoteRepositoryContent remoteRepository, String remotePath, ManagedRepositoryContent repository, File resource, File tmpDirectory, String ext, File 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, File origFile, File 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, File 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, File)
)localFile
- the local file (utilized by the DownloadPolicy.applyPolicy(String, Properties, File)
)PolicyViolationException
private void validatePolicies(Map<String,DownloadErrorPolicy> policies, Map<String,String> settings, Properties request, ArtifactReference artifact, RemoteRepositoryContent content, File localFile, Exception exception, Map<String,Exception> previousExceptions) throws ProxyDownloadException
ProxyDownloadException
private File createWorkingDirectory(ManagedRepositoryContent repository)
repository
- private void moveTempToTarget(File temp, File 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 RepositoryProxyConnectors
repository
- 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.RegistryListener
protected 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.RegistryListener
public 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–2022 The Apache Software Foundation. All rights reserved.