use of org.apache.archiva.configuration.model.ProxyConnectorConfiguration in project archiva by apache.
the class ConfigurationRegistryReader method readProxyConnectorRuleConfiguration.
private ProxyConnectorRuleConfiguration readProxyConnectorRuleConfiguration(String prefix, Registry registry) {
ProxyConnectorRuleConfiguration value = new ProxyConnectorRuleConfiguration();
// String ruleType = registry.getString( prefix + "ruleType", value.getRuleType() );
List<String> ruleTypeList = registry.getList(prefix + "ruleType");
String ruleType = value.getRuleType();
if (ruleTypeList != null && !ruleTypeList.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (int i = 0, size = ruleTypeList.size(); i < size; i++) {
sb.append(ruleTypeList.get(i));
if (i < size - 1) {
sb.append(',');
}
}
ruleType = sb.toString();
}
value.setRuleType(ruleType);
// String pattern = registry.getString( prefix + "pattern", value.getPattern() );
List<String> patternList = registry.getList(prefix + "pattern");
String pattern = value.getPattern();
if (patternList != null && !patternList.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (int i = 0, size = patternList.size(); i < size; i++) {
sb.append(patternList.get(i));
if (i < size - 1) {
sb.append(',');
}
}
pattern = sb.toString();
}
value.setPattern(pattern);
java.util.List proxyConnectors = new java.util.ArrayList();
List proxyConnectorsSubsets = registry.getSubsetList(prefix + "proxyConnectors.proxyConnector");
for (Iterator i = proxyConnectorsSubsets.iterator(); i.hasNext(); ) {
ProxyConnectorConfiguration v = readProxyConnectorConfiguration("", (Registry) i.next());
proxyConnectors.add(v);
}
value.setProxyConnectors(proxyConnectors);
return value;
}
use of org.apache.archiva.configuration.model.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.model.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.getId());
connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId());
connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.ALWAYS.getId());
connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO.getId());
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.model.ProxyConnectorConfiguration in project archiva by apache.
the class MockRepoAdmin method getProxyConnectors.
@Override
public List<ProxyConnector> getProxyConnectors() throws RepositoryAdminException {
List<ProxyConnectorConfiguration> proxyConnectorConfigurations = archivaConfiguration.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.configuration.model.ProxyConnectorConfiguration in project archiva by apache.
the class AbstractRepositoryServletProxiedTestCase method setupConnector.
private void setupConnector(String repoId, RemoteRepoInfo remoteRepo, PolicyOption releasesPolicy, PolicyOption snapshotsPolicy) {
ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
connector.setSourceRepoId(repoId);
connector.setTargetRepoId(remoteRepo.id);
connector.addPolicy(ProxyConnectorConfiguration.POLICY_RELEASES, releasesPolicy.getId());
connector.addPolicy(ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotsPolicy.getId());
connector.addPolicy(ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE.getId());
connector.addPolicy(ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO.getId());
archivaConfiguration.getConfiguration().addProxyConnector(connector);
}
Aggregations