Commit c217b594 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Merge branch 'revert-b3bc9f71' into 'Support/2.4.X'

Revert "Merge branch 'develop' into 'Support/2.4.X'"

See merge request maarch/archivesPubliques!100
parents b3bc9f71 10675080
# CHANGELOG
## Version 2.5
### IHM
- `Fixed` Affichage des objets-données associés à un objet principal
(conversions, signatures) présents dans le sas d'échange à partir
de l'écran de détail des bordereaux SEDA 1
## Version 2.4.1
- `Fixed` Les ressources dont l'archive est en statut "éliminée", "restituée" ou "transférée", ne sont plus visible dans l'application avant même que le batch de suppression soit passé.
......
......@@ -566,7 +566,7 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$term,
$keyword
);
$jsonContentDescriptions = $this->sdoFactory->find("recordsManagement/archive", $jsonQueryString, $jsonQueryParams, '>depositDate', 0, 100);
return array_merge($tableContentDescriptions, $jsonContentDescriptions);
......@@ -650,7 +650,7 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$term = null,
$keyword = array())
{
$queryParts['json'] = "(descriptionClass = 'seda2' || descriptionClass = 'seda2/Content')";
$queryParts['json'] = "descriptionClass = 'archivesPubliques/seda2Content'";
if (count($keyword)) {
foreach ($keyword as $keywordObj) {
......
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle recordsManagement.
*
* Bundle recordsManagement is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle recordsManagement is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle recordsManagement. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\archivesPubliques\bundle\medona\Controller;
/**
* Archives modification
*/
class ArchiveModification extends \ext\thirdPartyArchiving\bundle\medona\Controller\ArchiveModification
{
protected $sdoFactory;
protected $archiveController;
/**
* Constructor
* @param \dependency\sdo\Factory $sdoFactory The sdo factory
*/
public function __construct(\dependency\sdo\Factory $sdoFactory)
{
$this->sdoFactory = $sdoFactory;
$this->archiveController = \laabs::newController("recordsManagement/archive");
}
/**
* Modify the archive access
* @param recordsManagement/archiveAccessCode $accessRule The access rule object
* @param array $archiveIds The archives ids
* @param string $comment The comment of modification
* @param string $identifier Message identifier
*
* @return bool The result of the operation
*/
public function modifyAccessRule($accessRule, $archiveIds, $comment = null, $identifier = null)
{
$res = $this->archiveController->modifyAccessRule($accessRule, $archiveIds);
for($i = 0, $length = count($res['success']); $i < $length; $i++) {
$queryString = [];
$queryString[] = "archiveId=:archiveId";
$queryString[] = "resId=NULL";
$queryParam = [];
$queryParam["archiveId"] = (string) $res['success'][$i];
$contents = $this->sdoFactory->find("archivesPubliques/content", \laabs\implode(" AND ", $queryString), $queryParam);
$rule = $this->archiveController->editArchiveAccessRule($res['success'][$i]);
for($j = 0, $lengthContents = count($contents); $j < $lengthContents; $j++) {
$rule->contentId = $contents[$j]->contentId;
}
$this->sdoFactory->update($rule, "archivesPubliques/content", array("contentId" => (string) $rule->contentId));
}
$this->sendModificationNotification($archiveIds, $comment, $identifier);
return $res;
}
}
......@@ -22,7 +22,7 @@ namespace ext\archivesPubliques\bundle\seda\Controller;
/**
* Class for Acknowledgement message handling
*/
class Acknowledgement extends abstractMessage implements \bundle\medona\Controller\AcknowledgementInterface
class Acknowledgement extends abstractMessage implements \ext\thirdPartyArchiving\bundle\medona\Controller\AcknowledgementInterface
{
/**
......
......@@ -26,7 +26,7 @@ use core\Encoding\json;
*
* @package Seda
*/
class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controller\ArchiveTransferInterface
class ArchiveTransfer extends abstractMessage implements \ext\thirdPartyArchiving\bundle\medona\Controller\ArchiveTransferInterface
{
use ArchiveTransferSendingTrait;
......@@ -360,24 +360,18 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
$serviceLevelReference = '';
if ($archivalAgreement) {
$serviceLevelReference = $archivalAgreement->serviceLevelReference;
} elseif ($archive->serviceLevel[0]->value) {
} else {
$serviceLevelReference = $archive->serviceLevel[0]->value;
}
if (!$serviceLevelReference) {
$serviceLevelByDefault = $this->sdoFactory->find('recordsManagement/serviceLevel', 'default= true');
if (!$serviceLevelByDefault) {
$this->sendError("203", "Le niveau de service n'est pas renseigné.");
$this->sendError("203", "Le niveau de service n'est pas renseigné.");
return;
}
$serviceLevel = $serviceLevelByDefault[0];
} else {
$serviceLevel = $serviceLevelController->getByReference($serviceLevelReference);
return;
}
$serviceLevel = $serviceLevelController->getByReference($serviceLevelReference);
$attachmentId = 1;
//$attachmentElements = $message->xPath->query(".//seda:Attachment");
$documents = $this->getDocuments($archive);
......@@ -419,6 +413,8 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
if (strpos($serviceLevel->control, 'formatDetection') !== false) {
if (isset($attachment->format)) {
$sentPuid = $attachment->format;
} else {
$sentPuid = null;
}
try {
......@@ -430,7 +426,7 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
$puid = $format->puid;
$fileInfo->format = $format;
if (isset($sentPuid) && $format->puid != $sentPuid) {
if ($format->puid != $sentPuid) {
$this->sendError("205", "Format de document '$filename' non conforme au format déclaré.");
}
}
......@@ -542,12 +538,10 @@ class ArchiveTransfer extends abstractMessage implements \bundle\medona\Controll
if ($sedaArchive->serviceLevel) {
$archive->serviceLevelReference = $sedaArchive->serviceLevel[0]->value;
} elseif ($message->archivalAgreementReference) {
} else {
$archivalAgreementController = \laabs::newController("medona/archivalAgreement");
$archivalAgreement = $archivalAgreementController->getByReference($message->archivalAgreementReference);
$archive->serviceLevelReference = $archivalAgreement->serviceLevelReference;
} else {
$archive->serviceLevelReference = $this->sdoFactory->find('recordsManagement/serviceLevel', 'default= true')[0]->reference;
}
$this->processManagementRules($archive, $sedaArchive);
......
......@@ -22,7 +22,7 @@ namespace ext\archivesPubliques\bundle\seda\Controller;
/**
* Class for ArchiveTransferReply message handling
*/
class ArchiveTransferReply extends abstractMessage implements \bundle\medona\Controller\ArchiveTransferReplyInterface
class ArchiveTransferReply extends abstractMessage implements \ext\thirdPartyArchiving\bundle\medona\Controller\ArchiveTransferReplyInterface
{
/**
......
This diff is collapsed.
......@@ -23,6 +23,17 @@ class CustodialHistoryItem
*/
public $when;
/**
* Constructor
* @param string $value
* @param string $when
*/
public function __construct($value, $when=null)
{
$this->value = $value;
$this->when = $when;
}
/**
* String value
* @return string
......
......@@ -132,8 +132,8 @@ class Document
public $otherMetadata;
/**
* @var seda/RelatedData[]
* @var seda/RelatedData
* @xpath seda:RelatedData
*/
public $relatedData;
}
}
\ No newline at end of file
......@@ -38,6 +38,9 @@ class OtherMetadata
$xml = new \DOMDocument();
$root = $xml->createElementNS($this->namespaceURI, $this->nodeName);
foreach ($this->getArrayCopy() as $name => $value) {
if ($name == 'contentId' || $name == 'archiveId' || $name == 'resId') {
continue;
}
$this->toElement($root, $name, $value);
}
......
......@@ -30,8 +30,8 @@ class RelatedData
public $relation;
/**
* @var seda/RelatedData[]
* @var seda/RelatedData
* @xpath seda:RelatedData
*/
public $relatedData;
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
<?merge .serviceLevel ?>
<ServiceLevel listID="[?merge .listID @listID ?]" listName="[?merge .listName @listName ?]" name="[?merge .name @name ?]" listAgencyID="[?merge .listAgencyID @listAgencyID ?]" listAgencyName="[?merge .listAgencyName @listAgencyName ?]" listVersionID="[?merge .listVersionID @listVersionID ?]" listSchemeURI="[?merge .listSchemeDURI @listSchemeURI ?]" listURI="[?merge .listURI @listURI ?]" languageID="[?merge .languageID @languageID ?]"><?merge .value ?></ServiceLevel>
<TransferringAgencyArchiveIdentifier schemeID="[?merge .transferringAgencyArchiveIdentifier.schemeID @schemeID ?]" schemeName="[?merge .transferringAgencyArchiveIdentifier.schemeName @schemeName ?]" schemeAgencyID="[?merge .transferringAgencyArchiveIdentifier.schemeAgencyID @schemeAgencyID ?]" schemeAgencyName="[?merge .transferringAgencyArchiveIdentifier.schemeAgencyName @schemeAgencyName ?]" schemeVersionID="[?merge .transferringAgencyArchiveIdentifier.schemeVersionID @schemeVersionID ?]" schemeDataURI="[?merge .transferringAgencyArchiveIdentifier.schemeDataURI @schemeDataURI ?]" schemeURI="[?merge .transferringAgencyArchiveIdentifier.schemeURI @schemeURI ?]"><?merge .transferringAgencyArchiveIdentifier.value ?></TransferringAgencyArchiveIdentifier>
<?merge .contentDescription /seda/ContentDescription.xml ?>
<?merge .contentDescription.bool() ?><?xinclude /seda/ContentDescription.xml ?>
<?merge .accessRestrictionRule.bool() ?>
<AccessRestrictionRule>
<Code><?merge .accessRestrictionRule.code ?></Code>
......
......@@ -3,7 +3,7 @@
<Name><?merge .name ?></Name>
<OriginatingAgencyObjectIdentifier schemeID="[?merge .originatingAgencyObjectIdentifier.schemeID @schemeID ?]" schemeName="[?merge .originatingAgencyObjectIdentifier.schemeName @schemeName ?]" schemeAgencyID="[?merge .originatingAgencyObjectIdentifier.schemeAgencyID @schemeAgencyID ?]" schemeAgencyName="[?merge .originatingAgencyObjectIdentifier.schemeAgencyName @schemeAgencyName ?]" schemeVersionID="[?merge .originatingAgencyObjectIdentifier.schemeVersionID @schemeVersionID ?]" schemeDataURI="[?merge .originatingAgencyObjectIdentifier.schemeDataURI @schemeDataURI ?]" schemeURI="[?merge .originatingAgencyObjectIdentifier.schemeURI @schemeURI ?]"><?merge .originatingAgencyObjectIdentifier.value ?></OriginatingAgencyObjectIdentifier>
<TransferringAgencyObjectIdentifier schemeID="[?merge .transferringAgencyObjectIdentifier.schemeID @schemeID ?]" schemeName="[?merge .transferringAgencyObjectIdentifier.schemeName @schemeName ?]" schemeAgencyID="[?merge ..transferringAgencyObjectIdentifier.schemeAgencyID @schemeAgencyID ?]" schemeAgencyName="[?merge .transferringAgencyObjectIdentifier.schemeAgencyName @schemeAgencyName ?]" schemeVersionID="[?merge .transferringAgencyObjectIdentifier.schemeVersionID @schemeVersionID ?]" schemeDataURI="[?merge .transferringAgencyObjectIdentifier.schemeDataURI @schemeDataURI ?]" schemeURI="[?merge .transferringAgencyObjectIdentifier.schemeURI @schemeURI ?]"><?merge .transferringAgencyObjectIdentifier.value ?></TransferringAgencyObjectIdentifier>
<?merge .contentDescription /seda/ContentDescription.xml ?>
<?merge .contentDescription.bool() ?><?xinclude /seda/ContentDescription.xml ?>
<?merge .accessRestrictionRule.bool() ?>
<AccessRestrictionRule>
<Code><?merge .accessRestrictionRule.code ?></Code>
......
<ContentDescription xmlns="fr:gouv:culture:archivesdefrance:seda:v1.0">
<Description><?merge .description ?></Description>
<DescriptionLevel><?merge .descriptionLevel ?></DescriptionLevel>
<?merge .filePlanPosition ?>
<Description><?merge .contentDescription.description ?></Description>
<DescriptionLevel><?merge .contentDescription.descriptionLevel ?></DescriptionLevel>
<?merge .contentDescription.filePlanPosition ?>
<FilePlanPosition schemeID="[?merge .schemeID @schemeID ?]" schemeName="[?merge .schemeName @schemeName ?]" schemeAgencyID="[?merge .schemeAgencyID @schemeAgencyID ?]" schemeAgencyName="[?merge .schemeAgencyName @schemeAgencyName ?]" schemeVersionID="[?merge .schemeVersionID @schemeVersionID ?]" schemeDataURI="[?merge .schemeDataURI @schemeDataURI ?]" schemeURI="[?merge .schemeURI @schemeURI ?]"><?merge .value ?></FilePlanPosition>
<?merge .language.array() ?>
<?merge .contentDescription.language.array() ?>
<Language listVersionID="[?merge .listVersionID @listVersionID ?]"><?merge . ?></Language>
<LatestDate><?merge .latestDate ?></LatestDate>
<OldestDate><?merge .oldestDate ?></OldestDate>
<?merge .otherDescriptiveData.bool() ?>
<OtherDescriptiveData><?merge .otherDescriptiveData ?></OtherDescriptiveData>
<?merge .accessRestrictionRule.bool() ?>
<LatestDate><?merge .contentDescription.latestDate ?></LatestDate>
<OldestDate><?merge .contentDescription.oldestDate ?></OldestDate>
<?merge .contentDescription.otherDescriptiveData.bool() ?>
<OtherDescriptiveData><?merge .contentDescription.otherDescriptiveData ?></OtherDescriptiveData>
<?merge .contentDescription.accessRestrictionRule.bool() ?>
<AccessRestrictionRule>
<Code listVersionID="[?merge .accessRestrictionRule.code.listVersionID @listVersionID ?]"><?merge .accessRestrictionRule.code ?></Code>
<StartDate><?merge .accessRestrictionRule.startDate ?></StartDate>
<Code listVersionID="[?merge .contentDescription.accessRestrictionRule.code.listVersionID @listVersionID ?]"><?merge .contentDescription.accessRestrictionRule.code ?></Code>
<StartDate><?merge .contentDescription.accessRestrictionRule.startDate ?></StartDate>
</AccessRestrictionRule>
<?merge .custodialHistory.bool() ?>
<?merge .contentDescription.custodialHistory.bool() ?>
<CustodialHistory>
<?merge .custodialHistory.custodialHistoryItem ?>
<?merge .contentDescription.custodialHistory.custodialHistoryItem ?>
<CustodialHistoryItem when="[?merge .when ?]"><?merge .value ?></CustodialHistoryItem>
</CustodialHistory>
<?merge .keyword.array() ?><Keyword>
<?merge .contentDescription.keyword.array() ?><Keyword>
<?merge .keywordContent.value.bool() ?>
<KeywordContent role="[?merge .keywordContent.role @role ?]">
<?merge .keywordContent.value ?>
......@@ -38,22 +38,22 @@
<StartDate><?merge .accessRestrictionRule.startDate ?></StartDate>
</AccessRestrictionRule>
</Keyword>
<?merge .originatingAgency.bool() ?>
<?merge .contentDescription.originatingAgency.bool() ?>
<OriginatingAgency>
<?merge .originatingAgency[0] $organization ?>
<?merge .originatingAgency /seda/Organization.xml ?>
<?merge .contentDescription.originatingAgency[0] $organization ?>
<?merge .contentDescription.originatingAgency /seda/Organization.xml ?>
</OriginatingAgency>
<?merge .otherMetadata.bool() ?>
<?merge .contentDescription.otherMetadata.bool() ?>
<OtherMetadata>
<?merge .otherMetadata.toXML() ?>
<?merge .contentDescription.otherMetadata.toXML() ?>
</OtherMetadata>
<?merge .relatedObjectReference.array() ?>
<?merge .contentDescription.relatedObjectReference.array() ?>
<RelatedObjectReference>
<RelatedObjectIdentifier schemeID="[?merge .relatedObjectIdentifier.schemeID @schemeID ?]" schemeName="[?merge .relatedObjectIdentifier.schemeName @schemeName ?]" schemeAgencyID="[?merge .relatedObjectIdentifier.schemeAgencyID @schemeAgencyID ?]" schemeAgencyName="[?merge .relatedObjectIdentifier.schemeAgencyName @schemeAgencyName ?]" schemeVersionID="[?merge .relatedObjectIdentifier.schemeVersionID @schemeVersionID ?]" schemeDataURI="[?merge .relatedObjectIdentifier.schemeDataURI @schemeDataURI ?]" schemeURI="[?merge .relatedObjectIdentifier.schemeURI @schemeURI ?]"><?merge .relatedObjectIdentifier ?></RelatedObjectIdentifier>
<Relation listID="[?merge .relatedObjectRelation.listID @listID ?]" listName="[?merge .relatedObjectRelation.listName @listName ?]" name="[?merge .relatedObjectRelation.name @name ?]" listAgencyID="[?merge .relatedObjectRelation.listAgencyID @listAgencyID ?]" listAgencyName="[?merge .relatedObjectRelation.listAgencyName @listAgencyName ?]" listVersionID="[?merge .relatedObjectRelation.listVersionID @listVersionID ?]" listSchemeURI="[?merge .relatedObjectRelation.listSchemeDURI @listSchemeURI ?]" listURI="[?merge .relatedObjectRelation.listURI @listURI ?]" languageID="[?merge .relatedObjectRelation.languageID @languageID ?]"><?merge .relation ?></Relation>
</RelatedObjectReference>
<?merge .repository.bool() ?><Repository>
<?merge .repository $organization ?>
<?merge .repository /seda/Organization.xml ?>
<?merge .contentDescription.repository.bool() ?><Repository>
<?merge .contentDescription.repository $organization ?>
<?merge .contentDescription.repository /seda/Organization.xml ?>
</Repository>
</ContentDescription>
\ No newline at end of file
......@@ -75,7 +75,7 @@
<complexType name="CanonicalizationMethodType" mixed="true">
<sequence>
<any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) namespace seda -->
<!-- (0,unbounded) elements from (1,1) namespace ext\thirdPartyArchiving\-->
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
......@@ -85,7 +85,7 @@
<sequence>
<element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
<any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) external namespace seda -->
<!-- (0,unbounded) elements from (1,1) external namespace ext\thirdPartyArchiving\-->
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
......
......@@ -27,11 +27,8 @@ namespace ext\archivesPubliques\bundle\seda2\Controller;
*/
class ArchiveTransfer extends abstractMessage
{
use ArchiveTransferReceptionTrait,
ArchiveTransferValidationTrait,
ArchiveTransferProcessTrait;
public $droid;
public $jhove;
public $errors = [];
......
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle seda.
*
* Bundle seda is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle seda is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle seda. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\archivesPubliques\bundle\seda2\Controller;
/**
* Class ArchiveTransfer
*
* @package Seda
*/
trait ArchiveTransferReceptionTrait
{
/**
* Receive message with all contents embedded
* @param string $message The message
*/
public function receive($message)
{
$this->loadMessage($message);
// Conformité au schéma SEDA
switch ($message->xml->documentElement->namespaceURI) {
case 'fr:gouv:culture:archivesdefrance:seda:v2.0':
$schemaUri = 'seda2'.LAABS_URI_SEPARATOR.'2.0'.LAABS_URI_SEPARATOR.'schema'.LAABS_URI_SEPARATOR.'seda-2.0-main.xsd';
break;
case 'fr:gouv:culture:archivesdefrance:seda:v2.1':
$schemaUri = 'seda2'.LAABS_URI_SEPARATOR.'2.1'.LAABS_URI_SEPARATOR.'schema'.LAABS_URI_SEPARATOR.'seda-2.1-main.xsd';
break;
default:
$exception = \laabs::newException('seda/invalidMessageException', 'Bordereau non reçu : il ne respecte pas le standard SEDA 2.');
$exception->errors[] = new \core\Error('Bordereau non reçu : il ne respecte pas le standard SEDA 2 (le format utilisé est "'.$message->xml->documentElement->namespaceURI.'")');
throw $exception;
}
$router = new \core\Route\ResourceRouter($schemaUri);
$schemaFile = $router->getResource()->getRealPath();
libxml_use_internal_errors(true);
$valid = $message->xml->schemaValidate($schemaFile);
if ($valid == false) {
$exception = \laabs::newException('seda/invalidMessageException', 'Bordereau non reçu : il ne respecte pas le standard SEDA 2.');
$exception->errors = libxml_get_errors();
libxml_clear_errors();
libxml_use_internal_errors(false);
throw $exception;
}
$message->object = $message->xml->export('seda2/ArchiveTransfer');
$message->date = $message->object->date;
$message->senderOrgRegNumber = $message->object->transferringAgency->identifier->value;
$message->recipientOrgRegNumber = $message->object->archivalAgency->identifier->value;
$message->reference = $message->object->messageIdentifier->value;
if (isset($message->object->archivalAgreement->value)) {
$message->archivalAgreementReference = $message->object->archivalAgreement->value;
}
$this->receiveAttachments($message);
}
protected function receiveAttachments($message)
{
$archives = $message->object->dataObjectPackage->descriptiveMetadata->archiveUnit;
$binaryDataObjects = (array) $message->object->dataObjectPackage->binaryDataObject;
$physicalDataObjects = (array) $message->object->dataObjectPackage->physicalDataObject;
$message->dataObjectCount = count($binaryDataObjects) + count($physicalDataObjects);
foreach ($archives as $archive) {
if ($archive->dataObjectReference) {
$this->validateDocument($archive, $binaryDataObjects);
}
}
$messageDir = dirname($message->path);
// List received files
$receivedFiles = glob($messageDir.DIRECTORY_SEPARATOR."*.*");
$messageFiles = array($messageDir.DIRECTORY_SEPARATOR.(string) $message->messageId.".xml");
if (count($binaryDataObjects)) {
foreach ($binaryDataObjects as $dataObjectId => $binaryDataObject) {
$message->size += (integer) $binaryDataObject->size;
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;
}
$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;
}
$message->size += strlen($contents);
$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.");
continue;
}
$contents = base64_decode($attachment->value);
$message->size += strlen($contents);
$filepath = $messageDir.DIRECTORY_SEPARATOR.$dataObjectId;
}
// 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.");
}
}
}
// Check all files received are part of the message
foreach ($receivedFiles as $receivedFile) {
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.");
}
}
return $this->errors;
}
}
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle seda.
*
* Bundle seda is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle seda is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle seda. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\archivesPubliques\bundle\seda2\Controller;
/**
* Class ArchiveTransfer
*
* @package Seda
*/
trait ArchiveTransferValidationTrait
{
/**
* Validate against profile
* @param seda/message $message The message object with the xml
* @param object $archivalAgreement The archival agreement
*
* @return boolean The result of the operation