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);
}
}
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);
}
}
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);
}
}
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;
}
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);
}
Aggregations