Skip to content

Commit cece09f

Browse files
committed
simplified version check.
1 parent 1bf1635 commit cece09f

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ allprojects {
1313
tasks.withType(JavaCompile) {
1414
options.compilerArgs << '-Xlint:deprecation' << '-Xlint:unchecked'
1515
}
16+
repositories {
17+
maven { url "https://jitpack.io" }
18+
}
1619
}

restclient-lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies {
1515
'org.apache.httpcomponents:httpmime:4.5.2',
1616
'org.codehaus.groovy:groovy-all:2.4.4',
1717
'net.htmlparser.jericho:jericho-html:3.4',
18-
'org.wiztools:app-update:0.2.0'
18+
'com.github.wiztools:app-update-framework:app-update-0.2.1'
1919
compile('com.io7m.xom:xom:1.2.10') {
2020
exclude group: 'xerces', module: 'xmlParserAPIs'
2121
exclude group: 'xerces', module: 'xercesImpl'
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.wiztools.restclient;
22

3-
import java.util.Arrays;
3+
import org.wiztools.appupdate.Version;
4+
import org.wiztools.appupdate.VersionImpl;
45

56
/**
67
*
@@ -9,32 +10,23 @@
910
public final class Versions {
1011
public static final String CURRENT = "3.6";
1112

12-
private static final String[] VERSIONS = new String[]{
13-
"3.0", "3.1", "3.2", "3.2.1", "3.2.2", "3.2.3", "3.3", "3.3.1", "3.4",
14-
"3.4.1", "3.4.2", "3.5", CURRENT
15-
};
16-
17-
static {
18-
// Sort the version array for binary search
19-
Arrays.sort(VERSIONS);
20-
}
13+
private static final Version MIN = new VersionImpl("3.0");
14+
private static final Version MAX = new VersionImpl(CURRENT);
2115

2216
public static void versionValidCheck(final String restVersion)
2317
throws VersionValidationException {
2418
if (restVersion == null) {
2519
throw new VersionValidationException("Attribute `version' not available for root element");
2620
}
27-
int res = Arrays.binarySearch(VERSIONS, restVersion);
28-
if (res == -1) {
21+
Version stored = new VersionImpl(restVersion);
22+
if(!stored.isWithin(MIN, MAX)) {
2923
throw new VersionValidationException("Version not supported");
3024
}
3125
}
3226

3327
public static class VersionValidationException extends Exception {
34-
3528
public VersionValidationException(String message) {
3629
super(message);
3730
}
38-
3931
}
4032
}

0 commit comments

Comments
 (0)