]> source.dussan.org Git - archiva.git/commitdiff
Adapting base modules to the new repository api
authorMartin Stockhammer <martin_s@apache.org>
Wed, 1 Nov 2017 14:38:00 +0000 (15:38 +0100)
committerMartin Stockhammer <martin_s@apache.org>
Wed, 1 Nov 2017 14:38:00 +0000 (15:38 +0100)
Using the repository api and RepositoryRegistry for repo access

30 files changed:
archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/legacy/LegacyConverterArtifactConsumer.java
archiva-modules/archiva-base/archiva-indexer/pom.xml
archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchOSGITest.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java
archiva-modules/archiva-base/archiva-indexer/src/test/resources/spring-context.xml
archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnector.java
archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MockConfiguration.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-proxy/src/test/resources/spring-context.xml
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScanStatistics.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScanner.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScannerInstance.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/functors/TriggerBeginScanClosure.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/functors/TriggerScanCompletedClosure.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/InvalidScanConsumer.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/KnownScanConsumer.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryScannerTest.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/SampleKnownConsumer.java
archiva-modules/archiva-base/archiva-test-utils/pom.xml
archiva-modules/archiva-base/pom.xml

index ff04828e388b62daf89dcc648cfcf6774b91a463..3e8e168f9ae349c25aa8f25fc83598cbd46d1449 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.archiva.common.utils.PathUtil;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.archiva.converter.RepositoryConversionException;
+import org.apache.archiva.repository.BasicManagedRepository;
 import org.apache.archiva.repository.scanner.RepositoryScanner;
 import org.apache.archiva.repository.scanner.RepositoryScannerException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -40,6 +41,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * DefaultLegacyRepositoryConverter
@@ -90,10 +92,8 @@ public class DefaultLegacyRepositoryConverter
         {
             String defaultRepositoryUrl = PathUtil.toUrl( repositoryDirectory );
 
-            ManagedRepository legacyRepository = new ManagedRepository();
-            legacyRepository.setId( "legacy" );
-            legacyRepository.setName( "Legacy Repository" );
-            legacyRepository.setLocation( legacyRepositoryDirectory.toAbsolutePath().toString() );
+            BasicManagedRepository legacyRepository = new BasicManagedRepository( "legacy", "Legacy Repository");
+            legacyRepository.setLocation( legacyRepositoryDirectory.toAbsolutePath().toUri() );
             legacyRepository.setLayout( "legacy" );
 
             ArtifactRepository repository =
index 1dc82a50da2005466df644b471d20803239fa7a6..7fb542eb106d2f267d312b2ac931c885b3046e1b 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.archiva.converter.legacy;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
 import org.apache.archiva.consumers.AbstractMonitoredConsumer;
@@ -28,6 +27,7 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.archiva.converter.artifact.ArtifactConversionException;
 import org.apache.archiva.converter.artifact.ArtifactConverter;
 import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.archiva.repository.ManagedRepositoryContent;
 import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent;
 import org.apache.archiva.repository.layout.LayoutException;
@@ -85,7 +85,7 @@ public class LegacyConverterArtifactConsumer
     }
 
     @Override
-    public void beginScan( ManagedRepository repository, Date whenGathered )
+    public void beginScan( org.apache.archiva.repository.ManagedRepository repository, Date whenGathered )
         throws ConsumerException
     {
         this.managedRepository = new ManagedDefaultRepositoryContent();
index a9f24ef0ee120ba6cef9461f974b671e75901f93..992fcf7effc92850cd7adc3a0b3c65e16fd80dbe 100644 (file)
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-common</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+    </dependency>
+
 
     <dependency>
       <groupId>org.springframework</groupId>
index 0e410164868a72c50afda4480760cf535fd9a453..892d7b71a416e46e1877de6238722ac4ddc91e5a 100644 (file)
@@ -261,6 +261,12 @@ public class MavenRepositorySearch
         {
             throw new RepositorySearchException( "No search fields set." );
         }
+        System.err.println("CLAUSES "+q.getClauses());
+        if (q.getClauses()!=null) {
+            for (BooleanClause cl : q.getClauses()) {
+                System.err.println("Clause "+cl);
+            }
+        }
 
         return search( limits, q, indexingContextIds, Collections.<ArtifactInfoFilter>emptyList(),
                        searchFields.getRepositories(), searchFields.isIncludePomArtifacts() );
index e2946ff0084f311a22b98f1637d810d17cbcce67..ab85ec59b67cb731971e52d052b410766ac24cdf 100644 (file)
@@ -26,7 +26,9 @@ import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.common.utils.FileUtils;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.ConfigurationListener;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.repository.RepositoryRegistry;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.maven.index.ArtifactContext;
@@ -52,6 +54,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * @author Olivier Lamy
@@ -78,6 +81,9 @@ public abstract class AbstractMavenRepositorySearch
     @Inject
     ArtifactContextProducer artifactContextProducer;
 
+    @Inject
+    RepositoryRegistry repositoryRegistry;
+
     IMocksControl archivaConfigControl;
 
     Configuration config;
@@ -116,17 +122,28 @@ public abstract class AbstractMavenRepositorySearch
 
         DefaultProxyConnectorAdmin defaultProxyConnectorAdmin = new DefaultProxyConnectorAdmin();
         defaultProxyConnectorAdmin.setArchivaConfiguration( archivaConfig );
+        repositoryRegistry.setArchivaConfiguration( archivaConfig );
 
         search = new MavenRepositorySearch( nexusIndexer, defaultManagedRepositoryAdmin, defaultProxyConnectorAdmin,
                                             queryCreator );
 
         defaultManagedRepositoryAdmin.setIndexer( nexusIndexer );
         defaultManagedRepositoryAdmin.setIndexCreators( indexCreators );
+        assertNotNull( repositoryRegistry );
+        defaultManagedRepositoryAdmin.setRepositoryRegistry( repositoryRegistry );
 
         config = new Configuration();
         config.addManagedRepository( createRepositoryConfig( TEST_REPO_1 ) );
         config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
         config.addManagedRepository( createRepositoryConfig( REPO_RELEASE ) );
+
+
+        archivaConfig.addListener( EasyMock.anyObject( ConfigurationListener.class ) );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn(config).anyTimes();
+        archivaConfigControl.replay();
+        repositoryRegistry.reload();
+        archivaConfigControl.reset();
     }
 
     @After
