use of org.apache.archiva.configuration.ProxyConnectorConfiguration in project archiva by apache.
the class MetadataToolsTest method createProxyConnector.
private void createProxyConnector(String sourceRepoId, String targetRepoId) {
ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
connectorConfig.setSourceRepoId(sourceRepoId);
connectorConfig.setTargetRepoId(targetRepoId);
connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE);
connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS);
connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.ALWAYS);
connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO);
int count = config.getConfiguration().getProxyConnectors().size();
config.getConfiguration().addProxyConnector(connectorConfig);
// Proper Triggering ...
String prefix = "proxyConnectors.proxyConnector(" + count + ")";
config.triggerChange(prefix + ".sourceRepoId", connectorConfig.getSourceRepoId());
config.triggerChange(prefix + ".targetRepoId", connectorConfig.getTargetRepoId());
config.triggerChange(prefix + ".proxyId", connectorConfig.getProxyId());
config.triggerChange(prefix + ".policies.releases", connectorConfig.getPolicy("releases", ""));
config.triggerChange(prefix + ".policies.checksum", connectorConfig.getPolicy("checksum", ""));
config.triggerChange(prefix + ".policies.snapshots", connectorConfig.getPolicy("snapshots", ""));
config.triggerChange(prefix + ".policies.cache-failures", connectorConfig.getPolicy("cache-failures", ""));
}
use of org.apache.archiva.configuration.ProxyConnectorConfiguration in project archiva by apache.
the class MetadataToolsTest method removeProxyConnector.
private void removeProxyConnector(String sourceRepoId, String targetRepoId) {
ProxyConnectorConfiguration toRemove = null;
for (ProxyConnectorConfiguration pcc : config.getConfiguration().getProxyConnectors()) {
if (pcc.getTargetRepoId().equals(targetRepoId) && pcc.getSourceRepoId().equals(sourceRepoId)) {
toRemove = pcc;
}
}
if (toRemove != null) {
config.getConfiguration().removeProxyConnector(toRemove);
// XXX
String prefix = "proxyConnectors.proxyConnector(" + "1" + ")";
config.triggerChange(prefix + ".sourceRepoId", toRemove.getSourceRepoId());
config.triggerChange(prefix + ".targetRepoId", toRemove.getTargetRepoId());
config.triggerChange(prefix + ".proxyId", toRemove.getProxyId());
config.triggerChange(prefix + ".policies.releases", toRemove.getPolicy("releases", ""));
config.triggerChange(prefix + ".policies.checksum", toRemove.getPolicy("checksum", ""));
config.triggerChange(prefix + ".policies.snapshots", toRemove.getPolicy("snapshots", ""));
config.triggerChange(prefix + ".policies.cache-failures", toRemove.getPolicy("cache-failures", ""));
}
}
use of org.apache.archiva.configuration.ProxyConnectorConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
testRepo.setReleases(true);
testRepo.setSnapshots(false);
c.addManagedRepository(testRepo);
testRepoS = new ManagedRepositoryConfiguration();
testRepoS.setId(TEST_SNAP_REPO_ID);
testRepoS.setLocation(Paths.get("target/test-repositorys").toAbsolutePath().toString());
testRepoS.setReleases(false);
testRepoS.setSnapshots(true);
c.addManagedRepository(testRepoS);
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
testRemoteRepo.setLayout("default");
testRemoteRepo.setName("Central Repository");
testRemoteRepo.setUrl("http://central.repo.com/maven2");
testRemoteRepo.setTimeout(10);
c.addRemoteRepository(testRemoteRepo);
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
proxyConnector.setSourceRepoId(TEST_REPO_ID);
proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnector.setDisabled(false);
c.addProxyConnector(proxyConnector);
ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
proxyConnectors.setSourceRepoId(TEST_SNAP_REPO_ID);
proxyConnectors.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnectors.setDisabled(false);
c.addProxyConnector(proxyConnectors);
List<String> repos = new ArrayList<>();
repos.add(TEST_REPO_ID);
repos.add(TEST_SNAP_REPO_ID);
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
repoGroup.setId(TEST_REPO_GROUP_ID);
repoGroup.setRepositories(repos);
c.addRepositoryGroup(repoGroup);
configuration.save(c);
repositoryRegistry.reload();
assertFalse(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
assertTrue(c.getManagedRepositories().get(1).isSnapshots());
assertFalse(c.getManagedRepositories().get(1).isReleases());
wagonFactory = mock(WagonFactory.class);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
Aggregations