archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1393146 - in /archiva/trunk/archiva-modules: archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/ archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyc...
Date Tue, 02 Oct 2012 19:57:47 GMT
Author: olamy
Date: Tue Oct  2 19:57:47 2012
New Revision: 1393146

URL: http://svn.apache.org/viewvc?rev=1393146&view=rev
Log:
implements use of ProxyConnectorRules when fetching files from remote

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnectorrule/DefaultProxyConnectorRuleAdmin.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java?rev=1393146&r1=1393145&r2=1393146&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
Tue Oct  2 19:57:47 2012
@@ -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.ConcurrentHa
  * @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 DefaultRepositoryProxyConne
      *
      */
     @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 DefaultRepositoryProxyConne
      *
      */
     @Inject
-    @Named ( value = "archivaTaskScheduler#repository" )
+    @Named (value = "archivaTaskScheduler#repository")
     private ArchivaTaskScheduler scheduler;
 
     @Inject
@@ -171,14 +174,19 @@ public class DefaultRepositoryProxyConne
 
     }
 
-    @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 DefaultRepositoryProxyConne
                 }
                 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 DefaultRepositoryProxyConne
 
     }
 
+    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 DefaultRepositoryProxyConne
     {
         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();

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnectorrule/DefaultProxyConnectorRuleAdmin.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnectorrule/DefaultProxyConnectorRuleAdmin.java?rev=1393146&r1=1393145&r2=1393146&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnectorrule/DefaultProxyConnectorRuleAdmin.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnectorrule/DefaultProxyConnectorRuleAdmin.java
Tue Oct  2 19:57:47 2012
@@ -127,7 +127,7 @@ public class DefaultProxyConnectorRuleAd
         {
             if ( StringUtils.equals( proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern()
)
                 && StringUtils.equals( proxyConnectorRuleConfiguration.getRuleType(),
-                                       proxyConnectorRule.getProxyConnectorRuleType().toString()
) )
+                                       proxyConnectorRule.getProxyConnectorRuleType().getRuleType()
) )
             {
                 toSave = true;
             }
@@ -154,7 +154,7 @@ public class DefaultProxyConnectorRuleAd
         {
             if ( StringUtils.equals( proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern()
)
                 && StringUtils.equals( proxyConnectorRuleConfiguration.getRuleType(),
-                                       proxyConnectorRule.getProxyConnectorRuleType().toString()
) )
+                                       proxyConnectorRule.getProxyConnectorRuleType().getRuleType()
) )
             {
                 List<ProxyConnectorConfiguration> proxyConnectors =
                     new ArrayList<ProxyConnectorConfiguration>( proxyConnectorRule.getProxyConnectors().size()
);

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js?rev=1393146&r1=1393145&r2=1393146&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
Tue Oct  2 19:57:47 2012
@@ -137,50 +137,50 @@ define("redback",["jquery","utils","jque
 
     $('#modal-register-footer').append(smallSpinnerImg());
 
-    $.ajax({
-        url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
-        type: "GET",
-        dataType: 'text',
-        success: function(data){
-          $.log("applicationUrl ok:"+data);
-
-          var user = {
-            username: $("#user-register-form-username").val(),
-            fullName: $("#user-register-form-fullname").val(),
-            email: $("#user-register-form-email").val()
-          };
-
-          var userRegistrationRequest=new UserRegistrationRequest(user,data);
-          $.ajax({
-            url:  'restServices/redbackServices/userService/registerUser',
-            data:  JSON.stringify(userRegistrationRequest),
-            type: 'POST',
-            contentType: "application/json",
-            success: function(result){
-              var registered = false;
-              if (result == "-1") {
-                registered = false;
-              } else {
-                registered = true;
-              }
-
-              if (registered == true) {
+      $.ajax({
+          url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
+          type: "GET",
+          dataType: 'text',
+          success: function(data){
+            $.log("applicationUrl ok:"+data);
+
+            var user = {
+              username: $("#user-register-form-username").val(),
+              fullName: $("#user-register-form-fullname").val(),
+              email: $("#user-register-form-email").val()
+            };
+
+            var userRegistrationRequest=new UserRegistrationRequest(user,data);
+            $.ajax({
+              url:  'restServices/redbackServices/userService/registerUser',
+              data:  JSON.stringify(userRegistrationRequest),
+              type: 'POST',
+              contentType: "application/json",
+              success: function(result){
+                var registered = false;
+                if (result == "-1") {
+                  registered = false;
+                } else {
+                  registered = true;
+                }
+
+                if (registered == true) {
+                  window.modalRegisterWindow.modal('hide');
+                  $("#register-link").hide();
+                  // FIXME i18n
+                  displaySuccessMessage("registered your key has been sent");
+                }
+              },
+              complete: function(){
+                $("#modal-register-ok").removeAttr("disabled");
+                removeSmallSpinnerImg();
+              },
+              error: function(result) {
                 window.modalRegisterWindow.modal('hide');
-                $("#register-link").hide();
-                // FIXME i18n
-                displaySuccessMessage("registered your key has been sent");
               }
-            },
-            complete: function(){
-              $("#modal-register-ok").removeAttr("disabled");
-              removeSmallSpinnerImg();
-            },
-            error: function(result) {
-              window.modalRegisterWindow.modal('hide');
-            }
-          });
-        }
-    });
+            });
+          }
+      });
 
   }
 



Mime
View raw message