if (isGuest && !(this.isStoreInEntity(portletRequest) || this.isStoreInMemory(portletRequest))) {
return;
}
final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow);
final IPortletEntity portletEntity = this.portletWindowRegistry.getParentPortletEntity(httpServletRequest, portletWindow.getPortletWindowId());
final IPortletDefinition portletDefinition = this.portletEntityRegistry.getParentPortletDefinition(portletEntity.getPortletEntityId());
final PortletDD portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinition.getPortletDefinitionId());
//Is this CONFIG mode
final boolean configMode = IPortletAdaptor.CONFIG.equals(portletWindow.getPortletMode());
//Get Map of descriptor and definition preferences to check new preferences against
final Map<String, InternalPortletPreference> basePreferences = new HashMap<String, InternalPortletPreference>();
//Add deploy preferences
final List<IPortletPreference> descriptorPreferencesList = this.getDescriptorPreferences(portletDescriptor);
this.addPreferencesToMap(descriptorPreferencesList, basePreferences);
//Add definition preferences if not config mode
final IPortletPreferences definitionPreferences = portletDefinition.getPortletPreferences();
if (!configMode) {
final List<IPortletPreference> definitionPreferencesList = definitionPreferences.getPortletPreferences();
this.addPreferencesToMap(definitionPreferencesList, basePreferences);
}
final List<IPortletPreference> preferencesList = new ArrayList<IPortletPreference>(newPreferences.length);
for (InternalPortletPreference internalPreference : newPreferences) {
//Ignore preferences with null names
final String name = internalPreference.getName();
if (name == null) {
continue;
}
//Convert to a uPortal preference class to ensure quality check and persistence works
final IPortletPreference preference = new PortletPreferenceImpl(internalPreference);
//If the preference exactly equals a descriptor or definition preference ignore it
final InternalPortletPreference basePreference = basePreferences.get(name);
if (preference.equals(basePreference)) {
continue;
}
//New preference, add it to the list
preferencesList.add(preference);
}
//If in config mode store the preferences on the definition
if (configMode) {
definitionPreferences.setPortletPreferences(preferencesList);
this.portletDefinitionRegistry.updatePortletDefinition(portletDefinition);
}
//If not a guest or if guest prefs are shared store them on the entity
else if (this.isStoreInEntity(portletRequest)) {
//Update the portlet entity with the new preferences
final IPortletPreferences entityPreferences = portletEntity.getPortletPreferences();
entityPreferences.setPortletPreferences(preferencesList);
this.portletEntityRegistry.storePortletEntity(portletEntity);
}
//Must be a guest and share must be off so store the prefs on the session
else {
//Store memory preferences
this.storeSessionPreferences(portletEntity.getPortletEntityId(), httpServletRequest, preferencesList);
}
}