index 7257e4a925d291f3af14ea562df1d8fa626bf6cd..69429303db439b2a301c5768fa503ac880ab8a09 100644 (file)
@@ -26,6 +26,7 @@ import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * @author Olivier Lamy
@@ -44,7 +45,8 @@ public class MavenRepositorySearchOSGITest
         List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
 
         // search artifactId
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
index a9893111c68949c636576717c23be27cafd0f350..3c10633b0f6fe92f39c6ea03ae0210d77167cc98 100644 (file)
@@ -19,15 +19,20 @@ package org.apache.archiva.indexer.search;
  * under the License.
  */
 
+import org.apache.archiva.configuration.ConfigurationEvent;
+import org.apache.archiva.configuration.ConfigurationListener;
 import org.apache.archiva.indexer.util.SearchUtil;
+import org.apache.archiva.repository.RepositoryRegistry;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.maven.index_shaded.lucene.index.IndexUpgrader;
 import org.codehaus.plexus.util.FileUtils;
 import org.easymock.EasyMock;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
 
+import javax.inject.Inject;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
@@ -35,6 +40,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 
 
 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
@@ -106,7 +112,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
 
         // search artifactId
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -125,9 +132,10 @@ public class MavenRepositorySearchTest
 
         archivaConfigControl.reset();
 
-        // search groupId
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
+        // search groupId
         archivaConfigControl.replay();
 
         results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
