//
org.jboss.portal.portlet.spi.PortalContext portalContext =invocation.getPortalContext();
// Get the modes for this content type
CapabilitiesInfo capabilities = container.getInfo().getCapabilities();
// Add all the modes
Set<Mode> modes = new HashSet<Mode>();
for (ModeInfo modeInfo : capabilities.getModes(si.getMediaType()))
{
Mode mode = modeInfo.getMode();
//
if (modeInfo instanceof PortletManagedModeInfo || portalContext.getModes().contains(mode))