+ private static boolean isConfigSnapshot(String fileName) {
+ if(!Files.getFileExtension(fileName).equals(CONFIG_FILE_SUFFIX)) {
+ return false;
+ }
+
+ if(fileName.endsWith("jetty.xml")) {
+ // Special case - ignore the jetty.xml file as it contains a DTD and causes a "Connection refused"
+ // error when it tries to go out to the network to retrieve it. We don't want it trying to go out
+ // to the network nor do we want an error logged trying to parse it.
+ return false;
+ }
+
+ File file = new File(System.getProperty("karaf.home"), fileName);
+ try(FileInputStream fis = new FileInputStream(file)) {
+ DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+ builderFactory.setNamespaceAware(true);
+ builderFactory.setCoalescing(true);
+ builderFactory.setIgnoringElementContentWhitespace(true);
+ builderFactory.setIgnoringComments(true);
+
+ Element root = builderFactory.newDocumentBuilder().parse(fis).getDocumentElement();
+ return ConfigSnapshot.SNAPSHOT_ROOT_ELEMENT_NAME.equals(root.getLocalName());
+ } catch (Exception e) {
+ LOG.error("Could not parse XML file {}", file, e);
+ return false;
+ }
+ }
+