Search in sources :

Example 1 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 2 with PreferencesScope

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

the class StylesheetAttributeSource method getCacheKey.

@Override
public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final PreferencesScope stylesheetPreferencesScope = this.getStylesheetPreferencesScope(request);
    final CacheKeyBuilder<String, String> cacheKeyBuilder = CacheKey.builder(this.name);
    final Iterable<String> layoutAttributeNodeIds = this.stylesheetUserPreferencesService.getAllLayoutAttributeNodeIds(request, stylesheetPreferencesScope);
    for (final String nodeId : layoutAttributeNodeIds) {
        cacheKeyBuilder.add(nodeId);
        this.stylesheetUserPreferencesService.populateLayoutAttributes(request, stylesheetPreferencesScope, nodeId, cacheKeyBuilder);
    }
    return cacheKeyBuilder.build();
}
Also used : PreferencesScope(org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope)

Example 3 with PreferencesScope

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

the class StylesheetUserPreferencesTransformerConfigurationSource method getParameters.

/* (non-Javadoc)
     * @see org.apereo.portal.rendering.xslt.TransformerConfigurationSource#getTransformerParameters(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public final Map<String, Object> getParameters(HttpServletRequest request, HttpServletResponse response) {
    final PreferencesScope stylesheetPreferencesScope = this.getStylesheetPreferencesScope(request);
    final LinkedHashMap<String, Object> stylesheetParameters = new LinkedHashMap<String, Object>();
    this.stylesheetUserPreferencesService.populateStylesheetParameters(request, stylesheetPreferencesScope, new MapPopulator<String, String>(stylesheetParameters));
    return stylesheetParameters;
}
Also used : PreferencesScope(org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with PreferencesScope

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

the class StylesheetUserPreferencesTransformerConfigurationSource method getOutputProperties.

@Override
public Properties getOutputProperties(HttpServletRequest request, HttpServletResponse response) {
    final PreferencesScope stylesheetPreferencesScope = this.getStylesheetPreferencesScope(request);
    final PropertiesPopulator outputProperties = this.stylesheetUserPreferencesService.populateOutputProperties(request, stylesheetPreferencesScope, new PropertiesPopulator());
    return outputProperties.getProperties();
}
Also used : PropertiesPopulator(org.apereo.portal.utils.PropertiesPopulator) PreferencesScope(org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope)

Example 5 with PreferencesScope

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

the class StylesheetDescriptorTransformerConfigurationSource method getCacheKey.

@Override
public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final CacheKeyBuilder cacheKeyBuilder = CacheKey.builder(this.getName());
    final PreferencesScope preferencesScope = this.getStylesheetPreferencesScope(request);
    final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetUserPreferencesService.getStylesheetDescriptor(request, preferencesScope);
    // Build key from stylesheet descriptor parameters
    for (final IStylesheetParameterDescriptor stylesheetParameterDescriptor : stylesheetDescriptor.getStylesheetParameterDescriptors()) {
        final String defaultValue = stylesheetParameterDescriptor.getDefaultValue();
        if (defaultValue != null) {
            final String name = stylesheetParameterDescriptor.getName();
            cacheKeyBuilder.put(name, defaultValue);
        }
    }
    return cacheKeyBuilder.build();
}
Also used : IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) CacheKeyBuilder(org.apereo.portal.utils.cache.CacheKey.CacheKeyBuilder) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) 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