Search in sources :

Example 1 with PortletExecutionEvent

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);
}
Also used : MockPortletExecutionEvent(org.apereo.portal.events.MockPortletExecutionEvent) MockPortletExecutionEvent(org.apereo.portal.events.MockPortletExecutionEvent) PortletExecutionEvent(org.apereo.portal.events.PortletExecutionEvent) ArrayList(java.util.ArrayList)

Example 2 with PortletExecutionEvent

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());
}
Also used : PortletExecutionEvent(org.apereo.portal.events.PortletExecutionEvent) LrsObject(org.apereo.portal.events.tincan.om.LrsObject) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString)

Example 3 with PortletExecutionEvent

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;
}
Also used : PortletExecutionEvent(org.apereo.portal.events.PortletExecutionEvent) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString)

Aggregations

PortletExecutionEvent (org.apereo.portal.events.PortletExecutionEvent)3 LocalizedString (org.apereo.portal.events.tincan.om.LocalizedString)2 ArrayList (java.util.ArrayList)1 MockPortletExecutionEvent (org.apereo.portal.events.MockPortletExecutionEvent)1 AggregatedPortletMapping (org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping)1 LrsObject (org.apereo.portal.events.tincan.om.LrsObject)1