Loading bin/validation_cines.sh +28 −10 Original line number Diff line number Diff line #!/bin/bash ########################################################################################## ################################################################################################## # # Script d'appel du web service proposé par le site facile.cines.fr du CINES. ########################################################################################## # ################################################################################################## # # Arguments : # 1/ le chemin vers le fichier à valider, OBLIGATOIRE. # 2/ l'URL du web service, FACULTATIF ("https://facile.cines.fr/xml", par défaut). ########################################################################################## # -f|--file : chemin vers le fichier à valider, OBLIGATOIRE. # -u|--url : URL du web service, FACULTATIF, "https://facile.cines.fr/xml", par défaut. # -m|--maxtime : temps max d'exécution. # -t|--timeout : temps max de connexion. # ################################################################################################## DEFAULT_URL="https://facile.cines.fr/xml" ARGS=`getopt -o "f:u:m:" -l "file:,url:,maxtime:" -n "getopt.sh" -- "$@"` ARGS=`getopt -o "f:u:m:t:" -l "file:,url:,maxtime:,timeout:" -n "getopt.sh" -- "$@"` if [ $? -ne 0 ]; then exit 1 Loading Loading @@ -40,6 +46,13 @@ do fi shift 2;; -t|--timeout) #--------------- if [ -n "$2" ]; then timeout=$2 fi shift 2;; --) shift break;; Loading @@ -54,14 +67,19 @@ fi if [ ! "$url" ]; then url="$DEFAULT_URL" fi maxtime="" if [ -n "$maxtime" ]; then maxtime="--max-time $maxtime" fi if [ -n "$timeout" ]; then timeout="--connect-timeout $timeout" fi # "-k" : désactive la vérification du certificat SSL # "--max-time 600" : spécifie un temps maximum d'exécution de 5 minutes # Options de curl : # --insecure : pas de vérification du certificat SSL, https://curl.se/docs/manpage.html#-k # --max-time 60 : temps max d'exécution d'1 minute, https://curl.se/docs/manpage.html#-m # --connect-timeout 10 : temps max de connexion de 10 secondes, https://curl.se/docs/manpage.html#--connect-timeout # --silent : https://curl.se/docs/manpage.html#-s #curl --silent --connect-timeout 10 --form file="@$file" $host #curl --max-time 360 --form file="@$1" $host curl $maxtime --form file="@$file" $url No newline at end of file curl $maxtime $timeout --form file="@$file" $url config/autoload/global.php +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ return [ 'archivabilite' => [ 'check_ws_script_path' => __DIR__ . '/../../bin/from_cines/check_webservice_response.sh', 'script_path' => __DIR__ . '/../../bin/validation_cines.sh', 'proxy' => [ 'enable' => false, //'proxy_host' => 'http://proxy.unicaen.fr', //'proxy_port' => 3128, ], ], // Options pour le retraitement des fichiers PDF 'retraitement' => [ Loading module/Application/src/Application/Command/ValidationFichierCinesCommand.php +37 −6 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Application\Command\Exception\CommandExecutionException; use Application\Validator\Exception\CinesErrorException; use DOMDocument; use UnicaenApp\Exception\RuntimeException; use Webmozart\Assert\Assert; class ValidationFichierCinesCommand { Loading @@ -26,6 +27,11 @@ class ValidationFichierCinesCommand */ protected $xml; /** * @var array */ protected $options = []; /** * @var bool */ Loading @@ -34,11 +40,13 @@ class ValidationFichierCinesCommand /** * ValidationFichierCinesCommand constructor. * * @param string $scriptPath Chemin absolu du script à exécuter. * @param null $scriptPath Chemin absolu du script à exécuter. * @param array $options */ public function __construct($scriptPath = null) public function __construct($scriptPath = null, array $options = []) { $this->scriptPath = $scriptPath; $this->options = $options; } /** Loading Loading @@ -166,14 +174,15 @@ class ValidationFichierCinesCommand * Utilise le script spécifié pour valider le fichier. * * @param string $filePath Chemin du fichier à tester * @param string $url URL du web service, si différente de celle par défaut * @param int $maxExecutionTime En secondes * @param null $url URL du web service, si différente de celle par défaut * @param null $maxExecutionTime En secondes */ private function execValidationRequest($filePath, $url = null, $maxExecutionTime = null) private function execValidationRequest(string $filePath, $url = null, $maxExecutionTime = null) { $scriptPath = $this->scriptPath; $command = sprintf('%s --file "%s" %s %s', $command = sprintf('%s %s --file "%s" %s %s', $this->generateEnvVarsString(), realpath($scriptPath), $filePath, $url ? sprintf('--url "%s"', $url) : '', Loading Loading @@ -201,6 +210,28 @@ class ValidationFichierCinesCommand } } private function generateEnvVarsString(): string { $envVars = []; if ($proxyParams = $this->options['proxy'] ?? []) { Assert::keyExists($proxyParams, 'enabled'); $proxyEnabled = (bool) $proxyParams['enabled']; if ($proxyEnabled) { Assert::keyExists($proxyParams, 'proxy_host'); Assert::keyExists($proxyParams, 'proxy_port'); $envVars['http_proxy'] = $proxyParams['proxy_host'] . ':' . $proxyParams['proxy_port']; $envVars['https_proxy'] = '$http_proxy'; } } array_walk($envVars, function(&$v, $k) { $v = $k . '=' . $v; }); return implode(' ', $envVars); } /** * @param string $command * @param array $output Loading module/Application/src/Application/Command/ValidationFichierCinesCommandFactory.php +8 −6 Original line number Diff line number Diff line Loading @@ -3,19 +3,21 @@ namespace Application\Command; use Interop\Container\ContainerInterface; use Zend\ServiceManager\Exception\InvalidArgumentException; use Webmozart\Assert\Assert; class ValidationFichierCinesCommandFactory { public function __invoke(ContainerInterface $container) public function __invoke(ContainerInterface $container): ValidationFichierCinesCommand { $config = $container->get('config'); if (!isset($config['sygal']['archivabilite']['script_path'])) { throw new InvalidArgumentException("Option de config sygal.archivabilite.script_path introuvable"); } Assert::keyExists($config, 'sygal', "La clé %s est introuvable dans la config de l'application"); Assert::keyExists($config['sygal'], 'archivabilite', "La clé %s est introuvable dans la config 'sygal'"); $options = $config['sygal']['archivabilite']; Assert::keyExists($options, 'script_path', "La clé %s est introuvable dans la config 'archivabilite'"); $scriptPath = $config['sygal']['archivabilite']['script_path']; return new ValidationFichierCinesCommand($scriptPath); return new ValidationFichierCinesCommand($scriptPath, $options); } } No newline at end of file module/Application/src/Application/Entity/Db/VSitu/DepotVersionCorrigeeValidationPresident.php 0 → 100644 +127 −0 Original line number Diff line number Diff line <?php namespace Application\Entity\Db\VSitu; /** * DepotVersionCorrigeeValidationPresident */ class DepotVersionCorrigeeValidationPresident { /** * @var boolean */ private $valide; /** * @var integer */ private $id; /** * @var \Application\Entity\Db\These */ private $these; /** * @var \Application\Entity\Db\Individu */ private $individu; /** * Set valide * * @param boolean $valide * * @return DepotVersionCorrigeeValidationPresident */ public function setValide($valide) { $this->valide = $valide; return $this; } /** * Get valide * * @return boolean */ public function getValide() { return $this->valide; } /** * Set id * * @param integer $id * * @return DepotVersionCorrigeeValidationPresident */ public function setId($id) { $this->id = $id; return $this; } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set these * * @param \Application\Entity\Db\These $these * * @return DepotVersionCorrigeeValidationPresident */ public function setThese(\Application\Entity\Db\These $these = null) { $this->these = $these; return $this; } /** * Get these * * @return \Application\Entity\Db\These */ public function getThese() { return $this->these; } /** * Set individu * * @param \Application\Entity\Db\Individu $individu * * @return DepotVersionCorrigeeValidationPresident */ public function setIndividu(\Application\Entity\Db\Individu $individu = null) { $this->individu = $individu; return $this; } /** * Get individu * * @return \Application\Entity\Db\Individu */ public function getIndividu() { return $this->individu; } } Loading
bin/validation_cines.sh +28 −10 Original line number Diff line number Diff line #!/bin/bash ########################################################################################## ################################################################################################## # # Script d'appel du web service proposé par le site facile.cines.fr du CINES. ########################################################################################## # ################################################################################################## # # Arguments : # 1/ le chemin vers le fichier à valider, OBLIGATOIRE. # 2/ l'URL du web service, FACULTATIF ("https://facile.cines.fr/xml", par défaut). ########################################################################################## # -f|--file : chemin vers le fichier à valider, OBLIGATOIRE. # -u|--url : URL du web service, FACULTATIF, "https://facile.cines.fr/xml", par défaut. # -m|--maxtime : temps max d'exécution. # -t|--timeout : temps max de connexion. # ################################################################################################## DEFAULT_URL="https://facile.cines.fr/xml" ARGS=`getopt -o "f:u:m:" -l "file:,url:,maxtime:" -n "getopt.sh" -- "$@"` ARGS=`getopt -o "f:u:m:t:" -l "file:,url:,maxtime:,timeout:" -n "getopt.sh" -- "$@"` if [ $? -ne 0 ]; then exit 1 Loading Loading @@ -40,6 +46,13 @@ do fi shift 2;; -t|--timeout) #--------------- if [ -n "$2" ]; then timeout=$2 fi shift 2;; --) shift break;; Loading @@ -54,14 +67,19 @@ fi if [ ! "$url" ]; then url="$DEFAULT_URL" fi maxtime="" if [ -n "$maxtime" ]; then maxtime="--max-time $maxtime" fi if [ -n "$timeout" ]; then timeout="--connect-timeout $timeout" fi # "-k" : désactive la vérification du certificat SSL # "--max-time 600" : spécifie un temps maximum d'exécution de 5 minutes # Options de curl : # --insecure : pas de vérification du certificat SSL, https://curl.se/docs/manpage.html#-k # --max-time 60 : temps max d'exécution d'1 minute, https://curl.se/docs/manpage.html#-m # --connect-timeout 10 : temps max de connexion de 10 secondes, https://curl.se/docs/manpage.html#--connect-timeout # --silent : https://curl.se/docs/manpage.html#-s #curl --silent --connect-timeout 10 --form file="@$file" $host #curl --max-time 360 --form file="@$1" $host curl $maxtime --form file="@$file" $url No newline at end of file curl $maxtime $timeout --form file="@$file" $url
config/autoload/global.php +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ return [ 'archivabilite' => [ 'check_ws_script_path' => __DIR__ . '/../../bin/from_cines/check_webservice_response.sh', 'script_path' => __DIR__ . '/../../bin/validation_cines.sh', 'proxy' => [ 'enable' => false, //'proxy_host' => 'http://proxy.unicaen.fr', //'proxy_port' => 3128, ], ], // Options pour le retraitement des fichiers PDF 'retraitement' => [ Loading
module/Application/src/Application/Command/ValidationFichierCinesCommand.php +37 −6 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Application\Command\Exception\CommandExecutionException; use Application\Validator\Exception\CinesErrorException; use DOMDocument; use UnicaenApp\Exception\RuntimeException; use Webmozart\Assert\Assert; class ValidationFichierCinesCommand { Loading @@ -26,6 +27,11 @@ class ValidationFichierCinesCommand */ protected $xml; /** * @var array */ protected $options = []; /** * @var bool */ Loading @@ -34,11 +40,13 @@ class ValidationFichierCinesCommand /** * ValidationFichierCinesCommand constructor. * * @param string $scriptPath Chemin absolu du script à exécuter. * @param null $scriptPath Chemin absolu du script à exécuter. * @param array $options */ public function __construct($scriptPath = null) public function __construct($scriptPath = null, array $options = []) { $this->scriptPath = $scriptPath; $this->options = $options; } /** Loading Loading @@ -166,14 +174,15 @@ class ValidationFichierCinesCommand * Utilise le script spécifié pour valider le fichier. * * @param string $filePath Chemin du fichier à tester * @param string $url URL du web service, si différente de celle par défaut * @param int $maxExecutionTime En secondes * @param null $url URL du web service, si différente de celle par défaut * @param null $maxExecutionTime En secondes */ private function execValidationRequest($filePath, $url = null, $maxExecutionTime = null) private function execValidationRequest(string $filePath, $url = null, $maxExecutionTime = null) { $scriptPath = $this->scriptPath; $command = sprintf('%s --file "%s" %s %s', $command = sprintf('%s %s --file "%s" %s %s', $this->generateEnvVarsString(), realpath($scriptPath), $filePath, $url ? sprintf('--url "%s"', $url) : '', Loading Loading @@ -201,6 +210,28 @@ class ValidationFichierCinesCommand } } private function generateEnvVarsString(): string { $envVars = []; if ($proxyParams = $this->options['proxy'] ?? []) { Assert::keyExists($proxyParams, 'enabled'); $proxyEnabled = (bool) $proxyParams['enabled']; if ($proxyEnabled) { Assert::keyExists($proxyParams, 'proxy_host'); Assert::keyExists($proxyParams, 'proxy_port'); $envVars['http_proxy'] = $proxyParams['proxy_host'] . ':' . $proxyParams['proxy_port']; $envVars['https_proxy'] = '$http_proxy'; } } array_walk($envVars, function(&$v, $k) { $v = $k . '=' . $v; }); return implode(' ', $envVars); } /** * @param string $command * @param array $output Loading
module/Application/src/Application/Command/ValidationFichierCinesCommandFactory.php +8 −6 Original line number Diff line number Diff line Loading @@ -3,19 +3,21 @@ namespace Application\Command; use Interop\Container\ContainerInterface; use Zend\ServiceManager\Exception\InvalidArgumentException; use Webmozart\Assert\Assert; class ValidationFichierCinesCommandFactory { public function __invoke(ContainerInterface $container) public function __invoke(ContainerInterface $container): ValidationFichierCinesCommand { $config = $container->get('config'); if (!isset($config['sygal']['archivabilite']['script_path'])) { throw new InvalidArgumentException("Option de config sygal.archivabilite.script_path introuvable"); } Assert::keyExists($config, 'sygal', "La clé %s est introuvable dans la config de l'application"); Assert::keyExists($config['sygal'], 'archivabilite', "La clé %s est introuvable dans la config 'sygal'"); $options = $config['sygal']['archivabilite']; Assert::keyExists($options, 'script_path', "La clé %s est introuvable dans la config 'archivabilite'"); $scriptPath = $config['sygal']['archivabilite']['script_path']; return new ValidationFichierCinesCommand($scriptPath); return new ValidationFichierCinesCommand($scriptPath, $options); } } No newline at end of file
module/Application/src/Application/Entity/Db/VSitu/DepotVersionCorrigeeValidationPresident.php 0 → 100644 +127 −0 Original line number Diff line number Diff line <?php namespace Application\Entity\Db\VSitu; /** * DepotVersionCorrigeeValidationPresident */ class DepotVersionCorrigeeValidationPresident { /** * @var boolean */ private $valide; /** * @var integer */ private $id; /** * @var \Application\Entity\Db\These */ private $these; /** * @var \Application\Entity\Db\Individu */ private $individu; /** * Set valide * * @param boolean $valide * * @return DepotVersionCorrigeeValidationPresident */ public function setValide($valide) { $this->valide = $valide; return $this; } /** * Get valide * * @return boolean */ public function getValide() { return $this->valide; } /** * Set id * * @param integer $id * * @return DepotVersionCorrigeeValidationPresident */ public function setId($id) { $this->id = $id; return $this; } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set these * * @param \Application\Entity\Db\These $these * * @return DepotVersionCorrigeeValidationPresident */ public function setThese(\Application\Entity\Db\These $these = null) { $this->these = $these; return $this; } /** * Get these * * @return \Application\Entity\Db\These */ public function getThese() { return $this->these; } /** * Set individu * * @param \Application\Entity\Db\Individu $individu * * @return DepotVersionCorrigeeValidationPresident */ public function setIndividu(\Application\Entity\Db\Individu $individu = null) { $this->individu = $individu; return $this; } /** * Get individu * * @return \Application\Entity\Db\Individu */ public function getIndividu() { return $this->individu; } }