@Override
public <P extends Populator<String, String>> P populateLayoutAttributes(HttpServletRequest request,
PreferencesScope prefScope, String nodeId, P layoutAttributes) {
final StylesheetPreferencesKey stylesheetPreferencesKey = this.getStylesheetPreferencesKey(request, prefScope);
final IStylesheetDescriptor stylesheetDescriptor = stylesheetPreferencesKey.stylesheetDescriptor;
//Get the scoped sources once
final IStylesheetUserPreferences stylesheetUserPreferences = this.getStylesheetUserPreferences(request, stylesheetPreferencesKey);
final Map<String, Map<String, String>> sessionLayoutAttributes;
final HttpSession session = request.getSession(false);
if (session == null) {
sessionLayoutAttributes = null;
}
else {
sessionLayoutAttributes = getSessionLayoutAttributes(session, stylesheetPreferencesKey);
}
final Map<String, Map<String, String>> requestLayoutAttributes = getRequestLayoutAttributes(request, stylesheetPreferencesKey);
final IStylesheetUserPreferences distributedStylesheetUserPreferences = this.getDistributedStylesheetUserPreferences(request, prefScope);
if (distributedStylesheetUserPreferences != null) {
distributedStylesheetUserPreferences.populateLayoutAttributes(nodeId, layoutAttributes);
}
//Try getting each layout attribute to populate the Map
for (final ILayoutAttributeDescriptor layoutAttributeDescriptor : stylesheetDescriptor.getLayoutAttributeDescriptors()) {
final String name = layoutAttributeDescriptor.getName();
String value;
final Scope scope = layoutAttributeDescriptor.getScope();
switch (scope) {