use of alma.acs.makesupport.AcsFileFinder in project ACS by ACS-Community.
the class XmlSeeker method getXmls.
/**
* Get an Arraylist with the XMLs on the added dirs that conforms with the xsd filename.
* @param xsd the filename of the xsd to seek inside the XML files
* @return the XMLs list */
public ArrayList getXmls(String xsd) {
File[] fileArr;
ArrayList<File> files = new ArrayList<File>();
File[] dirArr = new File[dirs.size()];
dirs.toArray(dirArr);
AcsFileFinder fileFinder = new AcsFileFinder(dirArr, this, null);
fileArr = fileFinder.getAllFiles();
for (int i = 0; i < fileArr.length; i++) {
DOMParser dp;
dp = new DOMParser();
try {
dp.parse(fileArr[i].getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
}
Document doc = dp.getDocument();
// Hack to support both Errors and Logs
// TODO: Please do this thing in a generic way
Node typeNode = doc.getElementsByTagName("Type").item(0);
// Type node may not even exist
if (typeNode != null) {
NamedNodeMap atributes = typeNode.getAttributes();
Node schema = atributes.getNamedItem("xsi:schemaLocation");
if (schema.getNodeValue().contentEquals(xsd))
files.add(fileArr[i]);
}
}
return (files);
}
Aggregations