{
if (clonedContext instanceof StatefulPortletContext)
{
StatefulPortletContext statefulClonedContext = (StatefulPortletContext)clonedContext;
Serializable state = statefulClonedContext.getState();
PortletStateType stateType = statefulClonedContext.getType();
// Save the clone state
ConsumerState consumerState = new ConsumerState<Serializable>(clonedContext.getId(), stateType, state);
String stateId = persistenceManager.createState(consumerState);
String clonedId = CLONE_ID_PREFIX + stateId;
StateEvent event = new StateEvent(PortletContext.createPortletContext(clonedId), StateEvent.Type.PORTLET_CLONED_EVENT);
cictx.onStateEvent(event);
}
else
{
StateEvent event = new StateEvent(PortletContext.createPortletContext(clonedContext.getId()), StateEvent.Type.PORTLET_CLONED_EVENT);
cictx.onStateEvent(event);
}
}
else
{
PortletContext modifiedContext = pictx.modifiedContext;
if (modifiedContext != null)
{
// update state if needed
if (modifiedContext instanceof StatefulPortletContext)
{
StatefulPortletContext statefulClonedContext = (StatefulPortletContext)modifiedContext;
Serializable state = statefulClonedContext.getState();
PortletStateType stateType = statefulClonedContext.getType();
try
{
ConsumerState consumerState = new ConsumerState<Serializable>(modifiedContext.getId(), stateType, state);
persistenceManager.updateState(consumerContext.stateId, consumerState);
}