diff options
author | Jonatan Kronqvist <jonatan@vaadin.com> | 2014-08-12 13:52:09 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-13 13:37:42 +0000 |
commit | fba69ae5d8cd617424e324c62b14225decf0315e (patch) | |
tree | aea203ee02a551a8abd841b8a22cfcf1d2d9a8f4 /client-compiler/src/com/vaadin/tools/CvalChecker.java | |
parent | 223670ca8b6f8a89af59b0088bad97fddf2d956a (diff) | |
download | vaadin-framework-fba69ae5d8cd617424e324c62b14225decf0315e.tar.gz vaadin-framework-fba69ae5d8cd617424e324c62b14225decf0315e.zip |
Allow for multiple license keys in a single license file #14408
License files can now contain multiple keys to support different
versions of a product. The keys are identified by the major version
number followed by an equals sign and the key for that version, e.g.
1 = foo-bar-baz
2 = baz-foo-bar
The license file can also contain a "default" license key, which
is used for all versions except for the explicitly defined ones, e.g.
foo-bar-baz
3 = baz-bar-foo
4 = bar-baz-baz
Change-Id: Id07d22e9fdc44189c4298b634006cf0df128bfd9
Diffstat (limited to 'client-compiler/src/com/vaadin/tools/CvalChecker.java')
-rw-r--r-- | client-compiler/src/com/vaadin/tools/CvalChecker.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/client-compiler/src/com/vaadin/tools/CvalChecker.java b/client-compiler/src/com/vaadin/tools/CvalChecker.java index 2de7e10faa..e426c5c4e6 100644 --- a/client-compiler/src/com/vaadin/tools/CvalChecker.java +++ b/client-compiler/src/com/vaadin/tools/CvalChecker.java @@ -26,6 +26,7 @@ import java.net.URLConnection; import java.text.MessageFormat; import java.util.Arrays; import java.util.Date; +import java.util.List; import java.util.Locale; import java.util.ResourceBundle; import java.util.prefs.Preferences; @@ -465,7 +466,8 @@ public final class CvalChecker { if (url != null) { try { - key = IOUtils.toString(url.openStream()); + key = readKeyFromFile(url, + computeMajorVersion(productVersion)); if (key != null && !(key = key.trim()).isEmpty()) { return key; } @@ -480,6 +482,22 @@ public final class CvalChecker { productTitle, null, null); } + String readKeyFromFile(URL url, int majorVersion) throws IOException { + String majorVersionStr = String.valueOf(majorVersion); + List<String> lines = IOUtils.readLines(url.openStream()); + String defaultKey = null; + for (String line : lines) { + String[] parts = line.split("\\s*=\\s*"); + if (parts.length < 2) { + defaultKey = parts[0].trim(); + } + if (parts[0].equals(majorVersionStr)) { + return parts[1].trim(); + } + } + return defaultKey; + } + static String getErrorMessage(String key, Object... pars) { Locale loc = Locale.getDefault(); ResourceBundle res = ResourceBundle.getBundle( |