Commit ad53bf18 authored by Arnaud Pauget's avatar Arnaud Pauget

Merge branch 'Support/2.6.X' into 'master'

Support/2.6.x

See merge request !467
parents e8006135 dbbcf6a2
Pipeline #7987 failed with stages
# CHANGELOG
## Version 2.6.3
- `Fixed` Possiblité de verser en mode transactionnel via bordereau, avec des pièces de plus de 2Mo
- `Added` Possibilité de récupérer un contenu binaire d'une pièce d'archive directement via un appel en Web Service (voir nouvelle route pour les comptes de service dans le fichier configuration.ini.default)
## Version 2.6.2
- `Added` Possibiliter de récupérer un lien de téléchargement à la place du contenu binaire dans les réponses à l'appel web service de consultation
- `Added` Possibilité de récupérer un lien de téléchargement à la place du contenu binaire dans les réponses à l'appel web service de consultation
## Version 2.6.1
......
2.6.2
\ No newline at end of file
2.6.3
\ No newline at end of file
......@@ -439,6 +439,10 @@ servicePrivileges = "[
'description' : 'Mise à jour de la durée d\'utilité administrative'
},
{
'serviceURI' : 'recordsManagement/archive/read_archiveId_Digitalresource_resId_Contents',
'description' : 'Récupérer directement le contenu d\'une ressource d\'archive'
},
{
'serviceURI': '*',
'description' : 'Tous les droits'
}
......
......@@ -296,7 +296,9 @@ class ArchiveTransfer extends abstractMessage
}
}
} elseif (is_object($attachment)) {
if (filter_var($attachment->data, FILTER_VALIDATE_URL)) {
if (is_resource($attachment->data)) {
$data = base64_decode(stream_get_contents($attachment->data));
} elseif (filter_var($attachment->data, FILTER_VALIDATE_URL)) {
$data = stream_get_contents($attachment->data);
} elseif (preg_match('%^[a-zA-Z0-9\\\\/+]*={0,2}$%', $attachment->data)) {
$data = base64_decode($attachment->data);
......
......@@ -585,6 +585,58 @@ trait archiveAccessTrait
}
/**
* Retrieve stream of an archive resource contents
*
* @param string $archiveId The archive identifier
* @param string $resId The resource identifier
*
* @return stream Archive resource contents in a stream
*/
public function getBinaryContents($archiveId, $resId)
{
$accountController = \laabs::newController('auth/userAccount');
$accountController->isAuthorized('user');
$archive = $this->sdoFactory->read('recordsManagement/archive', $archiveId);
$this->checkRights($archive, false);
try {
$digitalResource = $this->digitalResourceController->retrieve($resId);
$resourceIntegrity = true;
foreach ($digitalResource->address as $address) {
if (!$address->integrityCheckResult) {
$resourceIntegrity = false;
}
}
if (!$resourceIntegrity) {
$this->logIntegrityCheck($archive, "Invalid resource", $digitalResource, false);
}
if ((!$this->accessVerification($archive)) || $digitalResource->archiveId != $archiveId) {
throw \laabs::newException('recordsManagement/accessDeniedException', "Permission denied");
}
$this->logConsultation($archive, $digitalResource);
} catch (\Exception $e) {
$this->logConsultation($archive, $digitalResource, false);
throw $e;
}
$filename = $digitalResource->fileName;
if (!$filename) {
$filename = $digitalResource->resId;
}
$response = \laabs::kernel()->response;
$response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"');
return $digitalResource->getHandler();
}
/**
* Retrieve an archive by its id
*
* @param string $archiveId The archive identifier
......
......@@ -112,6 +112,13 @@ interface archiveInterface
public function readContents_archiveId__resId_();
/**
* Retrieve stream of an archive content document (CDO)
*
* @action recordsManagement/archive/getBinaryContents
*/
public function read_archiveId_Digitalresource_resId_Contents();
/**
* Check if archive exists
*
* @action recordsManagement/archive/exists
......
Markdown is supported
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