refs #1693. Convert Image. Webhook updated.
testing/ogcore-api/pipeline/head This commit looks good Details

pull/26/head
Manuel Aranda Rosales 2025-03-12 17:35:24 +01:00
parent 868a015902
commit 4051497761
3 changed files with 15 additions and 3 deletions

View File

@ -32,7 +32,8 @@ class ConvertAction extends AbstractOgRepositoryController
*/
public function __invoke(ConvertImageRepositoryInput $input, ImageRepository $repository): JsonResponse
{
$image = $input->name;
$fileSystem = $input->filesystem;
$image = pathinfo($input->name, PATHINFO_FILENAME);
$imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['name' => $image]);
@ -45,6 +46,12 @@ class ConvertAction extends AbstractOgRepositoryController
$this->entityManager->persist($imageEntity);
}
$imageImageRepositoryEntity = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['image' => $imageEntity, 'repository' => $repository]);
if ($imageImageRepositoryEntity){
throw new ValidatorException('This image already exists in this repository');
}
$imageImageRepositoryEntity = new ImageImageRepository();
$imageImageRepositoryEntity->setStatus(ImageStatus::PENDING);
$imageImageRepositoryEntity->setImage($imageEntity);
@ -57,8 +64,8 @@ class ConvertAction extends AbstractOgRepositoryController
$params = [
'json' => [
'filesystem' => 'ext4',
'virtual_image' => $image
'filesystem' => $fileSystem,
'virtual_image' => $input->name
]
];

View File

@ -37,6 +37,7 @@ class ResponseController extends AbstractOgRepositoryController
str_starts_with($action, "CreateAuxiliarFiles_") => $this->handleImageRepositoryAction($data, true),
str_starts_with($action, "TransferImage_"), str_starts_with($action, "ExportImage_") => $this->processImageAction($data),
str_starts_with($action, "BackupImage_") => $this->handleImageRepositoryAction($data),
str_starts_with($action, "ConvertImage_") => $this->handleImageRepositoryAction($data),
default => $this->jsonResponseError('Invalid action', Response::HTTP_BAD_REQUEST),
};
}

View File

@ -12,4 +12,8 @@ class ConvertImageRepositoryInput
#[Assert\NotNull]
#[Groups(['repository:write'])]
public ?string $name = '';
#[Assert\NotNull]
#[Groups(['repository:write'])]
public ?string $filesystem = '';
}