Verified Commit ba74861d authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Fix Destruction of the archives by the batch processing

parent b79544ed
......@@ -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;
}
......
Markdown is supported
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