@Override
public String getStylesheetParameter(HttpServletRequest request, PreferencesScope prefScope, String name) {
final StylesheetPreferencesKey stylesheetPreferencesKey = this.getStylesheetPreferencesKey(request, prefScope);
final IStylesheetDescriptor stylesheetDescriptor = stylesheetPreferencesKey.stylesheetDescriptor;
final IStylesheetParameterDescriptor stylesheetParameterDescriptor = stylesheetDescriptor.getStylesheetParameterDescriptor(name);
if (stylesheetParameterDescriptor == null) {
logger.warn("Attempted to get stylesheet parameter {} but no such stylesheet parameter is defined in stylesheet descriptor {}. null will be returned", new Object[] {name, stylesheetDescriptor.getName()});
return null;
}
final String value;
final Scope scope = stylesheetParameterDescriptor.getScope();
switch (scope) {
case PERSISTENT: {
final IStylesheetUserPreferences stylesheetUserPreferences = this.getStylesheetUserPreferences(request, stylesheetPreferencesKey);
if (stylesheetUserPreferences == null) {
return null;
}
value = stylesheetUserPreferences.getStylesheetParameter(name);
break;
}
default: {
value = this.getDataValue(request, stylesheetPreferencesKey, scope, STYLESHEET_PARAMETERS_KEY, name);
break;
}
}
if (value == null) {
return null;
}
//If the value is equal to the default value remove the property and return null
if (this.compareValues(value, stylesheetParameterDescriptor.getDefaultValue())) {
this.removeStylesheetParameter(request, prefScope, name);
return null;
}
return value;