36 private $persistenceFacade = null;
37 private $session = null;
38 private $lockType = null;
40 private static $logger = null;
51 $this->persistenceFacade = $persistenceFacade;
52 $this->session = $session;
53 $this->lockType = $lockType;
54 if (self::$logger == null) {
71 if ($lock->getLogin() != $authUserLogin) {
83 $lock = new Lock($type, $oid, $authUserLogin);
87 $lock->setCurrentState($currentState);
101 $query = new ObjectQuery($this->lockType, __CLASS__.__METHOD__);
102 $tpl = $query->getObjectTemplate($this->lockType);
106 foreach($locks as $lock) {
108 $lock->getMapper()->delete($lock);
118 $query = new ObjectQuery($this->lockType, __CLASS__.__METHOD__);
119 $tpl = $query->getObjectTemplate($this->lockType);
122 foreach($locks as $lock) {
124 $lock->getMapper()->delete($lock);
136 $query = new ObjectQuery($this->lockType, __CLASS__.__METHOD__);
137 $tpl = $query->getObjectTemplate($this->lockType);
140 foreach($locks as $lock) {
142 $lock->getMapper()->delete($lock);
157 if (isset($locks[$oidStr])) {
158 $sessionLock = $locks[$oidStr];
167 $query = new ObjectQuery($this->lockType, __CLASS__.__METHOD__);
168 $tpl = $query->getObjectTemplate($this->lockType);
171 if (sizeof($locks) > 0) {
172 $lockObj = $locks[0];
174 $lockObj->getValue('created'));
179 if ($lockObj->getValue('login') == $authUserLogin) {
197 if ($lock->getLogin() == $authUserLogin) {
198 $lock->setCurrentState($object);
214 $lockObj->setValue('objectid', $lock->getObjectId());
215 $lockObj->setValue('login', $lock->getLogin());
216 $lockObj->setValue('created', $lock->getCreated());
218 $lockObj->getMapper()->save($lockObj);
229 return $this->session->getAuthUser();
238 if ($this->session->exist(self::SESSION_VARNAME)) {
239 return $this->session->get(self::SESSION_VARNAME);
250 $locks[$lock->getObjectId()->__toString()] = $lock;
251 $this->session->set(self::SESSION_VARNAME, $locks);
263 if ($type == null || $type != null && $lock->getType() == $type) {
265 $this->session->set(self::SESSION_VARNAME, $locks);
274 $this->session->remove(self::SESSION_VARNAME);
getAuthUser()
Get the login of the current user.
Session is the interface for session implementations and defines access to session variables.
getCreated()
Get the creation date/time of the lock.
addSessionLock(Lock $lock)
Add a given Lock instance to the session.
getLogin()
Get the login of the user who holds the lock.
releaseLock(ObjectId $oid, $type=null)
getObjectId()
Get the oid of the locked object.
__toString()
Get a string representation of the object id.
removeSessionLock(ObjectId $oid, $type)
Remove a given Lock instance from the session.
PessimisticLockException signals an exception when trying to create an pessimistic lock.
static asValue($operator, $value)
Factory method for constructing a Criteria that may be used as value on a PersistentObject's attribut...
Criteria defines a condition on a PersistentObject's attribute used to select specific instances.
ObjectId is the unique identifier of an object.
LockHandler defines the interface for LockHandler implementations.
BuildDepth values are used to define the depth when loading object trees.
removeSessonLocks()
Remove all Lock instances from the session.
storeLock(Lock $lock)
Store the given Lock instance for later retrieval.
DefaultLockHandler implements the LockHandler interface for relational databases.
releaseLocks(ObjectId $oid)
aquireLock(ObjectId $oid, $type, PersistentObject $currentState=null)
Lock represents a lock on an object.
PersistenceFacade defines the interface for PersistenceFacade implementations.
updateLock(ObjectId $oid, PersistentObject $object)
static getLogger($name)
Get the logger with the given name.
__construct(PersistenceFacade $persistenceFacade, Session $session, $lockType)
Constructor.
getSessionLocks()
Get the Lock instances stored in the session.
PersistentObject defines the interface of all persistent objects.
LogManager is used to retrieve Logger instances.
getType()
Get the type of the lock.
ObjectQuery implements a template based object query.