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;
}
Aggregations