Search in sources :

Example 16 with ProxyConnectorConfiguration

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;
    }
}
Also used : Path(java.nio.file.Path) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration)

Example 17 with ProxyConnectorConfiguration

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;
}
Also used : ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 18 with ProxyConnectorConfiguration

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;
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 19 with ProxyConnectorConfiguration

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;
}
Also used : ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule) ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 20 with ProxyConnectorConfiguration

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);
        }
    }
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration)

Aggregations

ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)23 Configuration (org.apache.archiva.configuration.Configuration)9 ArrayList (java.util.ArrayList)7 ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)4 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)4 ProxyConnectorRuleConfiguration (org.apache.archiva.configuration.ProxyConnectorRuleConfiguration)4 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)4 Path (java.nio.file.Path)3 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)3 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)3 WagonFactory (org.apache.archiva.proxy.common.WagonFactory)3 WagonFactoryRequest (org.apache.archiva.proxy.common.WagonFactoryRequest)3 Wagon (org.apache.maven.wagon.Wagon)3 Before (org.junit.Before)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)2 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)2 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)2 HashMap (java.util.HashMap)1 List (java.util.List)1