From 664fcd07efa08ac0d8ac68a4e02e9836861548af Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 29 Sep 2021 14:52:22 +0200 Subject: [PATCH 1/2] fix: Update `StoredObject` uuid property. --- src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index 7ba21b5da..8d350c2b2 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -9,6 +9,7 @@ use ChampsLibres\AsyncUploaderBundle\Model\AsyncFileInterface; use ChampsLibres\AsyncUploaderBundle\Validator\Constraints\AsyncFileExists; use ChampsLibres\WopiLib\Contract\Entity\Document; use DateTimeInterface; +use Ramsey\Uuid\Rfc4122\UuidInterface; use Ramsey\Uuid\Uuid; use Symfony\Component\Serializer\Annotation as Serializer; @@ -52,7 +53,7 @@ class StoredObject implements AsyncFileInterface, Document /** * @ORM\Column(type="uuid", unique=true) */ - private Uuid $uuid; + private UuidInterface $uuid; /** * @ORM\Column(type="datetime", name="creation_date") @@ -163,7 +164,7 @@ class StoredObject implements AsyncFileInterface, Document return $this; } - public function getUuid(): Uuid + public function getUuid(): UuidInterface { return $this->uuid; } From 86c2a5c3e80ad6070ce868179fdd742ec2649747 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 29 Sep 2021 15:07:27 +0200 Subject: [PATCH 2/2] fix: Update `ChillDocumentManager`. Fix statuscode and return types. --- .../src/Service/Wopi/ChillDocumentManager.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index bfa3ee8b0..1924edd01 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php @@ -21,6 +21,7 @@ use Error; use loophp\psr17\Psr17Interface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; +use Ramsey\Uuid\Uuid; use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Mime\MimeTypes; @@ -103,7 +104,7 @@ final class ChillDocumentManager implements DocumentManagerInterface public function findByDocumentId(string $documentId): ?Document { return $this->storedObjectRepository->findOneBy( [ - 'uuid' => $documentId, + 'uuid' => Uuid::fromString($documentId), ] ); } @@ -198,7 +199,7 @@ final class ChillDocumentManager implements DocumentManagerInterface ->createStream($this->getContent($document)); } - private function deleteContent(StoredObject $storedObject): string + private function deleteContent(StoredObject $storedObject): void { /** @var StdClass $object */ $object = $this->tempUrlGenerator->generate('DELETE', $storedObject->getFilename()); @@ -234,7 +235,7 @@ final class ChillDocumentManager implements DocumentManagerInterface $response = $this->httpClient->request('PUT', $object->url, ['body' => $content]); - if (200 !== $response->getStatusCode()) + if (201 !== $response->getStatusCode()) { throw new Error('Unable to save stored object.'); }