Search in sources :

Example 1 with PortletDefinition

use of org.apache.pluto.container.om.portlet.PortletDefinition 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;
}
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 PortletDefinition

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

the class PortletWindowRegistryImpl method getOrCreateStatelessPortletWindow.

@Override
public IPortletWindow getOrCreateStatelessPortletWindow(HttpServletRequest request, IPortletWindowId basePortletWindowId) {
    //Need the basePortletWindowId to be an instance of PortletWindowIdImpl so that we can extract the entity ID
    if (!(basePortletWindowId instanceof PortletWindowIdImpl)) {
        final String basePortletWindowIdStr = basePortletWindowId.getStringId();
        basePortletWindowId = this.getPortletWindowId(request, basePortletWindowIdStr);
    }
    //Get the entity ID for the portlet window
    final IPortletEntityId portletEntityId = ((PortletWindowIdImpl) basePortletWindowId).getPortletEntityId();
    //Create the stateless ID
    final PortletWindowIdImpl statelessPortletWindowId = this.createPortletWindowId(STATELESS_PORTLET_WINDOW_ID, portletEntityId);
    //See if there is already a request cached stateless window
    IPortletWindow statelessPortletWindow = this.getPortletWindow(request, statelessPortletWindowId);
    if (statelessPortletWindow != null) {
        return statelessPortletWindow;
    }
    //Lookup the base portlet window to clone the stateless from
    final IPortletWindow basePortletWindow = this.getPortletWindow(request, basePortletWindowId);
    final PortletWindowCache<PortletWindowData> statelessPortletWindowDataMap = this.getStatelessPortletWindowDataMap(request, true);
    //If no base to clone from lookup the entity and pluto definition data
    if (basePortletWindow == null) {
        final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
        if (portletEntity == null) {
            throw new IllegalArgumentException("No IPortletEntity could be found for " + portletEntity + " while creating stateless portlet window for " + basePortletWindowId);
        }
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
        final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
        final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
        final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
        statelessPortletWindowDataMap.storeWindow(portletWindowData);
        statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
    } else //Clone the existing base window
    {
        final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
        portletWindowData.setExpirationCache(basePortletWindow.getExpirationCache());
        portletWindowData.setPortletMode(basePortletWindow.getPortletMode());
        portletWindowData.setWindowState(basePortletWindow.getWindowState());
        portletWindowData.setPublicRenderParameters(basePortletWindow.getPublicRenderParameters());
        portletWindowData.setRenderParameters(basePortletWindow.getRenderParameters());
        statelessPortletWindowDataMap.storeWindow(portletWindowData);
        final IPortletEntity portletEntity = basePortletWindow.getPortletEntity();
        final PortletDefinition portletDescriptor = basePortletWindow.getPlutoPortletWindow().getPortletDefinition();
        statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
    }
    //Cache the stateless window in the request
    final PortletWindowCache<IPortletWindow> portletWindowMap = this.getPortletWindowMap(request);
    portletWindowMap.storeWindow(statelessPortletWindow);
    return statelessPortletWindow;
}
Also used : IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 3 with PortletDefinition

use of org.apache.pluto.container.om.portlet.PortletDefinition 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)

Example 4 with PortletDefinition

use of org.apache.pluto.container.om.portlet.PortletDefinition 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.
     * @throws PortletContainerException
     */
@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);
        portletContext.setAttribute(PlatformApiBroker.PORTLET_CONTEXT_ATTRIBUTE_NAME, platformApiBroker);
        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 5 with PortletDefinition

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

the class PortletEventCoordinatationServiceTest method testSupportedEventResolution.

@Test
public void testSupportedEventResolution() throws Exception {
    final QName searchRequestName = new QName("https://source.jasig.org/schemas/uportal/search", "SearchRequest");
    final QName searchResultsName = new QName("https://source.jasig.org/schemas/uportal/search", "SearchResults");
    //org.apereo.portal.search.SearchQuery
    final Event event = mock(Event.class);
    final MockPortletDefinitionId portletDefinitionId = new MockPortletDefinitionId(1);
    final PortletApplicationDefinition portletApplicationDefinition = mock(PortletApplicationDefinition.class);
    final PortletDefinition portletDefinition = mock(PortletDefinition.class);
    final EventDefinitionReference searchRequestEventDefinitionReference = mock(EventDefinitionReference.class);
    final EventDefinitionReference searchResultsEventDefinitionReference = mock(EventDefinitionReference.class);
    final EventDefinition searchRequestEventDefinition = mock(EventDefinition.class);
    final EventDefinition searchResultsEventDefinition = mock(EventDefinition.class);
    when(event.getQName()).thenReturn(searchRequestName);
    when(searchRequestEventDefinitionReference.getQualifiedName(anyString())).thenReturn(searchRequestName);
    when(searchRequestEventDefinitionReference.getQName()).thenReturn(searchRequestName);
    when(searchResultsEventDefinitionReference.getQualifiedName(anyString())).thenReturn(searchResultsName);
    when(searchResultsEventDefinitionReference.getQName()).thenReturn(searchResultsName);
    when(searchRequestEventDefinition.getQName()).thenReturn(searchRequestName);
    when(searchRequestEventDefinition.getQualifiedName(anyString())).thenReturn(searchRequestName);
    when(searchResultsEventDefinition.getQName()).thenReturn(searchResultsName);
    when(searchResultsEventDefinition.getQualifiedName(anyString())).thenReturn(searchResultsName);
    when(this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId)).thenReturn(portletApplicationDefinition);
    when(this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId)).thenReturn(portletDefinition);
    final List<? extends EventDefinition> eventDefinitions = Arrays.asList(searchRequestEventDefinition, searchResultsEventDefinition);
    when(portletApplicationDefinition.getEventDefinitions()).thenReturn((List) eventDefinitions);
    final List<? extends EventDefinitionReference> supportedProcessingEvents = Collections.singletonList(searchRequestEventDefinitionReference);
    when(portletDefinition.getSupportedProcessingEvents()).thenReturn((List) supportedProcessingEvents);
    final boolean supportsEvent = portletEventCoordinatationService.supportsEvent(event, portletDefinitionId);
    assertTrue(supportsEvent);
}
Also used : MockPortletDefinitionId(org.apereo.portal.mock.portlet.om.MockPortletDefinitionId) EventDefinitionReference(org.apache.pluto.container.om.portlet.EventDefinitionReference) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) QName(javax.xml.namespace.QName) Event(javax.portlet.Event) EventDefinition(org.apache.pluto.container.om.portlet.EventDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition) Test(org.junit.Test)

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