Search in sources :

Example 11 with PortletDefinition

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;
}
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 12 with PortletDefinition

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;
    }
}
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 13 with PortletDefinition

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;
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) EventDefinitionReference(org.apache.pluto.container.om.portlet.EventDefinitionReference) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) QName(javax.xml.namespace.QName) Element(net.sf.ehcache.Element) JAXBElement(javax.xml.bind.JAXBElement) Tuple(org.apereo.portal.utils.Tuple) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 14 with PortletDefinition

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;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 15 with PortletDefinition

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;
}
Also used : ContainerRuntimeOption(org.apache.pluto.container.om.portlet.ContainerRuntimeOption) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Aggregations

PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)19 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)13 PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)7 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)7 PortletContainerException (org.apache.pluto.container.PortletContainerException)6 QName (javax.xml.namespace.QName)4 PortletRegistryService (org.apache.pluto.container.driver.PortletRegistryService)4 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)4 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)4 EventDefinition (org.apache.pluto.container.om.portlet.EventDefinition)3 EventDefinitionReference (org.apache.pluto.container.om.portlet.EventDefinitionReference)3 Preference (org.apache.pluto.container.om.portlet.Preference)3 Preferences (org.apache.pluto.container.om.portlet.Preferences)3 PortletPreferenceImpl (org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl)3 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)3 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)3 CacheControl (javax.portlet.CacheControl)2 Event (javax.portlet.Event)2 Supports (org.apache.pluto.container.om.portlet.Supports)2 MockPortletDefinitionId (org.apereo.portal.mock.portlet.om.MockPortletDefinitionId)2