{
EventListener listener = eventListeners.nextEventListener();
ListenerCriteria criteria = observationRegistry.getListenerFilter(listener);
EntityCollection events = new EntityCollection();
ChangesLogIterator logIterator = ((CompositeChangesLog)changesLog).getLogIterator();
while (logIterator.hasNextLog())
{
PlainChangesLog subLog = logIterator.nextLog();
String sessionId = subLog.getSessionId();
SessionImpl userSession = sessionRegistry.getSession(sessionId);
if (userSession != null)
for (ItemState itemState : subLog.getAllStates())
{
if (itemState.isEventFire())
{
ItemData item = itemState.getData();
try
{
int eventType = eventType(itemState);
if (eventType != SKIP_EVENT && isTypeMatch(criteria, eventType)
&& isPathMatch(criteria, item, userSession) && isIdentifierMatch(criteria, item)
&& isNodeTypeMatch(criteria, item, userSession, subLog)
&& isSessionMatch(criteria, sessionId))
{
String path =
userSession.getLocationFactory().createJCRPath(item.getQPath()).getAsString(false);
events.add(new EventImpl(eventType, path, userSession.getUserID()));
}
}
catch (RepositoryException e)
{
log.error("Can not fire ActionLauncher.onSaveItems() for " + item.getQPath().getAsString()
+ " reason: " + e);
}
}
}
}
if (events.getSize() > 0)
{
// TCK says, no events - no onEvent() action
listener.onEvent(events);
}
}