Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,17 @@ public boolean update(String name, String category, String value) {
@Override
public String getValue(String name) {
ConfigurationVO config = findByName(name);
return (config == null) ? null : config.getValue();
if (config == null) {
return null;
}
try {
return config.getValue();
} catch (CloudRuntimeException ex) {
logger.error("Unable to get global configuration {}: {}. " +
"We expect the value of setting to be encrypted in the database with the Management Server's key, " +
"but we were unable to decrypt it using this key", name, ex.getMessage());
throw ex;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,7 @@ protected String getConfigStringValueInternal(Ternary<String, ConfigKey.Scope, L
}
return scopedConfigStorage.getConfigValue(scopeId, key);
}
ConfigurationVO configurationVO = _configDao.findById(key);
if (configurationVO != null) {
return configurationVO.getValue();
}
return null;
return _configDao.getValue(key);
}

protected Ternary<String, ConfigKey.Scope, Long> getConfigCacheKey(String key, ConfigKey.Scope scope, Long scopeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void setName(String name) {

@Override
public String getValue() {
if(isEncrypted()) {
if (isEncrypted()) {
return DBEncryptionUtil.decrypt(value);
} else {
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public void testIsNewConfig() {
}

private void runTestGetConfigStringValue(String key, String value) {
ConfigurationVO configurationVO = Mockito.mock(ConfigurationVO.class);
Mockito.when(configurationVO.getValue()).thenReturn(value);
Mockito.when(_configDao.findById(key)).thenReturn(configurationVO);
Mockito.when(_configDao.getValue(key)).thenReturn(value);
String result = configDepotImpl.getConfigStringValue(key, ConfigKey.Scope.Global, null);
Assert.assertEquals(value, result);
}
Expand All @@ -106,7 +104,7 @@ private void runTestGetConfigStringValueExpiry(long wait, int configDBRetrieval)
}
String result = configDepotImpl.getConfigStringValue(key, ConfigKey.Scope.Global, null);
Assert.assertEquals(value, result);
Mockito.verify(_configDao, Mockito.times(configDBRetrieval)).findById(key);
Mockito.verify(_configDao, Mockito.times(configDBRetrieval)).getValue(key);
}

@Test
Expand Down
Loading