Search in sources :

Example 6 with RemoteRepositoryConfiguration

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

the class DefaultRemoteRepositoryAdmin method getRepositoryConfiguration.

private RemoteRepositoryConfiguration getRepositoryConfiguration(org.apache.archiva.admin.model.beans.RemoteRepository repo) {
    RemoteRepositoryConfiguration repoConfig = new RemoteRepositoryConfiguration();
    setBaseRepoAttributes(repoConfig, repo);
    repoConfig.setUrl(getRepositoryCommonValidator().removeExpressions(repo.getUrl()));
    repoConfig.setRefreshCronExpression(repo.getCronExpression());
    repoConfig.setCheckPath(repo.getCheckPath());
    repoConfig.setExtraHeaders(repo.getExtraHeaders());
    repoConfig.setExtraParameters(repo.getExtraParameters());
    repoConfig.setUsername(repo.getUserName());
    repoConfig.setPassword(repo.getPassword());
    repoConfig.setTimeout(repo.getTimeout());
    repoConfig.setRemoteIndexUrl(repo.getRemoteIndexUrl());
    repoConfig.setDownloadRemoteIndex(repo.isDownloadRemoteIndex());
    repoConfig.setRemoteDownloadNetworkProxyId(repo.getRemoteDownloadNetworkProxyId());
    repoConfig.setDownloadRemoteIndexOnStartup(repo.isDownloadRemoteIndexOnStartup());
    repoConfig.setRemoteDownloadTimeout(repo.getRemoteDownloadTimeout());
    repoConfig.setDescription(repo.getDescription());
    repoConfig.setIndexDir(repo.getIndexDirectory());
    return repoConfig;
}
Also used : RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration)

Example 7 with RemoteRepositoryConfiguration

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

the class DefaultRemoteRepositoryAdmin method updateRemoteRepository.

@Override
public Boolean updateRemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository, AuditInformation auditInformation) throws RepositoryAdminException {
    String repositoryId = remoteRepository.getId();
    triggerAuditEvent(repositoryId, null, AuditEvent.MODIFY_REMOTE_REPO, auditInformation);
    // update means : remove and add
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRepositoryConfiguration(remoteRepository);
    try {
        repositoryRegistry.putRepository(remoteRepositoryConfiguration, configuration);
    } catch (RepositoryException e) {
        log.error("Could not update remote repository {}: {}", remoteRepositoryConfiguration.getId(), e.getMessage(), e);
        throw new RepositoryAdminException("Update of remote repository failed" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
    }
    saveConfiguration(configuration);
    return Boolean.TRUE;
}
Also used : RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) RepositoryException(org.apache.archiva.repository.RepositoryException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 8 with RemoteRepositoryConfiguration

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

the class DefaultRemoteRepositoryAdmin method addRemoteRepository.

@Override
public Boolean addRemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository, AuditInformation auditInformation) throws RepositoryAdminException {
    triggerAuditEvent(remoteRepository.getId(), null, AuditEvent.ADD_REMOTE_REPO, auditInformation);
    getRepositoryCommonValidator().basicValidation(remoteRepository, false);
    // TODO we can validate it's a good uri/url
    if (StringUtils.isEmpty(remoteRepository.getUrl())) {
        throw new RepositoryAdminException("url cannot be null");
    }
    // MRM-752 - url needs trimming
    // MRM-1940 - URL should not end with a slash
    remoteRepository.setUrl(StringUtils.stripEnd(StringUtils.trim(remoteRepository.getUrl()), "/"));
    if (StringUtils.isEmpty(remoteRepository.getCheckPath())) {
        String checkUrl = remoteRepository.getUrl().toLowerCase();
        for (RepositoryCheckPath path : getArchivaConfiguration().getConfiguration().getArchivaDefaultConfiguration().getDefaultCheckPaths()) {
            log.debug("Checking path for urls: {} <-> {}", checkUrl, path.getUrl());
            if (checkUrl.startsWith(path.getUrl())) {
                remoteRepository.setCheckPath(path.getPath());
                break;
            }
        }
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRepositoryConfiguration(remoteRepository);
    log.debug("Adding remote repo {}", remoteRepositoryConfiguration);
    try {
        repositoryRegistry.putRepository(remoteRepositoryConfiguration, configuration);
    } catch (RepositoryException e) {
        log.error("Could not add remote repository {}: {}", remoteRepositoryConfiguration.getId(), e.getMessage(), e);
        throw new RepositoryAdminException("Adding of remote repository failed" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
    }
    saveConfiguration(configuration);
    return Boolean.TRUE;
}
Also used : RepositoryCheckPath(org.apache.archiva.configuration.RepositoryCheckPath) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) RepositoryException(org.apache.archiva.repository.RepositoryException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 9 with RemoteRepositoryConfiguration

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

the class AbstractProxyTestCase method saveRemoteRepositoryConfig.

protected void saveRemoteRepositoryConfig(String id, String name, String url, String layout) {
    RemoteRepositoryConfiguration repoConfig = new RemoteRepositoryConfiguration();
    repoConfig.setId(id);
    repoConfig.setName(name);
    repoConfig.setLayout(layout);
    repoConfig.setUrl(url);
    int count = config.getConfiguration().getRemoteRepositories().size();
    config.getConfiguration().addRemoteRepository(repoConfig);
    String prefix = "remoteRepositories.remoteRepository(" + count + ")";
    config.triggerChange(prefix + ".id", repoConfig.getId());
    config.triggerChange(prefix + ".name", repoConfig.getName());
    config.triggerChange(prefix + ".url", repoConfig.getUrl());
    config.triggerChange(prefix + ".layout", repoConfig.getLayout());
    repositoryRegistry.reload();
}
Also used : RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration)

Example 10 with RemoteRepositoryConfiguration

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

the class AbstractRepositoryServletTestCase method createRemoteRepository.

protected RemoteRepositoryConfiguration createRemoteRepository(String id, String name, String url) {
    RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
    repo.setId(id);
    repo.setName(name);
    repo.setUrl(url);
    return repo;
}
Also used : RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration)

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