Loading module/Application/src/Application/Command/ValidationFichierCinesCommand.php +3 −20 Changes for module/Application/src/Application/Command/ValidationFichierCinesCommand.php: 3 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -3,16 +3,12 @@ namespace Application\Command; use Application\Command\Exception\CommandExecutionException; use Application\Entity\Db\Fichier; use Application\Service\Fichier\FichierServiceAwareTrait; use Application\Validator\Exception\CinesErrorException; use DOMDocument; use UnicaenApp\Exception\RuntimeException; class ValidationFichierCinesCommand { use FichierServiceAwareTrait; const XML_TAG_VALIDATOR = 'validator'; const XML_TAG_VALID = 'valid'; Loading Loading @@ -62,26 +58,13 @@ class ValidationFichierCinesCommand } /** * @param Fichier|string $fichier * @param string $filepath Chemin vers le fichier sur le disque * @param string $url URL du web service, si différente de celle par défaut * @param int $maxExecutionTime */ public function execute($fichier, $url = null, $maxExecutionTime = null) public function execute($filepath, $url = null, $maxExecutionTime = null) { if ($fichier instanceof Fichier) { // création du fichier temporaire sur le disque à partir de la bdd $filePath = $this->fichierService->writeFichierToDisk($fichier); } else { $filePath = $fichier; } $this->execValidationRequest($filePath, $url, $maxExecutionTime); if ($fichier instanceof Fichier) { // suppression du fichier temporaire sur le disque unlink($filePath); } $this->execValidationRequest($filepath, $url, $maxExecutionTime); } /** Loading module/Application/src/Application/Command/ValidationFichierCinesCommandFactory.php +1 −8 Changes for module/Application/src/Application/Command/ValidationFichierCinesCommandFactory.php: 1 added line, 8 removed lines. Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Application\Command; use Application\Service\Fichier\FichierService; use Zend\ServiceManager\Exception\InvalidArgumentException; use Zend\ServiceManager\ServiceLocatorInterface; Loading @@ -17,12 +16,6 @@ class ValidationFichierCinesCommandFactory $scriptPath = $config['sodoct']['archivabilite']['script_path']; /** @var FichierService $fichierService */ $fichierService = $serviceLocator->get(FichierService::class); $command = new ValidationFichierCinesCommand($scriptPath); $command->setFichierService($fichierService); return $command; return new ValidationFichierCinesCommand($scriptPath); } } No newline at end of file module/Application/src/Application/Service/Fichier/FichierService.php +11 −2 Changes for module/Application/src/Application/Service/Fichier/FichierService.php: 11 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -196,8 +196,11 @@ class FichierService extends BaseService { $exceptionThrown = null; // création du fichier temporaire sur le disque $filePath = $this->writeFichierToDisk($fichier); try { $estArchivable = $this->fichierCinesValidator->isValid($fichier); $estArchivable = $this->fichierCinesValidator->isValid($filePath); $message = $estArchivable ? "Le fichier est archivable" : current($this->fichierCinesValidator->getMessages()); } catch (CinesErrorException $cee) { // erreur possible à identifier Loading @@ -211,6 +214,9 @@ class FichierService extends BaseService $exceptionThrown = $re; } // suppression du fichier temporaire sur le disque unlink($filePath); $resultat = [ 'estArchivable' => $estArchivable, 'resultat' => $this->fichierCinesValidator->getResult(), Loading Loading @@ -277,9 +283,12 @@ class FichierService extends BaseService */ public function creerFichierRetraite(Fichier $fichier, $timeout = null) { $outputFilePath = $this->retraitementService->retraiterFichier($fichier, $timeout); $inputFilePath = $this->writeFichierToDisk($fichier); $outputFilePath = $this->retraitementService->retraiterFichier($inputFilePath, $timeout); // Si le timout éventuel est atteint, une exception TimedOutCommandException est levée. unlink($inputFilePath); $outputFileContent = file_get_contents($outputFilePath); unlink($outputFilePath); Loading module/Application/src/Application/Validator/FichierCinesValidator.php +3 −3 Changes for module/Application/src/Application/Validator/FichierCinesValidator.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -35,13 +35,13 @@ class FichierCinesValidator extends AbstractValidator } /** * @param Fichier|string $fichier * @param string $filepath Chemin vers le fichier sur le disque * @return bool * @throws CinesErrorException */ public function isValid($fichier) public function isValid($filepath) { $this->command->execute($fichier); $this->command->execute($filepath); $result = $this->command->getArrayResult(); Loading module/Retraitement/src/Retraitement/Service/RetraitementService.php +3 −9 Changes for module/Retraitement/src/Retraitement/Service/RetraitementService.php: 3 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -2,16 +2,12 @@ namespace Retraitement\Service; use Application\Entity\Db\Fichier; use Application\Service\Fichier\FichierServiceAwareTrait; use Retraitement\Exception\TimedOutCommandException; use Retraitement\Filter\Command\CommandInterface; use RuntimeException; class RetraitementService { use FichierServiceAwareTrait; /** * FichierStarCorrector constructor. * Loading Loading @@ -46,7 +42,7 @@ class RetraitementService * @return string Chemin du fichier retraité généré * @throws TimedOutCommandException Le timout a été atteint */ public function retraiterFichierByPath($inputFilePath, $timeout = null) private function retraiterFichierByPath($inputFilePath, $timeout = null) { $outputFilePath = $this->generateOutputFilePath($inputFilePath); $this->command->generate($outputFilePath, $inputFilePath, $errorFilePath); Loading Loading @@ -86,16 +82,14 @@ class RetraitementService /** * Crée un fichier retraité à partir du Fichier spécifié. * * @param Fichier $fichier Fichier à retraiter * @param string $inputFilePath Chemin sur le disque vers le fichier à retraiter * @param string $timeout Timeout à appliquer au lancement du script de retraitement. * @return string Chemin du fichier retraité généré * @throws TimedOutCommandException Le timout a été atteint */ public function retraiterFichier(Fichier $fichier, $timeout = null) public function retraiterFichier($inputFilePath, $timeout = null) { $inputFilePath = $this->fichierService->writeFichierToDisk($fichier); $outputFilePath = $this->retraiterFichierByPath($inputFilePath, $timeout); unlink($inputFilePath); return $outputFilePath; } Loading Loading
module/Application/src/Application/Command/ValidationFichierCinesCommand.php +3 −20 Changes for module/Application/src/Application/Command/ValidationFichierCinesCommand.php: 3 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -3,16 +3,12 @@ namespace Application\Command; use Application\Command\Exception\CommandExecutionException; use Application\Entity\Db\Fichier; use Application\Service\Fichier\FichierServiceAwareTrait; use Application\Validator\Exception\CinesErrorException; use DOMDocument; use UnicaenApp\Exception\RuntimeException; class ValidationFichierCinesCommand { use FichierServiceAwareTrait; const XML_TAG_VALIDATOR = 'validator'; const XML_TAG_VALID = 'valid'; Loading Loading @@ -62,26 +58,13 @@ class ValidationFichierCinesCommand } /** * @param Fichier|string $fichier * @param string $filepath Chemin vers le fichier sur le disque * @param string $url URL du web service, si différente de celle par défaut * @param int $maxExecutionTime */ public function execute($fichier, $url = null, $maxExecutionTime = null) public function execute($filepath, $url = null, $maxExecutionTime = null) { if ($fichier instanceof Fichier) { // création du fichier temporaire sur le disque à partir de la bdd $filePath = $this->fichierService->writeFichierToDisk($fichier); } else { $filePath = $fichier; } $this->execValidationRequest($filePath, $url, $maxExecutionTime); if ($fichier instanceof Fichier) { // suppression du fichier temporaire sur le disque unlink($filePath); } $this->execValidationRequest($filepath, $url, $maxExecutionTime); } /** Loading
module/Application/src/Application/Command/ValidationFichierCinesCommandFactory.php +1 −8 Changes for module/Application/src/Application/Command/ValidationFichierCinesCommandFactory.php: 1 added line, 8 removed lines. Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Application\Command; use Application\Service\Fichier\FichierService; use Zend\ServiceManager\Exception\InvalidArgumentException; use Zend\ServiceManager\ServiceLocatorInterface; Loading @@ -17,12 +16,6 @@ class ValidationFichierCinesCommandFactory $scriptPath = $config['sodoct']['archivabilite']['script_path']; /** @var FichierService $fichierService */ $fichierService = $serviceLocator->get(FichierService::class); $command = new ValidationFichierCinesCommand($scriptPath); $command->setFichierService($fichierService); return $command; return new ValidationFichierCinesCommand($scriptPath); } } No newline at end of file
module/Application/src/Application/Service/Fichier/FichierService.php +11 −2 Changes for module/Application/src/Application/Service/Fichier/FichierService.php: 11 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -196,8 +196,11 @@ class FichierService extends BaseService { $exceptionThrown = null; // création du fichier temporaire sur le disque $filePath = $this->writeFichierToDisk($fichier); try { $estArchivable = $this->fichierCinesValidator->isValid($fichier); $estArchivable = $this->fichierCinesValidator->isValid($filePath); $message = $estArchivable ? "Le fichier est archivable" : current($this->fichierCinesValidator->getMessages()); } catch (CinesErrorException $cee) { // erreur possible à identifier Loading @@ -211,6 +214,9 @@ class FichierService extends BaseService $exceptionThrown = $re; } // suppression du fichier temporaire sur le disque unlink($filePath); $resultat = [ 'estArchivable' => $estArchivable, 'resultat' => $this->fichierCinesValidator->getResult(), Loading Loading @@ -277,9 +283,12 @@ class FichierService extends BaseService */ public function creerFichierRetraite(Fichier $fichier, $timeout = null) { $outputFilePath = $this->retraitementService->retraiterFichier($fichier, $timeout); $inputFilePath = $this->writeFichierToDisk($fichier); $outputFilePath = $this->retraitementService->retraiterFichier($inputFilePath, $timeout); // Si le timout éventuel est atteint, une exception TimedOutCommandException est levée. unlink($inputFilePath); $outputFileContent = file_get_contents($outputFilePath); unlink($outputFilePath); Loading
module/Application/src/Application/Validator/FichierCinesValidator.php +3 −3 Changes for module/Application/src/Application/Validator/FichierCinesValidator.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -35,13 +35,13 @@ class FichierCinesValidator extends AbstractValidator } /** * @param Fichier|string $fichier * @param string $filepath Chemin vers le fichier sur le disque * @return bool * @throws CinesErrorException */ public function isValid($fichier) public function isValid($filepath) { $this->command->execute($fichier); $this->command->execute($filepath); $result = $this->command->getArrayResult(); Loading
module/Retraitement/src/Retraitement/Service/RetraitementService.php +3 −9 Changes for module/Retraitement/src/Retraitement/Service/RetraitementService.php: 3 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -2,16 +2,12 @@ namespace Retraitement\Service; use Application\Entity\Db\Fichier; use Application\Service\Fichier\FichierServiceAwareTrait; use Retraitement\Exception\TimedOutCommandException; use Retraitement\Filter\Command\CommandInterface; use RuntimeException; class RetraitementService { use FichierServiceAwareTrait; /** * FichierStarCorrector constructor. * Loading Loading @@ -46,7 +42,7 @@ class RetraitementService * @return string Chemin du fichier retraité généré * @throws TimedOutCommandException Le timout a été atteint */ public function retraiterFichierByPath($inputFilePath, $timeout = null) private function retraiterFichierByPath($inputFilePath, $timeout = null) { $outputFilePath = $this->generateOutputFilePath($inputFilePath); $this->command->generate($outputFilePath, $inputFilePath, $errorFilePath); Loading Loading @@ -86,16 +82,14 @@ class RetraitementService /** * Crée un fichier retraité à partir du Fichier spécifié. * * @param Fichier $fichier Fichier à retraiter * @param string $inputFilePath Chemin sur le disque vers le fichier à retraiter * @param string $timeout Timeout à appliquer au lancement du script de retraitement. * @return string Chemin du fichier retraité généré * @throws TimedOutCommandException Le timout a été atteint */ public function retraiterFichier(Fichier $fichier, $timeout = null) public function retraiterFichier($inputFilePath, $timeout = null) { $inputFilePath = $this->fichierService->writeFichierToDisk($fichier); $outputFilePath = $this->retraiterFichierByPath($inputFilePath, $timeout); unlink($inputFilePath); return $outputFilePath; } Loading