refs #1472. Changes in images and imageRepo
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
a448fb071d
commit
3ed65f0668
|
@ -34,7 +34,7 @@ class DeletePermanentAction extends AbstractOgRepositoryController
|
|||
|
||||
$this->logger->info('Deleting image', ['image' => $image->getName()]);
|
||||
|
||||
$repository = $image->getClient()->getRepository();
|
||||
$repository = $data->getRepository();
|
||||
|
||||
$content = $this->createRequest( 'DELETE', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/'.$data->getImageFullsum().'?method=permanent');
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Controller\OgRepository;
|
||||
|
||||
use App\Entity\Image;
|
||||
use App\Entity\ImageImageRepository;
|
||||
use App\Entity\ImageRepository;
|
||||
use App\Model\ImageStatus;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
@ -22,26 +23,37 @@ class SyncAction extends AbstractOgRepositoryController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(ImageRepository $data): JsonResponse
|
||||
public function __invoke(ImageRepository $input): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest('GET', 'http://'.$data->getIp(). ':8006/ogrepository/v1/images');
|
||||
$content = $this->createRequest('GET', 'http://'.$input->getIp(). ':8006/ogrepository/v1/images');
|
||||
|
||||
if (!isset($content['output']['REPOSITORY']['images'])) {
|
||||
return new JsonResponse(data: 'No images found', status: Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
foreach ($content['output']['REPOSITORY']['images'] as $image) {
|
||||
$imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['imageFullsum' => $image['fullsum']]);
|
||||
$imageImageRepositoryEntity = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['imageFullsum' => $image['fullsum']]);
|
||||
$imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['name' => $image['name']]);
|
||||
|
||||
if (!$imageEntity) {
|
||||
$imageEntity = new Image();
|
||||
$imageEntity->setName($image['name'].$image['type']);
|
||||
$imageEntity->setStatus(ImageStatus::SUCCESS);
|
||||
//$imageEntity->setRepository($data);
|
||||
$imageEntity->setCreated(true );
|
||||
$imageEntity->setImageFullsum($image['fullsum']);
|
||||
$imageEntity->setName($image['name']);
|
||||
$imageEntity->setRemotePc(false);
|
||||
$imageEntity->setIsGlobal(false);
|
||||
|
||||
$this->entityManager->persist($imageEntity);
|
||||
}
|
||||
$this->entityManager->persist($imageEntity);
|
||||
|
||||
if (!$imageImageRepositoryEntity) {
|
||||
$imageImageRepositoryEntity = new ImageImageRepository();
|
||||
$imageImageRepositoryEntity->setImageFullsum($image['fullsum']);
|
||||
$imageImageRepositoryEntity->setStatus(ImageStatus::SUCCESS);
|
||||
$imageImageRepositoryEntity->setImage($imageEntity);
|
||||
$imageImageRepositoryEntity->setRepository($input);
|
||||
|
||||
$this->entityManager->persist($imageImageRepositoryEntity);
|
||||
}
|
||||
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
|
|
@ -93,6 +93,11 @@ class ResponseController extends AbstractOgRepositoryController
|
|||
$repository = $this->entityManager->getRepository(ImageRepository::class)->findOneBy(['uuid' => $repositoryUuid]);
|
||||
$imageImageRepository = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['uuid' => $imageImageRepositoryUuid]);
|
||||
|
||||
if ($data['success'] !== true) {
|
||||
$this->updateTraceStatus($trace, TraceStatus::FAILED, 'Action failed');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($image === null) {
|
||||
$this->updateTraceStatus($trace, TraceStatus::FAILED, 'Image not found');
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue