|
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\JobStatus\Entity\JobStatus as JobStatusEntity; |
|
24
|
|
|
use OCA\DAV\JobStatus\Entity\JobStatusMapper; |
|
25
|
|
|
use Sabre\DAV\File; |
|
26
|
|
|
|
|
27
|
|
|
class JobStatus extends File { |
|
28
|
|
|
|
|
29
|
|
|
/** @var string */ |
|
30
|
|
|
private $jobId; |
|
31
|
|
|
/** @var string */ |
|
32
|
|
|
private $userId; |
|
33
|
|
|
/** @var string */ |
|
34
|
|
|
private $data; |
|
35
|
|
|
/** @var JobStatusMapper */ |
|
36
|
|
|
private $mapper; |
|
37
|
|
|
/** @var JobStatusEntity */ |
|
38
|
|
|
private $entity; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct($userId, $jobId, |
|
41
|
|
|
JobStatusMapper $mapper, |
|
42
|
|
|
JobStatusEntity $entity) { |
|
43
|
|
|
$this->userId = $userId; |
|
44
|
|
|
$this->jobId = $jobId; |
|
45
|
|
|
$this->mapper = $mapper; |
|
46
|
|
|
$this->entity = $entity; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Returns the name of the node. |
|
51
|
|
|
* |
|
52
|
|
|
* This is used to generate the url. |
|
53
|
|
|
* |
|
54
|
|
|
* @return string |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getName() { |
|
57
|
|
|
return $this->jobId; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function get() { |
|
61
|
|
|
if ($this->entity === null) { |
|
62
|
|
|
$this->entity = $this->mapper |
|
63
|
|
|
->findByUserIdAndJobId($this->userId, $this->jobId); |
|
64
|
|
|
} |
|
65
|
|
|
return $this->entity->getStatusInfo(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getETag() { |
|
69
|
|
|
return '"' . \sha1($this->get()) . '"'; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getSize() { |
|
73
|
|
|
return \strlen($this->get()); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function refreshStatus() { |
|
77
|
|
|
$this->entity = null; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|