use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class Maven3DependencyTreeBuilder method resolve.
private void resolve(ResolveRequest resolveRequest) {
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system, resolveRequest.localRepoDir);
org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(resolveRequest.groupId + ":" + resolveRequest.artifactId + ":" + resolveRequest.version);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
// add remote repositories
for (RemoteRepository remoteRepository : resolveRequest.remoteRepositories) {
collectRequest.addRepository(new org.sonatype.aether.repository.RemoteRepository(remoteRepository.getId(), "default", remoteRepository.getUrl()));
}
collectRequest.setRequestContext("project");
try {
CollectResult collectResult = system.collectDependencies(session, collectRequest);
collectResult.getRoot().accept(resolveRequest.dependencyVisitor);
log.debug("test");
} catch (DependencyCollectionException e) {
log.error(e.getMessage(), e);
}
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class MockRepoAdmin method getRemoteRepositories.
@Override
public List<RemoteRepository> getRemoteRepositories() throws RepositoryAdminException {
List<RemoteRepository> remoteRepositories = new ArrayList<>(archivaConfiguration.getConfiguration().getRemoteRepositories().size());
for (RemoteRepositoryConfiguration repositoryConfiguration : archivaConfiguration.getConfiguration().getRemoteRepositories()) {
RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault(), repositoryConfiguration.getId(), repositoryConfiguration.getName(), repositoryConfiguration.getUrl(), repositoryConfiguration.getLayout(), repositoryConfiguration.getUsername(), repositoryConfiguration.getPassword(), repositoryConfiguration.getTimeout());
remoteRepository.setDownloadRemoteIndex(repositoryConfiguration.isDownloadRemoteIndex());
remoteRepository.setRemoteIndexUrl(repositoryConfiguration.getRemoteIndexUrl());
remoteRepository.setCronExpression(repositoryConfiguration.getRefreshCronExpression());
remoteRepository.setIndexDirectory(repositoryConfiguration.getIndexDir());
remoteRepository.setRemoteDownloadNetworkProxyId(repositoryConfiguration.getRemoteDownloadNetworkProxyId());
remoteRepository.setRemoteDownloadTimeout(repositoryConfiguration.getRemoteDownloadTimeout());
remoteRepository.setDownloadRemoteIndexOnStartup(repositoryConfiguration.isDownloadRemoteIndexOnStartup());
remoteRepositories.add(remoteRepository);
}
return remoteRepositories;
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class AbstractRepositoryAdminTest method getRemoteRepository.
protected RemoteRepository getRemoteRepository(String id) {
RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
remoteRepository.setUrl("http://foo.com/maven-it-rocks");
remoteRepository.setTimeout(10);
remoteRepository.setName("maven foo");
remoteRepository.setUserName("foo-name");
remoteRepository.setPassword("toto");
remoteRepository.setId(id);
remoteRepository.setRemoteDownloadNetworkProxyId("foo");
remoteRepository.setDescription("cool apache repo");
Map<String, String> extraParameters = new HashMap<>();
extraParameters.put("foo", "bar");
remoteRepository.setExtraParameters(extraParameters);
Map<String, String> extraHeaders = new HashMap<>();
extraHeaders.put("beer", "wine");
remoteRepository.setExtraHeaders(extraHeaders);
return remoteRepository;
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class ProxyConnectorRuleAdminTest method addProxyConnectorRuleWithTwoProxyConnectors.
@Test
public void addProxyConnectorRuleWithTwoProxyConnectors() throws Exception {
RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
remoteRepository.setId("archiva");
remoteRepository.setName("archiva rocks");
remoteRepository.setUrl("http://wine.org");
remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
assertEquals(0, size);
ProxyConnector proxyConnector1 = new ProxyConnector();
proxyConnector1.setSourceRepoId("snapshots");
proxyConnector1.setTargetRepoId("central");
proxyConnectorAdmin.addProxyConnector(proxyConnector1, getFakeAuditInformation());
ProxyConnector proxyConnector2 = new ProxyConnector();
proxyConnector2.setSourceRepoId("snapshots");
proxyConnector2.setTargetRepoId("archiva");
proxyConnectorAdmin.addProxyConnector(proxyConnector2, getFakeAuditInformation());
ProxyConnectorRule rule = new ProxyConnectorRule("org/apache/maven", ProxyConnectorRuleType.BLACK_LIST, Arrays.asList(proxyConnector1, proxyConnector2));
try {
proxyConnectorRuleAdmin.addProxyConnectorRule(rule, getFakeAuditInformation());
assertEquals(size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size());
rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get(0);
assertEquals("org/apache/maven", rule.getPattern());
assertEquals(2, rule.getProxyConnectors().size());
assertEquals(ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType());
} finally {
proxyConnectorRuleAdmin.deleteProxyConnectorRule(rule, getFakeAuditInformation());
proxyConnectorAdmin.deleteProxyConnector(proxyConnector1, getFakeAuditInformation());
proxyConnectorAdmin.deleteProxyConnector(proxyConnector2, getFakeAuditInformation());
remoteRepositoryAdmin.deleteRemoteRepository(remoteRepository.getId(), getFakeAuditInformation());
}
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class ProxyConnectorRuleAdminTest method updateProxyConnectorRuleWithTwoProxyConnectors.
@Test
public void updateProxyConnectorRuleWithTwoProxyConnectors() throws Exception {
RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
remoteRepository.setId("archiva");
remoteRepository.setName("archiva rocks");
remoteRepository.setUrl("http://wine.org");
remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
assertEquals(0, size);
ProxyConnector proxyConnector1 = new ProxyConnector();
proxyConnector1.setSourceRepoId("snapshots");
proxyConnector1.setTargetRepoId("central");
proxyConnectorAdmin.addProxyConnector(proxyConnector1, getFakeAuditInformation());
ProxyConnector proxyConnector2 = new ProxyConnector();
proxyConnector2.setSourceRepoId("snapshots");
proxyConnector2.setTargetRepoId("archiva");
proxyConnectorAdmin.addProxyConnector(proxyConnector2, getFakeAuditInformation());
ProxyConnectorRule rule = new ProxyConnectorRule("org/apache/maven", ProxyConnectorRuleType.BLACK_LIST, Arrays.asList(proxyConnector1, proxyConnector2));
try {
proxyConnectorRuleAdmin.addProxyConnectorRule(rule, getFakeAuditInformation());
assertEquals(size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size());
rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get(0);
assertEquals("org/apache/maven", rule.getPattern());
assertEquals(2, rule.getProxyConnectors().size());
// assertEquals( "snapshots", rule.getProxyConnectors().get( 0 ).getSourceRepoId() );
// assertEquals( "central", rule.getProxyConnectors().get( 0 ).getTargetRepoId() );
assertEquals(ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType());
rule.setProxyConnectors(Arrays.asList(proxyConnector1));
proxyConnectorRuleAdmin.updateProxyConnectorRule(rule, getFakeAuditInformation());
assertEquals(size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size());
rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get(0);
assertEquals("org/apache/maven", rule.getPattern());
assertEquals(1, rule.getProxyConnectors().size());
assertEquals("snapshots", rule.getProxyConnectors().get(0).getSourceRepoId());
assertEquals("central", rule.getProxyConnectors().get(0).getTargetRepoId());
} finally {
proxyConnectorRuleAdmin.deleteProxyConnectorRule(rule, getFakeAuditInformation());
proxyConnectorAdmin.deleteProxyConnector(proxyConnector1, getFakeAuditInformation());
proxyConnectorAdmin.deleteProxyConnector(proxyConnector2, getFakeAuditInformation());
remoteRepositoryAdmin.deleteRemoteRepository(remoteRepository.getId(), getFakeAuditInformation());
}
}
Aggregations