Search in sources :

Example 16 with IPortletPreference

use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.

the class PortletEntityRegistryImpl method createPersistentEntity.

protected IPortletEntity createPersistentEntity(final IPortletEntity portletEntity, final IPortletEntityId wrapperPortletEntityId) {
    final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId();
    final String layoutNodeId = portletEntity.getLayoutNodeId();
    final int userId = portletEntity.getUserId();
    IPortletEntity persistentEntity = this.portletEntityDao.getPortletEntity(layoutNodeId, userId);
    if (persistentEntity != null) {
        this.logger.warn("A persistent portlet entity already exists: " + persistentEntity + ". The data from the passed in entity will be copied to the persistent entity: " + portletEntity);
    } else {
        persistentEntity = this.portletEntityDao.createPortletEntity(portletDefinitionId, layoutNodeId, userId);
    }
    // Copy over preferences to avoid modifying any part of the interim entity by reference
    final List<IPortletPreference> existingPreferences = portletEntity.getPortletPreferences();
    final List<IPortletPreference> persistentPreferences = persistentEntity.getPortletPreferences();
    // Only do the copy if the List objects are not the same instance
    if (persistentPreferences != existingPreferences) {
        persistentPreferences.clear();
        for (final IPortletPreference preference : existingPreferences) {
            persistentPreferences.add(new PortletPreferenceImpl(preference));
        }
    }
    // Copy over WindowStates
    final Map<Long, WindowState> windowStates = portletEntity.getWindowStates();
    for (Map.Entry<Long, WindowState> windowStateEntry : windowStates.entrySet()) {
        final Long stylesheetDescriptorId = windowStateEntry.getKey();
        final IStylesheetDescriptor stylesheetDescriptor = stylesheetDescriptorDao.getStylesheetDescriptor(stylesheetDescriptorId);
        final WindowState windowState = windowStateEntry.getValue();
        persistentEntity.setWindowState(stylesheetDescriptor, windowState);
    }
    this.portletEntityDao.updatePortletEntity(persistentEntity);
    return persistentEntity;
}
Also used : WindowState(javax.portlet.WindowState) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) Map(java.util.Map) ConcurrentMap(java.util.concurrent.ConcurrentMap) PortletPreferenceImpl(org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl)

Example 17 with IPortletPreference

use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.

the class AbstractPortletPreferencesImpl method getPortletPreference.

protected final IPortletPreference getPortletPreference(String key) {
    Assert.notNull(key, "Preference Key cannot be null");
    final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences();
    final IPortletPreference portletPreference = targetPortletPreferences.get(key);
    if (portletPreference != null) {
        return portletPreference;
    }
    final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences();
    return basePortletPreferences.get(key);
}
Also used : IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference)

Example 18 with IPortletPreference

use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.

the class PortletDefinitionPreferencesImpl method loadBasePortletPreferences.

@Override
protected void loadBasePortletPreferences(IPortletDefinition portletDefinition, Map<String, IPortletPreference> basePortletPreferences) {
    // Add descriptor prefs to base Map
    final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
    final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
    final Preferences descriptorPreferences = portletDescriptor.getPortletPreferences();
    for (final Preference preference : descriptorPreferences.getPortletPreferences()) {
        final IPortletPreference preferenceWrapper = new PortletPreferenceImpl(preference);
        basePortletPreferences.put(preferenceWrapper.getName(), preferenceWrapper);
    }
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) Preference(org.apache.pluto.container.om.portlet.Preference) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) Preferences(org.apache.pluto.container.om.portlet.Preferences) PortletPreferenceImpl(org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 19 with IPortletPreference

use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.

the class PortletEntityPreferencesImpl method loadBasePortletPreferences.

@Override
protected void loadBasePortletPreferences(IPortletEntity portletEntity, Map<String, IPortletPreference> basePortletPreferences) {
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    // Add descriptor prefs to base Map
    final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
    final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
    final Preferences descriptorPreferences = portletDescriptor.getPortletPreferences();
    for (final Preference preference : descriptorPreferences.getPortletPreferences()) {
        final IPortletPreference preferenceWrapper = new PortletPreferenceImpl(preference);
        basePortletPreferences.put(preferenceWrapper.getName(), preferenceWrapper);
    }
    // Add definition prefs to base Map
    final List<IPortletPreference> definitionPreferences = portletDefinition.getPortletPreferences();
    for (final IPortletPreference preference : definitionPreferences) {
        basePortletPreferences.put(preference.getName(), preference);
    }
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) Preference(org.apache.pluto.container.om.portlet.Preference) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) Preferences(org.apache.pluto.container.om.portlet.Preferences) PortletPreferenceImpl(org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 20 with IPortletPreference

use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.

the class RenderOnWebFlagSet method apply.

@Override
public boolean apply(final HttpServletRequest request) {
    try {
        final IPortletDefinition portletDefinition = utils.getPortletDefinitionFromServletRequest(request);
        Iterator<IPortletPreference> iterator = portletDefinition.getPortletPreferences().iterator();
        while (iterator.hasNext()) {
            IPortletPreference cur = iterator.next();
            if ("renderOnWeb".equalsIgnoreCase(cur.getName())) {
                return cur.getValues() != null && cur.getValues().length == 1 && Boolean.parseBoolean(cur.getValues()[0]);
            }
        }
    } catch (Exception e) {
        logger.error("Failed to process renderOnWeb check for redirect during pipeline. Failing gracefully by returning false.", e);
    }
    return false;
}
Also used : IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)37 Test (org.junit.Test)18 PortletPreferenceImpl (org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl)15 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)12 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)11 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)10 List (java.util.List)8 BasePortalJpaDaoTest (org.apereo.portal.test.BasePortalJpaDaoTest)8 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)7 ArrayList (java.util.ArrayList)6 Callable (java.util.concurrent.Callable)4 IPortletDescriptorKey (org.apereo.portal.portlet.om.IPortletDescriptorKey)4 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)3 Preference (org.apache.pluto.container.om.portlet.Preference)3 Preferences (org.apache.pluto.container.om.portlet.Preferences)3 IPortletDefinitionParameter (org.apereo.portal.portlet.om.IPortletDefinitionParameter)3 IPortletType (org.apereo.portal.portlet.om.IPortletType)3 LinkedHashSet (java.util.LinkedHashSet)2 ReadOnlyException (javax.portlet.ReadOnlyException)2