Updated code fix.
This commit is contained in:
@@ -208,7 +208,6 @@ public class AppointmentDao {
|
||||
}
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
attempt++;
|
||||
log.error("Failed to login to odessa due to some error");
|
||||
|
||||
// Extract raw response body
|
||||
@@ -245,14 +244,16 @@ public class AppointmentDao {
|
||||
} catch (IOException e) {
|
||||
log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
}
|
||||
if (attempt >= maxRetries) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale("Maximum retry attempts reached while trying to login to Odessa."));
|
||||
if (attempt + 1 < maxRetries) {
|
||||
regenerateTokenAndSave(hub);
|
||||
} else {
|
||||
loginToOdessa(hub, application);
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale("Maximum retry attempts reached while trying to login to Odessa."));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e);
|
||||
throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
} finally {
|
||||
attempt++;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -430,6 +431,7 @@ public class AppointmentDao {
|
||||
}
|
||||
|
||||
private HubEntity authenticateAndSaveToken(HubEntity hub) {
|
||||
|
||||
int maxRetries = 3;
|
||||
int attempt = 0;
|
||||
boolean success = false;
|
||||
@@ -467,7 +469,6 @@ public class AppointmentDao {
|
||||
// Handle non-OK response
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
attempt++;
|
||||
log.error("Failed to login to odessa due to some error occurred.");
|
||||
|
||||
// Extract raw response body
|
||||
@@ -500,14 +501,16 @@ public class AppointmentDao {
|
||||
} catch (IOException e) {
|
||||
log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
}
|
||||
if (attempt >= maxRetries) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale("Maximum retry attempts reached while trying to login to Odessa."));
|
||||
} else {
|
||||
if (attempt + 1 < maxRetries) {
|
||||
regenerateTokenAndSave(hub);
|
||||
} else {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale("Maximum retry attempts reached while trying to login to Odessa."));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e);
|
||||
throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
} finally {
|
||||
attempt++;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user