Class ValidationService
java.lang.Object
cf.maybelambda.httpvalidator.springboot.service.ValidationService
Service for handling validation tasks, executing scheduled validations,
and managing validation results.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor to initialize the HTTP client with default connection-timeout and follow-redirects settings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Executes validation tasks periodically based on a cron schedule.Retrieves information about the last run of validation tasks.boolean
Checks if the configuration is valid by validating the cron expression currently in use.boolean
isValidCronExpression
(String cronExpr) Validates a given cron expression.
-
Field Details
-
HEADER_KEY_VALUE_DELIMITER
- See Also:
-
-
Constructor Details
-
ValidationService
public ValidationService()Constructor to initialize the HTTP client with default connection-timeout and follow-redirects settings.
-
-
Method Details
-
execValidations
@Scheduled(cron="${cron.expression}") public void execValidations() throws FileNotFoundException, XMLParseException, com.fasterxml.jackson.core.JsonProcessingException, ConnectIOException, ExecutionException, InterruptedExceptionExecutes validation tasks periodically based on a cron schedule. Retrieves tasks, sends HTTP requests, and processes responses. Sends email notifications for any validation failures and updates information about the last run of validation tasks.- Throws:
FileNotFoundException
- if the data file is not foundXMLParseException
- if there is an error parsing the XML filecom.fasterxml.jackson.core.JsonProcessingException
- when a validation task contains invalid JSON contentConnectIOException
- if there is an error sending notification emailExecutionException
- when an unhandled error occurs while processing the HTTP requestsInterruptedException
- when interrupted before completing all the requests
-
getLastRunInfo
Retrieves information about the last run of validation tasks.- Returns:
- A map containing start time, time elapsed, total tasks, successful tasks and failed tasks.
-
isValidConfig
public boolean isValidConfig()Checks if the configuration is valid by validating the cron expression currently in use.- Returns:
- true if the configuration is valid, false otherwise
-
isValidCronExpression
Validates a given cron expression.- Parameters:
cronExpr
- Cron expression to validate- Returns:
- true if the cron expression is valid, false otherwise
-