List actions = Collections.EMPTY_LIST;
PortletMode currentMode = requestContext.getPortalURL().getNavigationalState().getMode(window);
WindowState currentState = requestContext.getPortalURL().getNavigationalState().getState(window);
ContentTypeSet content = portlet.getContentTypeSet();
if ( fragment.equals(requestContext.getPage().getRootFragment()) )
{
fragmentSupportsActions = true;
actions = getPageModes(requestContext, window, content, currentMode, currentState, pageActionAccess, decoration, isAjaxRequest);
}
else if ( !Fragment.LAYOUT.equals(fragment.getType()) )
{
fragmentSupportsActions = true;
String fragmentId = fragment.getId();
PortletApplication pa = (PortletApplication)window.getPortletEntity().getPortletDefinition().getPortletApplicationDefinition();
String portletName = portlet.getUniqueName();
PortletMode currentMappedMode = pa.getMappedPortletMode(currentMode);
WindowState currentMappedState = pa.getMappedWindowState(currentState);
Object action;
PortletMode mappedMode;
PortletMode customMode;
WindowState mappedState;
WindowState customState;
ArrayList actionTemplates = new ArrayList();
DecoratorActionsFactory actionsAdapter = getDecoratorActionsAdapter(decoration);
List supportedActions = actionsAdapter.getSupportedActions(requestContext, pa, window, currentMappedMode, currentMappedState, decoration);
Iterator iter = supportedActions.iterator();
String currentModeAction = null;
String currentStateAction = null;
while ( iter.hasNext() )
{
action = iter.next();
if ( action instanceof PortletMode )
{
mappedMode = (PortletMode)action;
customMode = pa.getCustomPortletMode(mappedMode);
if ( customMode != null )
{
boolean equalsCurrentMode = customMode.equals(currentMode);
if ( equalsCurrentMode )
{
currentModeAction = mappedMode.toString();
}
if ( ! equalsCurrentMode || isAjaxRequest )
{
if ( (content.supportsPortletMode(customMode) || isAutoSwitchableCustomMode(content, customMode))
&& (!PortletMode.EDIT.equals(customMode) || pageActionAccess.isEditAllowed())
&& pageActionAccess.checkPortletMode(fragmentId, portletName, mappedMode)
)
{
actionTemplates.add(new DecoratorActionTemplate(mappedMode, customMode));