1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Thomas Müller <[email protected]> |
4
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
5
|
|
|
* @license AGPL-3.0 |
6
|
|
|
* |
7
|
|
|
* This code is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
9
|
|
|
* as published by the Free Software Foundation. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU Affero General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace OC\Lock\Persistent; |
21
|
|
|
|
22
|
|
|
use OCP\AppFramework\Db\Entity; |
23
|
|
|
use OCP\Lock\Persistent\ILock; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class Lock |
27
|
|
|
* |
28
|
|
|
* @method string getTokenHash() |
29
|
|
|
* @method string getPath() |
30
|
|
|
* @method string getOwnerAccountId() |
31
|
|
|
* |
32
|
|
|
* @method setFileId(int $fileId) |
33
|
|
|
* @method setCreatedAt(int $timestamp) |
34
|
|
|
* @method setTimeout(int $timeout) |
35
|
|
|
* @method setScope(int $scope) |
36
|
|
|
* @method setDepth(int $depth) |
37
|
|
|
* |
38
|
|
|
* @package OC\Lock\Persistent |
39
|
|
|
*/ |
40
|
|
|
class Lock extends Entity implements ILock { |
41
|
|
|
|
42
|
|
|
/** @var int BIGINT - foreign key to oc_filecache.fileid */ |
43
|
|
|
protected $fileId; |
44
|
|
|
/** @var string - plain text field as transmitted by clients */ |
45
|
|
|
protected $owner; |
46
|
|
|
/** @var int - seconds of lock life time */ |
47
|
|
|
protected $timeout; |
48
|
|
|
/** @var int - unix timestamp when lock was created */ |
49
|
|
|
protected $createdAt; |
50
|
|
|
/** @var string - uuid in WebDAV */ |
51
|
|
|
protected $token; |
52
|
|
|
/** @var string - md5 of token */ |
53
|
|
|
protected $tokenHash; |
54
|
|
|
/** @var int - LOCK_SCOPE_EXCLUSIVE or LOCK_SCOPE_SHARED */ |
55
|
|
|
protected $scope; |
56
|
|
|
/** @var int: 0, 1 or infinite */ |
57
|
|
|
protected $depth; |
58
|
|
|
/** @var int - foreign key zu oc_account.id */ |
59
|
|
|
protected $ownerAccountId; |
60
|
|
|
|
61
|
|
|
/** @var string - joined with oc_filecache */ |
62
|
|
|
protected $path; |
63
|
|
|
/** @var string - computed value */ |
64
|
|
|
protected $davUserId; |
65
|
|
|
/** @var string - computed value */ |
66
|
|
|
protected $absoluteDavPath; |
67
|
|
|
|
68
|
|
|
public function __construct() { |
69
|
|
|
$this->addType('fileId', 'integer'); |
70
|
|
|
$this->addType('timeout', 'integer'); |
71
|
|
|
$this->addType('createdAt', 'integer'); |
72
|
|
|
$this->addType('scope', 'integer'); |
73
|
|
|
$this->addType('depth', 'integer'); |
74
|
|
|
$this->addType('ownerAccountId', 'integer'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param $token |
79
|
|
|
*/ |
80
|
|
|
public function setToken($token) { |
81
|
|
|
parent::setter('token', [$token]); |
|
|
|
|
82
|
|
|
parent::setter('tokenHash', [\md5($token)]); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Return the owner of the lock - plain text field as transmitted by clients |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
* @since 11.0.0 |
90
|
|
|
*/ |
91
|
|
|
public function getOwner(): ?string { |
92
|
|
|
return parent::getOwner(); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Foreign key to oc_filecache.fileid |
97
|
|
|
* |
98
|
|
|
* @return int |
99
|
|
|
* @since 11.0.0 |
100
|
|
|
*/ |
101
|
|
|
public function getFileId(): int { |
102
|
|
|
return parent::getFileId(); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Seconds of lock life time |
107
|
|
|
* |
108
|
|
|
* @return int |
109
|
|
|
* @since 11.0.0 |
110
|
|
|
*/ |
111
|
|
|
public function getTimeout(): int { |
112
|
|
|
return parent::getTimeout(); |
|
|
|
|
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Unix timestamp when lock was created |
117
|
|
|
* |
118
|
|
|
* @return mixed |
119
|
|
|
* @since 11.0.0 |
120
|
|
|
*/ |
121
|
|
|
public function getCreatedAt(): int { |
122
|
|
|
return parent::getCreatedAt(); |
|
|
|
|
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Token to identify the lock - uuid usually |
127
|
|
|
* |
128
|
|
|
* @return string |
129
|
|
|
* @since 11.0.0 |
130
|
|
|
*/ |
131
|
|
|
public function getToken(): string { |
132
|
|
|
return parent::getToken(); |
|
|
|
|
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Either shared lock or exclusive lock |
137
|
|
|
* |
138
|
|
|
* @return int |
139
|
|
|
* @since 11.0.0 |
140
|
|
|
*/ |
141
|
|
|
public function getScope(): int { |
142
|
|
|
return parent::getScope(); |
|
|
|
|
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Depth as used in WebDAV: 0, 1 or infinite |
147
|
|
|
* |
148
|
|
|
* @return int |
149
|
|
|
* @since 11.0.0 |
150
|
|
|
*/ |
151
|
|
|
public function getDepth(): int { |
152
|
|
|
return parent::getDepth(); |
|
|
|
|
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Absolute path to the file/folder on webdav |
157
|
|
|
* |
158
|
|
|
* @return string |
159
|
|
|
* @since 11.0.0 |
160
|
|
|
*/ |
161
|
|
|
public function getAbsoluteDavPath(): string { |
162
|
|
|
return parent::getAbsoluteDavPath(); |
|
|
|
|
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* User id on webdav URI |
167
|
|
|
* |
168
|
|
|
* @return string |
169
|
|
|
* @since 11.0.0 |
170
|
|
|
*/ |
171
|
|
|
public function getDavUserId(): string { |
172
|
|
|
return parent::getDavUserId(); |
|
|
|
|
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Set the owner |
177
|
|
|
* |
178
|
|
|
* @param string $owner |
179
|
|
|
* @return mixed |
180
|
|
|
* @since 11.0.0 |
181
|
|
|
*/ |
182
|
|
|
public function setOwner(?string $owner) : void { |
183
|
|
|
parent::setOwner($owner); |
|
|
|
|
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.