code: public Lock lock( AbstractJcrNode node,
                        boolean isDeep,
                        boolean isSessionScoped,
                        long timeoutHint,
                        String ownerInfo )
          throws LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
          if (!node.isLockable()) {
              throw new LockException(JcrI18n.nodeNotLockable.text(node.location()));
          }
          if (node.isLocked()) {
              throw new LockException(JcrI18n.alreadyLocked.text(node.location()));            
          }
          if (node.isNew()|| node.isModified()) {
              throw new InvalidItemStateException(JcrI18n.changedNodeCannotBeLocked.text(node.location()));
          }
  
          // Try to obtain the lock ...
          ModeShapeLock lock = lockManager.lock(session, node.node(), isDeep, isSessionScoped, timeoutHint, ownerInfo);
          String token = lock.getLockToken();
          lockTokens.add(token);
          return lock.lockFor(session);
      }
docs: Attempt to obtain a lock on the supplied node.
  
  @param node the node; may not be null
  @param isDeep true if the lock should be a deep lock
  @param isSessionScoped true if the lock should be scoped to the session
  @param timeoutHint desired lock timeout in seconds (servers are free to ignore this value); specify {@link Long#MAX_VALUE}
  for no timeout.
  @param ownerInfo a string containing owner information supplied by the client, and recorded on the lock; if null, then the
  session's user ID will be used
  @return the lock; never null
  @throws AccessDeniedException if the caller does not have privilege to lock the node
  @throws InvalidItemStateException if the node has been modified and cannot be locked
  @throws LockException if the lock could not be obtained
  @throws RepositoryException if an error occurs updating the graph state