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 ) ; }
Attempt to obtain a lock on the supplied node .