Search in sources :

Example 1 with PortletRegistryService

use of org.apache.pluto.container.driver.PortletRegistryService 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<PortletApplicationDefinition>();
    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();
        Collections.sort(portlets, 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);
    }
    Collections.sort(contexts, 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 2 with PortletRegistryService

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

the class PortletDefinitionRegistryImpl method getParentPortletDescriptor.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.registry.IPortletDefinitionRegistry#getParentPortletDescriptor(org.apereo.portal.portlet.om.IPortletDefinitionId)
     */
@Override
public PortletDefinition getParentPortletDescriptor(IPortletDefinitionId portletDefinitionId) {
    final IPortletDefinition portletDefinition = this.getPortletDefinition(portletDefinitionId);
    if (portletDefinition == null) {
        return null;
    }
    final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(portletDefinition);
    final PortletRegistryService portletRegistryService = this.portalDriverContainerServices.getPortletRegistryService();
    try {
        return portletRegistryService.getPortlet(portletDescriptorKeys.first, portletDescriptorKeys.second);
    } catch (PortletContainerException e) {
        if (this.logger.isDebugEnabled()) {
            this.logger.warn("No portlet descriptor could be found for the portlet definition, null will be returned: " + portletDefinition, e);
        } else {
            this.logger.warn("No portlet descriptor could be found for the portlet definition, null will be returned: " + portletDefinition + " Enable DEBUG for stack trace.");
        }
        return null;
    }
}
Also used : PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 3 with PortletRegistryService

use of org.apache.pluto.container.driver.PortletRegistryService 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) {
        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("Failed to load portlet descriptor for appId='" + portletAppId + "', portletName='" + portletName + "'", e);
        return false;
    }
    if (portletDescriptor == null) {
        return false;
    }
    //Iterate over supported portlet modes, this ignores the content types for now
    final List<? extends Supports> supports = portletDescriptor.getSupports();
    for (final Supports support : supports) {
        final List<String> portletModes = support.getPortletModes();
        for (final String portletMode : portletModes) {
            if (IPortletRenderer.CONFIG.equals(PortletUtils.getPortletMode(portletMode))) {
                return true;
            }
        }
    }
    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)

Example 4 with PortletRegistryService

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

the class PortletAdministrationHelper method getPortletDescriptor.

/**
     * Get a portlet descriptor matching the current portlet definition form. If the current form
     * does not represent a portlet, the application or portlet name fields are blank, or the
     * portlet description cannot be retrieved, the method will return <code>null</code>.
     *
     * @param form
     * @return
     */
public PortletDefinition getPortletDescriptor(PortletDefinitionForm form) {
    final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(form);
    if (portletDescriptorKeys == null) {
        return null;
    }
    final String portletAppId = portletDescriptorKeys.first;
    final String portletName = portletDescriptorKeys.second;
    final PortletRegistryService portletRegistryService = portalDriverContainerServices.getPortletRegistryService();
    try {
        PortletDefinition portletDD = portletRegistryService.getPortlet(portletAppId, portletName);
        return portletDD;
    } catch (PortletContainerException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 5 with PortletRegistryService

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

the class PortletDefinitionRegistryImpl method getParentPortletApplicationDescriptor.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.registry.IPortletDefinitionRegistry#getParentPortletApplicationDescriptor(org.apereo.portal.portlet.om.IPortletDefinitionId)
     */
@Override
public PortletApplicationDefinition getParentPortletApplicationDescriptor(IPortletDefinitionId portletDefinitionId) {
    final IPortletDefinition portletDefinition = this.getPortletDefinition(portletDefinitionId);
    if (portletDefinition == null) {
        return null;
    }
    final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(portletDefinition);
    final PortletRegistryService portletRegistryService = this.portalDriverContainerServices.getPortletRegistryService();
    try {
        return portletRegistryService.getPortletApplication(portletDescriptorKeys.first);
    } catch (PortletContainerException e) {
        this.logger.warn("No portlet application descriptor could be found likely not deplotyed. For portlet definition: " + portletDefinition, e);
        return null;
    }
}
Also used : PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

PortletContainerException (org.apache.pluto.container.PortletContainerException)6 PortletRegistryService (org.apache.pluto.container.driver.PortletRegistryService)6 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)6 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)4 Supports (org.apache.pluto.container.om.portlet.Supports)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DisplayName (org.apache.pluto.container.om.portlet.DisplayName)1 PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)1