@Test public void newDeniedRightObject() throws XWikiException, AccessDeniedException { XWikiDocument document = new XWikiDocument(new DocumentReference("wiki", "space", "page")); BaseObject rightObject = document.newXObject(XWikiRightsDocumentInitializer.CLASS_REFERENCE, oldcore.getXWikiContext()); document.setOriginalDocument(document.clone()); document.getOriginalDocument().removeXObjects(XWikiRightsDocumentInitializer.CLASS_REFERENCE); rightObject.setStringValue("levels", "view"); doThrow(AccessDeniedException.class).when(this.authorization).checkAccess(Right.VIEW, null, document.getDocumentReference()); XWikiDocument before = document.clone(); this.listener.onEvent(new UserUpdatingDocumentEvent(), document, null); assertNotEquals(before, document); assertEquals(document.getOriginalDocument(), document); }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; UserEvent userEvent = (UserEvent) event; checkModifiedRights(userEvent.getUserReference(), document, XWikiRightsDocumentInitializer.CLASS_REFERENCE, null); checkModifiedRights(userEvent.getUserReference(), document, XWikiGlobalRightsDocumentInitializer.CLASS_REFERENCE, (CancelableEvent) event); }
RightsFilterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; UserEvent userEvent = (UserEvent) event; checkModifiedRights(userEvent.getUserReference(), document, XWikiRightsDocumentInitializer.CLASS_REFERENCE, null); checkModifiedRights(userEvent.getUserReference(), document, XWikiGlobalRightsDocumentInitializer.CLASS_REFERENCE, (CancelableEvent) event); } }
RightsFilterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; UserEvent userEvent = (UserEvent) event; checkModifiedRights(userEvent.getUserReference(), document, XWikiRightsDocumentInitializer.CLASS_REFERENCE, null); checkModifiedRights(userEvent.getUserReference(), document, XWikiGlobalRightsDocumentInitializer.CLASS_REFERENCE, (CancelableEvent) event); } RightsFilterListener(); }
RightsFilterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; UserEvent userEvent = (UserEvent) event; checkModifiedRights(userEvent.getUserReference(), document, XWikiRightsDocumentInitializer.CLASS_REFERENCE, null); checkModifiedRights(userEvent.getUserReference(), document, XWikiGlobalRightsDocumentInitializer.CLASS_REFERENCE, (CancelableEvent) event); } RightsFilterListener(); @Override void onEvent(Event event, Object source, Object data); }
RightsFilterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; UserEvent userEvent = (UserEvent) event; checkModifiedRights(userEvent.getUserReference(), document, XWikiRightsDocumentInitializer.CLASS_REFERENCE, null); checkModifiedRights(userEvent.getUserReference(), document, XWikiGlobalRightsDocumentInitializer.CLASS_REFERENCE, (CancelableEvent) event); } RightsFilterListener(); @Override void onEvent(Event event, Object source, Object data); static final String NAME; }