Search in sources :

Example 26 with RemoteRepositoryConfiguration

use of org.apache.archiva.configuration.RemoteRepositoryConfiguration in project archiva by apache.

the class MavenRepositoryProvider method getRemoteConfiguration.

@Override
public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException {
    if (!(remoteRepository instanceof MavenRemoteRepository)) {
        log.error("Wrong remote repository type " + remoteRepository.getClass().getName());
        throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName());
    }
    RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration();
    cfg.setType(remoteRepository.getType().toString());
    cfg.setId(remoteRepository.getId());
    cfg.setName(remoteRepository.getName());
    cfg.setDescription(remoteRepository.getDescription());
    cfg.setUrl(remoteRepository.getLocation().toString());
    cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000);
    cfg.setCheckPath(remoteRepository.getCheckPath());
    RepositoryCredentials creds = remoteRepository.getLoginCredentials();
    if (creds != null) {
        if (creds instanceof PasswordCredentials) {
            PasswordCredentials pCreds = (PasswordCredentials) creds;
            cfg.setPassword(new String(pCreds.getPassword()));
            cfg.setUsername(pCreds.getUsername());
        }
    }
    cfg.setLayout(remoteRepository.getLayout());
    cfg.setExtraParameters(remoteRepository.getExtraParameters());
    cfg.setExtraHeaders(remoteRepository.getExtraHeaders());
    cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition());
    IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get();
    cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath()));
    cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath()));
    RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get();
    cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString());
    cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS));
    cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup());
    cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex());
    cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId());
    return cfg;
}
Also used : RepositoryCredentials(org.apache.archiva.repository.RepositoryCredentials) PasswordCredentials(org.apache.archiva.repository.PasswordCredentials) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) RepositoryException(org.apache.archiva.repository.RepositoryException)

Aggregations

RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)26 Configuration (org.apache.archiva.configuration.Configuration)9 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)8 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)7 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)7 Test (org.junit.Test)6 ContextConfiguration (org.springframework.test.context.ContextConfiguration)6 RemoteIndexFeature (org.apache.archiva.repository.features.RemoteIndexFeature)5 ArrayList (java.util.ArrayList)4 PasswordCredentials (org.apache.archiva.repository.PasswordCredentials)4 Before (org.junit.Before)4 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)3 WagonFactory (org.apache.archiva.proxy.common.WagonFactory)3 WagonFactoryRequest (org.apache.archiva.proxy.common.WagonFactoryRequest)3 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)3 RepositoryCredentials (org.apache.archiva.repository.RepositoryCredentials)3 RepositoryException (org.apache.archiva.repository.RepositoryException)3 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)3 Wagon (org.apache.maven.wagon.Wagon)3 URI (java.net.URI)2