Commit 568b3956 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Merge branch 'fix/9859_archive_restitution' into 'develop'

Fix/9859 archive restitution

See merge request maarch/thirdPartyArchiving!64
parents 88a2fac3 ba74861d
......@@ -271,7 +271,19 @@ class ArchiveDestructionRequest extends abstractMessage
{
$results = array();
$index = $this->sdoFactory->index('medona/message', array('messageId'), 'type = "ArchiveDestructionRequest" AND status = "validated"');
$index = $this->sdoFactory->index(
'medona/message',
array('messageId'),
'(
type = "ArchiveDestructionRequest"
OR type = "ArchiveRestitution"
OR (
type = "ArchiveTransfer"
&& isIncoming = false
)
)
AND status = "validated"'
);
foreach ($index as $messageId) {
$results[(string) $messageId] = $this->process($messageId);
......@@ -311,7 +323,7 @@ class ArchiveDestructionRequest extends abstractMessage
try {
$archives = $this->archiveController->destruct($archiveIds);
$logMessage = ["message" => "%s archives are deleted", "variables"=> count($archives)];
$logMessage = ["message" => "%s archives are deleted", "variables"=> count($archives['success'])];
\laabs::notify(\bundle\audit\AUDIT_ENTRY_OUTPUT, $logMessage);
$message->status = "processed";
......@@ -338,8 +350,15 @@ class ArchiveDestructionRequest extends abstractMessage
$archiveDestructionNotificationController = \laabs::newController("medona/ArchiveDestructionNotification");
// TO DO : Write destruction failures in comments
$replyMessage = $archiveDestructionNotificationController->send($message, $archives['success']);
try {
if (count($archives['success']) > 0) {
$replyMessage = $archiveDestructionNotificationController->send($message, $archives['success']);
} else {
return;
}
} catch (\Exception $e) {
throw $e;
}
return $replyMessage->messageId;
}
......
......@@ -167,6 +167,11 @@ class ArchiveRestitution extends abstractMessage
$message->recipientOrgRegNumber = $replyMessage->recipientOrgRegNumber;
$this->readOrgs($message); // read org names, addresses, communications, contacts
$message->unitIdentifier = $requestMessage->unitIdentifier;
foreach ($message->unitIdentifier as $unitIdentifier) {
$unitIdentifier->messageId = $message->messageId;
}
if ($replyMessage->replyCode == "000" || $replyMessage->replyCode == "001") {
foreach ($archives as $archive) {
$archive->lifeCycleEvent = $this->lifeCycleJournalController->getObjectEvents($archive->archiveId, 'recordsManagement/archive');
......
......@@ -273,6 +273,7 @@ class ArchiveRestitutionRequest extends abstractMessage
$this->changeStatus($messageId, "accepted");
$message = $this->sdoFactory->read('medona/message', array('messageId' => $messageId));
$message->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $message);
$this->lifeCycleJournalController->logEvent(
'medona/acceptance',
......@@ -283,7 +284,7 @@ class ArchiveRestitutionRequest extends abstractMessage
);
$archiveRestitutionRequestReplyController = \laabs::newController('medona/ArchiveRestitutionRequestReply');
$replyMessage = $archiveRestitutionRequestReplyController->send($messageId, "000");
$replyMessage = $archiveRestitutionRequestReplyController->send($message, "000");
return $replyMessage;
}
......
......@@ -70,6 +70,9 @@ class ArchiveRestitutionRequestReply extends abstractMessage
$message->replyCode = $replyCode;
$message->unitIdentifier = $requestMessage->unitIdentifier;
foreach ($message->unitIdentifier as $unitIdentifier) {
$unitIdentifier->messageId = $message->messageId;
}
try {
mkdir($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId, 0777, true);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment