From e19090b2ad942a8caecea8c5236aa645b76dc39b Mon Sep 17 00:00:00 2001 From: David Pilato Date: Mon, 17 Aug 2015 14:52:45 +0200 Subject: [PATCH] [plugin] shorten plugin names We can now simplify PluginHandle as `name` and `repo` are the same thing. --- .../elasticsearch/plugins/PluginManager.java | 28 +++++++++---------- .../plugins/PluginManagerUnitTests.java | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginManager.java b/core/src/main/java/org/elasticsearch/plugins/PluginManager.java index fc611fe6295..fbd5b74ee1d 100644 --- a/core/src/main/java/org/elasticsearch/plugins/PluginManager.java +++ b/core/src/main/java/org/elasticsearch/plugins/PluginManager.java @@ -163,7 +163,7 @@ public class PluginManager { terminal.println("Failed: %s", ExceptionsHelper.detailedMessage(e)); } } else { - if (PluginHandle.isOfficialPlugin(pluginHandle.repo, pluginHandle.user, pluginHandle.version)) { + if (PluginHandle.isOfficialPlugin(pluginHandle.name, pluginHandle.user, pluginHandle.version)) { checkForOfficialPlugins(pluginHandle.name); } } @@ -438,16 +438,14 @@ public class PluginManager { */ static class PluginHandle { - final String name; final String version; final String user; - final String repo; + final String name; - PluginHandle(String name, String version, String user, String repo) { - this.name = name; + PluginHandle(String name, String version, String user) { this.version = version; this.user = user; - this.repo = repo; + this.name = name; } List urls() { @@ -457,24 +455,24 @@ public class PluginManager { if (user == null) { // TODO Update to https if (!Strings.isNullOrEmpty(System.getProperty(PROPERTY_SUPPORT_STAGING_URLS))) { - addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/%s-%s/org/elasticsearch/plugin/%s/%s/%s-%s.zip", version, Build.CURRENT.hashShort(), repo, version, repo, version)); + addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/%s-%s/org/elasticsearch/plugin/%s/%s/%s-%s.zip", version, Build.CURRENT.hashShort(), name, version, name, version)); } - addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%s/%s/%s-%s.zip", repo, version, repo, version)); + addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%s/%s/%s-%s.zip", name, version, name, version)); } else { // Elasticsearch old download service // TODO Update to https - addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/%1$s/%2$s/%2$s-%3$s.zip", user, repo, version)); + addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/%1$s/%2$s/%2$s-%3$s.zip", user, name, version)); // Maven central repository - addUrl(urls, String.format(Locale.ROOT, "http://search.maven.org/remotecontent?filepath=%1$s/%2$s/%3$s/%2$s-%3$s.zip", user.replace('.', '/'), repo, version)); + addUrl(urls, String.format(Locale.ROOT, "http://search.maven.org/remotecontent?filepath=%1$s/%2$s/%3$s/%2$s-%3$s.zip", user.replace('.', '/'), name, version)); // Sonatype repository - addUrl(urls, String.format(Locale.ROOT, "https://oss.sonatype.org/service/local/repositories/releases/content/%1$s/%2$s/%3$s/%2$s-%3$s.zip", user.replace('.', '/'), repo, version)); + addUrl(urls, String.format(Locale.ROOT, "https://oss.sonatype.org/service/local/repositories/releases/content/%1$s/%2$s/%3$s/%2$s-%3$s.zip", user.replace('.', '/'), name, version)); // Github repository - addUrl(urls, String.format(Locale.ROOT, "https://github.com/%1$s/%2$s/archive/%3$s.zip", user, repo, version)); + addUrl(urls, String.format(Locale.ROOT, "https://github.com/%1$s/%2$s/archive/%3$s.zip", user, name, version)); } } if (user != null) { // Github repository for master branch (assume site) - addUrl(urls, String.format(Locale.ROOT, "https://github.com/%1$s/%2$s/archive/master.zip", user, repo)); + addUrl(urls, String.format(Locale.ROOT, "https://github.com/%1$s/%2$s/archive/master.zip", user, name)); } return urls; } @@ -527,10 +525,10 @@ public class PluginManager { } if (isOfficialPlugin(repo, user, version)) { - return new PluginHandle(repo, Version.CURRENT.number(), null, repo); + return new PluginHandle(repo, Version.CURRENT.number(), null); } - return new PluginHandle(repo, version, user, repo); + return new PluginHandle(repo, version, user); } static boolean isOfficialPlugin(String repo, String user, String version) { diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java index ab28badda3a..6ee0fc8b8b8 100644 --- a/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java +++ b/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java @@ -62,7 +62,7 @@ public class PluginManagerUnitTests extends ESTestCase { .build(); Environment environment = new Environment(settings); - PluginManager.PluginHandle pluginHandle = new PluginManager.PluginHandle(pluginName, "version", "user", "repo"); + PluginManager.PluginHandle pluginHandle = new PluginManager.PluginHandle(pluginName, "version", "user"); String configDirPath = Files.simplifyPath(pluginHandle.configDir(environment).normalize().toString()); String expectedDirPath = Files.simplifyPath(genericConfigFolder.resolve(pluginName).normalize().toString());