use of javax.jcr.lock.LockManager in project jackrabbit by apache.
the class NodeImpl method getLock.
/**
* {@inheritDoc}
*/
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
// check state of this instance
sanityCheck();
LockManager lockMgr = getSession().getWorkspace().getLockManager();
return lockMgr.getLock(getPath());
}
use of javax.jcr.lock.LockManager in project pentaho-platform by pentaho.
the class DefaultLockHelper method removeLockTokenFromSessionIfNecessary.
/**
* {@inheritDoc}
*/
public void removeLockTokenFromSessionIfNecessary(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId) throws RepositoryException {
Node fileNode = session.getNodeByIdentifier(fileId.toString());
if (fileNode.isLocked()) {
LockManager lockManager = session.getWorkspace().getLockManager();
Lock lock = lockManager.getLock(fileNode.getPath());
String lockToken = getLockToken(session, pentahoJcrConstants, lock);
lockManager.removeLockToken(lockToken);
}
}
use of javax.jcr.lock.LockManager in project pentaho-platform by pentaho.
the class DefaultLockHelper method lockFile.
/**
* {@inheritDoc}
*/
public void lockFile(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final String message) throws RepositoryException {
LockManager lockManager = session.getWorkspace().getLockManager();
// locks are always deep in this impl
final boolean isDeep = true;
// locks are always open-scoped since a session is short-lived and all work occurs in a transaction
// anyway; from spec, "if a lock is enabled and then disabled within the same transaction, its effect never
// makes it to the persistent workspace and therefore it does nothing"
final boolean isSessionScoped = false;
final long timeoutHint = Long.MAX_VALUE;
final String ownerInfo = makeOwnerInfo(JcrTenantUtils.getTenantedUser(PentahoSessionHolder.getSession().getName()), Calendar.getInstance().getTime(), message);
Node fileNode = session.getNodeByIdentifier(fileId.toString());
Assert.isTrue(fileNode.isNodeType(pentahoJcrConstants.getMIX_LOCKABLE()));
Lock lock = lockManager.lock(fileNode.getPath(), isDeep, isSessionScoped, timeoutHint, ownerInfo);
addLockToken(session, pentahoJcrConstants, lock);
}
Aggregations