Commit a178b739 authored by Alexandre Goldstein's avatar Alexandre Goldstein
Browse files

Maj Demo 2.3 en cours

parent 4847108a
......@@ -48,30 +48,6 @@ abstract class abstractMessage extends \ext\demorm_publique\bundle\medona\Contro
$message->xPath->registerNamespace('digitalResource', 'maarch.org:laabs:digitalResource');
}
protected function sendMessage($message)
{
$messageObject = \laabs::newInstance('medona/'.$message->type);
$messageObject->id = (string) $message->messageId;
$messageObject->comment = $message->comment;
$messageObject->date = $message->date;
$messageObject->messageIdentifier = \laabs::newInstance('medona/Identifier', $message->reference);
return $messageObject;
}
protected function sendReplyCode($code)
{
$replyCode = \laabs::newInstance('medona/Code', $code);
$replyCode->name = $this->getReplyMessage($code);
return $replyCode;
}
protected function sendError($code, $message = false, $variable = null)
{
if ($message) {
......
......@@ -79,6 +79,10 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
protected $parentsDerogation;
protected $finfo;
protected $schemas = [];
/**
* Constructor
* @param string $messageDirectory The message directory
......@@ -96,7 +100,8 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
$parentsDerogation = true,
$removeMessageTask = null,
$autoValidateSize = 0,
$autoProcessSize = 0)
$autoProcessSize = 0,
$packageSchemas = [])
{
$this->orgController = \laabs::newController('organization/organization');
$this->archiveController = \laabs::newController('recordsManagement/archive');
......@@ -123,6 +128,10 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
$this->autoProcessSize = $autoProcessSize;
$this->errors = array();
$this->finfo = new \finfo(\FILEINFO_MIME_TYPE);
$this->packageSchemas = $packageSchemas;
}
/**
......@@ -148,138 +157,54 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
*/
public function loadData($message, $filename = null)
{
$this->loadXmlFile($message);
$this->readOrgs($message);
if (!empty($message->data)) {
$message->object = json_decode($message->data);
if (isset($message->object->dataObjectPackage->descriptiveMetadata)
&& isset($message->object->dataObjectPackage->descriptiveMetadata->descriptiveMetadataClass)
&& $message->object->dataObjectPackage->descriptiveMetadataClass == 'medona/archivePackage'
&& is_object($message->object->dataObjectPackage->descriptiveMetadata->archive)) {
$message->object->dataObjectPackage->descriptiveMetadata->archive = get_object_vars($message->object->dataObjectPackage->descriptiveMetadata->archive);
}
}
}
/**
* Load file
* @param medona/message $message The medona message object
* @param string $filename The path to a message xml file
*
* @return object The Xml document
*/
public function loadXmlFile($message, $filename = null)
{
if (!$filename) {
$filename = $this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId.DIRECTORY_SEPARATOR.(string) $message->messageId.'.xml';
}
if (is_file($filename)) {
$message->xml = \laabs::newService('dependency/xml/Document');
$message->xml->load($filename);
$message->xPath = new \DOMXPath($message->xml);
$message->xPath->registerNamespace('medona', 'org:afnor:medona:1.0');
if (!isset($message->schema)) {
$this->getMessageSchema($message);
}
$message->xml->uri = $filename;
}
}
/**
* Load string
* @param medona/message $message The medona message object
* @param string $contents The xml contents of a message xml file
*
* @return object The Xml document
*/
public function loadXml($message, $contents = null)
{
if (!$contents) {
$contents = file_get_contents($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId.DIRECTORY_SEPARATOR.(string) $message->messageId.'.xml');
}
$message->xml = \laabs::newService('dependency/xml/Document');
libxml_use_internal_errors(true);
$valid = $message->xml->loadXml($contents);
if ($valid == false) {
foreach (libxml_get_errors() as $error) {
$this->sendError('101', $error->message);
}
libxml_clear_errors();
libxml_use_internal_errors(false);
$this->lifeCycleJournalController->logEvent(
'medona/reception',
'medona/message',
$message->messageId,
$message,
false
);
$exception = \laabs::newException('medona/invalidMessageException', "Malformed XML", 400);
$exception->errors = $this->errors;
throw $exception;
} else {
libxml_use_internal_errors(false);
$message->xPath = new \DOMXPath($message->xml);
$message->xPath->registerNamespace('medona', 'org:afnor:medona:1.0');
if (!isset($message->schema)) {
$this->getMessageSchema($message);
}
$message->xml->uri = $this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId.DIRECTORY_SEPARATOR.(string) $message->messageId.'.xml';
}
}
/**
* Get processed archive history message
* @param string $type
* @param string $reference
* @param string $archiver
* @param string $originator
* @param string $depositor
* @param string $archivalAgreement
* @param date $fromDate
* @param date $toDate
*
* @param string $type Type
* @param string $reference Reference
* @param string $archiver Archiver
* @param string $originator Originator
* @param string $depositor Depositor
* @param string $archivalAgreement Archival agreement
* @param date $fromDate From date
* @param date $toDate To date
* @param string $status Status
*
* @return array Array of medona/message object
*/
public function search($type, $reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $isIncoming = null)
public function search($type, $reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $status = null, $isIncoming = null)
{
$queryParams = array();
$queryString = $this->searchMessage($type, $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $isIncoming,$queryParams);
$queryString = $this->searchMessage($type, $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $status, $isIncoming,$queryParams);
return $this->sdoFactory->find('medona/message', $queryString, $queryParams, false, false, 300);
}
/**
* Search message by sender / recipient / reference / date
* @param string $type
* @param string $reference
* @param string $archiver
* @param string $originator
* @param string $depositor
* @param string $archivalAgreement
* @param date $fromDate
* @param date $toDate
*
* @param string $type Type
* @param string $reference Reference
* @param string $archiver Archiver
* @param string $originator Originator
* @param string $depositor Depositor
* @param string $archivalAgreement Archival agreement
* @param date $fromDate From date
* @param date $toDate To date
* @param string $status Status
* @param bool $isIncoming Is incoming
* @param string $queryParams Status
*
* @return medona/message[]
*/
public function searchMessage($type, $reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $isIncoming = null,&$queryParams)
public function searchMessage($type, $reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $status = null, $isIncoming = null, &$queryParams)
{
$queryParts = array();
$currentService = \laabs::getToken("ORGANIZATION");
......@@ -330,6 +255,12 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
$queryParts[] = "date <= :toDate";
$queryParams['toDate'] = $toDate;
}
if ($status) {
$queryParts[] = "status= :status";
$queryParams['status'] = $status;
}
if ($reference) {
$queryParts[] = "reference= :reference";
$queryParams['reference'] = $reference;
......@@ -461,6 +392,7 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
*/
public function create($message)
{
$message->reference = $message->reference . "_" . \laabs::newTimestamp()->getTimestamp();
// Check unique
$unique = array(
'type' => $message->type,
......@@ -758,15 +690,16 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
$message = $message = $this->sdoFactory->read('medona/message', $messageId);
$message->object = json_decode($message->data);
$status = '';
if ($message->schema !== 'medona') {
$messageController = \laabs::newController($message->schema.'/'.$message->type);
$status = $messageController->retry($message);
} else {
// TODO
$fromStatus = ['error','processing','toBeModified'];
if (!in_array($message->status, $fromStatus)) {
$this->sendError("101", "Le statut du message est incorrect.");
}
$this->changeStatus($messageId, $status);
if ($message->status == 'toBeModified') {
$this->changeStatus($messageId, 'Modified');
} else {
$this->changeStatus($messageId, 'accepted');
}
$this->lifeCycleJournalController->logEvent(
'medona/retry',
......@@ -1084,7 +1017,7 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
{
// $queryParts = $this->searchMessage(null, $reference);
$queryParams = array();
$queryString = $this->searchMessage(null, $reference, null, null, null, null, null, null, null,$queryParams);
$queryString = $this->searchMessage(null, $reference, null, null, null, null, null, null, null,null,$queryParams);
$message = $this->sdoFactory->find('medona/message', $queryString, $queryParams, false, false, 300);
......@@ -1099,7 +1032,7 @@ class message extends \ext\thirdPartyArchiving\bundle\medona\Controller\message
if ($nbMessages != 1) {
throw new \core\Exception\NotFoundException("The message does not exist");
}
return $messages;
}
......
......@@ -39,6 +39,7 @@ class ArchiveTransferComposition extends \ext\archivesPubliques\bundle\seda\Cont
}
$message->reference = $message->reference . "_" . \laabs::newTimestamp()->getTimestamp();
var_dump($message);exit;
if ($this->sdoFactory->exists('medona/message', array('type'=>$message->type, 'senderOrgRegNumber'=>$message->senderOrgRegNumber, 'reference'=>$message->reference))) {
throw \laabs::newException("seda/invalidMessageException", "L'identifiant du message existe déjà.");
......@@ -53,4 +54,3 @@ class ArchiveTransferComposition extends \ext\archivesPubliques\bundle\seda\Cont
return $message->messageId;
}
}
\ No newline at end of file
......@@ -60,8 +60,9 @@ class authentication extends \presentation\maarchRM\Presenter\auth\authenticatio
$view->addHeaders();
$view->addContentFile("auth/userAccount/login/form.html");
$view->setSource('nextExecution', date_format($date, 'H:i:s'));
$view->setSource('nextExecution', date_format($date, 'H:i:s'));
$view->setSource('logo', $this->logoUri);
$view->setSource('loginBackground', $this->loginBackground);
$view->translate();
$view->merge();
......
......@@ -26,7 +26,7 @@
Caps Lock On
</div>
<div style="color: red;">
<p>Ceci est une version de démo de Maarch RM V2.2 avec son extension "Archives Publiques" (<a href="//cdn.maarch.org/demorm/MaarchRMv2.2_GuideDeVisite_spherePublique.pdf" target="_blank">Guide de visite</a>)</p>
<p>Ceci est une version de démo de Maarch RM V2.3 avec son extension "Archives Publiques" (<a href="//cdn.maarch.org/demorm/MaarchRMv2.2_GuideDeVisite_spherePublique.pdf" target="_blank">Guide de visite</a>)</p>
<p>Le jeu de démo est disponible <a href="//cdn.maarch.org/demorm/ArchiveTransfer_RM_AP.zip" target="_blank">ici</a></p>
<p>Prochaine remise à zéro des données à <?merge nextExecution ?> (Europe / Paris)</p>
<hr/>
......@@ -85,7 +85,16 @@
<span id="loginPasswordNotSame">Passwords are not the same</span>
</div>
</div>
<style>
[?merge loginBackground ?]
.modal {
text-align: center;
padding: 0!important;
}
</style>
<script>
document.onkeydown = function (e) { //check if capslock key was pressed in the whole window
e = e || event;
......
......@@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" type="image/x-icon" href="[?merge .favicon ?]" />
<meta class="datePicker">
<!--
stylesheets
-->
......@@ -42,6 +43,4 @@
</script>
<!-- End Matomo Code -->
<title><?merge .title ?> </title>
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