use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class RemoteRepositoriesServiceTest method addAndUpdateAndDeleteRemoteRepository.
@Test
public void addAndUpdateAndDeleteRemoteRepository() throws Exception {
RemoteRepositoriesService service = getRemoteRepositoriesService();
WebClient.client(service).header("Authorization", authorizationHeader);
int initialSize = service.getRemoteRepositories().size();
service.addRemoteRepository(getRemoteRepository());
assertNotNull(service.getRemoteRepository("id-new"));
assertEquals(getRemoteRepository().getName(), service.getRemoteRepository("id-new").getName());
assertEquals(getRemoteRepository().getUrl(), service.getRemoteRepository("id-new").getUrl());
assertEquals(getRemoteRepository().getLayout(), service.getRemoteRepository("id-new").getLayout());
assertEquals(getRemoteRepository().getUserName(), service.getRemoteRepository("id-new").getUserName());
assertEquals(getRemoteRepository().getPassword(), service.getRemoteRepository("id-new").getPassword());
assertEquals(getRemoteRepository().getTimeout(), service.getRemoteRepository("id-new").getTimeout());
assertEquals(initialSize + 1, service.getRemoteRepositories().size());
RemoteRepository repo = getRemoteRepository();
repo.setName("name changed");
repo.setPassword("new password");
repo.setUserName("new username");
repo.setUrl("http://foo.new.org");
repo.setDescription("foo bar");
service.updateRemoteRepository(repo);
assertEquals(repo.getName(), service.getRemoteRepository("id-new").getName());
assertEquals(repo.getUrl(), service.getRemoteRepository("id-new").getUrl());
assertEquals(repo.getLayout(), service.getRemoteRepository("id-new").getLayout());
assertEquals(repo.getUserName(), service.getRemoteRepository("id-new").getUserName());
assertEquals(repo.getPassword(), service.getRemoteRepository("id-new").getPassword());
assertEquals(repo.getTimeout(), service.getRemoteRepository("id-new").getTimeout());
assertEquals(repo.getDescription(), service.getRemoteRepository("id-new").getDescription());
service.deleteRemoteRepository("id-new");
assertNull(service.getRemoteRepository("id-new"));
assertEquals(initialSize, service.getRemoteRepositories().size());
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class Maven3DependencyTreeBuilder method buildDependencyTree.
@Override
public void buildDependencyTree(List<String> repositoryIds, String groupId, String artifactId, String version, DependencyVisitor dependencyVisitor) throws DependencyTreeBuilderException {
Artifact projectArtifact = factory.createProjectArtifact(groupId, artifactId, version);
ManagedRepository repository = null;
try {
repository = findArtifactInRepositories(repositoryIds, projectArtifact);
} catch (RepositoryAdminException e) {
// FIXME better exception
throw new DependencyTreeBuilderException("Cannot build project dependency tree " + e.getMessage(), e);
}
if (repository == null) {
// metadata could not be resolved
return;
}
List<RemoteRepository> remoteRepositories = new ArrayList<>();
Map<String, NetworkProxy> networkProxies = new HashMap<>();
try {
// MRM-1411
// TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
// handled there. It doesn't cache anything locally!
Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get(repository.getId());
if (proxyConnectors != null) {
for (ProxyConnector proxyConnector : proxyConnectors) {
remoteRepositories.add(remoteRepositoryAdmin.getRemoteRepository(proxyConnector.getTargetRepoId()));
NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy(proxyConnector.getProxyId());
if (networkProxyConfig != null) {
// key/value: remote repo ID/proxy info
networkProxies.put(proxyConnector.getTargetRepoId(), networkProxyConfig);
}
}
}
} catch (RepositoryAdminException e) {
throw new DependencyTreeBuilderException(e.getMessage(), e);
}
// FIXME take care of relative path
ResolveRequest resolveRequest = new ResolveRequest();
resolveRequest.dependencyVisitor = dependencyVisitor;
resolveRequest.localRepoDir = repository.getLocation();
resolveRequest.groupId = groupId;
resolveRequest.artifactId = artifactId;
resolveRequest.version = version;
resolveRequest.remoteRepositories = remoteRepositories;
resolveRequest.networkProxies = networkProxies;
resolve(resolveRequest);
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class NetworkProxyAdminTest method addAndDeleteWithRemoteRepoLinked.
/**
* ensure we cleanup remote repos linked to a network proxy
*/
@Test
public void addAndDeleteWithRemoteRepoLinked() throws Exception {
mockAuditListener.clearEvents();
int initialSize = networkProxyAdmin.getNetworkProxies().size();
NetworkProxy networkProxy = getNetworkProxyTest("foo");
networkProxyAdmin.addNetworkProxy(networkProxy, getFakeAuditInformation());
assertEquals(initialSize + 1, networkProxyAdmin.getNetworkProxies().size());
networkProxy = networkProxyAdmin.getNetworkProxy("foo");
assertNotNull(networkProxy);
RemoteRepository remoteRepository = getRemoteRepository();
remoteRepository.setRemoteDownloadNetworkProxyId(networkProxy.getId());
remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
networkProxyAdmin.deleteNetworkProxy("foo", getFakeAuditInformation());
remoteRepository = remoteRepositoryAdmin.getRemoteRepository(getRemoteRepository().getId());
assertNull(remoteRepository.getRemoteDownloadNetworkProxyId());
remoteRepositoryAdmin.deleteRemoteRepository(getRemoteRepository().getId(), getFakeAuditInformation());
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class ProxyConnectorAdminTest method addAndUpdateAndDelete.
@Test
public void addAndUpdateAndDelete() throws Exception {
mockAuditListener.clearEvents();
RemoteRepository remoteRepository = getRemoteRepository("test-new-one");
remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
assertEquals("not proxyConnectors 1 " + proxyConnectorAdmin.getProxyConnectors(), 1, proxyConnectorAdmin.getProxyConnectors().size());
assertFalse(proxyConnectorAdmin.getProxyConnectors().isEmpty());
ProxyConnector proxyConnector = new ProxyConnector();
proxyConnector.setSourceRepoId("snapshots");
proxyConnector.setTargetRepoId("central");
proxyConnector.setWhiteListPatterns(Arrays.asList("foo", "bar"));
proxyConnectorAdmin.addProxyConnector(proxyConnector, getFakeAuditInformation());
assertFalse(proxyConnectorAdmin.getProxyConnectors().isEmpty());
assertEquals(2, proxyConnectorAdmin.getProxyConnectors().size());
assertNotNull(proxyConnectorAdmin.getProxyConnector("snapshots", "central"));
assertEquals(Arrays.asList("foo", "bar"), proxyConnectorAdmin.getProxyConnector("snapshots", "central").getWhiteListPatterns());
proxyConnectorAdmin.deleteProxyConnector(proxyConnector, getFakeAuditInformation());
proxyConnector.setTargetRepoId(remoteRepository.getId());
proxyConnectorAdmin.addProxyConnector(proxyConnector, getFakeAuditInformation());
assertNull(proxyConnectorAdmin.getProxyConnector("snapshots", "central"));
assertNotNull(remoteRepository.getId(), proxyConnectorAdmin.getProxyConnector("snapshots", remoteRepository.getId()));
proxyConnectorAdmin.deleteProxyConnector(proxyConnector, getFakeAuditInformation());
assertNull(proxyConnectorAdmin.getProxyConnector("snapshots", "central"));
assertEquals(1, proxyConnectorAdmin.getProxyConnectors().size());
assertFalse(proxyConnectorAdmin.getProxyConnectors().isEmpty());
assertEquals(5, mockAuditListener.getAuditEvents().size());
assertEquals(AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get(0).getAction());
assertEquals(AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get(1).getAction());
assertEquals("root", mockAuditListener.getAuditEvents().get(2).getUserId());
assertEquals("archiva-localhost", mockAuditListener.getAuditEvents().get(2).getRemoteIP());
assertEquals(AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get(2).getAction());
assertEquals(AuditEvent.ADD_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get(3).getAction());
assertEquals(AuditEvent.DELETE_PROXY_CONNECTOR, mockAuditListener.getAuditEvents().get(4).getAction());
assertEquals("root", mockAuditListener.getAuditEvents().get(4).getUserId());
remoteRepositoryAdmin.deleteRemoteRepository(remoteRepository.getId(), getFakeAuditInformation());
mockAuditListener.clearEvents();
}
use of org.apache.archiva.admin.model.beans.RemoteRepository in project archiva by apache.
the class RemoteRepositoryAdminTest method getById.
@Test
public void getById() throws Exception {
RemoteRepository central = remoteRepositoryAdmin.getRemoteRepository("central");
assertNotNull(central);
assertEquals("https://repo.maven.apache.org/maven2", central.getUrl());
assertEquals(60, central.getTimeout());
assertNull(central.getUserName());
assertNull(central.getPassword());
}
Aggregations