use of org.apache.archiva.repository.RepositoryCredentials 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;
}
Aggregations