Search in sources :

Example 6 with PortletApplicationDefinition

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

Example 7 with PortletApplicationDefinition

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

the class EventProviderImpl method isValueInstanceOfDefinedClass.

private boolean isValueInstanceOfDefinedClass(QName qname, Serializable value) {
    final PortletDefinition portletDefinition = this.portletWindow.getPlutoPortletWindow().getPortletDefinition();
    final PortletApplicationDefinition app = portletDefinition.getApplication();
    final List<? extends EventDefinition> events = app.getEventDefinitions();
    if (events == null) {
        return true;
    }
    final String defaultNamespace = app.getDefaultNamespace();
    for (final EventDefinition eventDefinition : events) {
        if (eventDefinition.getQName() != null) {
            if (eventDefinition.getQName().equals(qname)) {
                final Class<? extends Serializable> valueClass = value.getClass();
                return valueClass.getName().equals(eventDefinition.getValueType());
            }
        } else {
            final QName tmp = new QName(defaultNamespace, eventDefinition.getName());
            if (tmp.equals(qname)) {
                final Class<? extends Serializable> valueClass = value.getClass();
                return valueClass.getName().equals(eventDefinition.getValueType());
            }
        }
    }
    // event not declared
    return true;
}
Also used : PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) QName(javax.xml.namespace.QName) EventDefinition(org.apache.pluto.container.om.portlet.EventDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 8 with PortletApplicationDefinition

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

the class PortletEventCoordinatationService method isGlobalEvent.

protected boolean isGlobalEvent(HttpServletRequest request, IPortletWindowId sourceWindowId, Event event) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, sourceWindowId);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
    final PortletApplicationDefinition parentPortletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId);
    final ContainerRuntimeOption globalEvents = parentPortletApplicationDescriptor.getContainerRuntimeOption(GLOBAL_EVENT__CONTAINER_OPTION);
    if (globalEvents != null) {
        final QName qName = event.getQName();
        final String qNameStr = qName.toString();
        for (final String globalEvent : globalEvents.getValues()) {
            if (qNameStr.equals(globalEvent)) {
                return true;
            }
        }
    }
    return false;
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) QName(javax.xml.namespace.QName) ContainerRuntimeOption(org.apache.pluto.container.om.portlet.ContainerRuntimeOption) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 9 with PortletApplicationDefinition

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

the class CachedPasswordUserInfoService method isPasswordRequested.

/**
 * Determine whether the portlet has expects a password as one of the user attributes.
 *
 * @param request portlet request
 * @param plutoPortletWindow portlet window
 * @return <code>true</code> if a password is expected, <code>false</code> otherwise
 * @throws PortletContainerException if expeced attributes cannot be determined
 */
public boolean isPasswordRequested(PortletRequest request, PortletWindow plutoPortletWindow) throws PortletContainerException {
    // get the list of requested user attributes
    final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinition.getPortletDefinitionId());
    // check to see if the password key is one of the requested user attributes
    List<? extends UserAttribute> requestedUserAttributes = portletApplicationDescriptor.getUserAttributes();
    for (final UserAttribute userAttributeDD : requestedUserAttributes) {
        final String attributeName = userAttributeDD.getName();
        if (attributeName.equals(this.passwordKey))
            return true;
    }
    // if the password key wasn't found in the list of requested attributes
    return false;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) UserAttribute(org.apache.pluto.container.om.portlet.UserAttribute) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 10 with PortletApplicationDefinition

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

the class PersonDirectoryUserInfoService method getExpectedUserAttributes.

/**
 * Get the list of user attributes the portlet expects
 *
 * @param request The current request.
 * @param portletWindow The window to get the expected user attributes for.
 * @return The List of expected user attributes for the portlet
 * @throws PortletContainerException If expected attributes cannot be determined
 */
protected List<? extends UserAttribute> getExpectedUserAttributes(HttpServletRequest request, final IPortletWindow portletWindow) throws PortletContainerException {
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinition.getPortletDefinitionId());
    return portletApplicationDescriptor.getUserAttributes();
}
Also used : PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

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