Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| TaskQueueRestApi | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| get | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getStatus | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getTaskEntity | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 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) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoTaskQueue\controller; |
| 23 | |
| 24 | use oat\tao\model\taskQueue\TaskLog\Entity\EntityInterface; |
| 25 | use oat\tao\model\taskQueue\TaskLogInterface; |
| 26 | |
| 27 | /** |
| 28 | * RestAPI controller to get data from task queue |
| 29 | * |
| 30 | * @deprecated Use \tao_actions_TaskQueue |
| 31 | * |
| 32 | * @author Gyula Szucs <gyula@taotesting.com> |
| 33 | */ |
| 34 | class TaskQueueRestApi extends \tao_actions_RestController |
| 35 | { |
| 36 | public const PARAMETER_TASK_ID = 'id'; |
| 37 | |
| 38 | /** |
| 39 | * Returns the details of a task, independently from the owner. |
| 40 | */ |
| 41 | public function get() |
| 42 | { |
| 43 | try { |
| 44 | $this->returnSuccess($this->getTaskEntity()->toArray()); |
| 45 | } catch (\Exception $e) { |
| 46 | $this->returnFailure($e); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns only the status of a task, independently from the owner. |
| 52 | */ |
| 53 | public function getStatus() |
| 54 | { |
| 55 | try { |
| 56 | $this->returnSuccess((string) $this->getTaskEntity()->getStatus()); |
| 57 | } catch (\Exception $e) { |
| 58 | $this->returnFailure($e); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @return EntityInterface |
| 64 | * @throws \common_exception_MissingParameter |
| 65 | * @throws \common_exception_NotFound |
| 66 | */ |
| 67 | private function getTaskEntity() |
| 68 | { |
| 69 | if (!$this->hasRequestParameter(self::PARAMETER_TASK_ID)) { |
| 70 | throw new \common_exception_MissingParameter(self::PARAMETER_TASK_ID, $this->getRequestURI()); |
| 71 | } |
| 72 | |
| 73 | /** @var TaskLogInterface $taskLogService */ |
| 74 | $taskLogService = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID); |
| 75 | |
| 76 | return $taskLogService->getById((string) $this->getRequestParameter(self::PARAMETER_TASK_ID)); |
| 77 | } |
| 78 | } |