use of org.apache.archiva.configuration.model.ProxyConnectorConfiguration 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.configuration.model.ProxyConnectorConfiguration in project archiva by apache.
the class DefaultProxyConnectorAdmin method addProxyConnector.
@Override
public Boolean addProxyConnector(ProxyConnector proxyConnector, AuditInformation auditInformation) throws RepositoryAdminException {
if (getProxyConnector(proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId()) != null) {
throw new RepositoryAdminException("Unable to add proxy connector, as one already exists with source repository id [" + proxyConnector.getSourceRepoId() + "] and target repository id [" + proxyConnector.getTargetRepoId() + "].");
}
validateProxyConnector(proxyConnector);
proxyConnector.setBlackListPatterns(unescapePatterns(proxyConnector.getBlackListPatterns()));
proxyConnector.setWhiteListPatterns(unescapePatterns(proxyConnector.getWhiteListPatterns()));
Configuration configuration = getArchivaConfiguration().getConfiguration();
ProxyConnectorConfiguration proxyConnectorConfiguration = getProxyConnectorConfiguration(proxyConnector);
configuration.addProxyConnector(proxyConnectorConfiguration);
saveConfiguration(configuration);
triggerAuditEvent(proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null, AuditEvent.ADD_PROXY_CONNECTOR, auditInformation);
return Boolean.TRUE;
}
use of org.apache.archiva.configuration.model.ProxyConnectorConfiguration 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;
}
use of org.apache.archiva.configuration.model.ProxyConnectorConfiguration in project archiva by apache.
the class ArchivaProxyRegistry method updateConnectors.
private void updateConnectors() {
List<ProxyConnectorConfiguration> proxyConnectorConfigurations = getArchivaConfiguration().getConfiguration().getProxyConnectors();
connectorList = proxyConnectorConfigurations.stream().map(this::buildProxyConnector).filter(Optional::isPresent).map(Optional::get).sorted(comparator).collect(Collectors.toList());
connectorMap = connectorList.stream().collect(Collectors.groupingBy(a -> a.getSourceRepository().getId()));
for (RepositoryProxyHandler handler : repositoryProxyHandlers) {
handler.setProxyConnectors(connectorList);
}
}
use of org.apache.archiva.configuration.model.ProxyConnectorConfiguration in project archiva by apache.
the class MetadataTools method initConfigVariables.
private void initConfigVariables() {
assert (this.artifactPatterns != null);
assert (proxies != null);
synchronized (this.artifactPatterns) {
this.artifactPatterns.clear();
this.artifactPatterns.addAll(filetypes.getFileTypePatterns(FileTypes.ARTIFACTS));
}
synchronized (proxies) {
this.proxies.clear();
List<ProxyConnectorConfiguration> proxyConfigs = configuration.getConfiguration().getProxyConnectors();
for (ProxyConnectorConfiguration proxyConfig : proxyConfigs) {
String key = proxyConfig.getSourceRepoId();
Set<String> remoteRepoIds = this.proxies.get(key);
if (remoteRepoIds == null) {
remoteRepoIds = new HashSet<String>();
}
remoteRepoIds.add(proxyConfig.getTargetRepoId());
this.proxies.put(key, remoteRepoIds);
}
}
}
Aggregations