|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +/** |
| 6 | + * This file is licensed under the Affero General Public License version 3 or |
| 7 | + * later. See the COPYING file. |
| 8 | + * |
| 9 | + * @author Maxence Lange <maxence@artificial-owl.com> |
| 10 | + * @copyright 2019, Maxence Lange <maxence@artificial-owl.com> |
| 11 | + * @license GNU AGPL version 3 or any later version |
| 12 | + * |
| 13 | + * This program is free software: you can redistribute it and/or modify |
| 14 | + * it under the terms of the GNU Affero General Public License as |
| 15 | + * published by the Free Software Foundation, either version 3 of the |
| 16 | + * License, or (at your option) any later version. |
| 17 | + * |
| 18 | + * This program is distributed in the hope that it will be useful, |
| 19 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | + * GNU Affero General Public License for more details. |
| 22 | + * |
| 23 | + * You should have received a copy of the GNU Affero General Public License |
| 24 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 | + * |
| 26 | + */ |
| 27 | + |
| 28 | + |
| 29 | +namespace OCP\Lock; |
| 30 | + |
| 31 | + |
| 32 | +/** |
| 33 | + * Class ManuallyLockedException |
| 34 | + * |
| 35 | + * @package OCP\Lock |
| 36 | + * @since 18.0.0 |
| 37 | + */ |
| 38 | +class ManuallyLockedException extends LockedException { |
| 39 | + |
| 40 | + |
| 41 | + /** |
| 42 | + * owner of the lock |
| 43 | + * |
| 44 | + * @var string|null |
| 45 | + */ |
| 46 | + private $owner = null; |
| 47 | + |
| 48 | + /** |
| 49 | + * estimated timeout for the lock |
| 50 | + * |
| 51 | + * @var int |
| 52 | + * @since 18.0.0 |
| 53 | + */ |
| 54 | + private $timeout = -1; |
| 55 | + |
| 56 | + |
| 57 | + /** |
| 58 | + * ManuallyLockedException constructor. |
| 59 | + * |
| 60 | + * @param string $path locked path |
| 61 | + * @param \Exception|null $previous previous exception for cascading |
| 62 | + * @param string $existingLock |
| 63 | + * @param string|null $owner |
| 64 | + * @param int $timeout |
| 65 | + * |
| 66 | + * @since 18.0.0 |
| 67 | + */ |
| 68 | + public function __construct(string $path, \Exception $previous = null, string $existingLock = null, string $owner = null, int $timeout = -1) { |
| 69 | + parent::__construct($path, $previous, $existingLock); |
| 70 | + $this->owner = $owner; |
| 71 | + $this->timeout = $timeout; |
| 72 | + } |
| 73 | + |
| 74 | + |
| 75 | + /** |
| 76 | + * @return int |
| 77 | + * @since 18.0.0 |
| 78 | + */ |
| 79 | + public function getTimeout(): int { |
| 80 | + return $this->timeout; |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * @return string|null |
| 85 | + * @since 18.0.0 |
| 86 | + */ |
| 87 | + public function getOwner(): ?string { |
| 88 | + return $this->owner; |
| 89 | + } |
| 90 | + |
| 91 | +} |
0 commit comments