chg: [galaxyClusters] Improved logging and error reporting

pull/6120/head
mokaddem 2020-05-22 09:04:01 +02:00
parent ad81a03813
commit 95cbfa2878
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
4 changed files with 9 additions and 11 deletions

View File

@ -279,10 +279,10 @@ class Galaxy extends AppModel
$saveResult = $this->GalaxyCluster->captureClusters($user, $existingGalaxy, $clusters, $forceUpdate=$forceUpdate, $orgId=$user['org_id']);
$results['imported'] += $saveResult['imported'];
$results['ignored'] += $saveResult['ignored'];
$results['failed'] += $saveResult['failed'];
$results['errors'] = array_merge($results['errors'], $saveResult['errors']);
}
$results['success'] = $results['imported'] > 0;
debug($results);
return $results;
}

View File

@ -220,21 +220,18 @@ class GalaxyCluster extends AppModel
public function captureClusters($user, $galaxy, $clusters, $forceUpdate=false, $orgId=0)
{
$importResult = array('success' => false, 'imported' => 0, 'ignored' => 0, 'errors' => array());
$importResult = array('success' => false, 'imported' => 0, 'ignored' => 0, 'failed' => 0,'errors' => array());
foreach ($clusters as $k => $cluster) {
$cluster['GalaxyCluster']['galaxy_id'] = $galaxy['Galaxy']['id'];
$saveResult = $this->captureCluster($user, $cluster, $fromPull=true, $orgId=$orgId);
if ($saveResult) {
$importResult['imported'] += 1;
} else {
$importResult['ignored'] += 1;
}
$importResult['imported'] += $saveResult['imported'];
$importResult['ignored'] += $saveResult['ignored'];
$importResult['failed'] += $saveResult['failed'];
$importResult['errors'] = array_merge($importResult['errors'], $saveResult['errors']);
}
if ($importResult['imported'] > 0) {
$importResult['success'] = true;
}
$importResult['errors'] = array_merge($importResult['errors'], $saveResult['errors']);
debug($importResult);
return $importResult;
}
@ -287,7 +284,7 @@ class GalaxyCluster extends AppModel
} else {
$orgc = array('Orgc' => array('uuid' => $cluster['GalaxyCluster']['Orgc']['uuid']));
}
if ($this->OrgBlacklist->hasAny(array('OrgBlacklist.org_uuid' => $orgc['Orgc']['uuid']))) {
if ($cluster['GalaxyCluster']['orgc_id'] != 0 && $this->OrgBlacklist->hasAny(array('OrgBlacklist.org_uuid' => $orgc['Orgc']['uuid']))) {
$results['failed']++; // Organisation blacklisted
return $results;
}

View File

@ -60,7 +60,7 @@ class GalaxyClusterRelationTag extends AppModel
$saveResult = $this->save(array('galaxy_cluster_relation_id' => $galaxyClusterRelationId, 'tag_id' => $tagId));
$allSaved = $allSaved && $saveResult;
if (!$saveResult) {
debug($saveResult);
$this->Log->createLogEntry($user, 'attachTags', 'GalaxyClusterRelationTag', 0, __('Could not attach tag %s', $tagName), __('relation (%s)', $galaxyClusterRelationId));
}
}
}

View File

@ -24,6 +24,7 @@ class Log extends AppModel
'acceptRegistrations',
'add',
'admin_email',
'attachTags',
'auth',
'auth_fail',
'blacklisted',