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;
}
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;
}
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;
}
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();
}
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;
}
Aggregations