Search in sources :

Example 1 with PortletContainerException

use of org.apache.pluto.container.PortletContainerException in project uPortal by Jasig.

the class LocalPortletContextManager method getPortletApplication.

@Override
public PortletApplicationDefinition getPortletApplication(String applicationName) throws PortletContainerException {
    DriverPortletContext ipc = portletContexts.get(applicationName);
    if (ipc != null) {
        return ipc.getPortletApplicationDefinition();
    }
    String msg = "Unable to retrieve portlet application: '" + applicationName + "'";
    logger.warn(msg);
    throw new PortletContainerException(msg);
}
Also used : DriverPortletContext(org.apache.pluto.container.driver.DriverPortletContext) PortletContainerException(org.apache.pluto.container.PortletContainerException)

Example 2 with PortletContainerException

use of org.apache.pluto.container.PortletContainerException in project uPortal by Jasig.

the class LocalPortletContextManager method getPortlet.

@Override
public PortletDefinition getPortlet(String applicationName, String portletName) throws PortletContainerException {
    DriverPortletConfig ipc = portletConfigs.get(applicationName + "/" + portletName);
    if (ipc != null) {
        return ipc.getPortletDefinition();
    }
    String msg = "Unable to retrieve portlet: '" + applicationName + "/" + portletName + "'";
    logger.warn(msg);
    throw new PortletContainerException(msg);
}
Also used : PortletContainerException(org.apache.pluto.container.PortletContainerException) DriverPortletConfig(org.apache.pluto.container.driver.DriverPortletConfig)

Example 3 with PortletContainerException

use of org.apache.pluto.container.PortletContainerException in project uPortal by Jasig.

the class LocalPortletContextManager method getPortletConfig.

@Override
public DriverPortletConfig getPortletConfig(String applicationName, String portletName) throws PortletContainerException {
    DriverPortletConfig ipc = portletConfigs.get(applicationName + "/" + portletName);
    if (ipc != null) {
        return ipc;
    }
    String msg = "Unable to locate portlet config [applicationName=" + applicationName + "]/[" + portletName + "].";
    logger.warn(msg);
    throw new PortletContainerException(msg);
}
Also used : PortletContainerException(org.apache.pluto.container.PortletContainerException) DriverPortletConfig(org.apache.pluto.container.driver.DriverPortletConfig)

Example 4 with PortletContainerException

use of org.apache.pluto.container.PortletContainerException in project uPortal by Jasig.

the class PortletAdministrationHelper method getPortletApplications.

/**
 * Retreive the list of portlet application contexts currently available in this portlet
 * container.
 *
 * @return list of portlet context
 */
public List<PortletApplicationDefinition> getPortletApplications() {
    final PortletRegistryService portletRegistryService = portalDriverContainerServices.getPortletRegistryService();
    final List<PortletApplicationDefinition> contexts = new ArrayList<>();
    for (final Iterator<String> iter = portletRegistryService.getRegisteredPortletApplicationNames(); iter.hasNext(); ) {
        final String applicationName = iter.next();
        final PortletApplicationDefinition applicationDefninition;
        try {
            applicationDefninition = portletRegistryService.getPortletApplication(applicationName);
        } catch (PortletContainerException e) {
            throw new RuntimeException("Failed to load PortletApplicationDefinition for '" + applicationName + "'");
        }
        final List<? extends PortletDefinition> portlets = applicationDefninition.getPortlets();
        portlets.sort(new ComparableExtractingComparator<PortletDefinition, String>(String.CASE_INSENSITIVE_ORDER) {

            @Override
            protected String getComparable(PortletDefinition o) {
                final List<? extends DisplayName> displayNames = o.getDisplayNames();
                if (displayNames != null && displayNames.size() > 0) {
                    return displayNames.get(0).getDisplayName();
                }
                return o.getPortletName();
            }
        });
        contexts.add(applicationDefninition);
    }
    contexts.sort(new ComparableExtractingComparator<PortletApplicationDefinition, String>(String.CASE_INSENSITIVE_ORDER) {

        @Override
        protected String getComparable(PortletApplicationDefinition o) {
            final String portletContextName = o.getName();
            if (portletContextName != null) {
                return portletContextName;
            }
            final String applicationName = o.getContextPath();
            if ("/".equals(applicationName)) {
                return "ROOT";
            }
            if (applicationName.startsWith("/")) {
                return applicationName.substring(1);
            }
            return applicationName;
        }
    });
    return contexts;
}
Also used : PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) ArrayList(java.util.ArrayList) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition) PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) DisplayName(org.apache.pluto.container.om.portlet.DisplayName) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with PortletContainerException

use of org.apache.pluto.container.PortletContainerException in project uPortal by Jasig.

the class PortletAdministrationHelper method supportsConfigMode.

/**
 * If the portlet is a portlet and if one of the supported portlet modes is {@link
 * IPortletRenderer#CONFIG}
 */
public boolean supportsConfigMode(PortletDefinitionForm form) {
    final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(form);
    if (portletDescriptorKeys == null) {
        logger.trace("Unable to determine supportsConfig - portletDescriptorKeys is null.");
        return false;
    }
    final String portletAppId = portletDescriptorKeys.first;
    final String portletName = portletDescriptorKeys.second;
    final PortletRegistryService portletRegistryService = this.portalDriverContainerServices.getPortletRegistryService();
    final PortletDefinition portletDescriptor;
    try {
        portletDescriptor = portletRegistryService.getPortlet(portletAppId, portletName);
    } catch (PortletContainerException e) {
        this.logger.warn("Unable to determine supportsConfig - Failed to load portlet descriptor for appId='" + portletAppId + "', portletName='" + portletName + "'", e);
        return false;
    }
    if (portletDescriptor == null) {
        logger.trace("Unable to determine supportsConfig - portletDescriptor is null.");
        return false;
    }
    logger.trace("Checking supportsConfig for portlet ID=[{}] and Name=[{}].", portletAppId, portletName);
    // Iterate over supported portlet modes, this ignores the content types for now
    final List<? extends Supports> supports = portletDescriptor.getSupports();
    for (final Supports support : supports) {
        logger.trace("Checking Supports instance:  {}", support.getMimeType());
        final List<String> portletModes = support.getPortletModes();
        for (final String portletMode : portletModes) {
            logger.trace("Checking portletMode {}.", portletMode);
            if (IPortletRenderer.CONFIG.equals(PortletUtils.getPortletMode(portletMode))) {
                logger.trace("Returning supportsConfig is true.");
                return true;
            }
        }
    }
    logger.trace("Returning supportsConfig is false.");
    return false;
}
Also used : PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) Supports(org.apache.pluto.container.om.portlet.Supports) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Aggregations

PortletContainerException (org.apache.pluto.container.PortletContainerException)17 PortletRegistryService (org.apache.pluto.container.driver.PortletRegistryService)6 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)6 IOException (java.io.IOException)5 PortletException (javax.portlet.PortletException)5 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)5 PortletDispatchException (org.apereo.portal.portlet.PortletDispatchException)5 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)5 PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)4 PortletHttpServletResponseWrapper (org.apereo.portal.utils.web.PortletHttpServletResponseWrapper)3 CacheControl (javax.portlet.CacheControl)2 DriverPortletConfig (org.apache.pluto.container.driver.DriverPortletConfig)2 DriverPortletContext (org.apache.pluto.container.driver.DriverPortletContext)2 Supports (org.apache.pluto.container.om.portlet.Supports)2 HeaderSettingCacheControl (org.apereo.portal.portlet.container.cache.HeaderSettingCacheControl)2 InputStream (java.io.InputStream)1 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1