org.pentaho.platform.repository2.unified.jcr
Interface ILockHelper

All Known Implementing Classes:
DefaultLockHelper

public interface ILockHelper

Helper class that stores, retrieves, and removes lock tokens. In section 8.4.7 of the JSR-170 specification, it states, "the user must additionally ensure that a reference to the lock token is preserved separately so that it can later be attached to another session." This manual step is necessary when using open-scoped locks and this implementation uses open-scoped locks exclusively.

Author:
mlowery

Method Summary
 void addLockTokenToSessionIfNecessary(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
          Adds the lock token associated with the file with the given file id if the file is locked.
 boolean canUnlock(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, javax.jcr.lock.Lock lock)
          Returns true if user represented by session can potentially unlock the given lock.
 void lockFile(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId, String lockMessage)
          Locks a file.
 void removeLockToken(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, javax.jcr.lock.Lock lock)
          Removes a lock token so that it can never be associated with anyone's session again.
 void removeLockTokenFromSessionIfNecessary(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
          Removes the lock token associated with the file with the given file id
 void unlockFile(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
          Unlocks a file.
 

Method Detail

removeLockToken

void removeLockToken(javax.jcr.Session session,
                     PentahoJcrConstants pentahoJcrConstants,
                     javax.jcr.lock.Lock lock)
                     throws javax.jcr.RepositoryException
Removes a lock token so that it can never be associated with anyone's session again. (To be called after the file has been unlocked (or the file is deleted) and therefore the token associated with the lock is unnecessary.)

Parameters:
session - session
pentahoJcrConstants - constants
lock - lock
Throws:
javax.jcr.RepositoryException - if anything goes wrong

canUnlock

boolean canUnlock(javax.jcr.Session session,
                  PentahoJcrConstants pentahoJcrConstants,
                  javax.jcr.lock.Lock lock)
                  throws javax.jcr.RepositoryException
Returns true if user represented by session can potentially unlock the given lock. This can be a function of access control or some other mechanism.

Parameters:
session - session
pentahoJcrConstants - constants
lock - lock
Throws:
javax.jcr.RepositoryException - if anything goes wrong

lockFile

void lockFile(javax.jcr.Session session,
              PentahoJcrConstants pentahoJcrConstants,
              Serializable fileId,
              String lockMessage)
              throws javax.jcr.RepositoryException
Locks a file.

Parameters:
session - session
pentahoJcrConstants - constants
fileId - file id
lockMessage - lock message
Throws:
javax.jcr.RepositoryException - if anything goes wrong

unlockFile

void unlockFile(javax.jcr.Session session,
                PentahoJcrConstants pentahoJcrConstants,
                Serializable fileId)
                throws javax.jcr.RepositoryException
Unlocks a file.

Parameters:
session - session
pentahoJcrConstants - constants
fileId - file id
Throws:
javax.jcr.RepositoryException - if anything goes wrong

addLockTokenToSessionIfNecessary

void addLockTokenToSessionIfNecessary(javax.jcr.Session session,
                                      PentahoJcrConstants pentahoJcrConstants,
                                      Serializable fileId)
                                      throws javax.jcr.RepositoryException
Adds the lock token associated with the file with the given file id if the file is locked.

Parameters:
session - session
pentahoJcrConstants - constants
fileId - file id
Throws:
javax.jcr.RepositoryException - if anything goes wrong

removeLockTokenFromSessionIfNecessary

void removeLockTokenFromSessionIfNecessary(javax.jcr.Session session,
                                           PentahoJcrConstants pentahoJcrConstants,
                                           Serializable fileId)
                                           throws javax.jcr.RepositoryException
Removes the lock token associated with the file with the given file id

Parameters:
session - session
pentahoJcrConstants - constants
fileId - file id
Throws:
javax.jcr.RepositoryException - if anything goes wrong