Verified Commit 672af63c authored by Alexandre Morin's avatar Alexandre Morin
Browse files

fix () : add check right parameter on check integrity

parent 0f91cf5b
Pipeline #6929 canceled with stages
......@@ -930,7 +930,7 @@ class journal
}
$resources = $archiveController->getDigitalResources($journal->archiveId, $checkAccess = false);
$journalResource = $digitalResourceController->retrieve($resources[0]->resId);
$resIntegrity = $archiveController->verifyIntegrity($journal->archiveId);
$resIntegrity = $archiveController->verifyIntegrity($journal->archiveId, false);
if (is_array($resIntegrity["error"]) && !empty($resIntegrity["error"])) {
throw \laabs::newException(
......
......@@ -167,10 +167,11 @@ trait archiveComplianceTrait
/**
* Check integrity of one or several archives giving their identifiers
* @param object $archiveIds An array of archive identifier or an archive identifier
* @param boolean $checkRight Check right for originator or archiver. if false, caller MUST control access before or after
*
* @return recordsManagement/archive[] Array of archive object
*/
public function verifyIntegrity($archiveIds)
public function verifyIntegrity($archiveIds, $checkRight = true)
{
if (!is_array($archiveIds)) {
$archiveIds = array($archiveIds);
......@@ -181,7 +182,7 @@ trait archiveComplianceTrait
$archives = $this->sdoFactory->find("recordsManagement/archive", "archiveId=['".implode("', '", $archiveIds)."']");
foreach ($archives as $archive) {
if ($this->checkArchiveIntegrity($archive)) {
if ($this->checkArchiveIntegrity($archive, $checkRight)) {
$res['success'][] = (string) $archive->archiveId;
} else {
$res['error'][] = (string) $archive->archiveId;
......@@ -208,10 +209,11 @@ trait archiveComplianceTrait
/**
* Verify archives integrity
* @param archive $archive The archive object
* @param boolean $checkRight Check right for originator or archiver. if false, caller MUST control access before or after
*
* @return bool The result of the integrity check
*/
protected function checkArchiveIntegrity($archive)
protected function checkArchiveIntegrity($archive, $checkRights = true)
{
$valid = true;
$info = 'Checking succeeded';
......@@ -222,7 +224,9 @@ trait archiveComplianceTrait
throw \laabs::newException("recordsManagement/logException", "An organization is required to check an archive integrity");
}
$this->checkRights($archive, true);
if ($checkRights) {
$this->checkRights($archive, true);
}
$archive->digitalResources = $this->getDigitalResources($archive->archiveId, $checkAccess = false);
......
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