Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/specs/validator-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
contact:
name: IGNF/validator
url: "https://github.com/IGNF/validator/issues"
version: "0.5.3"
version: "0.5.5"
title: "API Validator"
license:
name: "AGPL-3.0-or-later"
Expand Down
13 changes: 13 additions & 0 deletions src/Repository/ValidationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,17 @@ public function findAllToBeArchived(DateTime $expiryDate)
->getResult()
;
}

/**
* Drop schema corresponding to input validation
*
* @param Validation $validation
* @return boolean
*/
public function dropSchema(Validation $validation)
{
$sql = sprintf('DROP SCHEMA IF EXISTS "validation%s" CASCADE', $validation->getUid());
$reponse = $this->getEntityManager()->getConnection()->executeQuery($sql);
return $reponse->rowCount() != 0;
}
}
14 changes: 13 additions & 1 deletion src/Validation/ValidationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Entity\Validation;
use App\Exception\ZipArchiveValidationException;
use App\Repository\ValidationRepository;
use App\Storage\ValidationsStorage;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -40,6 +41,11 @@ class ValidationManager
*/
private $zipArchiveValidator;

/**
* @var ValidationRepository
*/
private $validationRepository;

/**
* Current validation (in order to handle SIGTERM)
* @var Validation
Expand All @@ -51,13 +57,15 @@ public function __construct(
ValidationsStorage $storage,
ValidatorCLI $validatorCli,
ZipArchiveValidator $zipArchiveValidator,
LoggerInterface $logger
LoggerInterface $logger,
ValidationRepository $validationRepository
) {
$this->em = $em;
$this->storage = $storage;
$this->validatorCli = $validatorCli;
$this->zipArchiveValidator = $zipArchiveValidator;
$this->logger = $logger;
$this->validationRepository = $validationRepository;
}

/**
Expand Down Expand Up @@ -96,6 +104,10 @@ public function archive(Validation $validation)
if ($this->storage->getStorage()->directoryExists($outputDirectory)) {
$this->storage->getStorage()->deleteDirectory($outputDirectory);
}
$this->logger->info('Validation[{uid}] : drop validation schema', [
'uid' => $validation->getUid(),
]);
$this->validationRepository->dropSchema($validation);
$this->logger->info('Validation[{uid}] : archive removing all files : completed', [
'uid' => $validation->getUid(),
'status' => Validation::STATUS_ARCHIVED,
Expand Down
Loading