Search in sources :

Example 11 with IStylesheetDescriptor

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor)

Example 12 with IStylesheetDescriptor

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);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) IUserProfile(org.apereo.portal.IUserProfile) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager)

Example 13 with IStylesheetDescriptor

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;
}
Also used : Scope(org.apereo.portal.layout.om.IStylesheetData.Scope) HttpSession(javax.servlet.http.HttpSession) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) IStylesheetUserPreferences(org.apereo.portal.layout.om.IStylesheetUserPreferences) ILayoutAttributeDescriptor(org.apereo.portal.layout.om.ILayoutAttributeDescriptor) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 14 with IStylesheetDescriptor

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);
}
Also used : LayoutAttributeDescriptorImpl(org.apereo.portal.layout.dao.jpa.LayoutAttributeDescriptorImpl) OutputPropertyDescriptorImpl(org.apereo.portal.layout.dao.jpa.OutputPropertyDescriptorImpl) ArrayList(java.util.ArrayList) StylesheetParameterDescriptorImpl(org.apereo.portal.layout.dao.jpa.StylesheetParameterDescriptorImpl) ILayoutAttributeDescriptor(org.apereo.portal.layout.om.ILayoutAttributeDescriptor) IOutputPropertyDescriptor(org.apereo.portal.layout.om.IOutputPropertyDescriptor) IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) Scope(org.apereo.portal.layout.om.IStylesheetData.Scope) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with IStylesheetDescriptor

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;
}
Also used : IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor)

Aggregations

IStylesheetDescriptor (org.apereo.portal.layout.om.IStylesheetDescriptor)31 IStylesheetUserPreferences (org.apereo.portal.layout.om.IStylesheetUserPreferences)15 Scope (org.apereo.portal.layout.om.IStylesheetData.Scope)11 IStylesheetParameterDescriptor (org.apereo.portal.layout.om.IStylesheetParameterDescriptor)10 Map (java.util.Map)7 ILayoutAttributeDescriptor (org.apereo.portal.layout.om.ILayoutAttributeDescriptor)7 Transactional (org.springframework.transaction.annotation.Transactional)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 WindowState (javax.portlet.WindowState)4 HttpSession (javax.servlet.http.HttpSession)4 IUserProfile (org.apereo.portal.IUserProfile)4 IOutputPropertyDescriptor (org.apereo.portal.layout.om.IOutputPropertyDescriptor)4 IPerson (org.apereo.portal.security.IPerson)4 IUserInstance (org.apereo.portal.user.IUserInstance)4 MapPopulator (org.apereo.portal.utils.MapPopulator)4 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)3 PreferencesScope (org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope)3 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)3