use of com.qcadoo.plugin.internal.DefaultPlugin.Builder in project qcadoo by qcadoo.
the class DefaultPluginDescriptorParser method parsePluginNode.
private Builder parsePluginNode(final Node pluginNode, final boolean ignoreModules) {
Preconditions.checkState("plugin".equals(pluginNode.getNodeName()), "Wrong plugin description root tag");
String pluginIdentifier = getStringAttribute(pluginNode, "plugin");
checkNotNull(pluginIdentifier, "No plugin identifier");
LOG.info("Parsing plugin " + pluginIdentifier);
Builder pluginBuilder = new Builder(pluginIdentifier, moduleFactoryAccessor.getModuleFactories());
String pluginVersionStr = getStringAttribute(pluginNode, "version");
checkNotNull(pluginVersionStr, "No plugin version");
pluginBuilder.withVersion(pluginVersionStr);
String isSystemPluginStr = getStringAttribute(pluginNode, "system");
if (isSystemPluginStr != null && Boolean.parseBoolean(isSystemPluginStr)) {
pluginBuilder.asSystem();
}
String pluginGroup = getStringAttribute(pluginNode, "group");
pluginBuilder.withGroup(pluginGroup);
for (Node child : getChildNodes(pluginNode)) {
if ("information".equals(child.getNodeName())) {
addPluginInformation(child, pluginBuilder);
} else if ("dependencies".equals(child.getNodeName())) {
addDependenciesInformation(child, pluginBuilder);
} else if ("modules".equals(child.getNodeName())) {
if (!ignoreModules) {
addModules(child, pluginBuilder, pluginIdentifier);
}
} else if ("features".equals(child.getNodeName())) {
addFeturesInformation(child, pluginBuilder);
} else {
throw new IllegalStateException("Wrong plugin tag: " + child.getNodeName());
}
}
return pluginBuilder;
}
use of com.qcadoo.plugin.internal.DefaultPlugin.Builder in project qcadoo by qcadoo.
the class DefaultPluginDescriptorParser method parse.
private InternalPlugin parse(final InputStream inputStream, final boolean ignoreModules, final String fileName) throws IOException {
try {
Document document = documentBuilder.parse(inputStream);
Node root = document.getDocumentElement();
Builder pluginBuilder = parsePluginNode(root, ignoreModules);
InternalPlugin plugin = pluginBuilder.withFileName(fileName).build();
LOG.info("Parse complete");
return plugin;
} catch (SAXException e) {
throw new PluginException(e.getMessage(), e);
}
}
Aggregations