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

Revert "Merge branch 'feature/6024-AsyncDeposit' into 'develop'"

This reverts commit 1976ef11
parent 1976ef11
......@@ -27,7 +27,8 @@ namespace ext\thirdPartyArchiving\bundle\medona\Controller;
* @package Medona
* @author Alexis Ragot <alexis.ragot@maarch.org>
*/
class Acknowledgement extends abstractMessage implements AcknowledgementInterface
class Acknowledgement
extends abstractMessage
{
/**
......@@ -70,9 +71,34 @@ class Acknowledgement extends abstractMessage implements AcknowledgementInterfac
}
try {
$archiveTransferReplyController = \laabs::newController($message->schema.'/Acknowledgement');
$archiveTransferReplyController->send($message);
if ($message->schema != 'medona') {
$archiveTransferReplyController = \laabs::newController($message->schema.'/Acknowledgement');
$archiveTransferReplyController->send($message);
} else {
/*$archiveTransferReply = $this->sendMessage($message);
$message->object = $archiveTransferReply;
$archiveTransferReply->replyCode = $this->sendReplyCode($message->replyCode);
if (isset($message->requestReference)) {
$archiveTransferReply->messageRequestIdentifier = \laabs::newInstance('medona/Identifier', $message->requestReference);
}
if (isset($message->operationDate)) {
$archiveTransferReply->grantDate = (string) $message->operationDate;
}
$archiveTransferReply->archivalAgency = $this->sendOrganization($message->senderOrg);
$archiveTransferReply->transferringAgency = $this->sendOrganization($message->recipientOrg);
// Generate XML
$this->generate($message);
$this->save($message);*/
}
$operationResult = true;
} catch (\Exception $e) {
......
<?php
/*
* Copyright (C) 2018 Maarch
*
* This file is part of bundle medona.
*
* Bundle medona 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 medona 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 medona. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\thirdPartyArchiving\bundle\medona\Controller;
/**
* Acknowledgement interface
*
* @package Medona
* @author Alexis Ragot <alexis.ragot@maarch.org>
*/
interface AcknowledgementInterface
{
/**
* Send an aknowledgement
* @param mixed $receivedMessage The received message or it's identifier
*
* @return object The acknowledgement
*/
public function send($receivedMessage);
}
......@@ -49,20 +49,22 @@ class ArchivalProfileModificationNotification extends ArchiveNotification
$messages = array();
$this->retentionRuleController = \laabs::newController('recordsManagement/retentionRule');
$retentionRule = $this->retentionRuleController->read($profile->retentionRuleCode);
$profile->retentionRuleDuration = $retentionRule->duration;
$profile->retentionRuleFinalDisposition = $retentionRule->finalDisposition;
$this->accessRuleController = \laabs::newController('recordsManagement/accessRule');
$accessRule = $this->accessRuleController->edit($profile->accessRuleCode);
$profile->accessRuleDuration = $accessRule->duration;
if (!\laabs::hasBundle("seda")) {
$this->retentionRuleController = \laabs::newController('recordsManagement/retentionRule');
$retentionRule = $this->retentionRuleController->read($profile->retentionRuleCode);
$profile->retentionRuleDuration = $retentionRule->duration;
$profile->retentionRuleFinalDisposition = $retentionRule->finalDisposition;
$this->accessRuleController = \laabs::newController('recordsManagement/accessRule');
$accessRule = $this->accessRuleController->edit($profile->accessRuleCode);
$profile->accessRuleDuration = $accessRule->duration;
}
foreach ($recipients as $recipient) {
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->type = "ArchivalProfileModificationNotification";
$message->schema = "recordsManagement";
$message->schema = "medona";
$message->status = "sent";
$message->date = \laabs::newDatetime(null, "UTC");
$message->receptionDate = $message->date;
......
......@@ -46,7 +46,7 @@ class ArchiveConversionRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->schema = "recordsManagement";
$message->schema = "medona";
$message->type = "ArchiveConversionRequest";
$message->status = 'processWait';
$message->date = \laabs::newDatetime(null, "UTC");
......
......@@ -175,7 +175,7 @@ class ArchiveDeliveryRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$schema = "recordsManagement";
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -212,10 +212,22 @@ class ArchiveDeliveryRequest extends abstractMessage
}
try {
$archiveDeliveryRequestController = \laabs::newController($message->schema.'/ArchiveDeliveryRequest');
$archiveDeliveryRequestController->send($message);
if ($message->schema != 'medona') {
$archiveDeliveryRequestController = \laabs::newController($message->schema.'/ArchiveDeliveryRequest');
$archiveDeliveryRequestController->send($message);
} else {
$archiveDeliveryRequest = $this->sendMessage($message);
$message->object = $archiveDeliveryRequest;
$archiveDeliveryRequest->requester = $this->sendOrganization($message->senderOrg);
if ($userName) {
$archiveDeliveryRequest->requester->userName = $userName;
}
$archiveDeliveryRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$message->object->unitIdentifier = $message->unitIdentifier;
}
$operationResult = true;
$this->create($message);
......
<?php
/*
* Copyright (C) 2018 Maarch
*
* This file is part of bundle medona.
*
* Bundle medona 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 medona 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 medona. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\thirdPartyArchiving\bundle\medona\Controller;
/**
* Archive delivery request interface
*
* @package Medona
* @author Alexis Ragot <alexis.ragot@maarch.org>
*/
interface ArchiveDeliveryRequestInterface
{
/**
* Send an archive delivery request
* @param Object $message The message
*/
public function send($message);
}
......@@ -127,9 +127,19 @@ class ArchiveDeliveryRequestReply extends abstractMessage
try {
mkdir($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId, 0777, true);
$archiveDeliveryRequestReplyController = \laabs::newController($message->schema.'/ArchiveDeliveryRequestReply');
$archiveDeliveryRequestReplyController->send($message);
if ($message->schema != 'medona') {
$archiveDeliveryRequestReplyController = \laabs::newController($message->schema.'/ArchiveDeliveryRequestReply');
$archiveDeliveryRequestReplyController->send($message);
} else {
$archiveDeliveryRequestReply = $this->sendMessage($message);
$message->object = $archiveDeliveryRequestReply;
$archiveDeliveryRequestReply->requester = $this->sendOrganization($message->senderOrg);
$archiveDeliveryRequestReply->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
$message->status = "invalid";
......
<?php
/*
* Copyright (C) 2018 Maarch
*
* This file is part of bundle medona.
*
* Bundle medona 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 medona 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 medona. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\thirdPartyArchiving\bundle\medona\Controller;
/**
* Archive delivery request reply interface
*
* @package Medona
* @author Alexis Ragot <alexis.ragot@maarch.org>
*/
interface ArchiveDeliveryRequestReplyInterface
{
/**
* Send message with all contents embedded
* @param object $message The message
*/
public function send($message);
}
......@@ -41,7 +41,7 @@ class ArchiveDestructionNotification extends ArchiveNotification
$message->messageId = \laabs::newId();
$message->type = "ArchiveDestructionNotification";
$schema = "recordsManagement";
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -62,9 +62,16 @@ class ArchiveDestructionNotification extends ArchiveNotification
$message->dataObjectCount = count($message->archive);
try {
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
if ($message->schema != 'medona') {
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
} else {
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -105,7 +105,7 @@ class ArchiveDestructionRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$schema = "recordsManagement";
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -133,8 +133,21 @@ class ArchiveDestructionRequest extends abstractMessage
$message->unitIdentifier[] = $unitIdentifier;
}
$archiveDestructionRequestController = \laabs::newController($message->schema.'/ArchiveDestructionRequest');
$archiveDestructionRequestController->send($message);
if ($message->schema != 'medona') {
$archiveDestructionRequestController = \laabs::newController($message->schema.'/ArchiveDestructionRequest');
$archiveDestructionRequestController->send($message);
} else {
$archiveDestructionRequest = $this->sendMessage($message);
$message->object = $archiveDestructionRequest;
$archiveDestructionRequest->originatingAgency = $this->sendOrganization($message->senderOrg);
$archiveDestructionRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$message->object->unitIdentifier = $message->unitIdentifier;
$this->generate($message);
$this->save($message);
}
$this->create($message);
} catch (\Exception $e) {
......
......@@ -45,7 +45,7 @@ class ArchiveModificationNotification extends ArchiveNotification
$message->messageId = \laabs::newId();
$message->type = "ArchiveModificationNotification";
$schema = "recordsManagement";
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -77,9 +77,23 @@ class ArchiveModificationNotification extends ArchiveNotification
$message->dataObjectCount = count($message->archive);
try {
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
if ($message->schema != 'medona') {
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
} else {
$archiveModificationNotification = $this->sendMessage($message);
$message->object = $archiveModificationNotification;
$archiveModificationNotification->originatingAgency = $this->sendOrganization($message->senderOrg);
$archiveModificationNotification->archivalAgency = $this->sendOrganization($message->recipientOrg);
$message->object->unitIdentifier = $message->unitIdentifier;
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -177,9 +177,19 @@ class ArchiveRestitution extends abstractMessage
try {
mkdir($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId, 0777, true);
$archiveRestitutionController = \laabs::newController($message->schema.'/ArchiveRestitution');
$archiveRestitutionController->send($message);
if ($message->schema != 'medona') {
$archiveRestitutionController = \laabs::newController($message->schema.'/ArchiveRestitution');
$archiveRestitutionController->send($message);
} else {
$archiveRestitution = $this->sendMessage($message);
$message->object = $archiveRestitution;
$archiveRestitution->requester = $this->sendOrganization($message->senderOrg);
$archiveRestitution->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -129,7 +129,7 @@ class ArchiveRestitutionRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->schema = "recordsManagement";
$message->schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$message->schema = "seda";
}
......@@ -157,8 +157,23 @@ class ArchiveRestitutionRequest extends abstractMessage
$message->unitIdentifier[] = $unitIdentifier;
}
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
if ($message->schema != 'medona') {
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
} else {
$archiveRestitutionRequest = $this->sendMessage($message);
$message->object = $archiveRestitutionRequest;
$archiveRestitutionRequest->requester = $this->sendOrganization($message->senderOrg);
if ($userName) {
$archiveRestitutionRequest->requester->userName = $userName;
}
$archiveRestitutionRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$operationResult = true;
......@@ -209,8 +224,19 @@ class ArchiveRestitutionRequest extends abstractMessage
$this->readOrgs($message); // read org names, addresses, communications, contacts
try {
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
if ($message->schema != 'medona') {
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
} else {
$archiveRestitutionRequest = $this->sendMessage($message);
$message->object = $archiveRestitutionRequest;
$archiveRestitutionRequest->requester = $this->sendOrganization($message->senderOrg);
$archiveRestitutionRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$message->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $requestMessage);
foreach ($message->unitIdentifier as $unitIdentifier) {
......
......@@ -74,9 +74,19 @@ class ArchiveRestitutionRequestReply extends abstractMessage
try {
mkdir($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId, 0777, true);
$archiveRestitutionRequestReplyController = \laabs::newController($message->schema.'/ArchiveRestitutionRequestReply');
$archiveRestitutionRequestReplyController->send($message);
if ($message->schema != 'medona') {
$archiveRestitutionRequestReplyController = \laabs::newController($message->schema.'/ArchiveRestitutionRequestReply');
$archiveRestitutionRequestReplyController->send($message);
} else {
$archiveRestitutionRequestReply = $this->sendMessage($message);
$message->object = $archiveRestitutionRequestReply;
$archiveRestitutionRequestReply->requester = $this->sendOrganization($message->senderOrg);
$archiveRestitutionRequestReply->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -27,7 +27,7 @@ namespace ext\thirdPartyArchiving\bundle\medona\Controller;
* @package Medona
* @author Alexis Ragot <alexis.ragot@maarch.org>
*/
class ArchiveTransfer extends abstractMessage implements ArchiveTransferInterface
class ArchiveTransfer extends abstractMessage
{
protected $archiveParser;
......@@ -140,19 +140,7 @@ class ArchiveTransfer extends abstractMessage implements ArchiveTransferInterfac
}
if (is_file($messageFile)) {
$contentType = mime_content_type($messageFile);
switch ($contentType) {
case 'application/json':
$message->schema = 'recordsManagement';
$content = file_get_contents($messageFile);
$message->object = json_decode($content);
break;
case 'application/xml':
case 'text/xml':
$this->receiveXmlFile($message, $messageFile, $attachments);
break;
}
$this->receiveFile($message, $messageFile, $attachments);
} elseif (is_string($messageFile)) {
$messageFile = base64_decode($messageFile);
......@@ -160,14 +148,6 @@ class ArchiveTransfer extends abstractMessage implements ArchiveTransferInterfac
$contentType = $finfo->buffer($messageFile);
switch ($contentType) {
case 'application/json':
$message->schema = 'recordsManagement';
$message->object = $messageFile;
break;
case 'text/plain':
$message->schema = 'recordsManagement';
$message->object = json_decode($messageFile);
break;
case 'application/xml':
case 'text/xml':
$this->receiveXml($message, $messageFile, $attachments);
......@@ -180,10 +160,114 @@ class ArchiveTransfer extends abstractMessage implements ArchiveTransferInterfac
}
}
// Extract basic information for medona/message object
try {
$archiveTransferController = \laabs::newController($message->schema. '/ArchiveTransfer');
$archiveTransferController->receive($message);
if ($message->schema != 'medona') {
$archiveTransferController = \laabs::newController($message->schema.'/ArchiveTransfer');
$archiveTransferController->receive($message);
$errors = $archiveTransferController->checkResources($message);
if ($errors) {
$messageURI = $this->messageDirectory.DIRECTORY_SEPARATOR.$message->messageId;
if (is_dir($messageURI)) {
\laabs\rmdir($messageURI, true);
}
$exception = \laabs::newException('medona/invalidMessageException', "Invalid message", $errors[0]->getCode());
$exception->errors = $errors;
throw $exception;
}
} else {
// Validate xsd
$schemaFile = LAABS_EXTENSION.DIRECTORY_SEPARATOR.'thirdPartyArchiving'.DIRECTORY_SEPARATOR.LAABS_BUNDLE.DIRECTORY_SEPARATOR.'medona'.DIRECTORY_SEPARATOR.LAABS_RESOURCE.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'medona_V1.0.xsd';
libxml_use_internal_errors(true);
$valid = $message->xml->schemaValidate($schemaFile);
if ($valid == false) {
$exception = \laabs::newException('medona/invalidMessageException', "Message not received: It doesn't respect the schema.", 400);
foreach (libxml_get_errors() as $error) {
$this->sendError('101', $error->message);
}
libxml_clear_errors();
libxml_use_internal_errors(false);
throw $exception;
}
$message->object = $message->xml->export('medona/ArchiveTransfer');
// @todo : get class from xml ns+localName
$message->object->dataObjectPackage->managementMetadata->accessRuleClass = 'recordsManagement/archiveAccessRule';
// Get description package class
switch (get_class($message->object->dataObjectPackage->descriptiveMetadata)) {
case 'ext\thirdPartyArchiving\bundle\medona\Model\archivePackage':
$message->object->dataObjectPackage->descriptiveMetadataClass = 'medona/archivePackage';
foreach ($message->object->dataObjectPackage->descriptiveMetadata->archive as $archive) {
if (isset($archive->descriptionObject) && is_object($archive->descriptionObject)) {
$archive->descriptionClass = \laabs::getClassName($archive->descriptionObject);
$archive->descriptionId = \laabs::objectId($archive->descriptionObject);
}
}
break;
case 'bundle\recordsManagement\Model\archive':
$message->object->dataObjectPackage->descriptiveMetadataClass = 'recordsManagement/archive';
$archive = $message->object->dataObjectPackage->descriptiveMetadata;
$descriptionClass = \laabs::getClassName($archive->descriptionObject);
$archive->descriptionClass = $descriptionClass;
if (isset($archive->descriptionObject) && is_object($archive->descriptionObject)) {
$archive->descriptionId = \laabs::objectId($archive->descriptionObject);
}
break;
// Custom extraction scripts ?
}
$message->date = $message->object->date;
$message->senderOrgRegNumber = $message->object->transferringAgency->identifier->value;
$message->recipientOrgRegNumber = $message->object->archivalAgency->identifier->value;