PortletContext portletContext = updateResponse.getPortletContext();
SessionHandler sessionHandler = consumer.getSessionHandler();
if (portletContext != null)
{
PortletContext originalContext = requestPrecursor.getPortletContext();
InstanceContext context = invocation.getInstanceContext();
String handle = portletContext.getPortletHandle();
if (!originalContext.getPortletHandle().equals(handle))
{
if (debug)
{
log.debug("Portlet '" + requestPrecursor.getPortletHandle() + "' was implicitely cloned. New handle is '"
+ handle + "'");
}
StateEvent event = new StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext), StateEvent.Type.PORTLET_CLONED_EVENT);
context.onStateEvent(event);
}
else
{
// check if the state was modified
byte[] originalState = originalContext.getPortletState();
byte[] newState = portletContext.getPortletState();
if (!Arrays.equals(originalState, newState))
{
StateEvent event = new StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext), StateEvent.Type.PORTLET_MODIFIED_EVENT);
context.onStateEvent(event);
}
}
// update the session information associated with the portlet handle
sessionHandler.updateSessionInfoFor(originalContext.getPortletHandle(), handle, invocation);