/** * {@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); } } } }
private XWikiDocument getDocument(DocumentReference documentReference) throws XWikiException { XWikiDocument document = new XWikiDocument(documentReference); Map<String, XWikiDocument> docs = getDocuments(document.getDatabase(), false); if (docs.containsKey(document.getFullName())) { return docs.get(document.getFullName()); } else { return document; } }
private void saveDocument(XWikiDocument document) throws XWikiException { document.setNew(false); Map<String, XWikiDocument> database = getDocuments(document.getDatabase(), true); database.remove(document.getFullName()); database.put(document.getFullName(), document); }