Commit 54e8c58f authored by Arnaud Pauget's avatar Arnaud Pauget
Browse files

Merge branch 'feat/18569_delivery' into 'develop'

feat/18569 : add accepting delivery when coming from user in service different than owner

See merge request !693
parents 3b3d84b8 f4a787f2
Pipeline #14396 failed with stages
in 57 seconds
......@@ -56,6 +56,7 @@ INSERT INTO "lifeCycle"."eventFormat" (type, format, message, notification) VALU
('medona/reception', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Réception du message %14$s de type %9$s de %11$s (%10$s) par %13$s (%12$s)', false),
('medona/validation', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference code info', 'Validation du message %14$s : %16$s (%15$s)', false),
('medona/acknowledgement', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference code info', 'Acquittement du message %14$s : %16$s (%15$s)', false),
('medona/authorization', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Traitement du message %14$s de type %9$s de %11$s (%10$s) par %13$s (%12$s)', false),
('medona/processing', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Traitement du message %14$s de type %9$s de %11$s (%10$s) par %13$s (%12$s)', false),
('medona/acceptance', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Message %14$s de type %9$s accepté par %13$s (%12$s)', false),
('medona/rejection', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Message %14$s de type %9$s rejeté par %13$s (%12$s)', false),
......
......@@ -139,6 +139,7 @@ INSERT INTO "auth"."servicePrivilege" ("accountId","serviceURI") VALUES
('System', 'audit/event/createChainjournal'),
('System', 'batchProcessing/scheduling/updateProcess'),
('System', 'lifeCycle/journal/createChainjournal'),
('System', 'medona/ArchiveDelivery/updateProcessBatch'),
('System', 'recordsManagement/archiveCompliance/readPeriodic'),
('System', 'recordsManagement/archives/deleteDisposablearchives'),
('System', 'recordsManagement/archives/updateArchivesretentionrule'),
......@@ -193,6 +194,7 @@ INSERT INTO "lifeCycle"."eventFormat" ("type","format","message","notification")
('digitalResource/integrityCheck', 'repositoryReference addressesToCheck checkedAddresses failed', 'Contrôle d''intégrité des ressources présentes dans %6$s', false),
('medona/acceptance', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Message %14$s de type %9$s accepté par %13$s (%12$s)', false),
('medona/acknowledgement', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference code info', 'Acquittement du message %14$s : %16$s (%15$s)', false),
('medona/authorization', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Traitement du message %14$s de type %9$s de %11$s (%10$s) par %13$s (%12$s)', false),
('medona/processing', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Traitement du message %14$s de type %9$s de %11$s (%10$s) par %13$s (%12$s)', false),
('medona/reception', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Réception du message %14$s de type %9$s de %11$s (%10$s) par %13$s (%12$s)', false),
('medona/rejection', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Message %14$s de type %9$s rejeté par %13$s (%12$s)', false),
......
......@@ -29,3 +29,6 @@ WITH (
ALTER TABLE "recordsManagement"."archivalProfile" ADD COLUMN "isRetentionLastDeposit" boolean default false;
ALTER TABLE "recordsManagement"."archivalProfile" ADD COLUMN "isDiscoverable" boolean default false;
INSERT INTO "lifeCycle"."eventFormat" ("type","format","message","notification") VALUES
('medona/authorization', 'type senderOrgRegNumber senderOrgName recipientOrgRegNumber recipientOrgName reference', 'Traitement du message %14$s de type %9$s de %11$s (%10$s) par %13$s (%12$s)', false);
......@@ -35,11 +35,11 @@ class AuthorizationOriginatingAgencyRequest extends abstractMessage
$authorizationOriginatingAgencyRequest->authorizationOriginatingAgencyRequestIdentifier =
$message->reference;
$authorizationOriginatingAgencyRequest->request = $this->sendRequest($message->authorizationRequestContent);
$authorizationOriginatingAgencyRequest->archivalAgency = $this->sendOrganization($message->senderOrg);
$authorizationOriginatingAgencyRequest->originatingAgency = $this->sendOrganization($message->recipientOrg);
$authorizationOriginatingAgencyRequest->request = $this->sendRequest($message->authorizationRequestContent);
}
}
......@@ -377,6 +377,7 @@ class ArchiveDeliveryRequest extends abstractMessage
}
}
/**
* Derogation archive delivery request message
* @param string $messageId The message identifier
......@@ -384,12 +385,25 @@ class ArchiveDeliveryRequest extends abstractMessage
public function derogation($messageId)
{
$this->changeStatus($messageId, "derogation");
$message = $this->sdoFactory->read('medona/message', array('messageId' => $messageId));
$message->derogation = "true";
$controlAutorityControler = \laabs::newController("medona/ControlAuthority");
// $message = $this->sdoFactory->read('medona/message', array('messageId' => $messageId));
$message = $this->read($messageId);
$archives = $this->getArchivesByMessageIdentifier($messageId);
$authorizationControlAuthorityRequestController = \laabs::newController('medona/AuthorizationControlAuthorityRequest');
$authorizationOriginatingAgencyRequestController = \laabs::newController('medona/AuthorizationOriginatingAgencyRequest');
$message->derogation = true;
$this->update($message);
foreach ($archives as $archive) {
if ($message->senderOrgRegNumber != $archive->originatorOrgRegNumber) {
$authorizationOriginatingAgencyRequestController->send($message, $archive->originatorOrgRegNumber);
} elseif (count($controlAutorityControler->index()) > 0) {
$authorizationControlAuthorityRequestController->send((string) $message->messageId, $archive->originatorOrgRegNumber);
} else {
$this->accept((string) $message->messageId);
}
}
$event = $this->lifeCycleJournalController->logEvent(
'medona/authorization',
'medona/message',
......@@ -397,13 +411,6 @@ class ArchiveDeliveryRequest extends abstractMessage
$message,
true
);
$controlAutorityControler = \laabs::newController("medona/ControlAuthority");
if (count($controlAutorityControler->index()) > 0) {
$this->sendAuthorizationRequest((string) $message->messageId);
} else {
$this->accept((string) $message->messageId);
}
}
/**
......@@ -511,7 +518,7 @@ class ArchiveDeliveryRequest extends abstractMessage
$archives[] = $this->archiveController->communicate($unitIdentifier->objectId);
}
$logMessage = ["message" => "%s archives are communicated", "variables"=> count($archives)];
$logMessage = ["message" => "%s archives are communicated", "variables" => count($archives)];
\laabs::notify(\bundle\audit\AUDIT_ENTRY_OUTPUT, $logMessage);
try {
......
......@@ -41,6 +41,8 @@ class AuthorizationOriginatingAgencyRequest extends AuthorizationRequest
$requestMessage = $this->read($requestMessage);
}
$this->loadData($requestMessage);
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->schema = $requestMessage->schema;
......@@ -129,8 +131,8 @@ class AuthorizationOriginatingAgencyRequest extends AuthorizationRequest
$authorizationControlAuthorityRequestController = \laabs::newController('medona/AuthorizationControlAuthorityRequest');
$authorizationControlAuthorityRequestController->send($requestMessage, $message->recipientOrgRegNumber);
} else {
$requestMessageController = \laabs::newController('medona/'.$requestMessage->type);
$requestMessageController->accept($requestMessage);
$requestMessageController = \laabs::newController('medona/' . $requestMessage->type);
$requestMessageController->accept((string) $requestMessage->messageId);
}
$this->lifeCycleJournalController->logEvent(
......
......@@ -54,8 +54,8 @@ class AuthorizationOriginatingAgencyRequestReply extends abstractMessage
$message->reference = $requestMessage->reference.'_Reply_'.date("Y-m-d_H-i-s");
$message->requestReference = $requestMessage->reference;
$message->authorizationReason = $requestMessage->authorizationReason;
$requestMessage->replyReference = $message->reference;
$message->authorizationReason = $requestMessage->authorizationReason;
$message->senderOrgRegNumber = $requestMessage->recipientOrgRegNumber;
$senderOrg = $this->orgController->getOrgByRegNumber($message->senderOrgRegNumber);
......
......@@ -39,7 +39,7 @@ class AuthorizationRequest extends abstractMessage
$registrationNumber = $this->getCurrentRegistrationNumber();
$queryParts = array();
$queryParts[] = "type='AuthorizationControlAuthorityRequest'";
$queryParts[] = "type=['AuthorizationOriginatingAgencyRequest', 'AuthorizationControlAuthorityRequest']";
$queryParts[] = "recipientOrgRegNumber=$registrationNumber";
$queryParts[] = "authorizationReason = 'ArchiveDeliveryRequest'";
$queryParts[] = "status='sent'";
......
......@@ -1367,4 +1367,15 @@ class message
return $name;
}
public function getArchivesByMessageIdentifier($messageId)
{
$message = $this->read($messageId);
$archives = [];
foreach ($message->unitIdentifier as $unitIdentifier) {
$archives[] = $this->archiveController->read($unitIdentifier->objectId);
}
return $archives;
}
}
<?php
/*
* Copyright (C) 2021 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 bundle\medona\Exception;
class notCommunicableException extends \core\Exception
{
public $message = false;
public function __construct($message = false, $code = 403)
{
if (!$message) {
$message = "Archive or children archive not communicable";
}
parent::__construct($message, $code);
}
}
......@@ -1486,7 +1486,7 @@ trait archiveAccessTrait
$unitIdentifiers = $this->sdoFactory->find('medona/unitIdentifier', "objectId='$archiveId'");
foreach ($unitIdentifiers as $unitIdentifier) {
$queryString [] ="messageId='$unitIdentifier->messageId'";
$queryString [] = "messageId='$unitIdentifier->messageId'";
}
if (count($unitIdentifiers) != 0) {
......
......@@ -239,6 +239,8 @@ class archive
if ($communicationDelay->invert != 0) {
$archive->isCommunicable = '1';
}
} elseif (!$archive->hasRights) {
$archive->isCommunicable = '1';
}
$archive->isInUserCollection = false;
......
......@@ -52,4 +52,23 @@ interface deliveryAuthorizationRequestInterface
* @return medona/message/rejectAuthorizationControlAuthorityRequest
*/
public function updateAuthorizationcontrolauthorityrequest_messageId_Reject($messageId, $comment = null);
/**
* Accept authorization originating agency request
* @param string $messageId The message identifier
*
* @uses medona/archiveAuthorization/updateOriginatingagencyrequestacceptance_messageId_
* @return medona/message/acceptAuthorizationOriginatingAgencyRequest
*/
public function updateAuthorizationoriginatingagencyrequest_messageId_Accept($messageId);
/**
* Reject authorization originating agencyy request
* @param string $messageId The message identifier
* @param string $comment The message comment
*
* @uses medona/archiveAuthorization/updateOriginatingagencyrequestrejection
* @return medona/message/rejectAuthorizationOriginatingAgencyRequest
*/
public function updateAuthorizationoriginatingagencyrequest_messageId_Reject($messageId, $comment =null);
}
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