use of org.apache.archiva.configuration.model.RepositoryCheckPath in project archiva by apache.
the class DefaultArchivaConfiguration method updateCheckPathDefaults.
/*
* Updates the checkpath list for repositories.
*
* We are replacing existing ones and adding new ones. This allows to update the list with new releases.
*
* We are also updating existing remote repositories, if they exist already.
*
* This update method should only be called, if the config version changes to avoid overwriting
* user repository settings all the time.
*/
private void updateCheckPathDefaults(Configuration config, Registry defaultConfiguration) {
List<RepositoryCheckPath> existingCheckPathList = config.getArchivaDefaultConfiguration().getDefaultCheckPaths();
HashMap<String, RepositoryCheckPath> existingCheckPaths = new HashMap<>();
HashMap<String, RepositoryCheckPath> newCheckPaths = new HashMap<>();
for (RepositoryCheckPath path : config.getArchivaDefaultConfiguration().getDefaultCheckPaths()) {
existingCheckPaths.put(path.getUrl(), path);
}
List defaultCheckPathsSubsets = defaultConfiguration.getSubsetList("archivaDefaultConfiguration.defaultCheckPaths.defaultCheckPath");
for (Iterator i = defaultCheckPathsSubsets.iterator(); i.hasNext(); ) {
RepositoryCheckPath v = readRepositoryCheckPath((Registry) i.next());
if (existingCheckPaths.containsKey(v.getUrl())) {
existingCheckPathList.remove(existingCheckPaths.get(v.getUrl()));
}
existingCheckPathList.add(v);
newCheckPaths.put(v.getUrl(), v);
}
// Remote repositories update
for (RemoteRepositoryConfiguration remoteRepositoryConfiguration : config.getRemoteRepositories()) {
String url = remoteRepositoryConfiguration.getUrl().toLowerCase();
if (newCheckPaths.containsKey(url)) {
String currentPath = remoteRepositoryConfiguration.getCheckPath();
String newPath = newCheckPaths.get(url).getPath();
log.info("Updating connection check path for repository {}, from '{}' to '{}'.", remoteRepositoryConfiguration.getId(), currentPath, newPath);
remoteRepositoryConfiguration.setCheckPath(newPath);
}
}
}
Aggregations