Search in sources :

Example 1 with PortletApplicationDefinition

use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition 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<>();
    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();
        portlets.sort(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);
    }
    contexts.sort(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)

Example 2 with PortletApplicationDefinition

use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition 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 3 with PortletApplicationDefinition

use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.

the class LocalPortletContextManager method register.

// Public Methods ----------------------------------------------------------
/**
 * Retrieves the PortletContext associated with the given ServletContext. If one does not exist,
 * it is created.
 *
 * @param config the servlet config.
 * @return the InternalPortletContext associated with the ServletContext.
 */
@Override
public synchronized String register(ServletConfig config) throws PortletContainerException {
    ServletContext servletContext = config.getServletContext();
    String contextPath = servletContext.getContextPath();
    if (!portletContexts.containsKey(contextPath)) {
        PortletApplicationDefinition portletApp = this.getPortletAppDD(servletContext, contextPath, contextPath);
        DriverPortletContext portletContext = new DriverPortletContextImpl(servletContext, portletApp, requestDispatcherService);
        portletContexts.put(contextPath, portletContext);
        fireRegistered(portletContext);
        if (logger.isInfoEnabled()) {
            logger.info("Registered portlet application for context '" + contextPath + "'");
            logger.info("Registering " + portletApp.getPortlets().size() + " portlets for context " + portletContext.getApplicationName());
        }
        // TODO have the portlet servlet provide the portlet's classloader as parameter to this
        // method
        // This approach is needed as all pluto callbacks in uPortal have an aspect that
        // switches the thread classloader back
        // to uPortal's classloader.
        ClassLoader classLoader = ThreadContextClassLoaderAspect.getPreviousClassLoader();
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        classLoaders.put(portletApp.getName(), classLoader);
        for (PortletDefinition portlet : portletApp.getPortlets()) {
            String appName = portletContext.getApplicationName();
            if (appName == null) {
                throw new PortletContainerException("Portlet application name should not be null.");
            }
            portletConfigs.put(portletContext.getApplicationName() + "/" + portlet.getPortletName(), new DriverPortletConfigImpl(portletContext, portlet));
        }
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("Portlet application for context '" + contextPath + "' already registered.");
        }
    }
    return contextPath;
}
Also used : DriverPortletContext(org.apache.pluto.container.driver.DriverPortletContext) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) DriverPortletConfigImpl(org.apache.pluto.driver.container.DriverPortletConfigImpl) ServletContext(javax.servlet.ServletContext) DriverPortletContextImpl(org.apache.pluto.driver.container.DriverPortletContextImpl) PortletContainerException(org.apache.pluto.container.PortletContainerException) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 4 with PortletApplicationDefinition

use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.

the class LocalPortletContextManager method getPortletAppDD.

/**
 * Retrieve the Portlet Application Deployment Descriptor for the given servlet context. Create
 * it if it does not allready exist.
 *
 * @param servletContext the servlet context.
 * @return The portlet application deployment descriptor.
 * @throws PortletContainerException if the descriptor can not be found or parsed
 */
public synchronized PortletApplicationDefinition getPortletAppDD(ServletContext servletContext, String name, String contextPath) throws PortletContainerException {
    PortletApplicationDefinition portletApp = this.portletAppDefinitionCache.get(servletContext);
    if (portletApp == null) {
        portletApp = createDefinition(servletContext, name, contextPath);
        this.portletAppDefinitionCache.put(servletContext, portletApp);
    }
    return portletApp;
}
Also used : PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition)

Example 5 with PortletApplicationDefinition

use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.

the class EventProviderImpl method isDeclaredAsPublishingEvent.

private boolean isDeclaredAsPublishingEvent(QName qname) {
    final PortletDefinition portletDescriptor = this.portletWindow.getPlutoPortletWindow().getPortletDefinition();
    final List<? extends EventDefinitionReference> events = portletDescriptor.getSupportedPublishingEvents();
    if (events == null) {
        return false;
    }
    final PortletApplicationDefinition application = portletDescriptor.getApplication();
    final String defaultNamespace = application.getDefaultNamespace();
    for (final EventDefinitionReference ref : events) {
        final QName name = ref.getQualifiedName(defaultNamespace);
        if (name == null) {
            continue;
        }
        if (qname.equals(name)) {
            return true;
        }
    }
    return false;
}
Also used : EventDefinitionReference(org.apache.pluto.container.om.portlet.EventDefinitionReference) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) QName(javax.xml.namespace.QName) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Aggregations

PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)14 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)8 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)7 QName (javax.xml.namespace.QName)5 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)5 PortletContainerException (org.apache.pluto.container.PortletContainerException)4 EventDefinition (org.apache.pluto.container.om.portlet.EventDefinition)3 EventDefinitionReference (org.apache.pluto.container.om.portlet.EventDefinitionReference)3 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 UserAttribute (org.apache.pluto.container.om.portlet.UserAttribute)2 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)2 InputStream (java.io.InputStream)1 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Event (javax.portlet.Event)1 ServletContext (javax.servlet.ServletContext)1 JAXBContext (javax.xml.bind.JAXBContext)1