log.debug("assembling preference values for '"
+ preferenceEntityName
+ "' and user '" + user
+ "' and wiki macro ' " + instance + "'");
PreferenceEntity entity = preferenceRegistry.getPreferenceEntitiesByName().get(preferenceEntityName);
SortedSet<PreferenceValue> valueHolders = new TreeSet<PreferenceValue>();
Set<PreferenceValue> systemValueHolders = null;
if (visibilities.contains(PreferenceVisibility.SYSTEM)) {
log.trace("retrieving SYSTEM preference values from database");
systemValueHolders = loadSystemValues(preferenceEntityName);
// Check if all SYSTEM-level properties were present in the database
for (PreferenceEntity.Property systemVisibleProperty : entity.getPropertiesSystemVisible()) {
WikiPreferenceValue newValueHolder = new WikiPreferenceValue(systemVisibleProperty);
// If not, queue a new value holder (with a null "value") for that property and return it
if (!systemValueHolders.contains(newValueHolder)) {
systemValueHolders.add(newValueHolder);
newValueHolders.add(newValueHolder);
}
}
valueHolders.addAll(systemValueHolders);
}
Set<PreferenceValue> userValueHolders;
if (visibilities.contains(PreferenceVisibility.USER)) {
if (user == null)
throw new IllegalArgumentException("can't load preferences for null user");
log.trace("retrieving USER preference values from database");
userValueHolders = loadUserValues(preferenceEntityName, user);
// We need them when we iterate through missing properties next
if (systemValueHolders == null) systemValueHolders = loadSystemValues(preferenceEntityName);
// Check if all USER-level properties were present in the database
for (PreferenceEntity.Property userVisibleProperty : entity.getPropertiesUserVisible()) {
WikiPreferenceValue newValueHolder = new WikiPreferenceValue(userVisibleProperty);
// If not, queue a new value for that property and return it
if (!userValueHolders.contains(newValueHolder)) {
log.trace("creating new preference value for user, missing in database " + userVisibleProperty);