Mercurial > hg > release > thermostat-0.6
changeset 1005:8dfbb3b87fcd
Warn about potential problems in plugin.xml
Reviewed-by: ebaron, jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-February/005849.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Tue, 26 Feb 2013 13:23:34 -0500 |
parents | b0879f47909f |
children | eec62a0c5457 |
files | launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParser.java |
diffstat | 1 files changed, 32 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParser.java Tue Feb 26 12:47:39 2013 -0500 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParser.java Tue Feb 26 13:23:34 2013 -0500 @@ -142,6 +142,10 @@ } } + if (commands.getFirst().isEmpty() && commands.getSecond().isEmpty()) { + logger.warning("plugin " + pluginName + " does not extend any command or provide any new commands"); + } + return new PluginConfiguration(commands.getFirst(), commands.getSecond()); } @@ -180,11 +184,16 @@ if (node.getNodeName().equals("name")) { name = node.getTextContent().trim(); } else if (node.getNodeName().equals("bundles")) { - bundles.addAll(parseBundles(node)); + bundles.addAll(parseBundles(pluginName, name, node)); } else if (node.getNodeName().equals("dependencies")) { - dependencies.addAll(parseDependencies(node)); + dependencies.addAll(parseDependencies(pluginName, name, node)); } } + + if (bundles.isEmpty()) { + logger.warning("plugin " + pluginName + " extends the command " + name + " but supplies no bundles"); + } + if (name == null) { logger.warning("plugin " + pluginName + " provides extensions without specifying the command"); return null; @@ -212,12 +221,19 @@ } else if (node.getNodeName().equals("arguments")) { options = parseArguments(node); } else if (node.getNodeName().equals("bundles")) { - bundles.addAll(parseBundles(node)); + bundles.addAll(parseBundles(pluginName, name, node)); } else if (node.getNodeName().equals("dependencies")) { - dependencies.addAll(parseDependencies(node)); + dependencies.addAll(parseDependencies(pluginName, name, node)); } } + if (bundles.isEmpty()) { + logger.warning("plugin " + pluginName + " provides a new command " + name + " but supplies no bundles"); + } + if (dependencies.isEmpty()) { + logger.warning("plugin " + pluginName + " provides a new command " + name + " but lists no dependencies on thermostat"); + } + if (name == null || usage == null || description == null) { logger.warning("plugin " + pluginName + " provides an incomplete new command: " + "name='" + name + "', usage='" + usage + "', description='" + description + "', options='" + options + "'"); @@ -227,7 +243,7 @@ } } - private Collection<String> parseBundles(Node bundlesNode) { + private Collection<String> parseBundles(String pluginName, String commandName, Node bundlesNode) { List<String> bundles = new ArrayList<>(); NodeList nodes = bundlesNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { @@ -237,10 +253,15 @@ bundles.add(bundleName); } } + + if (bundles.isEmpty()) { + logger.warning("plugin " + pluginName + " has an empty bundles element for command " + commandName); + } + return bundles; } - private Collection<String> parseDependencies(Node dependenciesNode) { + private Collection<String> parseDependencies(String pluginName, String commandName, Node dependenciesNode) { List<String> dependencies = new ArrayList<>(); NodeList nodes = dependenciesNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { @@ -250,6 +271,11 @@ dependencies.add(bundleName); } } + + if (dependencies.isEmpty()) { + logger.warning("plugin " + pluginName + " has an empty dependencies element for command " + commandName); + } + return dependencies; }