@Test public void noLockForNonFamilyDocument() throws ComponentLookupException, XWikiException { when(this.familyRepository.get(this.currentDocumentReference.getName())).thenReturn(null); Assert.assertNull(this.mocker.getComponentUnderTest().getLock(this.currentDocumentReference)); }
@Override public DocumentLock getLock(DocumentReference doc) { XWikiContext context = this.provider.get(); XWikiDocument xdoc; try { xdoc = context.getWiki().getDocument(doc, context); if (xdoc == null) { return null; } String documentId = xdoc.getDocumentReference().getName(); Family family = this.familyRepository.get(documentId); if (family == null) { return null; } XWikiLock xlock = xdoc.getLock(context); if (xlock == null) { return null; } User user = this.userManager.getUser(xlock.getUserName()); if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) { Set<String> actions = Collections.singleton("edit"); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; }
FamilyLockModule implements LockModule { @Override public DocumentLock getLock(DocumentReference doc) { XWikiContext context = this.provider.get(); XWikiDocument xdoc; try { xdoc = context.getWiki().getDocument(doc, context); if (xdoc == null) { return null; } String documentId = xdoc.getDocumentReference().getName(); Family family = this.familyRepository.get(documentId); if (family == null) { return null; } XWikiLock xlock = xdoc.getLock(context); if (xlock == null) { return null; } User user = this.userManager.getUser(xlock.getUserName()); if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) { Set<String> actions = Collections.singleton("edit"); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; } }
FamilyLockModule implements LockModule { @Override public DocumentLock getLock(DocumentReference doc) { XWikiContext context = this.provider.get(); XWikiDocument xdoc; try { xdoc = context.getWiki().getDocument(doc, context); if (xdoc == null) { return null; } String documentId = xdoc.getDocumentReference().getName(); Family family = this.familyRepository.get(documentId); if (family == null) { return null; } XWikiLock xlock = xdoc.getLock(context); if (xlock == null) { return null; } User user = this.userManager.getUser(xlock.getUserName()); if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) { Set<String> actions = Collections.singleton("edit"); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; }  }
FamilyLockModule implements LockModule { @Override public DocumentLock getLock(DocumentReference doc) { XWikiContext context = this.provider.get(); XWikiDocument xdoc; try { xdoc = context.getWiki().getDocument(doc, context); if (xdoc == null) { return null; } String documentId = xdoc.getDocumentReference().getName(); Family family = this.familyRepository.get(documentId); if (family == null) { return null; } XWikiLock xlock = xdoc.getLock(context); if (xlock == null) { return null; } User user = this.userManager.getUser(xlock.getUserName()); if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) { Set<String> actions = Collections.singleton("edit"); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; }  @Override int getPriority(); @Override DocumentLock getLock(DocumentReference doc); }
FamilyLockModule implements LockModule { @Override public DocumentLock getLock(DocumentReference doc) { XWikiContext context = this.provider.get(); XWikiDocument xdoc; try { xdoc = context.getWiki().getDocument(doc, context); if (xdoc == null) { return null; } String documentId = xdoc.getDocumentReference().getName(); Family family = this.familyRepository.get(documentId); if (family == null) { return null; } XWikiLock xlock = xdoc.getLock(context); if (xlock == null) { return null; } User user = this.userManager.getUser(xlock.getUserName()); if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) { Set<String> actions = Collections.singleton("edit"); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; }  @Override int getPriority(); @Override DocumentLock getLock(DocumentReference doc);  }