Search in sources :

Example 6 with PreferencesScope

use of org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope in project uPortal by Jasig.

the class StylesheetAttributeSource method getAdditionalAttributes.

@Override
public final Iterator<Attribute> getAdditionalAttributes(HttpServletRequest request, HttpServletResponse response, StartElement event) {
    final IStylesheetDescriptor stylesheetDescriptor = this.getStylesheetDescriptor(request);
    final PreferencesScope stylesheetPreferencesScope = this.getStylesheetPreferencesScope(request);
    final Collection<Attribute> attributes = new LinkedList<Attribute>();
    for (final ILayoutAttributeDescriptor layoutAttributeDescriptor : stylesheetDescriptor.getLayoutAttributeDescriptors()) {
        final Set<String> targetElementNames = layoutAttributeDescriptor.getTargetElementNames();
        final QName eventName = event.getName();
        final String localEventName = eventName.getLocalPart();
        if (targetElementNames.contains(localEventName)) {
            final Attribute subscribeIdAttr = event.getAttributeByName(IUserLayoutManager.ID_ATTR_NAME);
            final String subscribeId = subscribeIdAttr.getValue();
            final String name = layoutAttributeDescriptor.getName();
            String value = this.stylesheetUserPreferencesService.getLayoutAttribute(request, stylesheetPreferencesScope, subscribeId, name);
            if (value == null) {
                value = layoutAttributeDescriptor.getDefaultValue();
            }
            if (value != null) {
                if (this.shouldDoSpelEvaluationForAttributeValue(value)) {
                    final ServletWebRequest webRequest = new ServletWebRequest(request, response);
                    value = this.doSpelEvaluationForAttributeValue(webRequest, value);
                }
                if (value != null) {
                    final Attribute attribute = xmlEventFactory.createAttribute(name, value);
                    attributes.add(attribute);
                }
            }
        }
    }
    return attributes.iterator();
}
Also used : Attribute(javax.xml.stream.events.Attribute) QName(javax.xml.namespace.QName) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) PreferencesScope(org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope) ILayoutAttributeDescriptor(org.apereo.portal.layout.om.ILayoutAttributeDescriptor) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) LinkedList(java.util.LinkedList)

Example 7 with PreferencesScope

use of org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope in project uPortal by Jasig.

the class StylesheetUserPreferencesTransformerConfigurationSource method getCacheKey.

/* (non-Javadoc)
     * @see org.apereo.portal.rendering.xslt.TransformerConfigurationSource#getTransformerConfigurationKey(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final CacheKeyBuilder<String, String> cacheKeyBuilder = CacheKey.builder(getName());
    final PreferencesScope stylesheetPreferencesScope = this.getStylesheetPreferencesScope(request);
    this.stylesheetUserPreferencesService.populateStylesheetParameters(request, stylesheetPreferencesScope, cacheKeyBuilder);
    this.stylesheetUserPreferencesService.populateOutputProperties(request, stylesheetPreferencesScope, cacheKeyBuilder);
    return cacheKeyBuilder.build();
}
Also used : PreferencesScope(org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope)

Aggregations

PreferencesScope (org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope)7 IStylesheetDescriptor (org.apereo.portal.layout.om.IStylesheetDescriptor)3 LinkedHashMap (java.util.LinkedHashMap)2 IStylesheetParameterDescriptor (org.apereo.portal.layout.om.IStylesheetParameterDescriptor)2 LinkedList (java.util.LinkedList)1 QName (javax.xml.namespace.QName)1 Attribute (javax.xml.stream.events.Attribute)1 ILayoutAttributeDescriptor (org.apereo.portal.layout.om.ILayoutAttributeDescriptor)1 PropertiesPopulator (org.apereo.portal.utils.PropertiesPopulator)1 CacheKeyBuilder (org.apereo.portal.utils.cache.CacheKey.CacheKeyBuilder)1 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)1