Loading module/Application/config/others/fichier.config.php +16 −0 Changes for module/Application/config/others/fichier.config.php: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -68,6 +68,13 @@ return array( ], 'roles' => [], ], [ 'controller' => 'Application\Controller\FichierThese', 'action' => [ 'recuperer-fusion', ], 'roles' => [], ], ], ], ], Loading Loading @@ -174,6 +181,15 @@ return array( ], ], ], 'recuperer-fusion' => [ 'type' => 'Segment', 'options' => [ 'route' => '/recuperer-fusion/:outputFile', 'defaults' => [ 'action' => 'recuperer-fusion', ], ], ], ], ], // 'these' Loading module/Application/config/others/these.config.php +1 −1 Changes for module/Application/config/others/these.config.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -574,7 +574,7 @@ return [ 'rdv-bu' => [ 'type' => 'Segment', 'options' => [ 'route' => '/rdv-bu/:these', 'route' => '/rdv-bu/:these[/:asynchronous]', 'constraints' => [ 'these' => '\d+', ], Loading module/Application/src/Application/Controller/FichierTheseController.php +34 −6 Changes for module/Application/src/Application/Controller/FichierTheseController.php: 34 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Application\Controller; use Application\Entity\Db\Fichier; use Application\Entity\Db\NatureFichier; use Application\Entity\Db\These; use Application\Entity\Db\TypeValidation; use Application\Entity\Db\VersionFichier; use Application\EventRouterReplacerAwareTrait; use Application\Filter\IdifyFilterAwareTrait; Loading @@ -23,13 +22,12 @@ use Application\View\Helper\Sortable; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\Tools\Pagination\Paginator; use DoctrineORMModule\Paginator\Adapter\DoctrinePaginator; use UnicaenApp\Exception\LogicException; use UnicaenApp\Exception\RuntimeException; use Zend\Console\Request as ConsoleRequest; use Zend\Form\Element\Hidden; use Zend\Http\Response; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; use Zend\Console\Request as ConsoleRequest; class FichierTheseController extends AbstractController { Loading Loading @@ -489,7 +487,8 @@ class FichierTheseController extends AbstractController throw new RuntimeException("Aucune thèse trouvée avec cet id : " . $id); } $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removeFirstPage, 2); $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removeFirstPage); // $outputFilePath = "/tmp/recuperer-fusion/35249-samassa-haoua-merged.pdf"; $this->eventRouterReplacer->replaceEventRouter($this->getEvent()); Loading @@ -498,9 +497,9 @@ class FichierTheseController extends AbstractController if ($notifier) { $destinataires = $notifier; $notif = $this->notifierService->getNotificationFactory()->createNotificationFusionFini($destinataires, $outputFilePath); $notif = $this->notifierService->getNotificationFactory()->createNotificationFusionFini($destinataires, $these, $outputFilePath); $this->notifierService->trigger($notif); echo "Destinataires du courriel envoyé: " . $notif->getTo(); echo "Destinataires du courriel envoyé: " . implode(",",$notif->getTo()); echo PHP_EOL; } Loading @@ -519,4 +518,33 @@ class FichierTheseController extends AbstractController return $routeMatch->getFichier(); } public function recupererFusionAction() { $theseId = $this->params()->fromRoute('these'); $these = $this->getTheseService()->getRepository()->find($theseId); $outputFile = $this->params()->fromRoute('outputFile'); $outputFilePath = sys_get_temp_dir() ."/". $outputFile; if (!is_readable($outputFilePath)) { throw new RuntimeException("Le fichier de votre manuscrit n'est plus disponible."); } /** Retourner un PDF ... */ $contenu = file_get_contents($outputFilePath); $content = is_resource($contenu) ? stream_get_contents($contenu) : $contenu; header('Content-Description: File Transfer'); header('Content-Type: ' . 'application/pdf'); header('Content-Disposition: attachment; filename=' . $outputFile); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen($content)); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); header('Pragma: public'); echo $content; exit; } } module/Application/src/Application/Controller/TheseController.php +15 −8 Changes for module/Application/src/Application/Controller/TheseController.php: 15 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ use Application\Service\These\Filter\TheseSelectFilter; use Application\Service\These\TheseRechercheServiceAwareTrait; use Application\Service\These\TheseServiceAwareTrait; use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait; use Application\Service\UserContextServiceAwareTrait; use Application\Service\Validation\ValidationServiceAwareTrait; use Application\Service\Variable\VariableServiceAwareTrait; use Application\Service\VersionFichier\VersionFichierServiceAwareTrait; Loading @@ -60,22 +61,23 @@ use Zend\View\Model\ViewModel; class TheseController extends AbstractController { use VariableServiceAwareTrait; use TheseServiceAwareTrait; use TheseRechercheServiceAwareTrait; use RoleServiceAwareTrait; use FichierServiceAwareTrait; use ValidationServiceAwareTrait; use MessageCollectorAwareTrait; use NotifierServiceAwareTrait; use RoleServiceAwareTrait; use TheseRechercheServiceAwareTrait; use TheseServiceAwareTrait; use ValidationServiceAwareTrait; use VersionFichierServiceAwareTrait; use WorkflowServiceAwareTrait; use NotifierServiceAwareTrait; use IdifyFilterAwareTrait; use EtablissementServiceAwareTrait; use EntityManagerAwareTrait; use MailConfirmationServiceAwareTrait; use UniteRechercheServiceAwareTrait; use ImportServiceAwareTrait; use UserContextServiceAwareTrait; use VariableServiceAwareTrait; private $timeoutRetraitement; Loading Loading @@ -438,6 +440,7 @@ class TheseController extends AbstractController { $estDoctorant = (bool) $this->userContextService->getSelectedRoleDoctorant(); $these = $this->requestedThese(); $asynchronous = $this->params()->fromRoute('asynchronous'); $versionArchivable = $this->fichierService->getRepository()->getVersionArchivable($these); $hasVA = $this->fichierService->getRepository()->hasVersion($these, VersionFichier::CODE_ARCHI); Loading @@ -462,6 +465,7 @@ class TheseController extends AbstractController 'hasVA' => $hasVA, 'hasVD' => $hasVD, 'pageCouvValidee' => $pageCouvValidee, 'asynchronous' => $asynchronous, ]); Loading Loading @@ -1465,10 +1469,13 @@ class TheseController extends AbstractController // Si ce timout est atteint, l'exécution du script est interrompue // et une exception TimedOutCommandException est levée. $timeout = $this->timeoutRetraitement; $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removal, $timeout=3); $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removal, $timeout); } catch (TimedOutCommandException $toce) { $destinataires = [ $this->userContextService->getIdentityDb()->getEmail() ] ; // relancer le retraitement en tâche de fond $this->fichierService->fusionneFichierTheseAsync($these, $versionFichier, $removal); $this->fichierService->fusionneFichierTheseAsync($these, $versionFichier, $removal, $destinataires); return $this->redirect()->toRoute('these/rdv-bu', ['these' => $these->getId(), 'asynchronous' => 1], [], true); } catch (RuntimeException $re) { // erreur prévue } Loading module/Application/src/Application/Service/Fichier/FichierService.php +7 −1 Changes for module/Application/src/Application/Service/Fichier/FichierService.php: 7 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Application\Service\Fichier; use Application\Command\MergeCommand; use Application\Command\ShellCommandRunner; use Application\Command\ShellScriptRunner; use Application\Command\TruncateAndMergeCommand; use Application\Entity\Db\Acteur; Loading Loading @@ -795,7 +796,8 @@ class FichierService extends BaseService public function fusionneFichierTheseAsync(These $these, $versionFichier, $removeFirstPage, $destinatairesNotification = []) { $scriptPath = sprintf("bash %s/merge.sh", APPLICATION_DIR . '/bin'); // $scriptPath = sprintf("bash %s/merge.sh", APPLICATION_DIR . '/bin'); $scriptPath = sprintf("%s/merge.sh", APPLICATION_DIR . '/bin'); $args = sprintf('--these=%d --versionFichier=%s', $these->getId(), $versionFichier); if ($removeFirstPage) { Loading @@ -809,6 +811,10 @@ class FichierService extends BaseService $runner = new ShellScriptRunner($scriptPath, 'bash'); $runner->setAsync(); $runner->run($args); // $command = $scriptPath. ' '.$args; // $runner = new ShellCommandRunner($command); // $runner->setAsync(); // $runner->run(); } Loading Loading
module/Application/config/others/fichier.config.php +16 −0 Changes for module/Application/config/others/fichier.config.php: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -68,6 +68,13 @@ return array( ], 'roles' => [], ], [ 'controller' => 'Application\Controller\FichierThese', 'action' => [ 'recuperer-fusion', ], 'roles' => [], ], ], ], ], Loading Loading @@ -174,6 +181,15 @@ return array( ], ], ], 'recuperer-fusion' => [ 'type' => 'Segment', 'options' => [ 'route' => '/recuperer-fusion/:outputFile', 'defaults' => [ 'action' => 'recuperer-fusion', ], ], ], ], ], // 'these' Loading
module/Application/config/others/these.config.php +1 −1 Changes for module/Application/config/others/these.config.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -574,7 +574,7 @@ return [ 'rdv-bu' => [ 'type' => 'Segment', 'options' => [ 'route' => '/rdv-bu/:these', 'route' => '/rdv-bu/:these[/:asynchronous]', 'constraints' => [ 'these' => '\d+', ], Loading
module/Application/src/Application/Controller/FichierTheseController.php +34 −6 Changes for module/Application/src/Application/Controller/FichierTheseController.php: 34 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ namespace Application\Controller; use Application\Entity\Db\Fichier; use Application\Entity\Db\NatureFichier; use Application\Entity\Db\These; use Application\Entity\Db\TypeValidation; use Application\Entity\Db\VersionFichier; use Application\EventRouterReplacerAwareTrait; use Application\Filter\IdifyFilterAwareTrait; Loading @@ -23,13 +22,12 @@ use Application\View\Helper\Sortable; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\Tools\Pagination\Paginator; use DoctrineORMModule\Paginator\Adapter\DoctrinePaginator; use UnicaenApp\Exception\LogicException; use UnicaenApp\Exception\RuntimeException; use Zend\Console\Request as ConsoleRequest; use Zend\Form\Element\Hidden; use Zend\Http\Response; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; use Zend\Console\Request as ConsoleRequest; class FichierTheseController extends AbstractController { Loading Loading @@ -489,7 +487,8 @@ class FichierTheseController extends AbstractController throw new RuntimeException("Aucune thèse trouvée avec cet id : " . $id); } $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removeFirstPage, 2); $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removeFirstPage); // $outputFilePath = "/tmp/recuperer-fusion/35249-samassa-haoua-merged.pdf"; $this->eventRouterReplacer->replaceEventRouter($this->getEvent()); Loading @@ -498,9 +497,9 @@ class FichierTheseController extends AbstractController if ($notifier) { $destinataires = $notifier; $notif = $this->notifierService->getNotificationFactory()->createNotificationFusionFini($destinataires, $outputFilePath); $notif = $this->notifierService->getNotificationFactory()->createNotificationFusionFini($destinataires, $these, $outputFilePath); $this->notifierService->trigger($notif); echo "Destinataires du courriel envoyé: " . $notif->getTo(); echo "Destinataires du courriel envoyé: " . implode(",",$notif->getTo()); echo PHP_EOL; } Loading @@ -519,4 +518,33 @@ class FichierTheseController extends AbstractController return $routeMatch->getFichier(); } public function recupererFusionAction() { $theseId = $this->params()->fromRoute('these'); $these = $this->getTheseService()->getRepository()->find($theseId); $outputFile = $this->params()->fromRoute('outputFile'); $outputFilePath = sys_get_temp_dir() ."/". $outputFile; if (!is_readable($outputFilePath)) { throw new RuntimeException("Le fichier de votre manuscrit n'est plus disponible."); } /** Retourner un PDF ... */ $contenu = file_get_contents($outputFilePath); $content = is_resource($contenu) ? stream_get_contents($contenu) : $contenu; header('Content-Description: File Transfer'); header('Content-Type: ' . 'application/pdf'); header('Content-Disposition: attachment; filename=' . $outputFile); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen($content)); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); header('Pragma: public'); echo $content; exit; } }
module/Application/src/Application/Controller/TheseController.php +15 −8 Changes for module/Application/src/Application/Controller/TheseController.php: 15 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ use Application\Service\These\Filter\TheseSelectFilter; use Application\Service\These\TheseRechercheServiceAwareTrait; use Application\Service\These\TheseServiceAwareTrait; use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait; use Application\Service\UserContextServiceAwareTrait; use Application\Service\Validation\ValidationServiceAwareTrait; use Application\Service\Variable\VariableServiceAwareTrait; use Application\Service\VersionFichier\VersionFichierServiceAwareTrait; Loading @@ -60,22 +61,23 @@ use Zend\View\Model\ViewModel; class TheseController extends AbstractController { use VariableServiceAwareTrait; use TheseServiceAwareTrait; use TheseRechercheServiceAwareTrait; use RoleServiceAwareTrait; use FichierServiceAwareTrait; use ValidationServiceAwareTrait; use MessageCollectorAwareTrait; use NotifierServiceAwareTrait; use RoleServiceAwareTrait; use TheseRechercheServiceAwareTrait; use TheseServiceAwareTrait; use ValidationServiceAwareTrait; use VersionFichierServiceAwareTrait; use WorkflowServiceAwareTrait; use NotifierServiceAwareTrait; use IdifyFilterAwareTrait; use EtablissementServiceAwareTrait; use EntityManagerAwareTrait; use MailConfirmationServiceAwareTrait; use UniteRechercheServiceAwareTrait; use ImportServiceAwareTrait; use UserContextServiceAwareTrait; use VariableServiceAwareTrait; private $timeoutRetraitement; Loading Loading @@ -438,6 +440,7 @@ class TheseController extends AbstractController { $estDoctorant = (bool) $this->userContextService->getSelectedRoleDoctorant(); $these = $this->requestedThese(); $asynchronous = $this->params()->fromRoute('asynchronous'); $versionArchivable = $this->fichierService->getRepository()->getVersionArchivable($these); $hasVA = $this->fichierService->getRepository()->hasVersion($these, VersionFichier::CODE_ARCHI); Loading @@ -462,6 +465,7 @@ class TheseController extends AbstractController 'hasVA' => $hasVA, 'hasVD' => $hasVD, 'pageCouvValidee' => $pageCouvValidee, 'asynchronous' => $asynchronous, ]); Loading Loading @@ -1465,10 +1469,13 @@ class TheseController extends AbstractController // Si ce timout est atteint, l'exécution du script est interrompue // et une exception TimedOutCommandException est levée. $timeout = $this->timeoutRetraitement; $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removal, $timeout=3); $outputFilePath = $this->fichierService->fusionneFichierThese($these, $versionFichier, $removal, $timeout); } catch (TimedOutCommandException $toce) { $destinataires = [ $this->userContextService->getIdentityDb()->getEmail() ] ; // relancer le retraitement en tâche de fond $this->fichierService->fusionneFichierTheseAsync($these, $versionFichier, $removal); $this->fichierService->fusionneFichierTheseAsync($these, $versionFichier, $removal, $destinataires); return $this->redirect()->toRoute('these/rdv-bu', ['these' => $these->getId(), 'asynchronous' => 1], [], true); } catch (RuntimeException $re) { // erreur prévue } Loading
module/Application/src/Application/Service/Fichier/FichierService.php +7 −1 Changes for module/Application/src/Application/Service/Fichier/FichierService.php: 7 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Application\Service\Fichier; use Application\Command\MergeCommand; use Application\Command\ShellCommandRunner; use Application\Command\ShellScriptRunner; use Application\Command\TruncateAndMergeCommand; use Application\Entity\Db\Acteur; Loading Loading @@ -795,7 +796,8 @@ class FichierService extends BaseService public function fusionneFichierTheseAsync(These $these, $versionFichier, $removeFirstPage, $destinatairesNotification = []) { $scriptPath = sprintf("bash %s/merge.sh", APPLICATION_DIR . '/bin'); // $scriptPath = sprintf("bash %s/merge.sh", APPLICATION_DIR . '/bin'); $scriptPath = sprintf("%s/merge.sh", APPLICATION_DIR . '/bin'); $args = sprintf('--these=%d --versionFichier=%s', $these->getId(), $versionFichier); if ($removeFirstPage) { Loading @@ -809,6 +811,10 @@ class FichierService extends BaseService $runner = new ShellScriptRunner($scriptPath, 'bash'); $runner->setAsync(); $runner->run($args); // $command = $scriptPath. ' '.$args; // $runner = new ShellCommandRunner($command); // $runner->setAsync(); // $runner->run(); } Loading