/** * Updates the underlying repository directly (i.e., outside the scope of the {@link Session}) to mark the token for the given * lock as being held (or not held) by some {@link Session}. Note that this method does not identify <i>which</i> (if any) * session holds the token for the lock, just that <i>some</i> session holds the token for the lock. * * @param session the session on behalf of which the lock operation is being performed * @param lockToken the lock token for which the "held" status should be modified; may not be null * @param value the new value * @return true if the lock "held" status was successfully changed to the desired value, or false otherwise * @throws LockException if there is no such lock with the supplied token */ boolean setHeldBySession( JcrSession session, String lockToken, boolean value ) throws LockException { assert lockToken != null; // Create a system session to remove the locks ... final ExecutionContext context = session.context(); SessionCache systemSession = repository.createSystemSession(context, false); SystemContent system = new SystemContent(systemSession); // Mark the session as held/unheld ... if (!system.changeLockHeldBySession(lockToken, value)) { return false; } // Now save the session ... system.save(); return true; }
/** * Updates the underlying repository directly (i.e., outside the scope of the {@link Session}) to mark the token for the given * lock as being held (or not held) by some {@link Session}. Note that this method does not identify <i>which</i> (if any) * session holds the token for the lock, just that <i>some</i> session holds the token for the lock. * * @param session the session on behalf of which the lock operation is being performed * @param lockToken the lock token for which the "held" status should be modified; may not be null * @param value the new value * @return true if the lock "held" status was successfully changed to the desired value, or false otherwise * @throws LockException if there is no such lock with the supplied token */ boolean setHeldBySession( JcrSession session, String lockToken, boolean value ) throws LockException { assert lockToken != null; // Create a system session to remove the locks ... final ExecutionContext context = session.context(); SessionCache systemSession = repository.createSystemSession(context, false); SystemContent system = new SystemContent(systemSession); // Mark the session as held/unheld ... if (!system.changeLockHeldBySession(lockToken, value)) { return false; } // Now save the session ... system.save(); return true; }