use of org.apache.archiva.configuration.ProxyConnectorConfiguration in project archiva by apache.
the class RepositoryServletProxiedReleasePolicyTest method assertGetProxiedReleaseArtifactWithPolicy.
private void assertGetProxiedReleaseArtifactWithPolicy(int expectation, String releasePolicy, boolean hasManagedCopy, long deltaManagedToRemoteTimestamp) throws Exception {
// --- Setup
setupCentralRemoteRepo();
setupCleanInternalRepo();
String resourcePath = "org/apache/archiva/test/1.0/test-1.0.jar";
String expectedRemoteContents = "archiva-test-1.0|jar-remote-contents";
String expectedManagedContents = null;
Path remoteFile = populateRepo(remoteCentral, resourcePath, expectedRemoteContents);
if (hasManagedCopy) {
expectedManagedContents = "archiva-test-1.0|jar-managed-contents";
Path managedFile = populateRepo(repoRootInternal, resourcePath, expectedManagedContents);
Files.setLastModifiedTime(managedFile, FileTime.fromMillis(Files.getLastModifiedTime(remoteFile).toMillis() + deltaManagedToRemoteTimestamp));
}
archivaConfiguration.getConfiguration().setProxyConnectors(new ArrayList<ProxyConnectorConfiguration>());
setupReleaseConnector(REPOID_INTERNAL, remoteCentral, releasePolicy);
saveConfiguration();
// --- Execution
// process the response code later, not via an exception.
// HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
WebRequest request = new GetMethodWebRequest("http://machine.com/repository/internal/" + resourcePath);
WebResponse response = getServletUnitClient().getResponse(request);
switch(expectation) {
case EXPECT_MANAGED_CONTENTS:
assertResponseOK(response);
assertTrue("Invalid Test Case: Can't expect managed contents with " + "test that doesn't have a managed copy in the first place.", hasManagedCopy);
assertEquals("Expected managed file contents", expectedManagedContents, response.getContentAsString());
break;
case EXPECT_REMOTE_CONTENTS:
assertResponseOK(response);
assertEquals("Expected remote file contents", expectedRemoteContents, response.getContentAsString());
break;
case EXPECT_NOT_FOUND:
assertResponseNotFound(response);
assertManagedFileNotExists(repoRootInternal, resourcePath);
break;
}
}
use of org.apache.archiva.configuration.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.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.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.ProxyConnectorConfiguration in project archiva by apache.
the class MetadataTools method initConfigVariables.
private void initConfigVariables() {
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