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);
}
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;
}
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;
}
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;
}
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();
}
Aggregations