@Override public Lock getLockInfo() { if (lock != LOCK_UNKNOWN) { return lock; } // no lock if not tied to a session if (!hasSession()) { return null; } lock = getSession().getLockInfo(ref); return lock; }
@Override public boolean isLocked(DocumentRef ref) { Lock lock = getSession().getLockInfo(ref); return lock != null; }
@Override public boolean isLocked(CoreSession session) { return session.getLockInfo(doc.getRef()) != null; }
@Override public String getCheckoutUser(DocumentRef ref) { Lock lock = getSession().getLockInfo(ref); if (lock != null) { return lock.getOwner(); } return null; }
@Override public Map<String, Serializable> getLockDetails(DocumentModel document) { if (lockDetails == null || !StringUtils.equals(documentId, document.getId())) { lockDetails = new HashMap<String, Serializable>(); documentId = document.getId(); Lock lock = documentManager.getLockInfo(document.getRef()); if (lock == null) { return lockDetails; } lockDetails.put(LOCKER, lock.getOwner()); lockDetails.put(LOCK_CREATED, lock.getCreated()); } return lockDetails; }
@Override public boolean isLockedByCurrentUser(CoreSession session) { Lock lockInfo = session.getLockInfo(doc.getRef()); if (lockInfo == null) { return false; } String lockOwner = lockInfo.getOwner(); NuxeoPrincipal userName = session.getPrincipal(); return userName.getName().equals(lockOwner); }
@GET public Object doGet() { try { DocumentModel doc = getTarget().getAdapter(DocumentModel.class); Lock lock = ctx.getCoreSession().getLockInfo(doc.getRef()); return lock.getOwner() + '/' + ISODateTimeFormat.dateTime().print(new DateTime(lock.getCreated())); } catch (NuxeoException e) { e.addInfo("Failed to get lock on document"); throw e; } }
public boolean canPublishTo(PublicationNode publicationNode) { DocumentModel doc = navigationContext.getCurrentDocument(); if (doc == null || documentManager.getLockInfo(doc.getRef()) != null) { return false; } PublicationTree tree = getCurrentPublicationTreeForPublishing(); return tree != null ? tree.canPublishTo(publicationNode) : false; }
/** * GR: * - can not published non approved document * - can publish a document even if there is a lock. */ @Override public boolean canPublishTo(PublicationNode publicationNode) throws ClientException { boolean canPublish = super.canPublishTo(publicationNode); DocumentModel doc = navigationContext.getCurrentDocument(); // canPublish can be false if lock on document is present. if (!canPublish) { Lock lock = documentManager.getLockInfo(doc.getRef()); // We authorize check of publication even if there is a lock. canPublish = lock != null ? true : false; } if (canPublish && ToutaticeNuxeoStudioConst.CST_DOC_STATE_APPROVED.equals(doc .getCurrentLifeCycleState())) { PublicationTree tree = getCurrentPublicationTreeForPublishing(); canPublish = tree != null ? tree.canPublishTo(publicationNode) : false; } return canPublish; }
@Override public Boolean getCanLockDoc(DocumentModel document) { boolean canLock; if (document == null) { log.warn("Can't evaluate lock action : currentDocument is null"); canLock = false; } else if (document.isProxy()) { canLock = false; } else { NuxeoPrincipal userName = documentManager.getPrincipal(); Lock lock = documentManager.getLockInfo(document.getRef()); canLock = lock == null && (userName.isAdministrator() || isManagerOnDocument(document.getRef()) || documentManager.hasPermission(document.getRef(), WRITE_PROPERTIES)) && !document.isVersion(); } return canLock; }
@Override public String lockDocument(DocumentModel document) { log.debug("Lock a document ..."); resetEventContext(); String message = "document.lock.failed"; DocumentRef ref = document.getRef(); if (documentManager.hasPermission(ref, WRITE_PROPERTIES) && documentManager.getLockInfo(ref) == null) { documentManager.setLock(ref); documentManager.save(); message = "document.lock"; Events.instance().raiseEvent(EventNames.DOCUMENT_LOCKED, document); Events.instance().raiseEvent(EventNames.DOCUMENT_CHANGED, document); } facesMessages.add(StatusMessage.Severity.INFO, resourcesAccessor.getMessages().get(message)); resetLockState(); webActions.resetTabList(); return null; }