use of org.apache.archiva.admin.model.beans.ProxyConnector 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.ProxyConnector in project archiva by apache.
the class ProxyConnectorAdminTest method findProxyConnector.
@Test
public void findProxyConnector() throws Exception {
ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector("internal", "central");
assertNotNull(proxyConnector);
}
use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.
the class DefaultProxyConnectorAdmin method getProxyConnectors.
@Override
public List<ProxyConnector> getProxyConnectors() throws RepositoryAdminException {
List<ProxyConnectorConfiguration> proxyConnectorConfigurations = getArchivaConfiguration().getConfiguration().getProxyConnectors();
List<ProxyConnector> proxyConnectors = new ArrayList<>(proxyConnectorConfigurations.size());
for (ProxyConnectorConfiguration configuration : proxyConnectorConfigurations) {
proxyConnectors.add(getProxyConnector(configuration));
}
Collections.sort(proxyConnectors, ProxyConnectorOrderComparator.getInstance());
return proxyConnectors;
}
use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.
the class DefaultProxyConnectorAdmin method getProxyConnectorAsMap.
@Override
public Map<String, List<ProxyConnector>> getProxyConnectorAsMap() throws RepositoryAdminException {
Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<>();
Iterator<ProxyConnector> it = getProxyConnectors().iterator();
while (it.hasNext()) {
ProxyConnector proxyConfig = it.next();
String key = proxyConfig.getSourceRepoId();
List<ProxyConnector> connectors = proxyConnectorMap.get(key);
if (connectors == null) {
connectors = new ArrayList<>(1);
proxyConnectorMap.put(key, connectors);
}
connectors.add(proxyConfig);
Collections.sort(connectors, ProxyConnectorOrderComparator.getInstance());
}
return proxyConnectorMap;
}
use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.
the class DefaultProxyConnectorRuleAdmin method getProxyConnectorRules.
@Override
public List<ProxyConnectorRule> getProxyConnectorRules() throws RepositoryAdminException {
List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations = getArchivaConfiguration().getConfiguration().getProxyConnectorRuleConfigurations();
if (proxyConnectorRuleConfigurations.isEmpty()) {
return Collections.emptyList();
}
List<ProxyConnectorRule> proxyConnectorRules = new ArrayList<>(proxyConnectorRuleConfigurations.size());
for (ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : proxyConnectorRuleConfigurations) {
ProxyConnectorRule proxyConnectorRule = new ProxyConnectorRule();
proxyConnectorRule.setPattern(proxyConnectorRuleConfiguration.getPattern());
proxyConnectorRule.setProxyConnectorRuleType(getProxyConnectorRuleType(proxyConnectorRuleConfiguration.getRuleType()));
for (ProxyConnectorConfiguration proxyConnectorConfiguration : proxyConnectorRuleConfiguration.getProxyConnectors()) {
ProxyConnector proxyConnector = new ProxyConnector();
proxyConnector.setSourceRepoId(proxyConnectorConfiguration.getSourceRepoId());
proxyConnector.setTargetRepoId(proxyConnectorConfiguration.getTargetRepoId());
proxyConnectorRule.getProxyConnectors().add(proxyConnector);
}
proxyConnectorRules.add(proxyConnectorRule);
}
return proxyConnectorRules;
}
Aggregations