use of org.apereo.portal.events.PortletExecutionEvent in project uPortal by Jasig.
the class PortletExecutionEventConverterTest method setupSupportsTest.
private boolean setupSupportsTest(String fname, boolean classMatch, boolean fnameMatch, FNameFilterType filterType) {
PortletExecutionEvent event = spy(new MockPortletExecutionEvent());
when(event.getFname()).thenReturn(fname);
PortletExecutionEventConverter converter = new PortletExecutionEventConverter();
List<Class<? extends PortletExecutionEvent>> classes = new ArrayList<Class<? extends PortletExecutionEvent>>();
classes.add(PortletActionExecutionEvent.class);
if (classMatch) {
classes.add(MockPortletExecutionEvent.class);
}
converter.setSupportedEventTypes(classes);
if (filterType != null) {
List<String> fnames = new ArrayList<String>(2);
fnames.add("_mock-fname");
if (fnameMatch && fname != null) {
fnames.add(fname);
}
converter.setFilterFNames(fnames);
converter.setFnameFilterType(filterType);
}
return converter.supports(event);
}
use of org.apereo.portal.events.PortletExecutionEvent in project uPortal by Jasig.
the class PortletExecutionEventConverter method getLrsObject.
@Override
protected LrsObject getLrsObject(PortalEvent event) {
final String fname = ((PortletExecutionEvent) event).getFname();
final AggregatedPortletMapping mappedPortletForFname = this.aggregatedPortletLookupDao.getMappedPortletForFname(fname);
final Builder<String, LocalizedString> definitionBuilder = ImmutableMap.builder();
definitionBuilder.put("name", new LocalizedString(Locale.US, mappedPortletForFname.getName()));
return new LrsObject(buildUrn("portlet", fname), getDefaultObjectType(), definitionBuilder.build());
}
use of org.apereo.portal.events.PortletExecutionEvent in project uPortal by Jasig.
the class PortletExecutionEventConverter method supports.
@Override
public boolean supports(PortalEvent event) {
boolean postEvent = false;
for (Class<?> cls : supportedEventTypes) {
if (cls.isAssignableFrom(event.getClass())) {
postEvent = true;
break;
}
}
if (postEvent && filterFNames != null) {
PortletExecutionEvent execEvent = (PortletExecutionEvent) event;
boolean foundFName = false;
for (String fname : filterFNames) {
if (fname != null && fname.equalsIgnoreCase(execEvent.getFname())) {
foundFName = true;
break;
}
}
postEvent = fnameFilterType == FNameFilterType.Whitelist ? foundFName : !foundFName;
}
return postEvent;
}
Aggregations