15 namespace Fossology\UI\Api\Controllers;
22 use Psr\Container\ContainerInterface;
23 use Psr\Http\Message\ServerRequestInterface;
56 $this->restHelper = $this->container->get(
'helper.restHelper');
57 $this->dbHelper = $this->restHelper->getDbHelper();
72 $content = $request->getBody()->getContents();
73 return json_decode($content,
true);
76 return $request->getParsedBody();
101 if (! $this->dbHelper->doesIdExist(
"upload",
"upload_pk", $id)) {
104 if (! $this->restHelper->getUploadDao()->isAccessible($id,
105 $this->restHelper->getGroupId())) {
124 if (! $this->restHelper->getUploadDao()->isEditable($id,
125 $this->restHelper->getGroupId())) {
127 "You do not have write permission on this upload.");
141 $uploadDao = $this->restHelper->getUploadDao();
142 $item = $uploadDao->getUploadEntry($itemId,
143 $uploadDao->getUploadtreeTableName($uploadId));
144 if (empty($item) || intval($item[
'upload_fk']) !== $uploadId) {
156 return strcasecmp($request->getHeaderLine(
'Content-Type'),
157 "application/json") === 0;
Contains the constants and helpers for authentication of user.
static isAdmin()
Check if user is admin.
Base controller for REST calls.
isItemExists(int $uploadId, int $itemId)
getParsedBody(ServerRequestInterface $request)
Parse request body as JSON and return associative PHP array.
Provides helper methods to access database for REST api.
Provides various DAO helper functions for REST api.