Search in sources :

Example 36 with IPortletDefinition

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

the class GuestPortletEntityPreferencesImpl 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);
    }
    // Add entity prefs to base Map
    final List<IPortletPreference> entityPreferences = portletEntity.getPortletPreferences();
    for (final IPortletPreference preference : entityPreferences) {
        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 37 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition 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 38 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition 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 39 with IPortletDefinition

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

the class PortletEntityRegistryImpl method getOrCreatePortletEntity.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.registry.IPortletEntityRegistry#getOrCreatePortletEntity(org.apereo.portal.portlet.om.IPortletDefinitionId, java.lang.String, int)
     */
@Override
public IPortletEntity getOrCreatePortletEntity(HttpServletRequest request, IPortletDefinitionId portletDefinitionId, String layoutNodeId, int userId) {
    final PortletEntityCache<IPortletEntity> portletEntityCache = getPortletEntityMap(request);
    // Try just getting an existing entity first
    IPortletEntity portletEntity = this.getPortletEntity(request, portletEntityCache, null, layoutNodeId, userId);
    // Found an existing entity!
    if (portletEntity != null) {
        // Verify the definition IDs match, this is a MUST in the case where the subscribed
        // portlet changes
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
        if (portletDefinitionId.equals(portletDefinition.getPortletDefinitionId())) {
            return portletEntity;
        }
        // Remove the entity if the definition IDs don't match
        this.logger.warn("Found portlet entity '{}' is not the correct entity for portlet definition id: {}. The entity will be deleted and a new one created.", portletEntity, portletDefinitionId);
        this.deletePortletEntity(request, portletEntity, false);
    }
    // Create the entity data object and store it in the session map (if not already there)
    final PortletEntityCache<PortletEntityData> portletEntityDataMap = this.getPortletEntityDataMap(request);
    final IPortletEntityId portletEntityId = this.createConsistentPortletEntityId(portletDefinitionId, layoutNodeId, userId);
    PortletEntityData portletEntityData = new PortletEntityData(portletEntityId, portletDefinitionId, layoutNodeId, userId);
    portletEntityData = portletEntityDataMap.storeIfAbsentEntity(portletEntityData);
    portletEntity = wrapPortletEntityData(portletEntityData);
    // Stick the wrapper in the request map
    portletEntity = portletEntityCache.storeIfAbsentEntity(portletEntity);
    return portletEntity;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 40 with IPortletDefinition

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

the class PortletEntityRegistryImpl method getOrCreateDefaultPortletEntity.

@Override
public IPortletEntity getOrCreateDefaultPortletEntity(HttpServletRequest request, IPortletDefinitionId portletDefinitionId) {
    Validate.notNull(request, "HttpServletRequest cannot be null");
    Validate.notNull(portletDefinitionId, "portletDefinitionId cannot be null");
    final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionId);
    if (portletDefinition == null) {
        throw new IllegalArgumentException("No portlet definition found for id '" + portletDefinitionId + "'.");
    }
    // Determine the appropriate portlet window ID for the definition
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    // Determine the subscribe ID
    final String portletFName = portletDefinition.getFName();
    final String layoutNodeId = userLayoutManager.getSubscribeId(portletFName);
    if (layoutNodeId == null) {
        throw new IllegalArgumentException("No layout node ID found for fname '" + portletFName + "'.");
    }
    this.logger.trace("Found layout node {} for portlet definition {}", layoutNodeId, portletFName);
    final IPerson person = userInstance.getPerson();
    final int personId = person.getID();
    return this.getOrCreatePortletEntity(request, portletDefinitionId, layoutNodeId, personId);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)109 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)24 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)22 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)17 ArrayList (java.util.ArrayList)16 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)14 HashSet (java.util.HashSet)13 IPerson (org.apereo.portal.security.IPerson)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)12 EntityIdentifier (org.apereo.portal.EntityIdentifier)11 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)9 HashMap (java.util.HashMap)8 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)8 IPortletDefinitionParameter (org.apereo.portal.portlet.om.IPortletDefinitionParameter)7 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)7 IUserInstance (org.apereo.portal.user.IUserInstance)7 Locale (java.util.Locale)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)6