diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index f8fd69431..93068de3f 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -138,7 +138,7 @@ class DocGeneratorTemplateController extends AbstractController $em->flush(); return $this->redirectToRoute('chill_wopi_file_edit', [ - 'fileId' => $genDocName, + 'fileId' => $storedObject->getUuid(), 'returnPath' => $request->query->get('returnPath', "/") ]); } diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index 7ba21b5da..a0e614025 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -10,6 +10,7 @@ use ChampsLibres\AsyncUploaderBundle\Validator\Constraints\AsyncFileExists; use ChampsLibres\WopiLib\Contract\Entity\Document; use DateTimeInterface; use Ramsey\Uuid\Uuid; +use Ramsey\Uuid\UuidInterface; use Symfony\Component\Serializer\Annotation as Serializer; /** @@ -51,8 +52,9 @@ class StoredObject implements AsyncFileInterface, Document /** * @ORM\Column(type="uuid", unique=true) + * @Serializer\Groups({"read"}) */ - private Uuid $uuid; + private UuidInterface $uuid; /** * @ORM\Column(type="datetime", name="creation_date") @@ -163,7 +165,7 @@ class StoredObject implements AsyncFileInterface, Document return $this; } - public function getUuid(): Uuid + public function getUuid(): UuidInterface { return $this->uuid; } diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210928182542.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210928182542.php index 756faf654..20d45ca37 100644 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20210928182542.php +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210928182542.php @@ -16,15 +16,15 @@ final class Version20210928182542 extends AbstractMigration public function up(Schema $schema): void { - // this up() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE chill_doc.stored_object ADD uuid UUID NOT NULL'); + $this->addSql('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"'); + $this->addSql('ALTER TABLE chill_doc.stored_object ADD uuid UUID DEFAULT NULL'); + $this->addSql('UPDATE chill_doc.stored_object SET uuid=uuid_generate_v4()'); + $this->addSql('ALTER TABLE chill_doc.stored_object ALTER uuid SET NOT NULL'); $this->addSql('CREATE UNIQUE INDEX UNIQ_49604E36D17F50A6 ON chill_doc.stored_object (uuid)'); } public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP INDEX UNIQ_49604E36D17F50A6'); $this->addSql('ALTER TABLE chill_doc.stored_object DROP uuid'); } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue index 3321a8005..f05f9fca3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue @@ -109,7 +109,7 @@ export default { this.toggleEditEvaluation(); }, buildEditLink(storedObject) { - return `/fr/chill_wopi/edit/${storedObject.filename}?returnPath=` + encodeURIComponent( + return `/fr/chill_wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent( window.location.pathname + window.location.search + window.location.hash); }, } diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index bfa3ee8b0..a6cf08063 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), ] ); }