super.doApplyConfiguration(repository, configuration, coreConfig);
// proxy stuff, but is optional!
// FIXME: hm, we are called when we are dirty, so....
CRepository repo = coreConfig.getConfiguration(true);
if (repo.getRemoteStorage() != null) {
// NOTE: we are intentionally _casting_ it, not calling adaptToFacet(), since repo implementation
// still does not know that is should be a proxy repo!
ProxyRepository prepository = (ProxyRepository) repository;
try {
if (repo.getRemoteStorage() != null) {
RemoteRepositoryStorage oldRemoteStorage = prepository.getRemoteStorage();
RemoteRepositoryStorage configRemoteStorage =
getRemoteRepositoryStorage(repo.getId(), repo.getRemoteStorage().getUrl(),
repo.getRemoteStorage().getProvider());
// detect do we really need to set remote storage
if (oldRemoteStorage == null || oldRemoteStorage != configRemoteStorage) {
// validate the remoteUrl with new remote storage
configRemoteStorage.validateStorageUrl(repo.getRemoteStorage().getUrl());
// set the chosen remote storage
prepository.setRemoteStorage(configRemoteStorage);
// mark remote storage context dirty, if applicable
final RemoteStorageContext ctx = prepository.getRemoteStorageContext();
if (ctx != null) {
ctx.incrementGeneration();
}
}
else {
// just validate
oldRemoteStorage.validateStorageUrl(repo.getRemoteStorage().getUrl());
}
if (repo.getRemoteStorage().getAuthentication() != null) {
prepository.setRemoteAuthenticationSettings(
authenticationInfoConverter.convertAndValidateFromModel(repo.getRemoteStorage().getAuthentication()));
}
if (repo.getRemoteStorage().getConnectionSettings() != null) {
prepository.setRemoteConnectionSettings(globalRemoteConnectionSettings
.convertAndValidateFromModel(repo.getRemoteStorage().getConnectionSettings()));
}
}
else {
prepository.setRemoteStorage(null);
}