if ( pageActionAccess == null )
{
throw new Exception( "cannot change action for root layout fragment due to null PageActionAccess object" );
}
//pageActionAccess.
PortletWindow window = requestContext.getPortletWindow(fragment);
if (!window.isValid())
{
throw new Exception("Failed to retrieve Portlet Definition for: "+ fragment.getId() + ", " + fragment.getName());
}
PortletMode currentMode = requestContext.getPortalURL().getNavigationalState().getMode( window );
WindowState currentState = requestContext.getPortalURL().getNavigationalState().getState( window );
boolean requestedModeAlreadySet = false;
if ( requestedMode == null )
{
requestedModeAlreadySet = true;
}
else
{
if ( requestedMode.equals( PortletMode.EDIT.toString() ) )
{
if( pageActionAccess.isEditing() )
requestedModeAlreadySet = true;
else
{
if ( pageActionAccess.isEditAllowed())
{
pageActionAccess.setEditing( true );
resultMap.put(STATUS, status);
resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
resultMap.put(PORTLET_MODE, requestedMode);
}
else
{
throw new Exception( "permissions do no allow page edit" );
}
}
}
else if ( requestedMode.equals( PortletMode.VIEW.toString() ) )
{
pageActionAccess.setEditing( false );
//if ( currentMode.equals( PortletMode.HELP ) )
resultMap.put(STATUS, status);
resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
resultMap.put(PORTLET_MODE, requestedMode);
}
else
{
requestedModeAlreadySet = true;
}
}
if ( requestedModeAlreadySet )
{
resultMap.put(STATUS, status);
resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
resultMap.put(PORTLET_MODE, currentMode.toString());
}
}
else
{
if (requestedState == null && requestedMode == null)
{
throw new Exception("portlet window state or mode not provided");
}
if (requestedState != null && !isValidWindowState(requestedState))
{
throw new Exception("portlet window state " + requestedState + " is not supported");
}
if (requestedMode != null && !isValidPortletMode(requestedMode))
{
throw new Exception("portlet mode " + requestedMode + " is not supported");
}
String oldState = fragment.getState();
String oldMode = fragment.getMode();
// Now Change the transient navigational state
MutableNavigationalState navState = (MutableNavigationalState)requestContext.getPortalURL().getNavigationalState();
PortletWindow portletWindow = requestContext.getPortletWindow(fragment);
if (portletWindow != null)
{
oldState = navState.getState(portletWindow).toString();
oldMode = navState.getMode(portletWindow).toString();
if (requestedState != null)