PortletEntityRegistryImpl should validate the IPortletEntity before returning it

Description

If the portlet deployment for a published channel changes and the user already has viewed the previous corresponding portlet in their UI the IPortletEntity stored for them will end up rendering the incorrect portlet. The PortletEntityRegistryImpl needs to check to make sure the definition id passed to getOrCreatePortletEntity matches the definition id that the entity references. If it doesn't the entity should be deleted and a new one created.

Environment

None

Activity

Show:
Eric Dalquist
September 24, 2009, 10:06 PM

public IPortletEntity getOrCreatePortletEntity(IPortletDefinitionId portletDefinitionId, String channelSubscribeId, int userId) {
final IPortletEntity portletEntity = this.getPortletEntity(channelSubscribeId, userId);
if (portletEntity != null) {
if (!portletDefinitionId.equals(portletEntity.getPortletDefinitionId())) {
this.logger.warn("Found portlet entity '" + portletEntity + "' is not the correct entity for portlet definition id: " + portletDefinitionId + ". The entity will be deleted and a new one created.");
this.deletePortletEntity(portletEntity);
}
else {
return portletEntity;
}
}

return this.createPortletEntity(portletDefinitionId, channelSubscribeId, userId);
}

Eric Dalquist
October 2, 2009, 3:18 PM

Fixed by apply patch

Fixed

Assignee

Eric Dalquist

Reporter

Eric Dalquist

Labels

None

Estimated End Date

None

Fix versions

Affects versions

Priority

Major