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