This commit is contained in:
Suresh Kumar Anaparti 2026-01-22 15:13:15 +01:00 committed by GitHub
commit 740b167984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 40 additions and 2 deletions

View File

@ -246,4 +246,9 @@ public abstract class ResourceDetailsDaoBase<R extends ResourceDetail> extends G
}
return resourceDetail.getValue();
}
public boolean doesKeyValuePairExist(String key, String value) {
List<R> details = findDetails(key, value, null);
return CollectionUtils.isNotEmpty(details);
}
}

View File

@ -277,4 +277,10 @@ public class ConfigKey<T> {
}
}
public boolean hasValueInScope(String value) {
if (value != null && s_depot != null) {
return s_depot.doesConfigKeyAndValueExistInScope(_name, value, _scope);
}
return false;
}
}

View File

@ -31,4 +31,10 @@ public interface ScopedConfigStorage {
default String getConfigValue(long id, ConfigKey<?> key) {
return getConfigValue(id, key.key());
}
boolean doesKeyValuePairExist(String key, String value);
default boolean doesConfigKeyAndValueExist(String key, String value) {
return doesKeyValuePairExist(key, value);
}
}

View File

@ -296,6 +296,27 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
return null;
}
public boolean doesConfigKeyAndValueExistInScope(String key, String value, ConfigKey.Scope scope) {
if (!ConfigKey.Scope.Global.equals(scope)) {
ScopedConfigStorage scopedConfigStorage = null;
for (ScopedConfigStorage storage : _scopedStorages) {
if (storage.getScope() == scope) {
scopedConfigStorage = storage;
}
}
if (scopedConfigStorage == null) {
logger.warn("Unable to check existence of config key {} and value {} in scope: {}, couldn't find config storage for this scope", key, value, scope);
return false;
}
return scopedConfigStorage.doesConfigKeyAndValueExist(key, value);
}
ConfigurationVO configurationVO = _configDao.findByName(key);
if (configurationVO != null) {
return configurationVO.getValue().equalsIgnoreCase(value);
}
return false;
}
protected Ternary<String, ConfigKey.Scope, Long> getConfigCacheKey(String key, ConfigKey.Scope scope, Long scopeId) {
return new Ternary<>(key, scope, scopeId);
}

View File

@ -947,7 +947,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
}
public boolean isDisabled(final Long zoneId) {
return !(BackupFrameworkEnabled.value() && BackupFrameworkEnabled.valueIn(zoneId));
return !(BackupFrameworkEnabled.valueIn(zoneId));
}
private void validateForZone(final Long zoneId) {
@ -980,7 +980,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
@Override
public List<Class<?>> getCommands() {
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
if (!BackupFrameworkEnabled.value()) {
if (!BackupFrameworkEnabled.value() && !BackupFrameworkEnabled.hasValueInScope(Boolean.TRUE.toString())) {
return cmdList;
}