![]() |
SudokuFX
|
Service for checking if the application version is up to date by querying GitHub. More...
Collaboration diagram for fr.softsf.sudokufx.service.external.VersionService:Public Member Functions | |
| VersionService (HttpClient httpClient, ObjectMapper objectMapper) | |
| Initializes the VersionService with the provided HttpClient. | |
| Task< Boolean > | checkLatestVersion () |
| Checks if the current application version is up-to-date by querying the GitHub API. | |
Private Member Functions | |
| int | compareVersions (final String version1, final String version2) |
| Compares two version strings in the format MAJOR.MINOR.PATCH (e.g., "1.2.3"). | |
| boolean | parseResponse (String json) |
| Parses the JSON response from the GitHub API to extract the latest published version. | |
Private Attributes | |
| final HttpClient | httpClient |
| final ObjectMapper | objectMapper |
Static Private Attributes | |
| static final String | CURRENT_VERSION |
| static final int | HTTP_STATUS_OK = 200 |
| static final Logger | LOG = LoggerFactory.getLogger(VersionService.class) |
Service for checking if the application version is up to date by querying GitHub.
It retrieves the latest release tag from the GitHub API and compares it with the current version. If an update is available, the result can be used to notify the user.
All method parameters and return values in this package are non-null by default, thanks to the @NonNullApi annotation at the package level.
| fr.softsf.sudokufx.service.external.VersionService.VersionService | ( | HttpClient | httpClient, |
| ObjectMapper | objectMapper ) |
Initializes the VersionService with the provided HttpClient.
This service is responsible for checking the latest version by making HTTP requests.
| httpClient | the HttpClient used to perform HTTP requests. |
| Task< Boolean > fr.softsf.sudokufx.service.external.VersionService.checkLatestVersion | ( | ) |
Checks if the current application version is up-to-date by querying the GitHub API.
This method runs in the background using a JavaFX Task to avoid blocking the UI thread. It retrieves the latest release version from the repository and compares it with the current application version. In case of errors (e.g., timeout, interruption, or network issues), it assumes the version is up-to-date and logs the exception details.
Task<Boolean> that returns true if the version is up-to-date or if an error occurs, and false if an update is available.
Here is the call graph for this function:
|
private |
Compares two version strings in the format MAJOR.MINOR.PATCH (e.g., "1.2.3").
The comparison is done based on the numeric values of major, minor, and patch components.
| version1 | the first version string, non-null and non-blank. |
| version2 | the second version string, non-null and non-blank. |
| IllegalArgumentException | if either version string is null, empty, or blank. |
| NumberFormatException | if the version strings are not properly formatted (e.g., not "X.Y.Z"). |
|
private |
Parses the JSON response from the GitHub API to extract the latest published version.
Validates the input, extracts the first tag, checks its format, and compares it with the current application version.
| json | The non-null, non-blank JSON response from the GitHub API. |
| IllegalArgumentException | if the JSON is null, empty or blank. |
Here is the call graph for this function:
|
staticprivate |
|
staticprivate |
|
private |
|
staticprivate |
|
private |