use of org.pentaho.platform.repository.usersettings.pojo.UserSetting in project pentaho-platform by pentaho.
the class UserSettingService method createSetting.
private static UserSetting createSetting(String name, String value) {
UserSetting setting = new UserSetting();
setting.setSettingName(name);
setting.setSettingValue(value);
return setting;
}
use of org.pentaho.platform.repository.usersettings.pojo.UserSetting in project pentaho-platform by pentaho.
the class UserSettingService method getUserSettings.
public List<IUserSetting> getUserSettings() {
// get the global settings and the user settings
// merge unseen global settings into the user settings list
List<IUserSetting> userSettings = new ArrayList<IUserSetting>();
String tentantHomePath = ClientRepositoryPaths.getEtcFolderPath();
Serializable tenantHomeId = repository.getFile(tentantHomePath).getId();
Map<String, Serializable> tenantMetadata = repository.getFileMetadata(tenantHomeId);
for (Map.Entry<String, Serializable> entry : tenantMetadata.entrySet()) {
String key = entry.getKey();
if (key.startsWith(SETTING_PREFIX)) {
UserSetting setting = createSetting(key.substring(SETTING_PREFIX.length()), entry.getValue());
userSettings.add(setting);
}
}
String homePath = ClientRepositoryPaths.getUserHomeFolderPath(PentahoSessionHolder.getSession().getName());
Serializable userHomeId = repository.getFile(homePath).getId();
Map<String, Serializable> userMetadata = repository.getFileMetadata(userHomeId);
for (Map.Entry<String, Serializable> entry : userMetadata.entrySet()) {
String key = entry.getKey();
if (key.startsWith(SETTING_PREFIX)) {
UserSetting setting = createSetting(key.substring(SETTING_PREFIX.length()), entry.getValue());
// see if a global setting exists which will be overridden
if (userSettings.contains(setting)) {
userSettings.remove(setting);
}
userSettings.add(setting);
}
}
return userSettings;
}
Aggregations