use of org.libresonic.player.domain.Version in project libresonic by Libresonic.
the class RESTRequestParameterProcessingFilter method checkAPIVersion.
private RESTController.ErrorCode checkAPIVersion(String version) {
Version serverVersion = new Version(jaxbWriter.getRestProtocolVersion());
Version clientVersion = new Version(version);
if (serverVersion.getMajor() > clientVersion.getMajor()) {
return RESTController.ErrorCode.PROTOCOL_MISMATCH_CLIENT_TOO_OLD;
} else if (serverVersion.getMajor() < clientVersion.getMajor()) {
return RESTController.ErrorCode.PROTOCOL_MISMATCH_SERVER_TOO_OLD;
} else if (serverVersion.getMinor() < clientVersion.getMinor()) {
return RESTController.ErrorCode.PROTOCOL_MISMATCH_SERVER_TOO_OLD;
}
return null;
}
use of org.libresonic.player.domain.Version in project libresonic by Libresonic.
the class VersionService method readLatestVersion.
/**
* Resolves the latest available Libresonic version by screen-scraping a web page.
*
* @throws IOException If an I/O error occurs.
*/
private void readLatestVersion() throws IOException {
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(10000).build();
HttpGet method = new HttpGet(VERSION_URL + "?v=" + getLocalVersion());
method.setConfig(requestConfig);
String content;
try (CloseableHttpClient client = HttpClients.createDefault()) {
ResponseHandler<String> responseHandler = new BasicResponseHandler();
content = client.execute(method, responseHandler);
}
Pattern finalPattern = Pattern.compile("LIBRESONIC_FULL_VERSION_BEGIN(.*)LIBRESONIC_FULL_VERSION_END");
Pattern betaPattern = Pattern.compile("LIBRESONIC_BETA_VERSION_BEGIN(.*)LIBRESONIC_BETA_VERSION_END");
try (BufferedReader reader = new BufferedReader(new StringReader(content))) {
String line = reader.readLine();
while (line != null) {
Matcher finalMatcher = finalPattern.matcher(line);
if (finalMatcher.find()) {
latestFinalVersion = new Version(finalMatcher.group(1));
LOG.info("Resolved latest Libresonic final version to: " + latestFinalVersion);
}
Matcher betaMatcher = betaPattern.matcher(line);
if (betaMatcher.find()) {
latestBetaVersion = new Version(betaMatcher.group(1));
LOG.info("Resolved latest Libresonic beta version to: " + latestBetaVersion);
}
line = reader.readLine();
}
}
}
use of org.libresonic.player.domain.Version in project libresonic by Libresonic.
the class VersionService method isNewBetaVersionAvailable.
/**
* Returns whether a new beta version of Libresonic is available.
*
* @return Whether a new beta version of Libresonic is available.
*/
public boolean isNewBetaVersionAvailable() {
Version latest = getLatestBetaVersion();
Version local = getLocalVersion();
if (latest == null || local == null) {
return false;
}
return local.compareTo(latest) < 0;
}
use of org.libresonic.player.domain.Version in project libresonic by Libresonic.
the class VersionService method isNewFinalVersionAvailable.
/**
* Returns whether a new final version of Libresonic is available.
*
* @return Whether a new final version of Libresonic is available.
*/
public boolean isNewFinalVersionAvailable() {
Version latest = getLatestFinalVersion();
Version local = getLocalVersion();
if (latest == null || local == null) {
return false;
}
return local.compareTo(latest) < 0;
}
use of org.libresonic.player.domain.Version in project libresonic by Libresonic.
the class VersionService method getLocalVersion.
/**
* Returns the version number for the locally installed Libresonic version.
*
* @return The version number for the locally installed Libresonic version.
*/
public synchronized Version getLocalVersion() {
if (localVersion == null) {
try {
localVersion = new Version(readLineFromResource("/version.txt"));
LOG.info("Resolved local Libresonic version to: " + localVersion);
} catch (Exception x) {
LOG.warn("Failed to resolve local Libresonic version.", x);
}
}
return localVersion;
}
Aggregations