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