Verified Commit cb18ec2e authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: feat(archive) - update archive request settings and improve error...

:sparkles: feat(archive) - update archive request settings and improve error handling for unexpected HTTP status codes
1 merge request!79Resolve "[Orchestrator] - Automatic Archiving Based on SupAnn Resource States"
Pipeline #32402 failed with stages
in 17 seconds
Showing with 4 additions and 6 deletions
+4 -6
...@@ -55,17 +55,15 @@ class Archive implements EndpointInterface ...@@ -55,17 +55,15 @@ class Archive implements EndpointInterface
// Set the archive endpoint and method using the same WebServiceCall object // Set the archive endpoint and method using the same WebServiceCall object
$archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]); $archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
$webServiceCall->setCurlSettings($archiveUrl, [], 'POST'); // Update settings for the archive request $webServiceCall->setCurlSettings($archiveUrl, NULL, 'POST'); // Update settings for the archive request
$response = $webServiceCall->execute(); $response = $webServiceCall->execute();
print_r([$response]); // Check if the HTTP status code is 204
exit; if ($webServiceCall->getHttpStatusCode() === 204) {
if (isset($response['success']) && $response['success'] === true) {
$result[$task['dn']]['result'] = "User successfully archived."; $result[$task['dn']]['result'] = "User successfully archived.";
$this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2'); $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2');
} else { } else {
throw new Exception("Invalid API response format"); throw new Exception("Unexpected HTTP status code: " . $webServiceCall->getHttpStatusCode());
} }
} catch (Exception $e) { } catch (Exception $e) {
$result[$task['dn']]['result'] = "Error archiving user: " . $e->getMessage(); $result[$task['dn']]['result'] = "Error archiving user: " . $e->getMessage();
......
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