Search in sources :

Example 1 with DisplayName

use of org.apache.pluto.container.om.portlet.DisplayName 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)

Aggregations

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