use of org.apache.pluto.container.om.portlet.PortletDefinition 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.om.portlet.PortletDefinition 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.om.portlet.PortletDefinition in project uPortal by Jasig.
the class PortletEventCoordinatationService method supportsEvent.
protected boolean supportsEvent(Event event, IPortletDefinitionId portletDefinitionId) {
final QName eventName = event.getQName();
//The cache key to use
final Tuple<IPortletDefinitionId, QName> key = new Tuple<IPortletDefinitionId, QName>(portletDefinitionId, eventName);
//Check in the cache if the portlet definition supports this event
final Element element = this.supportedEventCache.get(key);
if (element != null) {
final Boolean supported = (Boolean) element.getObjectValue();
if (supported != null) {
return supported;
}
}
final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId);
if (portletApplicationDescriptor == null) {
return false;
}
final Set<QName> aliases = this.getAllAliases(eventName, portletApplicationDescriptor);
final String defaultNamespace = portletApplicationDescriptor.getDefaultNamespace();
//No support found so far, do more complex namespace matching
final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
if (portletDescriptor == null) {
return false;
}
final List<? extends EventDefinitionReference> supportedProcessingEvents = portletDescriptor.getSupportedProcessingEvents();
for (final EventDefinitionReference eventDefinitionReference : supportedProcessingEvents) {
final QName qualifiedName = eventDefinitionReference.getQualifiedName(defaultNamespace);
if (qualifiedName == null) {
continue;
}
//Look for alias names
if (qualifiedName.equals(eventName) || aliases.contains(qualifiedName)) {
this.supportedEventCache.put(new Element(key, Boolean.TRUE));
return true;
}
//Look for namespaced events
if (StringUtils.isEmpty(qualifiedName.getNamespaceURI())) {
final QName namespacedName = new QName(defaultNamespace, qualifiedName.getLocalPart());
if (eventName.equals(namespacedName)) {
this.supportedEventCache.put(new Element(key, Boolean.TRUE));
return true;
}
}
}
this.supportedEventCache.put(new Element(key, Boolean.FALSE));
return false;
}
use of org.apache.pluto.container.om.portlet.PortletDefinition in project uPortal by Jasig.
the class PortletWindowRegistryImpl method wrapPortletWindowData.
protected IPortletWindow wrapPortletWindowData(HttpServletRequest request, PortletWindowData portletWindowData) {
final IPortletEntityId portletEntityId = portletWindowData.getPortletEntityId();
final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
if (portletEntity == null) {
return null;
}
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinition.getPortletDefinitionId());
if (portletDescriptor == null) {
return null;
}
final IPortletWindow portletWindow = new PortletWindowImpl(portletDescriptor, portletEntity, portletWindowData);
logger.trace("Wrapping PortletWindowData {} as IPortletWindow", portletWindow.getPortletWindowId());
return portletWindow;
}
use of org.apache.pluto.container.om.portlet.PortletDefinition in project uPortal by Jasig.
the class PortletExecutionManager method doesPortletNeedHeaderWorker.
/**
* @param portletWindowId
* @param request
* @return
*/
protected boolean doesPortletNeedHeaderWorker(IPortletWindowId portletWindowId, HttpServletRequest request) {
IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
PortletDefinition portletDefinition = portletWindow.getPlutoPortletWindow().getPortletDefinition();
ContainerRuntimeOption renderHeaderOption = portletDefinition.getContainerRuntimeOption(PORTLET_RENDER_HEADERS_OPTION);
boolean result = false;
if (renderHeaderOption != null) {
result = renderHeaderOption.getValues().contains(Boolean.TRUE.toString());
}
logger.debug("Portlet {} need render header worker: {}", portletDefinition.getPortletName(), result);
return result;
}
Aggregations