1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Thomas Müller <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
6
|
|
|
* @license AGPL-3.0 |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
namespace OCA\DAV\JobStatus; |
22
|
|
|
|
23
|
|
|
use OCA\DAV\DAV\LazyOpsPlugin; |
24
|
|
|
use OCA\DAV\JobStatus\Entity\JobStatusMapper; |
25
|
|
|
use OCP\AppFramework\Db\DoesNotExistException; |
26
|
|
|
use Sabre\DAV\Collection; |
27
|
|
|
use Sabre\DAV\Exception\Forbidden; |
28
|
|
|
use Sabre\DAV\Exception\MethodNotAllowed; |
29
|
|
|
use Sabre\DAV\Exception\NotFound; |
30
|
|
|
use Sabre\DAV\SimpleFile; |
31
|
|
|
use Sabre\HTTP\URLUtil; |
32
|
|
|
|
33
|
|
|
class Home extends Collection { |
34
|
|
|
/** @var array */ |
35
|
|
|
private $principalInfo; |
36
|
|
|
/** @var JobStatusMapper */ |
37
|
|
|
private $mapper; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Home constructor. |
41
|
|
|
* |
42
|
|
|
* @param array $principalInfo |
43
|
|
|
* @param JobStatusMapper $mapper |
44
|
|
|
*/ |
45
|
|
|
public function __construct($principalInfo, JobStatusMapper $mapper) { |
46
|
|
|
$this->principalInfo = $principalInfo; |
47
|
|
|
$this->mapper = $mapper; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getChild($name) { |
51
|
|
|
try { |
52
|
|
|
$entity = $this->mapper->findByUserIdAndJobId($this->getName(), $name); |
53
|
|
|
|
54
|
|
|
return new JobStatus($this->getName(), $name, $this->mapper, $entity); |
55
|
|
|
} catch (DoesNotExistException $ex) { |
56
|
|
|
throw new NotFound(); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getChildren() { |
61
|
|
|
throw new MethodNotAllowed('Listing members of this collection is disabled'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getName() { |
65
|
|
|
list(, $name) = URLUtil::splitPath($this->principalInfo['uri']); |
66
|
|
|
return $name; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|