diff --git a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php index b67298f4c..6718d2fd8 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Controller; use Chill\DocStoreBundle\Entity\StoredObject; +use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\MainBundle\CRUD\Controller\ApiController; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\JsonResponse; @@ -53,4 +54,17 @@ class StoredObjectApiController extends ApiController json: true ); } + + #[Route('/api/1.0/doc-store/stored-object/{uuid}', methods: ['GET'])] + public function getStoredObject(StoredObject $storedObject): JsonResponse + { + if (!$this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)) { + throw new AccessDeniedHttpException(); + } + + return new JsonResponse( + $this->serializer->serialize($storedObject, 'json', [AbstractNormalizer::GROUPS => ['read']]), + json: true + ); + } } diff --git a/src/Bundle/ChillDocStoreBundle/chill.api.specs.yaml b/src/Bundle/ChillDocStoreBundle/chill.api.specs.yaml index cdca3cf93..d0e4c35e3 100644 --- a/src/Bundle/ChillDocStoreBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillDocStoreBundle/chill.api.specs.yaml @@ -54,6 +54,30 @@ paths: 422: description: "Invalid data" + /1.0/doc-store/stored-object/{uuid}: + get: + tags: + - storedobject + summary: Get the content of a stored object + parameters: + - in: path + name: uuid + required: true + allowEmptyValue: false + description: The UUID of the storedObject + schema: + type: string + format: uuid + responses: + 200: + description: "OK" + content: + application/json: + schema: + $ref: "#/components/schemas/StoredObject" + 403: + description: "Unauthorized" + /1.0/doc-store/stored-object/{uuid}/is-ready: get: tags: