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;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
/**
* 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 =
* 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;
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;
}
@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();
<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>
{
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() );
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;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
+import java.util.Locale;
/**
* @author Olivier Lamy
@Inject
ArtifactContextProducer artifactContextProducer;
+ @Inject
+ RepositoryRegistry repositoryRegistry;
+
IMocksControl archivaConfigControl;
Configuration config;
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
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
/**
* @author Olivier Lamy
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();
* 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;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
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();
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 );
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();
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();
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();
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();
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 );
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();
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();
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();
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();
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();
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 );
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();
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();
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();
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();
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();
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();
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 )
{
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();
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();
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 );
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();
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();
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();
searchFields.setClassName( "SomeClass" );
searchFields.setRepositories( selectedRepos );
- EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
-
archivaConfigControl.replay();
SearchResults results = search.search( "user", searchFields, null );
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();
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">
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();
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;
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;
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
@Named(value = "archivaTaskScheduler#repository")
private ArchivaTaskScheduler scheduler;
+ @Inject
+ private RepositoryRegistry repositoryRegistry;
+
@Inject
private NetworkProxyAdmin networkProxyAdmin;
{
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 );
+
}
}
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 ) )
{
}
// 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
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;
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;
WagonDelegate delegate;
- @Inject
- protected ManagedRepositoryAdmin managedRepositoryAdmin;
+ protected RepositoryRegistry repositoryRegistry;
@Inject
protected NexusIndexer nexusIndexer;
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 );
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 =
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 )
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 );
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;
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;
// 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 =
( (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 );
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import javax.annotation.PostConstruct;
{
// no op
}
+
+ @Override
+ public Locale getDefaultLocale( )
+ {
+ return Locale.getDefault();
+ }
+
+ @Override
+ public List<Locale.LanguageRange> getLanguagePriorities( )
+ {
+ return Locale.LanguageRange.parse( "en,fr,de" );
+ }
}
--- /dev/null
+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;
+ }
+
+}
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"/>
*/
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;
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;
import javax.inject.Inject;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.*;
/**
* @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;
// 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 );
* 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;
* 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;
* 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;
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 )
* 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;
* 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;
* 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;
* 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;
*/
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;
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;
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;
}
*/
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;
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;
@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;
}
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;
* 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;
<artifactId>xmlunit</artifactId>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>compile</scope>
- </dependency>
- </dependencies>
+ </dependencies>
</project>
<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>