@Test public void returnsFalseWhenLockedAndRightCanEdit() throws ComponentLookupException, XWikiException { Mockito.doReturn(this.document).when(this.xwiki).getDocument(this.documentReference, this.context); BaseObject lock = mock(BaseObject.class); when(this.right.isReadOnly()).thenReturn(Boolean.FALSE); when(this.document.getXObject(Matchers.<EntityReference>any())).thenReturn(lock); Assert .assertFalse(this.mocker.getComponentUnderTest().hasAccess(this.user, this.right, this.documentReference)); }
@Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!(entity instanceof DocumentReference)) { return null; } XWikiContext context = this.contextProvider.get(); try { XWikiDocument doc = context.getWiki().getDocument((DocumentReference) entity, context); BaseObject lock = doc.getXObject(this.lockClassReference); if (lock != null && !access.isReadOnly()) { return Boolean.FALSE; } } catch (XWikiException | NullPointerException e) { return null; } return null; }
LockedAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!(entity instanceof DocumentReference)) { return null; } XWikiContext context = this.contextProvider.get(); try { XWikiDocument doc = context.getWiki().getDocument((DocumentReference) entity, context); BaseObject lock = doc.getXObject(this.lockClassReference); if (lock != null && !access.isReadOnly()) { return Boolean.FALSE; } } catch (XWikiException | NullPointerException e) { return null; } return null; } }
LockedAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!(entity instanceof DocumentReference)) { return null; } XWikiContext context = this.contextProvider.get(); try { XWikiDocument doc = context.getWiki().getDocument((DocumentReference) entity, context); BaseObject lock = doc.getXObject(this.lockClassReference); if (lock != null && !access.isReadOnly()) { return Boolean.FALSE; } } catch (XWikiException | NullPointerException e) { return null; } return null; }  }
LockedAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!(entity instanceof DocumentReference)) { return null; } XWikiContext context = this.contextProvider.get(); try { XWikiDocument doc = context.getWiki().getDocument((DocumentReference) entity, context); BaseObject lock = doc.getXObject(this.lockClassReference); if (lock != null && !access.isReadOnly()) { return Boolean.FALSE; } } catch (XWikiException | NullPointerException e) { return null; } return null; }  @Override int getPriority(); @Override Boolean hasAccess(User user, Right access, EntityReference entity); }
LockedAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!(entity instanceof DocumentReference)) { return null; } XWikiContext context = this.contextProvider.get(); try { XWikiDocument doc = context.getWiki().getDocument((DocumentReference) entity, context); BaseObject lock = doc.getXObject(this.lockClassReference); if (lock != null && !access.isReadOnly()) { return Boolean.FALSE; } } catch (XWikiException | NullPointerException e) { return null; } return null; }  @Override int getPriority(); @Override Boolean hasAccess(User user, Right access, EntityReference entity);  }