@@ -149,7 +157,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
 
         // search artifactId
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -169,7 +178,8 @@ public class MavenRepositorySearchTest
         archivaConfigControl.reset();
 
         // search groupId
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -193,7 +203,8 @@ public class MavenRepositorySearchTest
         selectedRepos.add( TEST_REPO_1 );
 
         // search artifactId
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -223,7 +234,8 @@ public class MavenRepositorySearchTest
         selectedRepos.add( TEST_REPO_1 );
 
         // search artifactId
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -259,7 +271,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<>();
         selectedRepos.add( TEST_REPO_1 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
         archivaConfigControl.replay();
 
         SearchResults results = search.search( "user", selectedRepos, "archiva search", null, null );
@@ -283,7 +296,8 @@ public class MavenRepositorySearchTest
         SearchResultLimits limits = new SearchResultLimits( 0 );
         limits.setPageSize( 1 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -303,7 +317,8 @@ public class MavenRepositorySearchTest
         limits = new SearchResultLimits( 1 );
         limits.setPageSize( 1 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -338,7 +353,8 @@ public class MavenRepositorySearchTest
 
         config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 5 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -373,7 +389,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<>();
         selectedRepos.add( TEST_REPO_1 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -392,7 +409,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<>();
         selectedRepos.add( TEST_REPO_1 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -410,8 +428,6 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<>();
         selectedRepos.add( "non-existing-repo" );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
-
         archivaConfigControl.replay();
 
         SearchResults results = search.search( "user", selectedRepos, "org.apache.archiva", null, null );
@@ -433,7 +449,8 @@ public class MavenRepositorySearchTest
         List<String> previousSearchTerms = new ArrayList<>();
         previousSearchTerms.add( "archiva-test" );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -471,7 +488,8 @@ public class MavenRepositorySearchTest
         searchFields.setVersion( "1.0" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -506,7 +524,8 @@ public class MavenRepositorySearchTest
         SearchResultLimits limits = new SearchResultLimits( 0 );
         limits.setPageSize( 1 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -524,7 +543,8 @@ public class MavenRepositorySearchTest
         limits = new SearchResultLimits( 1 );
         limits.setPageSize( 1 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -556,7 +576,8 @@ public class MavenRepositorySearchTest
         searchFields.setArtifactId( "artifactid-numeric" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -599,7 +620,8 @@ public class MavenRepositorySearchTest
 
         try
         {
-            EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+            EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+            EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
             archivaConfigControl.replay();
 
@@ -633,15 +655,16 @@ public class MavenRepositorySearchTest
 
         try
         {
-            EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
+            EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+            EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
             archivaConfigControl.replay();
 
             search.search( "user", searchFields, null );
 
             archivaConfigControl.verify();
 
-            fail( "A RepositorySearchExcecption should have been thrown." );
+            fail( "A RepositorySearchException should have been thrown." );
         }
         catch ( RepositorySearchException e )
         {
@@ -666,7 +689,8 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "org.apache.archiva.test.App" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -697,7 +721,8 @@ public class MavenRepositorySearchTest
         searchFields.setPackaging( "jar" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -725,7 +750,9 @@ public class MavenRepositorySearchTest
         searchFields.setPackaging( "war" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
+
         archivaConfigControl.replay();
 
         SearchResults results = search.search( "user", searchFields, null );
@@ -748,7 +775,8 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "com.classname.search.App" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -776,7 +804,8 @@ public class MavenRepositorySearchTest
         searchFields.setGroupId( "org.apache.archiva" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -800,7 +829,8 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "SomeClass" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
@@ -849,8 +879,6 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "SomeClass" );
         searchFields.setRepositories( selectedRepos );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
-
         archivaConfigControl.replay();
 
         SearchResults results = search.search( "user", searchFields, null );
@@ -881,7 +909,8 @@ public class MavenRepositorySearchTest
         SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
         limits.setPageSize( 300 );
 
-        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 5 );
+        EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+        EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
 
         archivaConfigControl.replay();
 
index e0bf5c41c680a462898ac48dc8cc08a757cfff7f..487790661845850cf30648b07899e1a802b10d40 100644 (file)
        default-lazy-init="false">
 
   <context:annotation-config/>
+  <context:component-scan base-package="org.apache.archiva.repository.content.maven2" />
+
+  <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+  <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+
 
   <bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
     <property name="properties">
index e8c20340af526008039c8897c012f6e849b0d409..d653de572fa39818d46251dd27d4131291b9bfdb 100644 (file)
@@ -137,7 +137,7 @@ public class ProxyConnector
 
         sb.append( "ProxyConnector[\n" );
         sb.append( "  source: [managed] " ).append( this.sourceRepository.getRepoRoot() ).append( "\n" );
-        sb.append( "  target: [remote] " ).append( this.targetRepository.getRepository().getUrl() ).append( "\n" );
+        sb.append( "  target: [remote] " ).append( this.targetRepository.getRepository().getLocation() ).append( "\n" );
         sb.append( "  proxyId:" ).append( this.proxyId ).append( "\n" );
 
         Iterator<String> keys = this.policies.keySet().iterator();
index 4266bf734e329a4750d50812ecb6cd68be7345bb..a76e74457e1227eb9fbf1fa5783b8c917a311e1b 100644 (file)
@@ -22,17 +22,27 @@ package org.apache.archiva.proxy;
 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.beans.RemoteRepository;
 import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
 import org.apache.archiva.common.filelock.FileLockException;
 import org.apache.archiva.common.filelock.FileLockManager;
 import org.apache.archiva.common.filelock.FileLockTimeoutException;
 import org.apache.archiva.common.filelock.Lock;
-import org.apache.archiva.configuration.*;
+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;
-import org.apache.archiva.policies.*;
+import org.apache.archiva.policies.DownloadErrorPolicy;
+import org.apache.archiva.policies.DownloadPolicy;
+import org.apache.archiva.policies.PolicyConfigurationException;
+import org.apache.archiva.policies.PolicyViolationException;
+import org.apache.archiva.policies.PostDownloadPolicy;
+import org.apache.archiva.policies.PreDownloadPolicy;
+import org.apache.archiva.policies.ProxyDownloadException;
 import org.apache.archiva.policies.urlcache.UrlFailureCache;
 import org.apache.archiva.proxy.common.WagonFactory;
 import org.apache.archiva.proxy.common.WagonFactoryException;
@@ -43,7 +53,16 @@ import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
 import org.apache.archiva.redback.components.registry.Registry;
 import org.apache.archiva.redback.components.registry.RegistryListener;
 import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
-import org.apache.archiva.repository.*;
+import org.apache.archiva.repository.ManagedRepository;
+import org.apache.archiva.repository.RemoteRepository;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.PasswordCredentials;
+import org.apache.archiva.repository.RemoteRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryCredentials;
+import org.apache.archiva.repository.RepositoryException;
+import org.apache.archiva.repository.RepositoryNotFoundException;
+import org.apache.archiva.repository.RepositoryRegistry;
 import org.apache.archiva.repository.metadata.MetadataTools;
 import org.apache.archiva.repository.metadata.RepositoryMetadataException;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
@@ -73,11 +92,15 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
 
 /**
  * DefaultRepositoryProxyConnectors
@@ -125,6 +148,9 @@ public class DefaultRepositoryProxyConnectors
     @Named(value = "archivaTaskScheduler#repository")
     private ArchivaTaskScheduler scheduler;
 
+    @Inject
+    private RepositoryRegistry repositoryRegistry;
+
     @Inject
     private NetworkProxyAdmin networkProxyAdmin;
 
@@ -157,86 +183,83 @@ public class DefaultRepositoryProxyConnectors
         {
             String key = proxyConfig.getSourceRepoId();
 
-            try
+            // Create connector object.
+            ProxyConnector connector = new ProxyConnector();
+
+            ManagedRepository repo = repositoryRegistry.getManagedRepository( proxyConfig.getSourceRepoId( ) );
+            if (repo==null) {
+                log.error("Cannot find source repository after config change "+proxyConfig.getSourceRepoId());
+                continue;
+            }
+            connector.setSourceRepository(repo.getContent());
+            RemoteRepository rRepo = repositoryRegistry.getRemoteRepository( proxyConfig.getTargetRepoId() );
+            if (rRepo==null) {
+                log.error("Cannot find target repository after config change "+proxyConfig.getSourceRepoId());
+                continue;
+            }
+            connector.setTargetRepository(rRepo.getContent());
+
+            connector.setProxyId( proxyConfig.getProxyId() );
+            connector.setPolicies( proxyConfig.getPolicies() );
+            connector.setOrder( proxyConfig.getOrder() );
+            connector.setDisabled( proxyConfig.isDisabled() );
+
+            // Copy any blacklist patterns.
+            List<String> blacklist = new ArrayList<>( 0 );
+            if ( CollectionUtils.isNotEmpty( proxyConfig.getBlackListPatterns() ) )
             {
-                // Create connector object.
-                ProxyConnector connector = new ProxyConnector();
-
-                connector.setSourceRepository(
-                    repositoryFactory.getManagedRepositoryContent( proxyConfig.getSourceRepoId() ) );
-                connector.setTargetRepository(
-                    repositoryFactory.getRemoteRepositoryContent( proxyConfig.getTargetRepoId() ) );
-
-                connector.setProxyId( proxyConfig.getProxyId() );
-                connector.setPolicies( proxyConfig.getPolicies() );
-                connector.setOrder( proxyConfig.getOrder() );
-                connector.setDisabled( proxyConfig.isDisabled() );
-
-                // Copy any blacklist patterns.
-                List<String> blacklist = new ArrayList<>( 0 );
-                if ( CollectionUtils.isNotEmpty( proxyConfig.getBlackListPatterns() ) )
-                {
-                    blacklist.addAll( proxyConfig.getBlackListPatterns() );
-                }
-                connector.setBlacklist( blacklist );
+                blacklist.addAll( proxyConfig.getBlackListPatterns() );
+            }
+            connector.setBlacklist( blacklist );
 
-                // Copy any whitelist patterns.
-                List<String> whitelist = new ArrayList<>( 0 );
-                if ( CollectionUtils.isNotEmpty( proxyConfig.getWhiteListPatterns() ) )
-                {
-                    whitelist.addAll( proxyConfig.getWhiteListPatterns() );
-                }
-                connector.setWhitelist( whitelist );
+            // Copy any whitelist patterns.
+            List<String> whitelist = new ArrayList<>( 0 );
+            if ( CollectionUtils.isNotEmpty( proxyConfig.getWhiteListPatterns() ) )
+            {
+                whitelist.addAll( proxyConfig.getWhiteListPatterns() );
+            }
+            connector.setWhitelist( whitelist );
 
-                List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations =
-                    findProxyConnectorRules( connector.getSourceRepository().getId(),
-                                             connector.getTargetRepository().getId(),
-                                             allProxyConnectorRuleConfigurations );
+            List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations =
+                findProxyConnectorRules( connector.getSourceRepository().getId(),
+                                         connector.getTargetRepository().getId(),
+                                         allProxyConnectorRuleConfigurations );
 
-                if ( !proxyConnectorRuleConfigurations.isEmpty() )
+            if ( !proxyConnectorRuleConfigurations.isEmpty() )
+            {
+                for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : proxyConnectorRuleConfigurations )
                 {
-                    for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : proxyConnectorRuleConfigurations )
+                    if ( StringUtils.equals( proxyConnectorRuleConfiguration.getRuleType(),
+                                             ProxyConnectorRuleType.BLACK_LIST.getRuleType() ) )
                     {
-                        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() );
-                        }
+                        connector.getBlacklist().add( proxyConnectorRuleConfiguration.getPattern() );
                     }
-                }
 
-                // Get other connectors
-                List<ProxyConnector> connectors = this.proxyConnectorMap.get( key );
-                if ( connectors == null )
-                {
-                    // Create if we are the first.
-                    connectors = new ArrayList<>( 1 );
+                    if ( StringUtils.equals( proxyConnectorRuleConfiguration.getRuleType(),
+                                             ProxyConnectorRuleType.WHITE_LIST.getRuleType() ) )
+                    {
+                        connector.getWhitelist().add( proxyConnectorRuleConfiguration.getPattern() );
+                    }
                 }
-
-                // Add the connector.
-                connectors.add( connector );
-
-                // Ensure the list is sorted.
-                Collections.sort( connectors, proxyOrderSorter );
-
-                // Set the key to the list of connectors.
-                this.proxyConnectorMap.put( key, connectors );
             }
-            catch ( RepositoryNotFoundException e )
-            {
-                log.warn( "Unable to use proxy connector: {}", e.getMessage(), e );
-            }
-            catch ( RepositoryException e )
+
+            // Get other connectors
+            List<ProxyConnector> connectors = this.proxyConnectorMap.get( key );
+            if ( connectors == null )
             {
-                log.warn( "Unable to use proxy connector: {}", e.getMessage(), e );
+                // Create if we are the first.
+                connectors = new ArrayList<>( 1 );
             }
 
+            // Add the connector.
+            connectors.add( connector );
+
+            // Ensure the list is sorted.
+            Collections.sort( connectors, proxyOrderSorter );
+
+            // Set the key to the list of connectors.
+            this.proxyConnectorMap.put( key, connectors );
+
 
         }
 
@@ -1176,8 +1199,14 @@ public class DefaultRepositoryProxyConnectors
         }
 
         AuthenticationInfo authInfo = null;
-        String username = remoteRepository.getRepository().getUserName();
-        String password = remoteRepository.getRepository().getPassword();
+        String username = "";
+        String password = "";
+        RepositoryCredentials repCred = remoteRepository.getRepository().getLoginCredentials();
+        if (repCred!=null && repCred instanceof PasswordCredentials) {
+            PasswordCredentials pwdCred = (PasswordCredentials) repCred;
+            username = pwdCred.getUsername();
+            password = pwdCred.getPassword()==null ? "" : new String(pwdCred.getPassword());
+        }
 
         if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) )
         {
@@ -1188,8 +1217,8 @@ public class DefaultRepositoryProxyConnectors
         }
 
         // Convert seconds to milliseconds
-        long timeoutInMilliseconds = TimeUnit.MILLISECONDS.convert( remoteRepository.getRepository().getTimeout(), //
-                                                                    TimeUnit.SECONDS );
+
+        long timeoutInMilliseconds = remoteRepository.getRepository().getTimeout().toMillis();
 
         // Set timeout  read and connect
         // FIXME olamy having 2 config values
index a8ffb633675e874690508a3253ddbc5f78bc0bb3..2a43b862e5cd19ef9f0b88d9003454f9d6681451 100644 (file)
@@ -36,6 +36,8 @@ import org.apache.archiva.policies.ReleasesPolicy;
 import org.apache.archiva.policies.SnapshotsPolicy;
 import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
 import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryRegistry;
+import org.apache.archiva.repository.maven2.MavenManagedRepository;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.index.NexusIndexer;
@@ -55,6 +57,7 @@ import javax.inject.Inject;
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.IOException;
+import java.net.URI;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -117,8 +120,7 @@ public abstract class AbstractProxyTestCase
 
     WagonDelegate delegate;
 
-    @Inject
-    protected ManagedRepositoryAdmin managedRepositoryAdmin;
+    protected RepositoryRegistry repositoryRegistry;
 
     @Inject
     protected NexusIndexer nexusIndexer;
@@ -143,38 +145,44 @@ public abstract class AbstractProxyTestCase
 
         managedDefaultDir = Paths.get( managedDefaultRepository.getRepoRoot() );
 
-        ManagedRepository repoConfig = managedDefaultRepository.getRepository();
+        org.apache.archiva.repository.ManagedRepository repoConfig = managedDefaultRepository.getRepository();
 
         ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
             ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
 
-        applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
+        applicationContext.getBean( RepositoryRegistry.class ).putRepository( repoConfig );
 
         // to prevent windauze file leaking
         removeMavenIndexes();
 
-        ManagedRepositoryAdmin managedRepositoryAdmin = applicationContext.getBean( ManagedRepositoryAdmin.class );
-
-        if ( managedRepositoryAdmin.getManagedRepository( repoConfig.getId() ) != null )
-        {
-            managedRepositoryAdmin.deleteManagedRepository( repoConfig.getId(), null, true );
-        }
-
-        managedRepositoryAdmin.addManagedRepository( repoConfig, false, null );
+        repositoryRegistry = applicationContext.getBean( RepositoryRegistry.class );
+        repositoryRegistry.setArchivaConfiguration( config );
 
         // Setup target (proxied to) repository.
         saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
-                                    Paths.get( REPOPATH_PROXIED1 ).toUri().toURL().toExternalForm(), "default" );
+            Paths.get( REPOPATH_PROXIED1 ).toUri().toURL().toExternalForm(), "default" );
 
         // Setup target (proxied to) repository.
         saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
-                                    Paths.get( REPOPATH_PROXIED2 ).toUri().toURL().toExternalForm(), "default" );
+            Paths.get( REPOPATH_PROXIED2 ).toUri().toURL().toExternalForm(), "default" );
+
+        repositoryRegistry.reload();
+
+        if ( repositoryRegistry.getManagedRepository( repoConfig.getId() ) != null )
+        {
+            org.apache.archiva.repository.ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( repoConfig.getId() );
+            repositoryRegistry.removeRepository( managedRepository );
+        }
+
+        repositoryRegistry.putRepository( repoConfig );
+
 
         // Setup the proxy handler.
         //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
 
         proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
 
+
         // Setup the wagon mock.
         wagonMockControl = EasyMock.createNiceControl();
         wagonMock = wagonMockControl.createMock( Wagon.class );
@@ -345,10 +353,8 @@ public abstract class AbstractProxyTestCase
     protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
         throws Exception
     {
-        ManagedRepository repo = new ManagedRepository();
-        repo.setId( id );
-        repo.setName( name );
-        repo.setLocation( path );
+        MavenManagedRepository repo = new MavenManagedRepository(id, name);
+        repo.setLocation( new URI(path) );
         repo.setLayout( layout );
 
         ManagedRepositoryContent repoContent =
@@ -477,6 +483,7 @@ public abstract class AbstractProxyTestCase
         config.triggerChange( prefix + ".name", repoConfig.getName() );
         config.triggerChange( prefix + ".url", repoConfig.getUrl() );
         config.triggerChange( prefix + ".layout", repoConfig.getLayout() );
+        repositoryRegistry.reload();
     }
 
     protected Path saveTargetedRepositoryConfig( String id, String originalPath, String targetPath, String layout )
index f1857fb1f078cb7a169ef70dc91a9e66c6c09cb0..3445ee86d62979d99acb4655ee10e0398ca91dc5 100644 (file)
@@ -112,6 +112,7 @@ public class CacheFailuresTransferTest
         saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
         saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/anotherrepo/", "default" );
 
+
         // Configure Connector (usually done within archiva.xml configuration)
         saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
index fad03d8025676211965ac0b27d58b28041b8e543..8b8d08e05c7593cf73931f9d3259343ffb1f4baf 100644 (file)
@@ -23,6 +23,8 @@ import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
 import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
+import org.apache.archiva.repository.RepositoryRegistry;
+import org.apache.archiva.repository.maven2.MavenManagedRepository;
 import org.apache.commons.io.FileUtils;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.NetworkProxyConfiguration;
@@ -55,10 +57,12 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.net.URI;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Locale;
 
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 
@@ -118,10 +122,8 @@ public class HttpProxyTransferTest
         // Make the destination dir.
         Files.createDirectories(destRepoDir);
 
-        ManagedRepository repo = new ManagedRepository();
-        repo.setId( MANAGED_ID );
-        repo.setName( "Default Managed Repository" );
-        repo.setLocation( repoPath );
+        MavenManagedRepository repo = new MavenManagedRepository( MANAGED_ID, "Default Managed Repository" );
+        repo.setLocation( new URI(repoPath) );
         repo.setLayout( "default" );
 
         ManagedRepositoryContent repoContent =
@@ -133,10 +135,10 @@ public class HttpProxyTransferTest
         ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
             ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
 
-        ManagedRepositoryAdmin managedRepositoryAdmin = applicationContext.getBean( ManagedRepositoryAdmin.class );
+        RepositoryRegistry managedRepositoryAdmin = applicationContext.getBean( RepositoryRegistry.class );
         if ( managedRepositoryAdmin.getManagedRepository( repo.getId() ) == null )
         {
-            managedRepositoryAdmin.addManagedRepository( repo, false, null );
+            managedRepositoryAdmin.putRepository( repo );
         }
 
         //config.getConfiguration().addManagedRepository( repo );
index 935f2a6e03cb5e0e3c67e6c234cc266c3ae42deb..fce694934d5131c5888ff2c80b2b3857e6d9efcd 100644 (file)
@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 import javax.annotation.PostConstruct;
 
@@ -145,4 +146,16 @@ public class MockConfiguration
     {
         // no op
     }
+
+    @Override
+    public Locale getDefaultLocale( )
+    {
+        return Locale.getDefault();
+    }
+
+    @Override
+    public List<Locale.LanguageRange> getLanguagePriorities( )
+    {
+        return Locale.LanguageRange.parse( "en,fr,de" );
+    }
 }
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
new file mode 100644 (file)
index 0000000..834ce5b
--- /dev/null
@@ -0,0 +1,231 @@
+package org.apache.archiva.repository.mock;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.repository.BasicManagedRepository;
+import org.apache.archiva.repository.BasicRemoteRepository;
+import org.apache.archiva.repository.EditableManagedRepository;
+import org.apache.archiva.repository.EditableRemoteRepository;
+import org.apache.archiva.repository.ManagedRepository;
+import org.apache.archiva.repository.PasswordCredentials;
+import org.apache.archiva.repository.ReleaseScheme;
+import org.apache.archiva.repository.RemoteRepository;
+import org.apache.archiva.repository.RepositoryCredentials;
+import org.apache.archiva.repository.RepositoryException;
+import org.apache.archiva.repository.RepositoryProvider;
+import org.apache.archiva.repository.RepositoryType;
+import org.apache.archiva.repository.features.ArtifactCleanupFeature;
+import org.apache.archiva.repository.features.IndexCreationFeature;
+import org.apache.archiva.repository.features.RemoteIndexFeature;
+import org.apache.archiva.repository.features.StagingRepositoryFeature;
+import org.springframework.stereotype.Service;
+
+import java.net.URI;
+import java.time.Duration;
+import java.time.Period;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Just a simple mock class for the repository provider
+ */
+@Service("mockRepositoryProvider")
+public class RepositoryProviderMock implements RepositoryProvider
+{
+
+    private static final Set<RepositoryType> TYPES = new HashSet<>( );
+
+    static
+    {
+        TYPES.add( RepositoryType.MAVEN );
+        TYPES.add( RepositoryType.NPM );
+    }
+
+    @Override
+    public Set<RepositoryType> provides( )
+    {
+        return TYPES;
+    }
+
+    @Override
+    public EditableManagedRepository createManagedInstance( String id, String name )
+    {
+        return new BasicManagedRepository( id, name );
+    }
+
+    @Override
+    public EditableRemoteRepository createRemoteInstance( String id, String name )
+    {
+        return new BasicRemoteRepository( id, name );
+    }
+
+    @Override
+    public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
+    {
+        BasicManagedRepository managedRepository = new BasicManagedRepository( configuration.getId( ), configuration.getName( ) );
+        updateManagedInstance( managedRepository, configuration );
+        return managedRepository;
+    }
+
+
+    @Override
+    public void updateManagedInstance( EditableManagedRepository managedRepository, ManagedRepositoryConfiguration configuration ) throws RepositoryException
+    {
+        try
+        {
+            managedRepository.setName( managedRepository.getPrimaryLocale(), configuration.getName( ) );
+            managedRepository.setLocation( new URI( configuration.getLocation( )==null ?"" : configuration.getLocation() ) );
+            managedRepository.setBaseUri( new URI( "" ) );
+            managedRepository.setBlocksRedeployment( configuration.isBlockRedeployments( ) );
+            managedRepository.setDescription( managedRepository.getPrimaryLocale(), configuration.getDescription( ) );
+            managedRepository.setLayout( configuration.getLayout( ) );
+            managedRepository.setScanned( configuration.isScanned( ) );
+            managedRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) );
+            if (configuration.isReleases()) {
+                managedRepository.addActiveReleaseScheme( ReleaseScheme.RELEASE );
+            }
+            if (configuration.isSnapshots()) {
+                managedRepository.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT );
+            }
+            ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( );
+            acf.setRetentionPeriod( Period.ofDays( configuration.getRetentionPeriod( ) ) );
+            acf.setDeleteReleasedSnapshots( configuration.isDeleteReleasedSnapshots( ) );
+            acf.setRetentionCount( configuration.getRetentionCount( ) );
+            IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( );
+            icf.setIndexPath( new URI( configuration.getIndexDir( ) ) );
+            icf.setSkipPackedIndexCreation( configuration.isSkipPackedIndexCreation( ) );
+            StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( );
+            srf.setStageRepoNeeded( configuration.isStageRepoNeeded( ) );
+        }
+        catch ( Exception e )
+        {
+            throw new RepositoryException( "Error", e );
+        }
+
+    }
+
+
+    @Override
+    public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
+    {
+        String id = configuration.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX;
+        BasicManagedRepository managedRepository = new BasicManagedRepository( id, configuration.getName( ) );
+        updateManagedInstance( managedRepository, configuration );
+        return managedRepository;
+    }
+
+    @Override
+    public RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration ) throws RepositoryException
+    {
+        BasicRemoteRepository remoteRepository = new BasicRemoteRepository( configuration.getId( ), configuration.getName( ) );
+        updateRemoteInstance( remoteRepository, configuration );
+        return remoteRepository;
+    }
+
+    @Override
+    public void updateRemoteInstance( EditableRemoteRepository remoteRepository, RemoteRepositoryConfiguration configuration ) throws RepositoryException
+    {
+        try
+        {
+            remoteRepository.setName( remoteRepository.getPrimaryLocale(), configuration.getName( ) );
+            remoteRepository.setBaseUri( new URI( "" ) );
+            remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), configuration.getDescription( ) );
+            remoteRepository.setLayout( configuration.getLayout( ) );
+            remoteRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) );
+            remoteRepository.setCheckPath( configuration.getCheckPath( ) );
+            remoteRepository.setExtraHeaders( configuration.getExtraHeaders( ) );
+            remoteRepository.setExtraParameters( configuration.getExtraParameters( ) );
+            remoteRepository.setTimeout( Duration.ofSeconds( configuration.getTimeout( ) ) );
+            char[] pwd = configuration.getPassword()==null ? "".toCharArray() : configuration.getPassword().toCharArray();
+            remoteRepository.setCredentials( new PasswordCredentials( configuration.getUsername( ), pwd ) );
+            remoteRepository.setLocation( new URI( configuration.getUrl( )==null ? "" : configuration.getUrl() ) );
+            RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( );
+            rif.setDownloadRemoteIndexOnStartup( configuration.isDownloadRemoteIndexOnStartup( ) );
+            rif.setDownloadRemoteIndex( configuration.isDownloadRemoteIndex( ) );
+            rif.setIndexUri( new URI( configuration.getIndexDir( ) ) );
+            rif.setDownloadTimeout( Duration.ofSeconds( configuration.getRemoteDownloadTimeout( ) ) );
+            rif.setProxyId( configuration.getRemoteDownloadNetworkProxyId( ) );
+        }
+        catch ( Exception e )
+        {
+            throw new RepositoryException( "Error", e );
+        }
+
+    }
+
+    @Override
+    public ManagedRepositoryConfiguration getManagedConfiguration( ManagedRepository managedRepository ) throws RepositoryException
+    {
+        ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration( );
+        configuration.setId( managedRepository.getId( ) );
+        configuration.setName(managedRepository.getName());
+        configuration.setLocation( managedRepository.getLocation( ) == null ? "" : managedRepository.getLocation().toString( ) );
+        configuration.setBlockRedeployments( managedRepository.blocksRedeployments( ) );
+        configuration.setDescription( managedRepository.getDescription( ) );
+        configuration.setLayout( managedRepository.getLayout( ) );
+        configuration.setScanned( managedRepository.isScanned( ) );
+        configuration.setRefreshCronExpression( managedRepository.getSchedulingDefinition( ) );
+        configuration.setReleases( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE) );
+        configuration.setSnapshots( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) );
+        ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( );
+        configuration.setRetentionPeriod( acf.getRetentionPeriod( ).getDays( ) );
+        configuration.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots( ) );
+        configuration.setRetentionCount( acf.getRetentionCount( ) );
+        IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( );
+        configuration.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation( ) );
+        configuration.setIndexDir( icf.getIndexPath( ) == null ? "" : icf.getIndexPath().toString( ) );
+        StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( );
+        configuration.setStageRepoNeeded( srf.isStageRepoNeeded( ) );
+        return configuration;
+    }
+
+
+    @Override
+    public RemoteRepositoryConfiguration getRemoteConfiguration( RemoteRepository remoteRepository ) throws RepositoryException
+    {
+        RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration( );
+        configuration.setId( remoteRepository.getId( ) );
+        configuration.setName( remoteRepository.getName( ) );
+        configuration.setDescription( remoteRepository.getDescription( ) );
+        configuration.setLayout( remoteRepository.getLayout( ) );
+        configuration.setRefreshCronExpression( remoteRepository.getSchedulingDefinition( ) );
+        configuration.setCheckPath( remoteRepository.getCheckPath( ) );
+        configuration.setExtraHeaders( remoteRepository.getExtraHeaders( ) );
+        configuration.setExtraParameters( remoteRepository.getExtraParameters( ) );
+        configuration.setTimeout( (int) remoteRepository.getTimeout( ).getSeconds( ) );
+        RepositoryCredentials creds = remoteRepository.getLoginCredentials( );
+        if (creds!=null)
+        {
+            PasswordCredentials pwdCreds = (PasswordCredentials) creds;
+            configuration.setUsername( pwdCreds.getUsername( ) );
+            configuration.setPassword( new String( pwdCreds.getPassword( ) ) );
+        }
+        configuration.setUrl( remoteRepository.getLocation( ) == null ? "" : remoteRepository.getLocation().toString( ) );
+        RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( );
+        configuration.setDownloadRemoteIndex( rif.isDownloadRemoteIndex( ) );
+        configuration.setDownloadRemoteIndexOnStartup( rif.isDownloadRemoteIndexOnStartup( ) );
+        configuration.setIndexDir( rif.getIndexUri( )==null ? "" : rif.getIndexUri().toString( ) );
+        configuration.setRemoteDownloadNetworkProxyId( rif.getProxyId( ) );
+        return configuration;
+    }
+
+}
index 7a57f01e0424b728f20505d0b178437d73608c30..6ec124f60cb66da500c0da409d035ced1e140e1a 100755 (executable)
        default-lazy-init="true">
 
   <context:annotation-config/>
-  <context:component-scan base-package="org.apache.archiva.metadata.repository"/>
+  <context:component-scan base-package="org.apache.archiva.metadata.repository,org.apache.archiva.repository.content.maven2,org.apache.archiva.proxy,org.apache.archiva.repository.mock"/>
+  <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+  <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+  <alias name="mockRepositoryProvider" alias="mavenRepositoryProvider" />
 
   <alias name="archivaConfiguration#mock" alias="archivaConfiguration#default"/>
   <alias name="archivaConfiguration#mock" alias="archivaConfiguration"/>
index 5daae074542af67bbc7c09181be745fd78d6a6f3..fff20693ad8ff5ee3e276caaef60b9acd7f4b781 100644 (file)
@@ -20,11 +20,11 @@ package org.apache.archiva.repository.scanner;
  */
 
 import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.configuration.FileTypes;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.archiva.consumers.RepositoryContentConsumer;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 5ccdb1ef9e7c197c69d32aee2584ff8606e8792a..c3159c7335d968589ffb0ca9dfac7279c0f4a73b 100644 (file)
@@ -21,13 +21,14 @@ package org.apache.archiva.repository.scanner;
 
 import org.apache.archiva.admin.model.RepositoryAdminException;
 import org.apache.archiva.admin.model.admin.ArchivaAdministration;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.common.utils.BaseFile;
+import org.apache.archiva.common.utils.PathUtil;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
 import org.apache.archiva.redback.components.registry.RegistryListener;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
 import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
 import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
@@ -41,6 +42,7 @@ import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 
 /**
@@ -262,7 +264,7 @@ public class RepositoryContentConsumers
      * @param localFile              the local file to execute the consumers against.
      * @param updateRelatedArtifacts TODO
      */
-    public void executeConsumers(ManagedRepository repository, Path localFile, boolean updateRelatedArtifacts )
+    public void executeConsumers( ManagedRepository repository, Path localFile, boolean updateRelatedArtifacts )
         throws RepositoryAdminException
     {
         List<KnownRepositoryContentConsumer> selectedKnownConsumers = null;
@@ -296,7 +298,8 @@ public class RepositoryContentConsumers
 
             // yuck. In case you can't read this, it says
             // "process the file if the consumer has it in the includes list, and not in the excludes list"
-            BaseFile baseFile = new BaseFile( repository.getLocation(), localFile.toFile() );
+            Path repoPath = PathUtil.getPathFromUri( repository.getLocation() );
+            BaseFile baseFile = new BaseFile( repoPath.toString(), localFile.toFile() );
             ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate( repository );
             predicate.setBasefile( baseFile );
             predicate.setCaseSensitive( false );
index 8e2dd8341d36549f11b2ebe63589c751af955163..1d9ebbeeb7de3c8322e05db4b112b4f8d34352c4 100644 (file)
@@ -19,7 +19,7 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.commons.collections.CollectionUtils;
 
 import javax.xml.bind.annotation.XmlRootElement;
index cfa8f17a75599ed0aabaae17429fe459c9645ded..8c5cb89461383c8bbafa6ef5f56f0dbc88dd3325 100644 (file)
@@ -19,9 +19,9 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.archiva.repository.ManagedRepository;
 
 import java.util.List;
 import java.util.Set;
index 55e0e52487e7d873685c5c683b1cffc50a31ea69..5928823eac2a9d125d7b77458526fdd438e8edb2 100644 (file)
@@ -19,11 +19,12 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.common.utils.BaseFile;
+import org.apache.archiva.common.utils.PathUtil;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
 import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
 import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
@@ -216,7 +217,8 @@ public class RepositoryScannerInstance
             stats.increaseFileCount();
 
             // consume files regardless - the predicate will check the timestamp
-            BaseFile basefile = new BaseFile( repository.getLocation(), file.toFile() );
+            Path repoPath = PathUtil.getPathFromUri( repository.getLocation() );
+            BaseFile basefile = new BaseFile( repoPath.toString(), file.toFile() );
 
             // Timestamp finished points to the last successful scan, not this current one.
             if ( Files.getLastModifiedTime(file).toMillis() >= changesSince )
index b830854118715c5b761cc80e667810c6398f498e..4ae19dc14cd309c85eada45e76cd61172e7d723d 100644 (file)
@@ -19,7 +19,7 @@ package org.apache.archiva.repository.scanner.functors;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.commons.collections.Closure;
 import org.apache.archiva.consumers.ConsumerException;
 import org.apache.archiva.consumers.RepositoryContentConsumer;
index 3b7cf9d7f2adfdeb5e4eff7e6d82c939ee088564..c4789be31769f41b9f9c97bf192b4311081f3faa 100644 (file)
@@ -19,7 +19,7 @@ package org.apache.archiva.repository.scanner.functors;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.commons.collections.Closure;
 import org.apache.archiva.consumers.RepositoryContentConsumer;
 import org.slf4j.Logger;
index cee2d72ec71e0a5bc281e3759d6950a25cb67d59..81f9440a9f6045a21b16972ce3e62b991544ad2e 100644 (file)
@@ -19,10 +19,10 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.consumers.AbstractMonitoredConsumer;
 import org.apache.archiva.consumers.ConsumerException;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.archiva.repository.ManagedRepository;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
index f494bf4ec0ac8c5c20a3354cf1eb8a33c33e1d81..7a48f71a52fc8832edbfba4a8f506f43ab1956a1 100644 (file)
@@ -19,12 +19,10 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.consumers.AbstractMonitoredConsumer;
 import org.apache.archiva.consumers.ConsumerException;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
+import org.apache.archiva.repository.ManagedRepository;
 
 import java.util.ArrayList;
 import java.util.Arrays;
index 988e3ef8b72c49f4d268e1cba302e14911d42eaf..c24c0c26bef62e963c39c1ab2448efc9e068ab22 100644 (file)
@@ -20,11 +20,13 @@ package org.apache.archiva.repository.scanner;
  */
 
 import junit.framework.TestCase;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.archiva.repository.BasicManagedRepository;
+import org.apache.archiva.repository.BasicRemoteRepository;
+import org.apache.archiva.repository.ManagedRepository;
+import org.apache.archiva.repository.RemoteRepository;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.lang.SystemUtils;
 import org.easymock.IMocksControl;
@@ -46,6 +48,8 @@ import org.springframework.test.context.ContextConfiguration;
 import javax.inject.Inject;
 import java.io.IOException;
 import java.lang.annotation.Annotation;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
@@ -72,19 +76,15 @@ public class RepositoryContentConsumersTest
 
     protected ManagedRepository createRepository( String id, String name, Path location )
     {
-        ManagedRepository repo = new ManagedRepository();
-        repo.setId( id );
-        repo.setName( name );
-        repo.setLocation( location.toAbsolutePath().toString() );
+        BasicManagedRepository repo = new BasicManagedRepository( id, name  );
+        repo.setLocation( location.toAbsolutePath().toUri() );
         return repo;
     }
 
-    protected RemoteRepository createRemoteRepository( String id, String name, String url )
+    protected RemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException
     {
-        RemoteRepository repo = new RemoteRepository();
-        repo.setId( id );
-        repo.setName( name );
-        repo.setUrl( url );
+        BasicRemoteRepository repo = new BasicRemoteRepository(id, name);
+        repo.setLocation( new URI( url ) );
         return repo;
     }
 
index e028b94eb3e8fe7a2e1404086168e0c5bc56381c..e9a462b22be2e52cfc7474f4f57f3c688648afcb 100644 (file)
@@ -20,10 +20,13 @@ package org.apache.archiva.repository.scanner;
  */
 
 import junit.framework.TestCase;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.archiva.repository.BasicManagedRepository;
+import org.apache.archiva.repository.BasicRemoteRepository;
+import org.apache.archiva.repository.EditableManagedRepository;
+import org.apache.archiva.repository.EditableRemoteRepository;
+import org.apache.archiva.repository.ManagedRepository;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.junit.Test;
@@ -33,6 +36,8 @@ import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -57,21 +62,17 @@ public class RepositoryScannerTest
     @Inject
     ApplicationContext applicationContext;
 
-    protected ManagedRepository createRepository( String id, String name, Path location )
+    protected EditableManagedRepository createRepository( String id, String name, Path location )
     {
-        ManagedRepository repo = new ManagedRepository();
-        repo.setId( id );
-        repo.setName( name );
-        repo.setLocation( location.toAbsolutePath().toString());
+        BasicManagedRepository repo = new BasicManagedRepository(id, name);
+        repo.setLocation( location.toAbsolutePath().toUri());
         return repo;
     }
 
-    protected RemoteRepository createRemoteRepository( String id, String name, String url )
+    protected EditableRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException
     {
-        RemoteRepository repo = new RemoteRepository();
-        repo.setId( id );
-        repo.setName( name );
-        repo.setUrl( url );
+        BasicRemoteRepository repo = new BasicRemoteRepository(id, name);
+        repo.setLocation( new URI( url ) );
         return repo;
     }
 
@@ -122,7 +123,7 @@ public class RepositoryScannerTest
 
         assertTrue( "Legacy Test Repository should exist.", Files.exists(repoDir) && Files.isDirectory(repoDir) );
 
-        ManagedRepository repo = createRepository( "testLegacyRepo", "Test Legacy Repository", repoDir );
+        EditableManagedRepository repo = createRepository( "testLegacyRepo", "Test Legacy Repository", repoDir );
         repo.setLayout( "legacy" );
 
         return repo;
index ab9a3c8df4209a5cc9eb52d3820eb4d9cb14b98b..02d961b76ca0fa49226b7920ff0c02ce0c87213a 100644 (file)
@@ -19,10 +19,10 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.consumers.AbstractMonitoredConsumer;
 import org.apache.archiva.consumers.ConsumerException;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.archiva.repository.ManagedRepository;
 
 import java.util.Date;
 import java.util.List;
index bb97001588959650ef37de9865f94c67d4a73846..bde3e5cc7aeb77c6f7d67b1f062532e889954a17 100644 (file)
       <artifactId>xmlunit</artifactId>
       <scope>compile</scope>
     </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-simple</artifactId>
-      <scope>compile</scope>
-    </dependency>
-  </dependencies>  
+  </dependencies>
 </project>
index e78f79b76a2a191b802e35cc429bc9062dd3611c..24021289d5f899ac09d8ec37a0db643af42b03c2 100644 (file)
@@ -41,6 +41,7 @@
     <module>archiva-policies</module>
     <module>archiva-indexer</module>
     <module>archiva-consumers</module>
+    <module>archiva-repository-api</module>
     <module>archiva-repository-layer</module>
     <module>archiva-xml-tools</module>
     <module>archiva-proxy-api</module>