![]() |
SudokuFX
|
Service for checking if the application version is up to date by querying GitHub. More...
Public Member Functions | |
VersionService (HttpClient httpClient, MyDateTime myDateTime) | |
Initializes the VersionService with the provided HttpClient and MyDateTime utility. | |
Task< Boolean > | checkLatestVersion () |
Checks if the current application version is up-to-date by querying the GitHub API. | |
String | getGitHubLinkToRepositoryReleases () |
Gets the GitHub link to the repository releases page. | |
Private Member Functions | |
int | compareVersions (final String version1, final String version2) |
Compares two version strings in the format MAJOR.MINOR.PATCH. | |
boolean | parseResponse (String json) |
Parses the JSON response from the GitHub API to extract the latest published version. | |
Private Attributes | |
final String | currentVersion = JVMApplicationProperties.getAppVersion().isEmpty() ? "" : JVMApplicationProperties.getAppVersion().substring(1) |
final HttpClient | httpClient |
final MyDateTime | myDateTime |
Static Private Attributes | |
static final String | GITHUB_API_URL = "https://api.github.com/" |
static final String | GITHUB_API_URL_REPO_TAGS = GITHUB_API_URL + "repos/" + OWNER + "/" + REPO + "/tags" |
static final String | GITHUB_URL = "https://github.com/" |
static final ObjectMapper | OBJECT_MAPPER = new ObjectMapper() |
static final String | OWNER = "Lob2018" |
static final String | REPO = "SudokuFX" |
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.
fr.softsf.sudokufx.service.VersionService.VersionService | ( | HttpClient | httpClient, |
MyDateTime | myDateTime ) |
Initializes the VersionService with the provided HttpClient and MyDateTime utility.
This service is responsible for checking the latest version by making HTTP requests.
httpClient | the HttpClient used to perform HTTP requests. |
myDateTime | the utility for handling date and time formatting. |
Task< Boolean > fr.softsf.sudokufx.service.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 false
if an update is available. On error, it defaults to true
.
|
private |
Compares two version strings in the format MAJOR.MINOR.PATCH.
version1 | the first version string (e.g., "1.2.3"). |
version2 | the second version string (e.g., "1.3.0"). |
NumberFormatException | if the version strings are not properly formatted. |
String fr.softsf.sudokufx.service.VersionService.getGitHubLinkToRepositoryReleases | ( | ) |
Gets the GitHub link to the repository releases page.
|
private |
Parses the JSON response from the GitHub API to extract the latest published version.
The method retrieves the latest tag name from the response, validates its format, and compares it with the current application version.
json | The raw JSON response from the GitHub API. |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |