SOLR-14108: Handle missing verify commands or missing default params in Package Manager

This commit is contained in:
Ishan Chattopadhyaya 2019-12-19 10:38:34 +05:30
parent 04e306f616
commit 3a4f43227b
2 changed files with 22 additions and 20 deletions

View File

@ -289,9 +289,10 @@ public class PackageManager implements Closeable {
public boolean verify(SolrPackageInstance pkg, List<String> collections) {
boolean success = true;
for (Plugin plugin: pkg.plugins) {
Command cmd = plugin.verifyCommand;
if (plugin.verifyCommand != null && !Strings.isNullOrEmpty(cmd.path)) {
for (String collection: collections) {
Map<String, String> collectionParameterOverrides = getPackageParams(pkg.name, collection);
Command cmd = plugin.verifyCommand;
Map<String, String> systemParams = PackageUtils.map("collection", collection, "package-name", pkg.name, "package-version", pkg.version);
String url = solrBaseUrl + PackageUtils.resolve(cmd.path, pkg.parameterDefaults, collectionParameterOverrides, systemParams);
@ -308,8 +309,7 @@ public class PackageManager implements Closeable {
PackageUtils.printRed("Failed to deploy plugin: " + plugin.name);
success = false;
}
} else {
throw new SolrException(ErrorCode.BAD_REQUEST, "Non-GET method not supported for setup commands");
}
}
}
}

View File

@ -172,9 +172,11 @@ public class PackageUtils {
// TODO: Should perhaps use Matchers etc. instead of this clumsy replaceAll().
if (str == null) return null;
if (defaults != null) {
for (String param: defaults.keySet()) {
str = str.replaceAll("\\$\\{"+param+"\\}", overrides.containsKey(param)? overrides.get(param): defaults.get(param));
}
}
for (String param: overrides.keySet()) {
str = str.replaceAll("\\$\\{"+param+"\\}", overrides.get(param));
}