public String getLockingUser() { try { XWikiLock lock = this.doc.getLock(getXWikiContext()); if (lock != null && !getXWikiContext().getUser().equals(lock.getUserName())) { return lock.getUserName(); } else { return ""; } } catch (XWikiException e) { return ""; } }
public boolean getLocked() { try { XWikiLock lock = this.doc.getLock(getXWikiContext()); if (lock != null && !getXWikiContext().getUser().equals(lock.getUserName())) { return true; } else { return false; } } catch (Exception e) { return false; } }
public Date getLockingDate() { try { XWikiLock lock = this.doc.getLock(getXWikiContext()); if (lock != null && !getXWikiContext().getUser().equals(lock.getUserName())) { return lock.getDate(); } else { return null; } } catch (XWikiException 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; } 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("locks.documentInUse", user.getName()), actions, true); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; } }
/** * return true if can be locked return null in case of an error return false in all the other cases * * @param fullName * @param force * @return */ @Override public Boolean lockDocument(String fullName, boolean force) throws XWikiGWTException { try { XWikiContext context = getXWikiContext(); XWikiDocument doc = context.getWiki().getDocument(fullName, context); if (context.getWiki().getRightService().hasAccessLevel("edit", context.getUser(), fullName, context)) { /* Setup a lock */ XWikiLock lock = doc.getLock(context); if ((lock == null) || (lock.getUserName().equals(context.getUser())) || force) { if (lock != null) doc.removeLock(context); doc.setLock(context.getUser(), context); return Boolean.valueOf(true); } else return Boolean.valueOf(false); } else return Boolean.valueOf(false); } catch (Exception e) { throw getXWikiGWTException(e); } }
XWikiLock xlock = memberXDoc.getLock(context); if (xlock != null) { user = this.userManager.getUser(xlock.getUserName()); date = (date.before(xlock.getDate())) ? xlock.getDate() : date; Set<String> actions = Collections.singleton("edit");
XWikiLock xlock = memberXDoc.getLock(context); if (xlock != null) { user = this.userManager.getUser(xlock.getUserName()); Set<String> actions = Collections.singleton("edit"); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyMemberInUse"),
@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(); Family family = this.familyRepository.getFamilyById(documentId); if (family == 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("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 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; } }
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");
if (xlock != null) { Set<String> actions = Collections.singleton("edit"); User user = this.userManager.getUser(xlock.getUserName()); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.patientFamilyInUse", user.getName()), actions, false);
if (xlock != null) { Set<String> actions = Collections.singleton("edit"); User user = this.userManager.getUser(xlock.getUserName()); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.patientFamilyInUse", user.getName()), actions, false);
if ((lock == null) || (lock.getUserName().equals(context.getUser())) || (peform.isLockForce())) doc.setLock(context.getUser(), context); } catch (Exception e) {
if ((lock == null) || (username.equals(lock.getUserName()))) { if ("inline".equals(request.get("action"))) { doc.setLock(username, context);
if (lock != null && lock.getUserName().equals(username)) { if ("inline".equals(request.get("action"))) { doc.removeLock(context);
if ((lock == null) || (lock.getUserName().equals(context.getUser())) || (peform.isLockForce())) { tdoc.setLock(context.getUser(), context);
if ((lock == null) || (lock.getUserName().equals(context.getUser())) || (peform.isLockForce())) { tdoc.setLock(context.getUser(), context);