Verified Commit 62c5ef85 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Feat #8364 - Update metadata message

parent 24f49b67
......@@ -223,7 +223,7 @@ class ArchiveTransfer extends abstractMessage
$messageDir = $this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId;
if (!$filename) {
$filename = (string) $message->messageId;
$filename = (string) $message->messageId . '.xml';
}
file_put_contents($messageDir.DIRECTORY_SEPARATOR.$filename, $data);
......@@ -378,7 +378,7 @@ class ArchiveTransfer extends abstractMessage
$this->validateMessageHeaders($message);
$archiveTransferController = \laabs::newController($message->schema.'/ArchiveTransfer');
$archiveTransferController->validate($message, $this->currentArchivalAgreement);
$res = $archiveTransferController->validate($message, $this->currentArchivalAgreement);
if ($archiveTransferController->replyCode) {
$this->replyCode = $archiveTransferController->replyCode;
......@@ -399,7 +399,11 @@ class ArchiveTransfer extends abstractMessage
// Non blocking errors
if (count($this->errors) > 0) {
$this->sendValidationError($message);
if ($res = -1) {
$this->sendValidationError($message, false,'toBeModified');
} else {
$this->sendValidationError($message);
}
$exception = \laabs::newException('medona/invalidMessageException', "Invalid message", 400);
$exception->errors = $this->errors;
......@@ -497,9 +501,13 @@ class ArchiveTransfer extends abstractMessage
return true;
}
protected function sendValidationError($message)
protected function sendValidationError($message, $sendReply = true, $status = null)
{
$message->status = "invalid";
if ($status) {
$message->status = $status;
} else {
$message->status = "invalid";
}
foreach ((array) $this->errors as $error) {
$eventInfo = array();
$eventInfo['type'] = "ArchiveTransfer";
......@@ -520,8 +528,10 @@ class ArchiveTransfer extends abstractMessage
$this->sdoFactory->update($message);
$archiveTransferReplyController = \laabs::newController('medona/ArchiveTransferReply');
$archiveTransferReplyController->send($message, $this->replyCode);
if ($sendReply) {
$archiveTransferReplyController = \laabs::newController('medona/ArchiveTransferReply');
$archiveTransferReplyController->send($message, $this->replyCode);
}
}
protected function validateDepositor($message)
......
......@@ -689,12 +689,16 @@ class message
$message = $message = $this->sdoFactory->read('medona/message', $messageId);
$message->object = json_decode($message->data);
$fromStatus = ['error','processing'];
$fromStatus = ['error','processing','toBeModified'];
if (!in_array($message->status, $fromStatus)) {
$this->sendError("101", "Le statut du message est incorrect.");
}
$this->changeStatus($messageId, 'accepted');
if ($message->status == 'toBeModified') {
$this->changeStatus($messageId, 'Modified');
} else {
$this->changeStatus($messageId, 'accepted');
}
$this->lifeCycleJournalController->logEvent(
'medona/retry',
......
......@@ -118,6 +118,13 @@ interface archiveTransferInterface
*/
public function updateRequestacceptance_messageId_();
/**
* Modify archive transfer
*
* @action medona/ArchiveTransfer/modify
*/
public function updateRequestmodify_messageId_();
/**
* Reject archive transfer
* @param string $messageId The message identifier
......
......@@ -750,7 +750,7 @@ class message
switch ($messageObject->type) {
case 'ArchiveTransfer':
if ($message->status == "received") {
if ($message->status == "received" || $message->status == "modified") {
if (!$message->isIncoming) {
$messageObject->acknowledgeButton = "/restitution/".$messageId."/Acknowledge";
}
......@@ -758,9 +758,10 @@ class message
} elseif ($message->status == "valid") {
$messageObject->acceptButton = "/transferAcceptance/".$messageId;
$messageObject->rejectButton = "/transferRejection/".$messageId;
} elseif ($message->status == "invalid") {
//$message->modifyButton = "".(string) $message->messageId;
//$message->rejectButton = "".(string) $message->messageId;
} elseif ($message->status == "toBeModified") {
$messageObject->rejectButton = "/transferRejection/".$messageId;
$messageObject->retryButton = "/medona/message/". $message->messageId . "/retry";
$messageObject->modifyButton = "/transferModify/". $message->messageId;
} elseif ($message->status == "accepted") {
$messageObject->processButton = "/transferProcess/".$messageId;
} elseif ($message->status == "sent") {
......
......@@ -13,6 +13,10 @@
<button type="button" class="btn btn-success messageExport" data-action="[?merge $message.exportButton ?]" title="Download"><i class="fa fa-download">&nbsp;</i></button>
<?merge $message.processButton.bool() ?>
<button type="button" class="btn btn-warning messageAction" data-action="[?merge $message.processButton ?]" title="Process"><i class="fa fa-cogs">&nbsp;</i>Process</button>
<?merge $message.modifyButton.bool() ?>
<button type="button" class="btn btn-warning messageAction" data-action="[?merge $message.modifyButton ?]" title="Modify"><i class="fa fa-edit">&nbsp;</i>Modify</button>
<?merge $message.retryButton.bool() ?>
<button type="button" class="btn btn-success messageAction" data-action="[?merge $message.retryButton ?]" title="Retry the process"><i class="fa fa-refresh">&nbsp;</i>Retry</button>
<?merge $message.acceptButton.bool() ?>
<button type="button" class="btn btn-success messageAction" data-action="[?merge $message.acceptButton ?]" title="Accept"><i class="fa fa-check">&nbsp;</i>Accept</button>
<?merge $message.acceptWarningButton.bool() ?>
......@@ -21,8 +25,6 @@
<button type="button" class="btn btn-danger messageActionReject" data-action="[?merge $message.rejectButton ?]" title="Reject"><i class="fa fa-times">&nbsp;</i>Reject</button>
<?merge $message.validateButton.bool() ?>
<button type="button" class="btn btn-success messageAction" data-action="[?merge $message.validateButton ?]" title="Validate" ><i class="fa fa-check">&nbsp;</i>Validate</button>
<?merge $message.modifyButton.bool() ?>
<button type="button" class="btn btn-warning messageAction" data-action="[?merge $message.modifyButton ?]" title="Modify"><i class="fa fa-times">&nbsp;</i>Modify</button>
<?merge $message.validationButton.bool() ?>
<button type="button" class="btn btn-danger messageActionValidation" data-action="[?merge $message.validationButton ?]" title="Destroy" ><i class="fa fa-trash">&nbsp;</i>Destroy</button>
<?merge $message.sendRequestAuth.bool() ?>
......@@ -31,8 +33,5 @@
<button type="button" class="btn btn-success viewArchive" data-archive-id="[?merge $message.messageIid ?]" title="Info"><span class="fa fa-info-circle"></span></button>
<?merge $message.acknowledgeButton.bool() ?>
<button type="button" class="btn btn-warning messageActionValidation" data-action="[?merge $message.acknowledgeButton ?]" title="Acknowledge"><i class="fa fa-gavel">&nbsp;</i>Acknowledge</button>
<?merge $message.retryButton.bool() ?>
<button type="button" class="btn btn-success messageAction" data-action="[?merge $message.retryButton ?]" title="Retry the process"><i class="fa fa-refresh">&nbsp;</i>Retry</button>
</div>
</h4>
\ No newline at end of file
......@@ -59,6 +59,14 @@ interface processTransferInterface
*/
public function updateTransferrejection_messageId_($messageId, $comment = null);
/**
* Modify archive transfer
*
* @return seda/messageComposer/editMessage
* @uses seda/ArchiveTransferComposition/read_messageId_
*/
public function readTransfermodify_messageId_();
/**
* Process archive transfer
*
......
......@@ -33,14 +33,6 @@ interface transferImportInterface
*/
public function createTransfer($messageFile, $attachments, $schema, $filename = null);
/**
* @param /medona/message/receivezip $body
*
* @uses medona/ArchiveTransfer/create
* @return medona/message/validate
*/
//public function createMessageReceivezip($body);
/**
* Get the message import view
*
......
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