Skip to content
Snippets Groups Projects
Verified Commit b1627f7e authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #15050 TIME 1 Migrate exportSeda config + fix export seda action

parent 5900deb5
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@
"accessRuleCode": "AR039",
"certificateSSL": "",
"userAgent": "service",
"statusReplyReceived": "REPLY_SEDA",
"externalSAE": {
"retentionRules": [
{
......
......@@ -3,6 +3,7 @@ php ./migrateConfigXml.php # mettre en premier
php ./migrateNotificationsProperties.php
php ./migrateNotificationsConfig.php
php ./migrateRemoteSignatureBookConfig.php
php ./migrateExportSedaConfig.php
php ./migrateImages.php
php ./migrateCustomLang.php
php ./migrateBasketListDisplay.php
......
<?php
require '../../vendor/autoload.php';
chdir('../..');
$nonReadableFiles = [];
$migrated = 0;
$customs = scandir('custom');
foreach ($customs as $custom) {
if (in_array($custom, ['custom.json', 'custom.xml', '.', '..'])) {
continue;
}
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $custom]);
$GLOBALS['customId'] = $custom;
$configPath = "custom/{$custom}/apps/maarch_entreprise/xml/config.json";
$exportSedaConfigPath = "modules/export_seda/xml/config.xml";
if (file_exists($configPath)) {
if (!is_readable($configPath) || !is_writable($configPath)) {
$nonReadableFiles[] = $configPath;
continue;
}
if (is_readable("custom/{$custom}/{$exportSedaConfigPath}") && is_writable("custom/{$custom}/{$exportSedaConfigPath}")) {
$exportSedaFilePath = "custom/{$custom}/{$exportSedaConfigPath}";
} elseif (is_readable($exportSedaConfigPath) && is_writable($exportSedaConfigPath)) {
$exportSedaFilePath = $exportSedaConfigPath;
} else {
printf("Aucun fichier de configuration de export seda trouvé pour le custom {$custom}\n");
continue;
}
$loadedExportSedaXml = simplexml_load_file($exportSedaFilePath);
if ($loadedExportSedaXml) {
$file = file_get_contents($configPath);
$file = json_decode($file, true);
$exportSeda = [];
$exportSeda['sae'] = 'MaarchRM';
$exportSeda['token'] = (string)$loadedExportSedaXml->CONFIG->token;
$exportSeda['urlSAEService'] = (string)$loadedExportSedaXml->CONFIG->urlSAEService;
$exportSeda['senderOrgRegNumber'] = (string)$loadedExportSedaXml->CONFIG->senderOrgRegNumber;
$exportSeda['accessRuleCode'] = (string)$loadedExportSedaXml->CONFIG->accessRuleCode;
$exportSeda['certificateSSL'] = (string)$loadedExportSedaXml->CONFIG->certificateSSL;
$exportSeda['userAgent'] = (string)$loadedExportSedaXml->CONFIG->userAgent;
$exportSeda['statusReplyReceived'] = 'REPLY_SEDA';
$exportSeda['M2M']['gec'] = 'maarch_courrier';
$file['exportSeda'] = $exportSeda;
$fp = fopen($configPath, 'w+');
fwrite($fp, json_encode($file, JSON_PRETTY_PRINT));
fclose($fp);
$migrated++;
}
}
}
foreach ($nonReadableFiles as $file) {
printf("The file %s it is not readable or not writable.\n", $file);
}
printf($migrated . " custom(s) avec config.xml (export seda) trouvé(s) et migré(s).\n");
......@@ -52,7 +52,7 @@ foreach ($customs as $custom) {
$file['config']['maarchUrl'] = (string)$loadedVisaXml->CONFIG->applicationUrl;
}
$fp = fopen($configPath, 'a+');
$fp = fopen($configPath, 'w+');
fwrite($fp, json_encode($file, JSON_PRETTY_PRINT));
fclose($fp);
......
......@@ -3,48 +3,24 @@
<CONFIG>
<name>export_seda</name>
<comment>_EXPORT_SEDA_COMMENT</comment>
<file_prefix>seda</file_prefix>
<loaded>true</loaded>
<sae>MaarchRM</sae>
<token>phdF9WkJuTKkDuPXoqDZuCFEQT7En7YqsVROsdD1HoNZV7jD5+XyCmlXwiQKoUdiii3QV4pIbPXC66kM8wxQUgL74LW6+dEf0buKoauGyVd8btoSWBK7M3Jx5T+SdRzp</token>
<urlSAEService>http://10.2.95.79:1506</urlSAEService>
<token>phdF9WkJuTKkDuPXoqDZuCFEQT7En7YqsVROsdD1HoNZV7jD5+XyCrrA61NWmmXVWU7AR5Sw+wq9eazIrIiGnLNDPB6BqMMum8fauclhcR2nklsEdTlveHjcGp/WIDlQ</token>
<urlSAEService>https://demo-ap.maarchrm.com</urlSAEService>
<urlSAE>https://demo-ap.maarchrm.com/transfer/sent</urlSAE>
<directoryMessage>/tmp/</directoryMessage>
<senderOrgRegNumber>org_987654321_DGS_SA</senderOrgRegNumber>
<accessRuleCode>AR039</accessRuleCode>
<deleteData>true</deleteData>
<certificateSSL></certificateSSL>
<userAgent>service</userAgent>
</CONFIG>
<externalSAE>
<id>otherSAE</id>
<retentionRules>
<retentionRule>
<id>id1</id>
<label>label1</label>
</retentionRule>
<retentionRule>
<id>id2</id>
<label>label2</label>
</retentionRule>
</retentionRules>
<archiveEntities>
<archiveEntity>
<id>id1</id>
<label>label1</label>
</archiveEntity>
<archiveEntity>
<id>id2</id>
<label>label2</label>
</archiveEntity>
</archiveEntities>
<archivalAgreements>
<archivalAgreement>
<id>id1</id>
<label>label1</label>
</archivalAgreement>
<archivalAgreement>
<id>id2</id>
<label>label2</label>
</archivalAgreement>
</archivalAgreements>
</externalSAE>
<TABLENAME/>
<HISTORY>
<sedaup>true</sedaup>
<sedaadd>true</sedaadd>
<sedadel>true</sedadel>
</HISTORY>
<M2M>
<gec>maarch_courrier</gec>
</M2M>
......
......@@ -14,41 +14,7 @@
<accessRuleCode>AR039</accessRuleCode>
<deleteData>true</deleteData>
<certificateSSL></certificateSSL>
<userAgent>service</userAgent>
</CONFIG>
<externalSAE>
<id>otherSAE</id>
<retentionRules>
<retentionRule>
<id>id1</id>
<label>label1</label>
</retentionRule>
<retentionRule>
<id>id2</id>
<label>label2</label>
</retentionRule>
</retentionRules>
<archiveEntities>
<archiveEntity>
<id>id1</id>
<label>label1</label>
</archiveEntity>
<archiveEntity>
<id>id2</id>
<label>label2</label>
</archiveEntity>
</archiveEntities>
<archivalAgreements>
<archivalAgreement>
<id>id1</id>
<label>label1</label>
</archivalAgreement>
<archivalAgreement>
<id>id2</id>
<label>label2</label>
</archivalAgreement>
</archivalAgreements>
</externalSAE>
<TABLENAME/>
<HISTORY>
<sedaup>true</sedaup>
......@@ -58,4 +24,4 @@
<M2M>
<gec>maarch_courrier</gec>
</M2M>
</root>
</root>
\ No newline at end of file
......@@ -147,7 +147,7 @@ class SedaController
];
$document = ResModel::getById(['select' => ['docserver_id', 'path', 'filename', 'version', 'fingerprint'], 'resId' => $args['resource']['res_id']]);
if (!empty($document['docserver_id']) && empty($document['filename'])) {
if (!empty($document['docserver_id']) && !empty($document['filename'])) {
$convertedDocument = AdrModel::getDocuments([
'select' => ['docserver_id', 'path', 'filename', 'fingerprint'],
'where' => ['res_id = ?', 'type = ?', 'version = ?'],
......@@ -182,7 +182,7 @@ class SedaController
return ['errors' => 'Document not found on docserver'];
}
$return['data']['archiveUnits'][0] = [
$return['archiveUnits'][0] = [
'id' => 'letterbox_' . $args['resource']['res_id'],
'label' => $args['resource']['subject'],
'type' => 'mainDocument',
......@@ -190,7 +190,7 @@ class SedaController
];
if ($args['getFile']) {
$return['data']['archiveUnits'][0]['filePath'] = $pathToDocument;
$return['archiveUnits'][0]['filePath'] = $pathToDocument;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment