Commit a080ac52 authored by Alexandre Morin's avatar Alexandre Morin

Merge branch 'develop' into 'master'

develop into master

See merge request maarch/archivesPubliques!146
parents 7740f7eb 22c525f5
# CHANGELOG
## Version 2.6
- `Fixed` Gestion du profil vide en SEDA 2.1
- `Fixed` Ajout d'une erreur si aucune règle de conservation est transmise dans le bordereau
- `Fixed` Meilleur gestion des messages d'erreurs au versement d'archives via bordereau
- `Fixed` Récupération du service producteur de l'archive parente afin de l'ajouter sur l'archive enfant
### Thesaurus
- `Added` Possibilité d'ajouter des thesaurus personnalisés
## Version 2.5.1
### Thesaurus
......
Description
===========
Maarch RM - Archives Publiques est une extension de Maarch RM, logiciel d'archivage électronique (SAE) libre et Open Source permettant de stocker, de rechercher et de consulter vos ressources numériques, dans le respect des réglementations internationales ISO concernant la conservation d'archives électroniques et de documents engageants.
Cette extension de Maarch RM vous permet d'intégrer le Standard d'Échanges de Données pour l'Archivage dans ses versions 1.0 et 2.1. Vous y trouverez un moteur de recherche spécifique, une gestion des métadonnées SEDA et des modes de ressorties adaptés.
Pour que cette extension soit fonctionnelle, Maarch RM (socle d'archivage) doit avoir été préalablement installé.
Licence
=======
Maarch RM - Archives Publiques est publié sous la licence GPL v3, consultable ici : [LICENCE.txt](https://labs.maarch.org/maarch/maarchRM/blob/master/LICENCE.txt)
Liens utiles
============
Retrouvez ici l'ensemble des espaces Maarch RM vous permettant de vous familiariser complètement avec nos outils.
* Environnement de démonstration en ligne, accompagnée du guide de visite et du jeu de données associé (**Attention** cette démonstration est remise à 0 toutes les 4 heures) : https://demo-ap.maarchrm.com/
* Téléchargement des images Docker (déploiement d’instances pour les démonstrations) : https://hub.docker.com/u/maarch
* Documentation fonctionnelle et technique : https://docs.maarch.org/maarchRM/
* Forum/espace communautaire de discussion autour du produit : https://community.maarch.org/c/maarch-rm
* Product Backlog (+ versions) : https://forge.maarch.org/projects/maarch-rm/roadmap
Références normatives
=====================
L'extension Maarch RM - Archives Publiques a été conçue sur la base des spécifications définies au sein des normes et référentiels impactants la gestion des archives publiques en France.
En plus du respect des spécifications intégrées à [Maarch RM](https://labs.maarch.org/maarch/maarchRM/blob/master/README.md), cette extension s'appuie sur :
* SEDA Standard d’échange de données pour l'archivage - Version 1.0 (Service interministériel des archives de France, Ministère de la culture et de la communication)
* SEDA Standard d’échange de données pour l'archivage - Version 2.1 (Service interministériel des archives de France, Ministère de la culture et de la communication)
* la grille d'exigences de l'agrément SIAF publiée par le SIAF.
......@@ -50,7 +50,7 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
*/
public function create($archive)
{
$contents = $archive->descriptionObject;
$contents = (array) $archive->descriptionObject;
if (count($contents) < 1) {
return;
......
......@@ -67,13 +67,14 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
$this->receiveAttachments($message);
}
protected function receiveAttachments($message) {
protected function receiveAttachments($message)
{
$messageDir = dirname($message->path);
$receivedFiles = glob($messageDir.DIRECTORY_SEPARATOR."*.*");
foreach ($message->object->archive as $archive) {
$documents = $this->getDocuments($archive);
foreach ($documents as $document) {
if (!isset($document->attachment)) {
continue;
......@@ -84,7 +85,7 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
// Validation de l'empreinte
if (isset($document->integrity)) {
$algorithm = substr($document->integrity->algorithme, strrpos($document->integrity->algorithme, '#') + 1);
}
}
if (isset($attachment->filename)) {
$filename = $attachment->filename;
......@@ -106,11 +107,10 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
}
$message->size += $filesize;
if ($algorithm && $document->integrity->value != hash_file($algorithm, $filepath)) {
$this->sendError("207", "L'empreinte numérique du document '$filename' ne correspond pas à celle transmise.");
}
} else {
if (strlen($attachment->value) == 0) {
$this->sendError("211", "Le contenu du document n'a pas été transmis.");
......@@ -260,6 +260,9 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
$this->sendError("302", "Le producteur de l'archive identifié par '$originatorIdentification' n'est pas indiqué dans l'accord de versement.");
}
if (!$originatorOrg->enabled) {
$this->sendError("302", "Le service producteur '$originatorIdentification' est désactivé : veuillez le réactiver pour pouvoir verser des archives");
}
}
}
} else {
......@@ -363,10 +366,10 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
$serviceLevelReference = $archive->serviceLevel[0]->value;
}
if (!$serviceLevelReference) {
if (!isset($serviceLevelReference) || empty($serviceLevelReference)) {
$serviceLevelByDefault = $this->sdoFactory->find('recordsManagement/serviceLevel', 'default= true');
if (!$serviceLevelByDefault) {
if (!isset($serviceLevelByDefault) || empty($serviceLevelByDefault)) {
$this->sendError("203", "Le niveau de service n'est pas renseigné.");
return;
......@@ -395,7 +398,6 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
$messageFiles[] = $filepath;
$contents = file_get_contents($filepath);
} elseif (isset($attachment->uri)) {
$uri = $attachment->uri;
$contents = file_get_contents($uri);
......@@ -438,7 +440,6 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
}
$this->infos[] = (string)\laabs::newDateTime() . ": Détection du format par Maarch FID";
} else {
if (isset($attachment->format)) {
$puid = $attachment->format;
......@@ -467,17 +468,17 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
}
// Check all files received are part of the message
foreach ($receivedFiles as $receivedFile) {
if (!isset($messageFiles)) {
break;
}
if (!in_array($receivedFile, $messageFiles) && $receivedFile != $message->path && $receivedFile != $message->path . '.old') {
$this->sendError("101", "Le fichier '" . basename($receivedFile) . "' n'est pas référencé dans le bordereau.");
}
foreach ($receivedFiles as $receivedFile) {
if (!isset($messageFiles)) {
break;
}
if (!in_array($receivedFile, $messageFiles) && $receivedFile != $message->path && $receivedFile != $message->path . '.old') {
$this->sendError("101", "Le fichier '" . basename($receivedFile) . "' n'est pas référencé dans le bordereau.");
}
}
}
/**
* Extract description from Xml
......@@ -501,7 +502,7 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
}
/* **********************************************************************************
**
**
** PROCESS XML MESSAGES -> rm objects
**
********************************************************************************** */
......@@ -557,10 +558,10 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
if (isset($archive->descriptionObject)) {
foreach ($archive->descriptionObject as $descriptionObject) {
switch ($descriptionObject->descriptionLevel) {
case 'item' :
case 'item':
$archive->fileplanLevel = 'item';
break;
default :
default:
$archive->fileplanLevel = 'file';
break;
}
......@@ -806,23 +807,6 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
$resource = $this->processBinaryObject($archive, $sedaDocument->attachment);
$content->resId = $resource->resId;
$binary = $resource->getContents();
if (isset($sedaDocument->integrity)) {
$resource->hash = (string) $sedaDocument->integrity->value;
$resource->hashAlgorithm = substr($sedaDocument->integrity->algorithme, strrpos($sedaDocument->integrity->algorithme, "#")+1);
} else {
$resource->hash = hash('SHA256', $binary);
$resource->hashAlgorithm = 'SHA256';
}
if (isset($sedaDocument->size)) {
$resource->size = (string) $sedaDocument->size->value;
} else {
$resource->size = strlen($binary);
}
$archive->digitalResources[] = $resource;
}
......@@ -894,50 +878,37 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
}
}
protected function createPdiDocument($sedaArchive)
{
// Create resource contents
$contents = '<?xml version="1.0" encoding="UTF-8" ?>';
$sedaArchive->setAttribute('xmlns', "fr:gouv:culture:archivesdefrance:seda:v1.0");
$contents .= $sedaArchive->ownerDocument->saveXml($sedaArchive);
$resource = \laabs::newInstance('digitalResource/digitalResource');
$resource->resId = \laabs::newId();
$resource->setContents($contents);
$resource->hash = hash('sha256', $contents);
$resource->hashAlgorithm = 'SHA256';
$resource->puid = 'fmt/101';
$resource->mimetype = 'text/xml';
$resource->size = strlen($contents);
$resource->type = 'PDI';
return $resource;
}
protected function processBinaryObject($archive, $sedaBinaryObject)
{
$resource = \laabs::newInstance('digitalResource/digitalResource');
switch (true) {
case isset($sedaBinaryObject->filename):
$messageDir = dirname($this->message->path);
$filepath = $messageDir.DIRECTORY_SEPARATOR.$sedaBinaryObject->filename;
$stream = fopen($filepath, 'r');
$resource = $this->digitalResourceController->createFromStream($stream);
$resource->fileName = $sedaBinaryObject->filename;
break;
case isset($sedaBinaryObject->uri):
$stream = fopen($sedaBinaryObject->uri, 'r');
$resource = $this->digitalResourceController->createFromStream($stream);
break;
case isset($sedaBinaryObject->value):
$contents = base64_decode($sedaBinaryObject->value);
$resource = $this->digitalResourceController->createFromContents($contents);
break;
default:
return false;
}
$resource->resId = $sedaBinaryObject->id;
$resource->archiveId = $archive->archiveId;
$resource->fileName = $sedaBinaryObject->filename;
$resource->mimetype = $sedaBinaryObject->mimeCode;
$resource->puid = $sedaBinaryObject->format;
// Get contents
if (isset($resource->fileName)) {
$messageDir = dirname($this->message->path);
$filepath = $messageDir.DIRECTORY_SEPARATOR.$resource->fileName;
$resource->fileExtension = pathinfo($resource->fileName, \PATHINFO_EXTENSION);
$contents = file_get_contents($filepath);
} else {
$contents = $sedaBinaryObject->value;
}
$resource->setContents($contents);
if (isset($sedaBinaryObject->relatedData)) {
foreach ($sedaBinaryObject->relatedData as $sedaRelatedData) {
$resource->relatedResource[] = $this->processRelatedData($archive, $resource, $sedaRelatedData);
......
......@@ -69,6 +69,7 @@ abstract class abstractMessage
$this->orgController = \laabs::newController('organization/organization');
$this->archiveController = \laabs::newController('recordsManagement/archive');
$this->digitalResourceController = \laabs::newController('digitalResource/digitalResource');
$this->lifeCycleJournalController = \laabs::newController('lifeCycle/journal');
}
......@@ -107,17 +108,21 @@ abstract class abstractMessage
libxml_use_internal_errors(true);
$valid = $message->xml->schemaValidate($schemaFile);
if ($valid == false) {
$errors = libxml_get_errors();
$libXMLerrors = libxml_get_errors();
$message = "";
foreach ($errors as $error) {
$message = "<br>" . $error->message;
$errors = [];
foreach ($libXMLerrors as $libXMLerror) {
$message = " " . $libXMLerror->message;
$errors[] = new \core\Error($libXMLerror->message, null, $libXMLerror->code, $libXMLerror->file, $libXMLerror->line);
}
if ($message) {
$exception = \laabs::newException('seda/invalidMessageException', 'Le bordereau ne respecte pas le formalisme du SEDA 1.0. <br>' . $message);
$exception = \laabs::newException('seda/invalidMessageException', 'Le bordereau ne respecte pas le formalisme du SEDA 1.0. ' . $message);
} else {
$exception = \laabs::newException('seda/invalidMessageException', 'Le bordereau ne respecte pas le formalisme du SEDA 1.0.');
}
$exception->errors = $errors;
libxml_clear_errors();
......@@ -163,35 +168,29 @@ abstract class abstractMessage
return false;
}
$resource = \laabs::newInstance('digitalResource/digitalResource');
switch (true) {
case isset($attachment->filename):
$messageDir = dirname($message->path);
$filepath = $messageDir.DIRECTORY_SEPARATOR.$attachment->filename;
$contents = file_get_contents($filepath);
$resource->fileExtension = pathinfo($attachment->filename, \PATHINFO_EXTENSION);
$resource->fileName = basename($attachment->filename);
$stream = fopen($filepath, 'r');
$resource = $this->digitalResourceController->createFromStream($stream);
break;
case isset($attachment->uri):
$contents = file_get_contents($attachment->uri);
$stream = fopen($attachment->uri, 'r');
$resource = $this->digitalResourceController->createFromStream($stream);
break;
case isset($attachment->value):
$contents = base64_decode($attachment->value);
$resource = $this->digitalResourceController->createFromContents($contents);
break;
default:
return false;
}
$finfo = new \finfo(\FILEINFO_MIME_TYPE);
$resource->mimetype = $finfo->buffer($contents);
$resource->setContents($contents);
return $resource;
}
......@@ -689,7 +688,7 @@ abstract class abstractMessage
} else {
$contentDescription->language[] = "fra";
}
if (!empty($content->startDate)) {
$contentDescription->oldestDate = $this->sendDate($content->startDate);
}
......@@ -890,7 +889,13 @@ abstract class abstractMessage
$custodialHistory = \laabs::newInstance('seda/CustodialHistory');
$custodialHistory->custodialHistoryItem = array();
foreach ($apCustodialHistory as $apCustodialHistoryItem) {
if (is_object($apCustodialHistory) && isset($apCustodialHistory->custodialHistoryItem) && is_array($apCustodialHistory->custodialHistoryItem)) {
$apCustodialHistoryItems = $apCustodialHistory->custodialHistoryItem;
} elseif (is_array($apCustodialHistory)) {
$apCustodialHistoryItems = $apCustodialHistory;
}
foreach ($apCustodialHistoryItems as $apCustodialHistoryItem) {
$custodialHistoryItem = \laabs::newInstance('seda/CustodialHistoryItem');
if (isset($apCustodialHistoryItem->item)) {
$custodialHistoryItem->value = (string) $apCustodialHistoryItem->item;
......@@ -923,6 +928,12 @@ abstract class abstractMessage
{
$document = \laabs::newInstance('seda/Document');
if (isset($apDocument->contentId)) {
$document->id = $apDocument->contentId;
} else {
$document->id = $rmArchive->archiveId;
}
if (isset($apDocument->archiverDocId)) {
$document->archivalAgencyDocumentIdentifier = \laabs::newInstance('seda/ID', (string) $apDocument->archiverDocId);
}
......@@ -934,10 +945,18 @@ abstract class abstractMessage
}
if (isset($apDocument->description)) {
$document->description = (string) $apDocument->description;
if (is_array($apDocument->description)) {
$document->description = reset($apDocument->description);
} else {
$document->description = $apDocument->description;
}
}
if (!empty($apDocument->language)) {
$document->language = (string) $apDocument->language;
if (is_array($apDocument->language)) {
$document->language = reset($apDocument->language);
} elseif (is_string($apDocument->language)) {
$document->language = $apDocument->language;
}
}
if (isset($apDocument->copy)) {
......@@ -957,19 +976,19 @@ abstract class abstractMessage
}
if (isset($apDocument->transactedDate)) {
if (isset($apDocument->transactedDate)) {
$document->issue = \laabs::cast($apDocument->transactedDate, 'date');
}
if (isset($apDocument->receivedDate)) {
if (isset($apDocument->receivedDate)) {
$document->receipt = \laabs::cast($apDocument->receivedDate, 'date');
}
if (isset($apDocument->sentDate)) {
if (isset($apDocument->sentDate)) {
$document->response = \laabs::cast($apDocument->sentDate, 'date');
}
if (isset($apDocument->registeredDate)) {
if (isset($apDocument->registeredDate)) {
$document->submission = \laabs::cast($apDocument->registeredDate, 'date');
}
if (isset($apDocument->createdDate)) {
if (isset($apDocument->createdDate)) {
$document->creation = \laabs::cast($apDocument->createdDate, 'date');
}
......@@ -1051,18 +1070,11 @@ abstract class abstractMessage
mkdir($messageDir, 0777, true);
}
try {
$this->validateSchema($message);
} catch (\Exception $e) {
$exception = \laabs::newException('seda/invalidMessageException', 'Le bordereau ne respecte pas le formalisme du SEDA 1.0. <br>');
$exception->errors = $e->getMessage();
throw $exception;
}
$message->path = $messageDir.DIRECTORY_SEPARATOR.$message->messageId.'.xml';
file_put_contents($message->path, $message->xml->saveXml());
$this->validateSchema($message);
// Documents
if ($withData && isset($message->archive)) {
foreach ($message->archive as $rmArchive) {
......@@ -1077,17 +1089,18 @@ abstract class abstractMessage
if (isset($rmArchive->digitalResources)) {
foreach ($rmArchive->digitalResources as $digitalResource) {
if ($contents = $digitalResource->getContents()) {
if ($handler = $digitalResource->getHandler()) {
if ($digitalResource->fileName) {
$filename = $digitalResource->fileName;
$filename = $digitalResource->fileName;
} else {
$filename = $digitalResource->resId;
if (isset($digitalResource->fileExtension)) {
$filename .= ".".$digitalResource->fileExtension;
}
}
file_put_contents($outdir.DIRECTORY_SEPARATOR.$filename, $contents);
$fp = fopen($outdir.DIRECTORY_SEPARATOR.$filename, 'w');
stream_copy_to_stream($handler, $fp);
fclose($fp);
$this->sendRelatedResource($digitalResource, $outdir);
}
......@@ -1110,7 +1123,11 @@ abstract class abstractMessage
foreach ($resource->relatedResource as $relatedResource) {
$this->sendRelatedResource($relatedResource, $dir);
file_put_contents($dir.DIRECTORY_SEPARATOR.$relatedResource->fileName, $relatedResource->getContents());
$handler = $relatedResource->getHandler();
$fp = fopen($dir.DIRECTORY_SEPARATOR.$relatedResource->fileName, 'w');
stream_copy_to_stream($handler, $fp);
fclose($fp);
}
}
......
......@@ -78,7 +78,7 @@ trait ArchiveTransferReceptionTrait
$this->receiveAttachments($message);
}
protected function receiveAttachments($message)
protected function receiveAttachments($message)
{
$archives = $message->object->dataObjectPackage->descriptiveMetadata->archiveUnit;
$binaryDataObjects = (array) $message->object->dataObjectPackage->binaryDataObject;
......@@ -88,73 +88,71 @@ trait ArchiveTransferReceptionTrait
foreach ($archives as $archive) {
if ($archive->dataObjectReference) {
$this->validateDocument($archive, $binaryDataObjects);
$this->validateDataObjectReferences($message, $archive);
}
}
$messageDir = dirname($message->path);
// List received files
$receivedFiles = glob($messageDir.DIRECTORY_SEPARATOR."*.*");
$declaredFiles = array($messageDir.DIRECTORY_SEPARATOR.(string) $message->messageId.".xml");
$messageFiles = array($messageDir.DIRECTORY_SEPARATOR.(string) $message->messageId.".xml");
if (count($binaryDataObjects)) {
foreach ($binaryDataObjects as $dataObjectId => $binaryDataObject) {
foreach ($binaryDataObjects as $binaryDataObject) {
$dataObjectId = $binaryDataObject->id;
$message->size += (integer) $binaryDataObject->size;
// Use attachment to create local file with uri access
if (isset($binaryDataObject->attachment)) {
$attachment = $binaryDataObject->attachment;
$filepath = $messageDir.DIRECTORY_SEPARATOR.$attachment->filename;
if (!is_file($filepath)) {
$this->sendError("211", "Le document '$attachment->filename' n'a pas été trouvé.");
continue;
if (!empty($attachment->value)) {
$contents = base64_decode($attachment->value);
file_put_contents($messageDir.DIRECTORY_SEPARATOR.$dataObjectId, $contents);
unset($contents);
unset($attachment->value);
$binaryDataObject->uri = $filename;
} elseif (isset($attachment->filename)) { // Non compliant with SEDA2 but...
$binaryDataObject->uri = $attachment->filename;
} elseif (isset($attachment->uri)) { // Non compliant with SEDA2 but...
$binaryDataObject->uri = $attachment->uri;
}
$filesize = filesize($filepath);
if ($filesize == 0) {
$this->sendError("211", "Le document '$attachment->filename' est vide.");
continue;
}
$message->size += $filesize;
$contents = file_get_contents($filepath);
$messageFiles[] = $attachment->filename;
} elseif ($binaryDataObject->uri) {
$contents = file_get_contents($messageDir.DIRECTORY_SEPARATOR.basename($binaryDataObject->uri));
if (!$contents) {
$this->sendError("211", "Le document à l'adresse '$attachment->uri' est indisponible.");
continue;
}
unset($binaryDataObject->attachment);
}
$message->size += strlen($contents);
if (!isset($binaryDataObject->uri)) {
$this->sendError("211", "Le document '$dataObjectId' n'a pas été trouvé.");
continue;
}
$filepath = $messageDir.DIRECTORY_SEPARATOR.$binaryDataObject->uri;
if (!is_file($filepath)) {
// Non compliant with SEDA2 but...
$filepath = $messageDir.DIRECTORY_SEPARATOR.basename($binaryDataObject->uri);
$messageFiles[] = $filepath;
} else {
if (strlen($attachmentElement->value) == 0) {
$this->sendError("211", "Le contenu du document n'a pas été transmis.");
if (!is_file($filepath)) {
$this->sendError("211", "Le document '$binaryDataObject->uri' n'a pas été trouvé.");
continue;
}
$contents = base64_decode($attachment->value);
$binaryDataObject->uri = basename($binaryDataObject->uri);
}
$declaredFiles[] = $binaryDataObject->uri;
$message->size += strlen($contents);
$binaryDataObject->size = filesize($filepath);
if ($binaryDataObject->size == 0) {
$this->sendError("211", "Le document '$binaryDataObject->uri' est vide.");
$filepath = $messageDir.DIRECTORY_SEPARATOR.$dataObjectId;
continue;
}
$message->size += $binaryDataObject->size;
// Validate hash
$messageDigest = $binaryDataObject->messageDigest;
if (strtolower($messageDigest->value) != strtolower(hash($messageDigest->algorithm, $contents))) {
$this->sendError("207", "L'empreinte numérique du document '".basename($filepath)."' ne correspond pas à celle transmise.");
if (strtolower($messageDigest->value) != strtolower(hash_file($messageDigest->algorithm, $filepath))) {
$this->sendError("207", "L'empreinte numérique du document '".$binaryDataObject->uri."' ne correspond pas à celle transmise.");
continue;
}
}
}
......@@ -164,11 +162,20 @@ trait ArchiveTransferReceptionTrait
if (basename($receivedFile) == basename($message->path)) {
continue;
}
if (!in_array($receivedFile, $messageFiles) && !in_array(basename($receivedFile), $messageFiles) && basename($receivedFile) != "0.info") {
$this->sendError("101", "Le fichier '".basename($receivedFile)."' n'est pas référencé dans le bordereau.");
if (!in_array($receivedFile, $declaredFiles) && !in_array(basename($receivedFile), $declaredFiles) && basename($receivedFile) != "0.info") {
$this->sendError("101", "Le document '".basename($receivedFile)."' n'est pas référencé dans le bordereau.");
}
}
return $this->errors;
}
protected function validateDataObjectReferences($message, $archive)
{
foreach ($archive->dataObjectReference as $dataObjectReference) {
if (!$this->getBinaryDataObjectById($dataObjectReference->dataObjectReferenceId, $message)) {
$this->sendError("213", "Le document référencé par '$dataObjectReference->dataObjectReferenceId' est introuvable.");
}
}
}
}
......@@ -56,10 +56,37 @@ trait ArchiveTransferValidationTrait
// Contrôle des documents attachés
$this->validateAttachments($this->message, $archivalAgreement);
$this->validateRules($this->message, $this->message->object->dataObjectPackage->descriptiveMetadata->archiveUnit);
return true;
}
protected function validateRules($message, $archives)
{
foreach ($archives as $archive) {
if (isset($archive->management->appraisalRule->rule) && !empty($archive->management->appraisalRule->rule)) {
foreach ($archive->management->appraisalRule->rule as $ruleObject) {
$ruleSdo = $this->retentionRuleController->read($ruleObject->value);
if (!isset($ruleSdo) || empty($ruleSdo)) {
$this->sendError("404", "La règle de conservation '$ruleObject->value' n'a pas pu être transmise");
}
}
}
if (isset($archive->management->accessRule->rule) && !empty($archive->management->accessRule->rule)) {
foreach ($archive->management->accessRule->rule as $ruleObject) {
$ruleSdo = $this->accessRuleController->edit($ruleObject->value);
if (!isset($ruleSdo) || empty($ruleSdo)) {
$this->sendError("404", "La règle de communicabilité '$ruleObject->value' n'a pas pu être transmise");
}
}
}
if (isset($archive->archiveUnit)) {
$this->validateRules($message, $archive->archiveUnit);
}
}
}
protected function validateOriginators($message, $archivalAgreement)
{
// Contrôle du producteur
......@@ -94,6 +121,10 @@ trait ArchiveTransferValidationTrait
if (!in_array((string) $originatorOrg->orgId, (array) $archivalAgreement->originatorOrgIds)) {
$this->sendError("302", "Le producteur de l'archive identifié par '$originatorIdentification' n'est pas indiqué dans l'accord de versement.");