Serializable userHomeId = repository.getFile( homePath ).getId();
Map<String, Serializable> userMetadata = repository.getFileMetadata( userHomeId );
for ( String key : userMetadata.keySet() ) {
if ( key.startsWith( SETTING_PREFIX ) ) {
UserSetting setting = new UserSetting();
setting.setSettingName( key.substring( SETTING_PREFIX.length() ) );
setting.setSettingValue( userMetadata.get( key ).toString() );
if ( setting.getSettingName().equals( settingName ) ) {
return setting;
}
}
}
String tentantHomePath = ClientRepositoryPaths.getEtcFolderPath();
Serializable tenantHomeId = repository.getFile( tentantHomePath ).getId();
Map<String, Serializable> tenantMetadata = repository.getFileMetadata( tenantHomeId );
for ( String key : tenantMetadata.keySet() ) {
if ( key.startsWith( SETTING_PREFIX ) ) {
UserSetting setting = new UserSetting();
setting.setSettingName( key.substring( SETTING_PREFIX.length() ) );
setting.setSettingValue( tenantMetadata.get( key ).toString() );
if ( setting.getSettingName().equals( settingName ) ) {
return setting;
}
}
}
} catch ( Throwable ignored ) {
// if anything goes wrong with authentication (anonymous user) or permissions
// just return the default value, if we continue to log these errors (like on before Login)
// we'll see *many* errors in the logs which are not helpful
}
}
UserSetting defaultSetting = new UserSetting();
defaultSetting.setSettingName( settingName );
defaultSetting.setSettingValue( defaultValue );
return defaultSetting;
}