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

Merge release/2.4 into master

parents 8f955941 a8429b79
......@@ -122,8 +122,8 @@ class ArchiveDeliveryRequest extends abstractMessage
$messages = array();
foreach ($archiveIds as $archiveId) {
$archive = $this->archiveController->retrieve($archiveId);
$archive = $this->archiveController->retrieve($archiveId, $withBinary = false, $checkAccess = true, $isCommunication = true);
if (!isset($archivesByOriginator[$archive->originatorOrgRegNumber])) {
$archivesByOriginator[$archive->originatorOrgRegNumber] = array();
}
......@@ -182,7 +182,7 @@ class ArchiveDeliveryRequest extends abstractMessage
$message->messageId = \laabs::newId();
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
if (\laabs::hasBundle('seda')) {
$schema = "seda";
}
$message->schema = $schema;
......
......@@ -42,7 +42,7 @@ class ArchiveDestructionNotification extends ArchiveNotification
$message->type = "ArchiveDestructionNotification";
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
if (\laabs::hasBundle('seda')) {
$schema = "seda";
}
$message->schema = $schema;
......
......@@ -108,7 +108,7 @@ class ArchiveDestructionRequest extends abstractMessage
$message->messageId = \laabs::newId();
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
if (\laabs::hasBundle('seda')) {
$schema = "seda";
}
$message->schema = $schema;
......@@ -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;
}
......
......@@ -46,7 +46,7 @@ class ArchiveModificationNotification extends ArchiveNotification
$message->type = "ArchiveModificationNotification";
$schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
if (\laabs::hasBundle('seda')) {
$schema = "seda";
}
$message->schema = $schema;
......
......@@ -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');
......
......@@ -130,7 +130,7 @@ class ArchiveRestitutionRequest extends abstractMessage
$message->messageId = \laabs::newId();
$message->schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
if (\laabs::hasBundle('seda')) {
$message->schema = "seda";
}
......@@ -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);
......
......@@ -168,7 +168,7 @@ class ArchiveTransferSending extends abstractMessage
$message->messageId = \laabs::newId();
$message->schema = "medona";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
if (\laabs::hasBundle('seda')) {
$message->schema = "seda";
}
......
<?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\thirdPartyArchiving\bundle\recordsManagement\Controller;
/**
* Archival profile class
*
* @author Alexis Ragot <alexis.ragot@maarch.org>
*/
class archivalProfile extends \bundle\recordsManagement\Controller\archivalProfile
{
protected $profilesDirectory;
/**
* Constructor
* @param \dependency\sdo\Factory $sdoFactory The sdo factory
* @param bool $notifyModification The state of the fonction of notification modification
* @param string $profilesDirectory The profile directory
*/
public function __construct(\dependency\sdo\Factory $sdoFactory, $notifyModification, $profilesDirectory)
{
parent::__construct($sdoFactory, $notifyModification, $profilesDirectory);
if (!is_dir($profilesDirectory) && !empty($profilesDirectory)) {
mkdir($profilesDirectory, 0777, true);
}
$this->profilesDirectory = $profilesDirectory;
$this->notifyModification = $notifyModification;
}
/**
* Read the agragates
* @param recordsManagement/archivalProfile $archivalProfile
*/
public function readDetail($archivalProfile)
{
parent::readDetail($archivalProfile);
$profilesDirectory = $this->profilesDirectory;
$profileFile = $profilesDirectory.DIRECTORY_SEPARATOR.$archivalProfile->reference;
if (file_exists($profileFile.'.rng') || file_exists($profileFile.'.xsd')) {
$archivalProfile->profileFile = $profileFile;
}
}
/**
* delete an archival profile
* @param string $archivalProfileId The identifier of the archival profile
*
* @return boolean The request of the request
*/
public function delete($archivalProfileId)
{
$archivalProfile = $this->sdoFactory->read('recordsManagement/archivalProfile', $archivalProfileId);
$archivalAgreementController = \laabs::newController('medona/archivalAgreement');
$archivalAgreement = $archivalAgreementController->getByProfileReference($archivalProfile->reference);
if ($archivalAgreement) {
return false;
}
return parent::delete($archivalProfileId);
}
/**
* Upload a profile file
* @param string $profileReference The profile reference
* @param string $archivalProfile The profile binary file
* @param string $format The profile file format
*
* @return boolean The result of the operation
*/
public function uploadArchivalProfile($profileReference, $archivalProfile,$content, $format = 'rng')
{
$profilesDirectory = $this->profilesDirectory;
$profilesDirectory .= DIRECTORY_SEPARATOR.$profileReference.'.'.$format ;
$content = base64_decode($content);
if(!$archivalProfile->archivalProfileId){
$archivalProfileController = \laabs::newController('recordsManagement/archivalProfile');
$archivalProfileController->create($archivalProfile);
}
file_put_contents($profilesDirectory, $content);
$archivalProfile = $this->getByReference($profileReference);
$archivalProfile->descriptionSchema = $profilesDirectory;
$this->sdoFactory->update($archivalProfile, "recordsManagement/archivalProfile");
return true;
}
/**
* Export profile file
* @param string $profileReference
*
* @return string
*/
public function export($profileReference)
{
$profilesDirectory = $this->profilesDirectory;
$fileDirectory = $profilesDirectory.DIRECTORY_SEPARATOR.$profileReference.".rng";
$file = file_get_contents($fileDirectory);
return $file;
}
}
......@@ -36,11 +36,11 @@ class archive extends \bundle\recordsManagement\Controller\archive
public function setStatus($archiveIds, $status)
{
$statusList = [];
$statusList['preserved'] = array('frozen', 'disposable', 'error', 'restituable', 'restituted', 'transferable');
$statusList['preserved'] = array('frozen', 'disposable', 'error', 'restituable', 'transferable');
$statusList['restituable'] = array('preserved');
$statusList['restituted'] = array('restituable');
$statusList['transfered'] = array('transferable');
$statusList['frozen'] = array('preserved', 'restituable', 'disposable');
$statusList['frozen'] = array('preserved', 'restituable', 'disposable', 'transferable');
$statusList['disposable'] = array('preserved');
$statusList['transferable'] = array('preserved');
$statusList['disposed'] = array('disposable', 'restituted');
......@@ -65,6 +65,8 @@ class archive extends \bundle\recordsManagement\Controller\archive
} else {
$archiveStatus->status = $status;
$archiveStatus->lastModificationDate = \laabs::newTimestamp();
$childrenArchives = $this->sdoFactory->index('recordsManagement/archive', "archiveId", "parentArchiveId = '$archiveId'");
$this->setStatus($childrenArchives, $status);
......@@ -75,4 +77,28 @@ class archive extends \bundle\recordsManagement\Controller\archive
return $res;
}
/**
* Check if the new status of an archive is possible depending on current status
* @param string $archiveId Identifier of the archives to check
* @param string $status New status to check
*
* @return boolean if the new status is possible on this archive (depends on the current status of the archive)
*/
public function checkStatus($archiveId, $status)
{
$statusList = [];
$statusList['restituable'] = array('preserved', 'restituted', 'disposed');
if (!isset($statusList[$status])) {
return false;
}
$archive = $this->sdoFactory->read('recordsManagement/archiveStatus', $archiveId);
if (!in_array($archive->status, $statusList[$status])) {
return false;
}
return true;
}
}
......@@ -56,6 +56,9 @@ profilesDirectory = "%laabsDirectory%/data/maarchRM/profiles"
; 3 = both
archivalProfileType = 2
; Default Retention Rule if any retention rule is set up ("dispose" or "preserve")
actionWithoutRetentionRule = "preserve"
; Delete the description of an archive when an archive is deleted
deleteDescription = false
......@@ -239,8 +242,8 @@ Password = %password%
; Path to the UK National Archives DROID signature file for file format detection
; Droid signature files can be found at http://www.nationalarchives.gov.uk/aboutapps/pronom/droid-signature-files.htm
signatureFile = "%laabsDirectory%/data/maarchRM/droidSignatureFiles/DROID_SignatureFile_V91.xml"
containerSignatureFile = "%laabsDirectory%/data/maarchRM/droidSignatureFiles/container-signature-20170330.xml"
signatureFile = "%laabsDirectory%/data/maarchRM/droidSignatureFiles/DROID_SignatureFile_V94.xml"
containerSignatureFile = "%laabsDirectory%/data/maarchRM/droidSignatureFiles/container-signature-20180920.xml"
; Path to libreOffice executable
;libreOfficeExecutable = "c:\Program Files (x86)\LibreOffice 5\program\soffice"
......@@ -425,4 +428,4 @@ tasks = "[
'route' : 'recordsManagement/archives/updateArchivesretentionrule',
'description' : 'Mise à jour de la durée d\'utilité administrative'
}
]"
\ No newline at end of file
]"
......@@ -94,6 +94,18 @@ trait archiveDeliveryTrait
$this->prepareMesageList($messages, true);
$this->initHistoryForm();
$statuses = [
'new' => $this->translator->getText('new'),
'sent' => $this->translator->getText('sent'),
'accepted' => $this->translator->getText('accepted'),
'rejected' => $this->translator->getText('rejected'),
'processing' => $this->translator->getText('processing'),
'processed' => $this->translator->getText('processed'),
'invalid' => $this->translator->getText('invalid'),
'error' => $this->translator->getText('error')
];
$this->view->setSource('statuses', $statuses);
$this->view->merge();
return $this->view->saveHtml();
......
......@@ -80,6 +80,18 @@ trait archiveDestructionTrait
$this->prepareMesageList($messages, true);
$this->initHistoryForm();
$statuses = [
'sent' => $this->translator->getText('sent'),
'validated' => $this->translator->getText('validated'),
'accepted' => $this->translator->getText('accepted'),
'rejected' => $this->translator->getText('rejected'),
'processing' => $this->translator->getText('processing'),
'processed' => $this->translator->getText('processed'),
'invalid' => $this->translator->getText('invalid'),
'error' => $this->translator->getText('error')
];
$this->view->setSource('statuses', $statuses);
$this->view->merge();
return $this->view->saveHtml();
......
......@@ -71,17 +71,23 @@ class archiveModification
} else {
$success = count($result['success']);
$echec = count($result['error']);
$this->json->message='';
$this->json->message = '%1$s archive(s) flagged for restitution.';
$this->json->message = $this->translator->getText($this->json->message);
$this->json->message = sprintf($this->json->message, $success);
if ($success > 0) {
$this->json->message = '%1$s archive(s) flagged for restitution.';
$this->json->message = $this->translator->getText($this->json->message);
$this->json->message = sprintf($this->json->message, $success);
}
if ($echec > 0) {
$message = '%1$s archive(s) can not be flagged.';
if ($success > 0) {
$this->json->message .= '<br>';
}
$message = '%1$s archive(s) can not be flagged because an action is already in progress on this(these) archive(s) (or on one of its/their objects).';
$message = $this->translator->getText($message);
$message = sprintf($message, $echec);
$this->json->message .= ' '.$message;
$this->json->message .= $message;
}
}
......
......@@ -40,6 +40,12 @@ trait archiveNotificationTrait
$this->prepareMesageList($messages, true);
$this->initHistoryForm();
$statuses = [
'sent' => $this->translator->getText('sent'),
'error' => $this->translator->getText('error')
];
$this->view->setSource('statuses', $statuses);
$this->view->merge();
return $this->view->saveHtml();
......
......@@ -76,6 +76,22 @@ trait archiveOutgoingTransferTrait
$this->prepareMesageList($messages, true);
$this->initHistoryForm();
$statuses = [
'sent' => $this->translator->getText('sent'),
'transferable' => $this->translator->getText('transferable'),
'downloaded' => $this->translator->getText('downloaded'),
'validating' => $this->translator->getText('validating'),
'validated' => $this->translator->getText('validated'),
'accepted' => $this->translator->getText('accepted'),
'rejected' => $this->translator->getText('rejected'),
'acknowledge' => $this->translator->getText('acknowledge'),
'processing' => $this->translator->getText('processing'),
'processed' => $this->translator->getText('processed'),
'invalid' => $this->translator->getText('invalid'),
'error' => $this->translator->getText('error')
];
$this->view->setSource('statuses', $statuses);
$this->view->merge();
return $this->view->saveHtml();
......
......@@ -94,6 +94,20 @@ trait archiveRestitutionTrait
$this->prepareMesageList($messages, true);
$this->initHistoryForm();
$statuses = [
'sent' => $this->translator->getText('sent'),
'received' => $this->translator->getText('received'),
'acknowledge' => $this->translator->getText('acknowledge'),
'validated' => $this->translator->getText('valid'),
'accepted' => $this->translator->getText('accepted'),
'rejected' => $this->translator->getText('rejected'),
'processing' => $this->translator->getText('processing'),
'processed' => $this->translator->getText('processed'),
'invalid' => $this->translator->getText('invalid'),
'error' => $this->translator->getText('error')
];
$this->view->setSource('statuses', $statuses);
$this->view->merge();
return $this->view->saveHtml();
......
......@@ -93,6 +93,23 @@ trait archiveTransferTrait
$this->prepareMesageList($messages, true);
$this->initHistoryForm();
$statuses = [
'template' => $this->translator->getText('template'),
'draft' => $this->translator->getText('draft'),
'sent' => $this->translator->getText('sent'),
'received' => $this->translator->getText('received'),
'valid' => $this->translator->getText('valid'),
'accepted' => $this->translator->getText('accepted'),
'processing' => $this->translator->getText('processing'),
'processed' => $this->translator->getText('processed'),
'toBeModified' => $this->translator->getText('toBeModified'),
'modified' => $this->translator->getText('modified'),
'rejected' => $this->translator->getText('rejected'),
'invalid' => $this->translator->getText('invalid'),
'error' => $this->translator->getText('error')
];
$this->view->setSource('statuses', $statuses);
$this->view->merge();
return $this->view->saveHtml();
......
......@@ -268,6 +268,10 @@ class message
$archive->content->originatingAgency->name = $this->loadOrganizationName($archive->content->originatingAgency, $message);
}
if ($archive->content->submissionAgency) {
$archive->content->submissionAgency->name = $this->loadOrganizationName($archive->content->submissionAgency, $message);
}
if ($archive->archiveUnit) {
foreach ($archive->archiveUnit as $archiveChildren) {
if ($archiveChildren->content->originatingAgency) {
......@@ -313,13 +317,49 @@ class message
}
}
}
} elseif($baseMessage->schema == 'seda') {
if (isset($messageObject->archive)) {
foreach ($messageObject->archive as $archive) {
if (isset($archive->document)) {
foreach ($archive->document as $document) {
if (isset($document->integrity)) {
$document->integrity->hashAlgorithm = substr($document->integrity->algorithme, strrpos($document->integrity->algorithme, "#") + 1);
}
}
}
}
}
}
if (isset($messageObject->archive)) {
foreach ($messageObject->archive as $archive) {
if (isset($archive->appraisalRule)) {
$dateInter = new \DateInterval($archive->appraisalRule->duration);
$numberDuration = 0;
$toDisplay = '';
if ($dateInter->y != 0) {
if ($dateInter->y == 999999999) {
$toDisplay = "Unlimited";
} else {
$numberDuration = $dateInter->y;
$toDisplay = "Year(s)";
}
} elseif ($dateInter->m != 0) {
$numberDuration = $dateInter->m;
$toDisplay = "Month(s)";
} elseif ($dateInter->d != 0) {
$numberDuration = $dateInter->d;
$toDisplay = "Day(s)";
}
$archive->appraisalRule->durationNumber = $numberDuration;
$archive->appraisalRule->durationToDisplay = $toDisplay;
}
}
}
$messageObjects[] = $messageObject;
}