use of org.walkmod.conf.providers.XMLConfigurationProvider in project walkmod-core by walkmod.
the class AbstractXMLConfigurationAction method execute.
@Override
public void execute() throws Exception {
File file = new File(provider.getConfigFileName());
if (!file.exists()) {
provider.createConfig();
provider.init(new ConfigurationImpl());
} else {
provider.init(new ConfigurationImpl());
}
if (recursive) {
Document document = provider.getDocument();
Element rootElement = document.getDocumentElement();
NodeList children = rootElement.getChildNodes();
int childSize = children.getLength();
boolean containsModules = false;
for (int i = 0; i < childSize; i++) {
Node childNode = children.item(i);
if (childNode instanceof Element) {
Element child = (Element) childNode;
final String nodeName = child.getNodeName();
if ("modules".equals(nodeName)) {
containsModules = true;
NodeList moduleNodeList = child.getChildNodes();
int max = moduleNodeList.getLength();
for (int j = 0; j < max; j++) {
String cfg = provider.getConfigFileName();
if (cfg != null) {
File auxFile = new File(cfg).getCanonicalFile().getParentFile();
File moduleFileDir = new File(auxFile, moduleNodeList.item(j).getTextContent());
XMLConfigurationProvider aux = new XMLConfigurationProvider(moduleFileDir.getAbsolutePath() + File.separator + "walkmod.xml", false);
AbstractXMLConfigurationAction ct = clone(aux, recursive);
ct.execute();
}
}
}
}
}
if (!containsModules) {
doAction();
}
} else {
doAction();
}
}
Aggregations