Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2015 (original work) Open Assessment Technologies SA;
19 *
20 */
21
22namespace oat\tao\model\lock;
23
24use core_kernel_classes_Resource;
25
26/**
27 * manage lock on a given resource
28 *
29 * @author plichart
30 */
31interface LockSystem
32{
33    public const SERVICE_ID = 'tao/lock';
34
35    /**
36     * set a lock on @resource with owner @user, succeeds also if there is a lock already exists but with the same owner
37     *
38     * @throws ResourceLockedException if the resource already has a lock with a different owner
39     * @param core_kernel_classes_Resource $resource
40     * @param core_kernel_classes_Resource $user
41     */
42    public function setLock(core_kernel_classes_Resource $resource, $ownerId);
43
44    /**
45     * return true is the resource is locked, else otherwise
46     * @return boolean
47     */
48    public function isLocked(core_kernel_classes_Resource $resource);
49
50    /**
51     *  release the lock if owned by @user
52     * @param core_kernel_classes_Resource $resource
53     * @param core_kernel_classes_Resource $user
54     * @throw common_Exception no lock to release
55     */
56    public function releaseLock(core_kernel_classes_Resource $resource, $ownerId);
57
58    /**
59      *  release the lock
60      * @param core_kernel_classes_Resource $resource
61      * @throw common_Exception no lock to release
62      */
63    public function forceReleaseLock(core_kernel_classes_Resource $resource);
64
65    /**
66     * Return lock details or null if no lock found
67     *
68     * @param core_kernel_classes_Resource $resource
69     * @return Lock
70     */
71    public function getLockData(core_kernel_classes_Resource $resource);
72}