use of org.xwiki.bridge.event.ActionExecutedEvent in project xwiki-platform by xwiki.
the class ActionExecutedEventTest method testEqualsSameAction.
@Test
public void testEqualsSameAction() {
ActionExecutedEvent event = new ActionExecutedEvent("something");
Assert.assertTrue("Same action wasn't equal!", event.equals(new ActionExecutedEvent("something")));
}
use of org.xwiki.bridge.event.ActionExecutedEvent in project xwiki-platform by xwiki.
the class XWikiStatsServiceImpl method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
if (Utils.getComponent(RemoteObservationManagerContext.class).isRemoteState()) {
// take care of this
return;
}
ActionExecutedEvent actionEvent = (ActionExecutedEvent) event;
XWikiDocument document = (XWikiDocument) source;
XWikiContext context = (XWikiContext) data;
// anything in the database)
if (context.getWiki().isReadOnly()) {
return;
}
// Initialize cookie used as unique identifier of a user visit and put it in the context
StatsUtil.findCookie(context);
String action = actionEvent.getActionName();
// Let's save in the session the last elements view, saved
synchronized (this) {
if (!action.equals(DownloadAction.ACTION_NAME)) {
Collection actions = StatsUtil.getRecentActionFromSessions(context, action);
if (actions == null) {
actions = new CircularFifoQueue(StatsUtil.getRecentVisitSize(context));
StatsUtil.setRecentActionsFromSession(context, action, actions);
}
String element = document.getPrefixedFullName();
if (actions.contains(element)) {
actions.remove(element);
}
actions.add(element);
}
}
try {
if (StatsUtil.isWikiStatsEnabled(context) && !StatsUtil.getStorageFilteredUsers(context).contains(this.currentDocumentReferenceResolver.resolve(context.getUser()))) {
this.statsRegister.addStats(document, action, context);
}
} catch (Exception e) {
LOGGER.error("Faild to get filter users list", e);
}
}
Aggregations