@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(); Patient patient = this.patientRepository.getPatientById(documentId); if (patient == null) { return null; } XWikiLock xlock = xdoc.getLock(context); 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("patient.locks.patientInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; } }
@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(); Patient patient = this.patientRepository.getPatientById(documentId); if (patient == null) { return null; } XWikiLock xlock = xdoc.getLock(context); 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("patient.locks.patientInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; } }