summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-proxy/src
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-10-02 19:57:47 +0000
committerOlivier Lamy <olamy@apache.org>2012-10-02 19:57:47 +0000
commitb36cafd1c99ba2bc20739d4c6b59a9948a43e780 (patch)
tree2c607d1a0d44be7571c433d3f7955d77b43442d4 /archiva-modules/archiva-base/archiva-proxy/src
parent774f97551febd023e6f600da00bcc00512bd8404 (diff)
downloadarchiva-b36cafd1c99ba2bc20739d4c6b59a9948a43e780.tar.gz
archiva-b36cafd1c99ba2bc20739d4c6b59a9948a43e780.zip
implements use of ProxyConnectorRules when fetching files from remote
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1393146 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-proxy/src')
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java69
1 files changed, 61 insertions, 8 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
index f15e7866d..bf2a8039f 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
@@ -22,11 +22,14 @@ package org.apache.archiva.proxy;
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.networkproxy.NetworkProxyAdmin;
import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ConfigurationNames;
import org.apache.archiva.configuration.NetworkProxyConfiguration;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorRuleConfiguration;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.Keys;
import org.apache.archiva.model.RepositoryURL;
@@ -92,7 +95,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @todo exception handling needs work - "not modified" is not really an exceptional case, and it has more layers than
* your average brown onion
*/
-@Service ( "repositoryProxyConnectors#default" )
+@Service ("repositoryProxyConnectors#default")
public class DefaultRepositoryProxyConnectors
implements RepositoryProxyConnectors, RegistryListener
{
@@ -102,21 +105,21 @@ public class DefaultRepositoryProxyConnectors
*
*/
@Inject
- @Named ( value = "archivaConfiguration#default" )
+ @Named (value = "archivaConfiguration#default")
private ArchivaConfiguration archivaConfiguration;
/**
*
*/
@Inject
- @Named ( value = "repositoryContentFactory#default" )
+ @Named (value = "repositoryContentFactory#default")
private RepositoryContentFactory repositoryFactory;
/**
*
*/
@Inject
- @Named ( value = "metadataTools#default" )
+ @Named (value = "metadataTools#default")
private MetadataTools metadataTools;
/**
@@ -157,7 +160,7 @@ public class DefaultRepositoryProxyConnectors
*
*/
@Inject
- @Named ( value = "archivaTaskScheduler#repository" )
+ @Named (value = "archivaTaskScheduler#repository")
private ArchivaTaskScheduler scheduler;
@Inject
@@ -171,14 +174,19 @@ public class DefaultRepositoryProxyConnectors
}
- @SuppressWarnings ( "unchecked" )
+ @SuppressWarnings ("unchecked")
private void initConnectorsAndNetworkProxies()
{
ProxyConnectorOrderComparator proxyOrderSorter = new ProxyConnectorOrderComparator();
this.proxyConnectorMap.clear();
- List<ProxyConnectorConfiguration> proxyConfigs = archivaConfiguration.getConfiguration().getProxyConnectors();
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ List<ProxyConnectorRuleConfiguration> allProxyConnectorRuleConfigurations =
+ configuration.getProxyConnectorRuleConfigurations();
+
+ List<ProxyConnectorConfiguration> proxyConfigs = configuration.getProxyConnectors();
for ( ProxyConnectorConfiguration proxyConfig : proxyConfigs )
{
String key = proxyConfig.getSourceRepoId();
@@ -214,6 +222,29 @@ public class DefaultRepositoryProxyConnectors
}
connector.setWhitelist( whitelist );
+ List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations =
+ findProxyConnectorRules( connector.getSourceRepository().getId(),
+ connector.getTargetRepository().getId(),
+ allProxyConnectorRuleConfigurations );
+
+ if ( !proxyConnectorRuleConfigurations.isEmpty() )
+ {
+ for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : proxyConnectorRuleConfigurations )
+ {
+ if ( StringUtils.equals( proxyConnectorRuleConfiguration.getRuleType(),
+ ProxyConnectorRuleType.BLACK_LIST.getRuleType() ) )
+ {
+ connector.getBlacklist().add( proxyConnectorRuleConfiguration.getPattern() );
+ }
+
+ if ( StringUtils.equals( proxyConnectorRuleConfiguration.getRuleType(),
+ ProxyConnectorRuleType.WHITE_LIST.getRuleType() ) )
+ {
+ connector.getWhitelist().add( proxyConnectorRuleConfiguration.getPattern() );
+ }
+ }
+ }
+
// Get other connectors
List<ProxyConnector> connectors = this.proxyConnectorMap.get( key );
if ( connectors == null )
@@ -263,6 +294,28 @@ public class DefaultRepositoryProxyConnectors
}
+ private List<ProxyConnectorRuleConfiguration> findProxyConnectorRules( String sourceRepository,
+ String targetRepository,
+ List<ProxyConnectorRuleConfiguration> all )
+ {
+ List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations =
+ new ArrayList<ProxyConnectorRuleConfiguration>();
+
+ for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : all )
+ {
+ for ( ProxyConnectorConfiguration proxyConnector : proxyConnectorRuleConfiguration.getProxyConnectors() )
+ {
+ if ( StringUtils.equals( sourceRepository, proxyConnector.getSourceRepoId() ) && StringUtils.equals(
+ targetRepository, proxyConnector.getTargetRepoId() ) )
+ {
+ proxyConnectorRuleConfigurations.add( proxyConnectorRuleConfiguration );
+ }
+ }
+ }
+
+ return proxyConnectorRuleConfigurations;
+ }
+
public File fetchFromProxies( ManagedRepositoryContent repository, ArtifactReference artifact )
throws ProxyDownloadException
{
@@ -1171,7 +1224,7 @@ public class DefaultRepositoryProxyConnectors
{
synchronized ( this.proxyConnectorMap )
{
- List<ProxyConnector> ret = (List<ProxyConnector>) this.proxyConnectorMap.get( repository.getId() );
+ List<ProxyConnector> ret = this.proxyConnectorMap.get( repository.getId() );
if ( ret == null )
{
return Collections.emptyList();