use of org.apereo.portal.layout.om.IStylesheetDescriptor in project uPortal by Jasig.
the class ThemeNameEqualsIgnoreCaseTester method test.
public boolean test(IPerson person) {
HttpServletRequest currentPortalRequest = getCurrentHttpServletRequest();
if (currentPortalRequest == null) {
return false;
}
IStylesheetDescriptor descriptor = getCurrentUserProfileStyleSheetDescriptor(person, currentPortalRequest);
String uiTheme = descriptor.getName();
logDebugMessages(uiTheme);
return getStringCompareResults(uiTheme);
}
use of org.apereo.portal.layout.om.IStylesheetDescriptor in project uPortal by Jasig.
the class StylesheetUserPreferencesServiceImpl method getStylesheetPreferencesKey.
protected final StylesheetPreferencesKey getStylesheetPreferencesKey(HttpServletRequest request, PreferencesScope prefScope) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPerson person = userInstance.getPerson();
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserProfile userProfile = preferencesManager.getUserProfile();
final IStylesheetDescriptor stylesheetDescriptor = getStylesheetDescriptor(request, prefScope);
return new StylesheetPreferencesKey(person, userProfile, stylesheetDescriptor);
}
use of org.apereo.portal.layout.om.IStylesheetDescriptor in project uPortal by Jasig.
the class StylesheetUserPreferencesServiceImpl method populateLayoutAttributes.
@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) {
case PERSISTENT:
{
if (stylesheetUserPreferences == null) {
value = null;
break;
}
value = stylesheetUserPreferences.getLayoutAttribute(nodeId, name);
break;
}
case SESSION:
{
if (sessionLayoutAttributes == null) {
value = null;
break;
}
final Map<String, String> nodeAttributes = sessionLayoutAttributes.get(nodeId);
if (nodeAttributes == null) {
value = null;
break;
}
value = nodeAttributes.get(name);
break;
}
case REQUEST:
{
if (requestLayoutAttributes == null) {
value = null;
break;
}
final Map<String, String> nodeAttributes = requestLayoutAttributes.get(nodeId);
if (nodeAttributes == null) {
value = null;
break;
}
value = nodeAttributes.get(name);
break;
}
default:
{
value = null;
break;
}
}
//Don't add unset properties
if (value == null) {
continue;
}
//If the value is equal to the default value remove the property and return null
if (this.compareValues(value, layoutAttributeDescriptor.getDefaultValue())) {
this.removeLayoutAttribute(request, prefScope, nodeId, name);
continue;
}
layoutAttributes.put(name, value);
}
return layoutAttributes;
}
use of org.apereo.portal.layout.om.IStylesheetDescriptor in project uPortal by Jasig.
the class StylesheetDescriptorImporterExporter method importData.
/* (non-Javadoc)
* @see org.apereo.portal.io.xml.IDataImporterExporter#importData(java.lang.Object)
*/
@Transactional
@Override
public void importData(ExternalStylesheetDescriptor data) {
final String stylesheetName = data.getName();
final String uri = data.getUri();
IStylesheetDescriptor stylesheetDescriptor = this.stylesheetDescriptorDao.getStylesheetDescriptorByName(stylesheetName);
if (stylesheetDescriptor == null) {
stylesheetDescriptor = this.stylesheetDescriptorDao.createStylesheetDescriptor(stylesheetName, uri);
} else {
stylesheetDescriptor.setStylesheetResource(uri);
}
stylesheetDescriptor.setUrlNodeSyntaxHelperName(data.getUrlSyntaxHelper());
stylesheetDescriptor.setDescription(data.getDescription());
final List<ExternalOutputPropertyDescriptor> extOutputProperties = data.getOutputProperties();
final List<IOutputPropertyDescriptor> outputPropertyDescriptors = new ArrayList<IOutputPropertyDescriptor>(extOutputProperties.size());
for (final ExternalOutputPropertyDescriptor extOutputProperty : extOutputProperties) {
final String name = extOutputProperty.getName();
final Scope scope = Scope.valueOf(extOutputProperty.getScope().name());
final OutputPropertyDescriptorImpl outputPropertyDescriptor = new OutputPropertyDescriptorImpl(name, scope);
outputPropertyDescriptor.setDefaultValue(extOutputProperty.getDefaultValue());
outputPropertyDescriptor.setDescription(extOutputProperty.getDescription());
outputPropertyDescriptors.add(outputPropertyDescriptor);
}
stylesheetDescriptor.setOutputPropertyDescriptors(outputPropertyDescriptors);
final List<ExternalStylesheetParameterDescriptor> extStylesheetParameters = data.getStylesheetParameters();
final List<IStylesheetParameterDescriptor> stylesheetParameterDescriptors = new ArrayList<IStylesheetParameterDescriptor>(extOutputProperties.size());
for (final ExternalStylesheetParameterDescriptor extStylesheetParameter : extStylesheetParameters) {
final String name = extStylesheetParameter.getName();
final Scope scope = Scope.valueOf(extStylesheetParameter.getScope().name());
final StylesheetParameterDescriptorImpl stylesheetParameterDescriptor = new StylesheetParameterDescriptorImpl(name, scope);
stylesheetParameterDescriptor.setDefaultValue(extStylesheetParameter.getDefaultValue());
stylesheetParameterDescriptor.setDescription(extStylesheetParameter.getDescription());
stylesheetParameterDescriptors.add(stylesheetParameterDescriptor);
}
stylesheetDescriptor.setStylesheetParameterDescriptors(stylesheetParameterDescriptors);
final List<ExternalLayoutAttributeDescriptor> extLayoutAttributes = data.getLayoutAttributes();
final List<ILayoutAttributeDescriptor> layoutAttributeDescriptors = new ArrayList<ILayoutAttributeDescriptor>(extOutputProperties.size());
for (final ExternalLayoutAttributeDescriptor extLayoutAttribute : extLayoutAttributes) {
final String name = extLayoutAttribute.getName();
final Scope scope = Scope.valueOf(extLayoutAttribute.getScope().name());
final LayoutAttributeDescriptorImpl layoutAttributeDescriptor = new LayoutAttributeDescriptorImpl(name, scope);
layoutAttributeDescriptor.setDefaultValue(extLayoutAttribute.getDefaultValue());
layoutAttributeDescriptor.setDescription(extLayoutAttribute.getDescription());
layoutAttributeDescriptor.setTargetElementNames(new LinkedHashSet<String>(extLayoutAttribute.getTargetElements()));
layoutAttributeDescriptors.add(layoutAttributeDescriptor);
}
stylesheetDescriptor.setLayoutAttributeDescriptors(layoutAttributeDescriptors);
this.stylesheetDescriptorDao.updateStylesheetDescriptor(stylesheetDescriptor);
}
use of org.apereo.portal.layout.om.IStylesheetDescriptor in project uPortal by Jasig.
the class StylesheetDescriptorImporterExporter method deleteData.
/**
* Treats the {@link String} id argument as the stylesheet name.
*
* <p>(non-Javadoc)
*
* @see IDataImporter#deleteData(java.lang.String)
*/
@Override
public ExternalStylesheetDescriptor deleteData(String name) {
final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetDescriptorDao.getStylesheetDescriptorByName(name);
if (stylesheetDescriptor == null) {
return null;
}
ExternalStylesheetDescriptor result = convert(stylesheetDescriptor);
this.stylesheetDescriptorDao.deleteStylesheetDescriptor(stylesheetDescriptor);
return result;
}
Aggregations