Verified Commit 91221738 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

remove medona XML messages iplementation

parent 8a8212b6
......@@ -70,34 +70,9 @@ class Acknowledgement extends abstractMessage implements AcknowledgementInterfac
}
try {
if ($message->schema != 'medona') {
$archiveTransferReplyController = \laabs::newController($message->schema.'/Acknowledgement');
$archiveTransferReplyController->send($message);
} else {
/*$archiveTransferReply = $this->sendMessage($message);
$message->object = $archiveTransferReply;
$archiveTransferReply->replyCode = $this->sendReplyCode($message->replyCode);
if (isset($message->requestReference)) {
$archiveTransferReply->messageRequestIdentifier = \laabs::newInstance('medona/Identifier', $message->requestReference);
}
if (isset($message->operationDate)) {
$archiveTransferReply->grantDate = (string) $message->operationDate;
}
$archiveTransferReply->archivalAgency = $this->sendOrganization($message->senderOrg);
$archiveTransferReply->transferringAgency = $this->sendOrganization($message->recipientOrg);
// Generate XML
$this->generate($message);
$this->save($message);*/
}
$archiveTransferReplyController = \laabs::newController($message->schema.'/Acknowledgement');
$archiveTransferReplyController->send($message);
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -49,22 +49,20 @@ class ArchivalProfileModificationNotification extends ArchiveNotification
$messages = array();
if (!\laabs::hasBundle("seda")) {
$this->retentionRuleController = \laabs::newController('recordsManagement/retentionRule');
$retentionRule = $this->retentionRuleController->read($profile->retentionRuleCode);
$profile->retentionRuleDuration = $retentionRule->duration;
$profile->retentionRuleFinalDisposition = $retentionRule->finalDisposition;
$this->accessRuleController = \laabs::newController('recordsManagement/accessRule');
$accessRule = $this->accessRuleController->edit($profile->accessRuleCode);
$profile->accessRuleDuration = $accessRule->duration;
}
$this->retentionRuleController = \laabs::newController('recordsManagement/retentionRule');
$retentionRule = $this->retentionRuleController->read($profile->retentionRuleCode);
$profile->retentionRuleDuration = $retentionRule->duration;
$profile->retentionRuleFinalDisposition = $retentionRule->finalDisposition;
$this->accessRuleController = \laabs::newController('recordsManagement/accessRule');
$accessRule = $this->accessRuleController->edit($profile->accessRuleCode);
$profile->accessRuleDuration = $accessRule->duration;
foreach ($recipients as $recipient) {
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->type = "ArchivalProfileModificationNotification";
$message->schema = "medona";
$message->schema = "recordsManagement";
$message->status = "sent";
$message->date = \laabs::newDatetime(null, "UTC");
$message->receptionDate = $message->date;
......
......@@ -46,7 +46,7 @@ class ArchiveConversionRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->schema = "medona";
$message->schema = "recordsManagement";
$message->type = "ArchiveConversionRequest";
$message->status = 'processWait';
$message->date = \laabs::newDatetime(null, "UTC");
......
......@@ -182,7 +182,7 @@ class ArchiveDeliveryRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$schema = "medona";
$schema = "recordsManagement";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -219,22 +219,10 @@ class ArchiveDeliveryRequest extends abstractMessage
}
try {
if ($message->schema != 'medona') {
$archiveDeliveryRequestController = \laabs::newController($message->schema.'/ArchiveDeliveryRequest');
$archiveDeliveryRequestController->send($message);
} else {
$archiveDeliveryRequest = $this->sendMessage($message);
$message->object = $archiveDeliveryRequest;
$archiveDeliveryRequestController = \laabs::newController($message->schema.'/ArchiveDeliveryRequest');
$archiveDeliveryRequest->requester = $this->sendOrganization($message->senderOrg);
if ($userName) {
$archiveDeliveryRequest->requester->userName = $userName;
}
$archiveDeliveryRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$archiveDeliveryRequestController->send($message);
$message->object->unitIdentifier = $message->unitIdentifier;
}
$operationResult = true;
$this->create($message);
......
......@@ -102,19 +102,9 @@ class ArchiveDeliveryRequestReply extends abstractMessage
try {
mkdir($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId, 0777, true);
if ($message->schema != 'medona') {
$archiveDeliveryRequestReplyController = \laabs::newController($message->schema.'/ArchiveDeliveryRequestReply');
$archiveDeliveryRequestReplyController->send($message);
} else {
$archiveDeliveryRequestReply = $this->sendMessage($message);
$message->object = $archiveDeliveryRequestReply;
$archiveDeliveryRequestReply->requester = $this->sendOrganization($message->senderOrg);
$archiveDeliveryRequestReply->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$archiveDeliveryRequestReplyController = \laabs::newController($message->schema.'/ArchiveDeliveryRequestReply');
$archiveDeliveryRequestReplyController->send($message);
$operationResult = true;
} catch (\Exception $e) {
$message->status = "invalid";
......
......@@ -41,7 +41,7 @@ class ArchiveDestructionNotification extends ArchiveNotification
$message->messageId = \laabs::newId();
$message->type = "ArchiveDestructionNotification";
$schema = "medona";
$schema = "recordsManagement";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -62,16 +62,9 @@ class ArchiveDestructionNotification extends ArchiveNotification
$message->dataObjectCount = count($message->archive);
try {
if ($message->schema != 'medona') {
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
} else {
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -105,7 +105,7 @@ class ArchiveDestructionRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$schema = "medona";
$schema = "recordsManagement";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -133,21 +133,8 @@ class ArchiveDestructionRequest extends abstractMessage
$message->unitIdentifier[] = $unitIdentifier;
}
if ($message->schema != 'medona') {
$archiveDestructionRequestController = \laabs::newController($message->schema.'/ArchiveDestructionRequest');
$archiveDestructionRequestController->send($message);
} else {
$archiveDestructionRequest = $this->sendMessage($message);
$message->object = $archiveDestructionRequest;
$archiveDestructionRequest->originatingAgency = $this->sendOrganization($message->senderOrg);
$archiveDestructionRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$message->object->unitIdentifier = $message->unitIdentifier;
$this->generate($message);
$this->save($message);
}
$archiveDestructionRequestController = \laabs::newController($message->schema.'/ArchiveDestructionRequest');
$archiveDestructionRequestController->send($message);
$this->create($message);
} catch (\Exception $e) {
......
......@@ -45,7 +45,7 @@ class ArchiveModificationNotification extends ArchiveNotification
$message->messageId = \laabs::newId();
$message->type = "ArchiveModificationNotification";
$schema = "medona";
$schema = "recordsManagement";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$schema = "seda";
}
......@@ -77,23 +77,9 @@ class ArchiveModificationNotification extends ArchiveNotification
$message->dataObjectCount = count($message->archive);
try {
if ($message->schema != 'medona') {
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
$archiveModificationNotificationController = \laabs::newController($message->schema.'/ArchiveModificationNotification');
$archiveModificationNotificationController->send($message);
} else {
$archiveModificationNotification = $this->sendMessage($message);
$message->object = $archiveModificationNotification;
$archiveModificationNotification->originatingAgency = $this->sendOrganization($message->senderOrg);
$archiveModificationNotification->archivalAgency = $this->sendOrganization($message->recipientOrg);
$message->object->unitIdentifier = $message->unitIdentifier;
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -177,19 +177,9 @@ class ArchiveRestitution extends abstractMessage
try {
mkdir($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId, 0777, true);
if ($message->schema != 'medona') {
$archiveRestitutionController = \laabs::newController($message->schema.'/ArchiveRestitution');
$archiveRestitutionController->send($message);
} else {
$archiveRestitution = $this->sendMessage($message);
$message->object = $archiveRestitution;
$archiveRestitution->requester = $this->sendOrganization($message->senderOrg);
$archiveRestitution->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$archiveRestitutionController = \laabs::newController($message->schema.'/ArchiveRestitution');
$archiveRestitutionController->send($message);
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -129,7 +129,7 @@ class ArchiveRestitutionRequest extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->schema = "medona";
$message->schema = "recordsManagement";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$message->schema = "seda";
}
......@@ -157,23 +157,8 @@ class ArchiveRestitutionRequest extends abstractMessage
$message->unitIdentifier[] = $unitIdentifier;
}
if ($message->schema != 'medona') {
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
} else {
$archiveRestitutionRequest = $this->sendMessage($message);
$message->object = $archiveRestitutionRequest;
$archiveRestitutionRequest->requester = $this->sendOrganization($message->senderOrg);
if ($userName) {
$archiveRestitutionRequest->requester->userName = $userName;
}
$archiveRestitutionRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
$operationResult = true;
......@@ -224,19 +209,8 @@ class ArchiveRestitutionRequest extends abstractMessage
$this->readOrgs($message); // read org names, addresses, communications, contacts
try {
if ($message->schema != 'medona') {
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
} else {
$archiveRestitutionRequest = $this->sendMessage($message);
$message->object = $archiveRestitutionRequest;
$archiveRestitutionRequest->requester = $this->sendOrganization($message->senderOrg);
$archiveRestitutionRequest->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
$message->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $requestMessage);
foreach ($message->unitIdentifier as $unitIdentifier) {
......
......@@ -74,19 +74,9 @@ class ArchiveRestitutionRequestReply extends abstractMessage
try {
mkdir($this->messageDirectory.DIRECTORY_SEPARATOR.(string) $message->messageId, 0777, true);
if ($message->schema != 'medona') {
$archiveRestitutionRequestReplyController = \laabs::newController($message->schema.'/ArchiveRestitutionRequestReply');
$archiveRestitutionRequestReplyController->send($message);
} else {
$archiveRestitutionRequestReply = $this->sendMessage($message);
$message->object = $archiveRestitutionRequestReply;
$archiveRestitutionRequestReply->requester = $this->sendOrganization($message->senderOrg);
$archiveRestitutionRequestReply->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$archiveRestitutionRequestReplyController = \laabs::newController($message->schema.'/ArchiveRestitutionRequestReply');
$archiveRestitutionRequestReplyController->send($message);
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -82,57 +82,10 @@ class ArchiveTransferReply extends abstractMessage implements ArchiveTransferRep
$message->senderOrg = $recipientOrg;
}
/*if ($archives) {
foreach ($archives as $archive) {
$unitIdentifier = \laabs::newInstance("medona/unitIdentifier");
$unitIdentifier->messageId = $message->messageId;
$unitIdentifier->objectId = (string) $archive->archiveId;
$unitIdentifier->objectClass = "recordsManagement/archive";
$message->unitIdentifier[] = $unitIdentifier;
}
}
$message->archive = $archives;*/
/*$message->lifeCycleEventId = \laabs::newTokenList();
foreach ($archives as $archive) {
foreach ($archives as $archive) {
if ($archive->lifeCycleEvent) {
foreach ($archive->lifeCycleEvent as $event) {
$message->lifeCycleEventId[] = (string) $event->eventId;
}
}
}
}*/
try {
if ($message->schema != 'medona') {
$archiveTransferReplyController = \laabs::newController($message->schema.'/ArchiveTransferReply');
$archiveTransferReplyController->send($message);
} else {
$archiveTransferReply = $this->sendMessage($message);
$message->object = $archiveTransferReply;
$archiveTransferReply->replyCode = $this->sendReplyCode($message->replyCode);
if (isset($message->requestReference)) {
$archiveTransferReply->messageRequestIdentifier = \laabs::newInstance('medona/Identifier', $message->requestReference);
}
if (isset($message->operationDate)) {
$archiveTransferReply->grantDate = (string) $message->operationDate;
}
$archiveTransferReply->archivalAgency = $this->sendOrganization($message->senderOrg);
$archiveTransferReply->transferringAgency = $this->sendOrganization($message->recipientOrg);
// Generate XML
$this->generate($message);
$archiveTransferReplyController = \laabs::newController($message->schema.'/ArchiveTransferReply');
$archiveTransferReplyController->send($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
$message->status = "error";
......
......@@ -144,7 +144,7 @@ class ArchiveTransferSending extends abstractMessage
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->schema = "medona";
$message->schema = "recordsManagement";
if (\laabs::hasBundle('seda') && $archives[0]->descriptionClass == 'archivesPubliques/content') {
$message->schema = "seda";
}
......@@ -179,19 +179,8 @@ class ArchiveTransferSending extends abstractMessage
$message->archive = $archives;
$message->dataObjectCount = count($archives);
if ($message->schema != 'medona') {
$archiveTransferController = \laabs::newController($message->schema.'/ArchiveTransfer');
$archiveTransferController->send($message);
} else {
$archiveTransfer = $this->sendMessage($message);
$message->object = $archiveTransfer;
$archiveTransfer->transferringAgency = $this->sendOrganization($message->senderOrg);
$archiveTransfer->archivalAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$archiveTransferController = \laabs::newController($message->schema.'/ArchiveTransfer');
$archiveTransferController->send($message);
$this->create($message);
$operationResult = true;
......
......@@ -78,22 +78,9 @@ class AuthorizationControlAuthorityRequest extends AuthorizationRequest
$message->authorizationRequestContent->requester = $requestMessage->senderOrg;
try {
if ($message->schema != 'medona') {
$authorizationControlAuthorityRequestController = \laabs::newController($message->schema.'/AuthorizationControlAuthorityRequest');
$authorizationControlAuthorityRequestController->send($message);
} else {
$authorizationControlAuthorityRequest = $this->sendMessage($message);
$message->object = $authorizationControlAuthorityRequest;
$authorizationControlAuthorityRequestController = \laabs::newController($message->schema.'/AuthorizationControlAuthorityRequest');
$authorizationControlAuthorityRequestController->send($message);
$authorizationControlAuthorityRequest->archivalAgency = $this->sendOrganization($message->senderOrg);
$authorizationControlAuthorityRequest->controlAuthority = $this->sendOrganization($message->recipientOrg);
$message->object->unitIdentifier = $requestMessage->unitIdentifier;
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
$message->status = "invalid";
......
......@@ -64,21 +64,9 @@ class AuthorizationControlAuthorityRequestReply extends abstractMessage
$this->readOrgs($message);
try {
if ($message->schema != 'medona') {
$authorizationControlAuthorityRequestReplyController = \laabs::newController($message->schema.'/AuthorizationControlAuthorityRequestReply');
$authorizationControlAuthorityRequestReplyController->send($message);
$authorizationControlAuthorityRequestReplyController = \laabs::newController($message->schema.'/AuthorizationControlAuthorityRequestReply');
$authorizationControlAuthorityRequestReplyController->send($message);
} else {
$authorizationControlAuthorityRequestReply = $this->sendMessage($message);
$message->object = $authorizationControlAuthorityRequestReply;
$authorizationControlAuthorityRequestReply->archivalAgency = $this->sendOrganization($message->senderOrg);
$authorizationControlAuthorityRequestReply->controlAuthority = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
......
......@@ -67,22 +67,9 @@ class AuthorizationOriginatingAgencyRequest extends AuthorizationRequest
$message->authorizationRequestContent->requester = $requestMessage->senderOrg;
try {
if ($message->schema != 'medona') {
$authorizationOriginatingAgencyRequestController = \laabs::newController($message->schema.'/AuthorizationOriginatingAgencyRequest');
$authorizationOriginatingAgencyRequestController->send($message);
} else {
$authorizationOriginatingAgencyRequest = $this->sendMessage($message);
$message->object = $authorizationOriginatingAgencyRequest;
$authorizationOriginatingAgencyRequestController = \laabs::newController($message->schema.'/AuthorizationOriginatingAgencyRequest');
$authorizationOriginatingAgencyRequestController->send($message);
$authorizationOriginatingAgencyRequest->archivalAgency = $this->sendOrganization($message->senderOrg);
$authorizationOriginatingAgencyRequest->originatingAgency = $this->sendOrganization($message->recipientOrg);
$message->object->unitIdentifier = $requestMessage->unitIdentifier;
$this->generate($message);
$this->save($message);
}
$operationResult = true;
} catch (\Exception $e) {
$message->status = "invalid";
......
......@@ -79,20 +79,8 @@ class AuthorizationOriginatingAgencyRequestReply extends abstractMessage
}
try {
if ($message->schema != 'medona') {
$authorizationOriginatingAgencyRequestReplyController = \laabs::newController($message->schema.'/AuthorizationOriginatingAgencyRequestReply');
$authorizationOriginatingAgencyRequestReplyController->send($message);
} else {
$authorizationOriginatingAgencyRequestReply = $this->sendMessage($message);
$message->object = $authorizationOriginatingAgencyRequestReply;
$authorizationOriginatingAgencyRequestReply->archivalAgency = $this->sendOrganization($message->senderOrg);
$authorizationOriginatingAgencyRequestReply->originatingAgency = $this->sendOrganization($message->recipientOrg);
$this->generate($message);
$this->save($message);
}
$authorizationOriginatingAgencyRequestReplyController = \laabs::newController($message->schema.'/AuthorizationOriginatingAgencyRequestReply');
$authorizationOriginatingAgencyRequestReplyController->send($message);
$this->sdoFactory->update($requestMessage, "medona/message");
} catch (\Exception $e) {
......
......@@ -48,43 +48,6 @@ abstract class abstractMessage extends message
$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) {
array_push($this->errors, new \core\Error($message, $variable, $code));
} else {
array_push($this->errors, new \core\Error($this->getReplyMessage($code), $variable, $code));
}
if ($this->replyCode == null) {
$this->replyCode = $code;
}
}