/** * {@inheritDoc} * * @see org.xwiki.observation.EventListener#onEvent(org.xwiki.observation.event.Event, * java.lang.Object, java.lang.Object) */ public void onEvent(Event event, Object source, Object data) { // Only take into account local events if (!Utils.getComponent(RemoteObservationManagerContext.class).isRemoteState()) { XWikiDocument document = ((XWikiDocument) source).getOriginalDocument(); XWikiContext context = (XWikiContext) data; String userOrGroupWiki = document.getDatabase(); String userOrGroupSpace = document.getSpace(); String userOrGroupName = document.getName(); if (document.getObject("XWiki.XWikiUsers") != null) { try { cleanDeletedUserOrGroup( userOrGroupWiki, userOrGroupSpace, userOrGroupName, true, context); } catch (XWikiException e) { LOG.warn("Error when cleaning for deleted user", e); } } else if (document.getObject("XWiki.XWikiGroups") != null) { try { cleanDeletedUserOrGroup( userOrGroupWiki, userOrGroupSpace, userOrGroupName, false, context); } catch (XWikiException e) { LOG.warn("Error when cleaning for deleted group", e); } } } }
/** * Generate page name from the container page We add Rating and getUniquePageName will add us a * counter to our page */ private String getPageName(String documentName) throws XWikiException { XWikiDocument doc = context.getWiki().getDocument(documentName, context); String ratingsSpace = ratingsManager.getRatingsSpaceName(); boolean hasRatingsSpaceForeachSpace = ratingsManager.hasRatingsSpaceForeachSpace(); if (hasRatingsSpaceForeachSpace) { return doc.getSpace() + ratingsSpace + "." + getUniquePageName(ratingsSpace, doc.getName(), "R", true); } else if (ratingsSpace == null) { return doc.getSpace() + "." + getUniquePageName(doc.getSpace(), doc.getName() + "R", "", true); } else { return ratingsSpace + "." + getUniquePageName(ratingsSpace, doc.getSpace() + "_" + doc.getName(), "R", true); } }