From 01ef106bfdcca204b86328f088d6c683fff56b6d Mon Sep 17 00:00:00 2001 From: Evie Lau Date: Wed, 25 Oct 2023 14:48:31 -0500 Subject: [PATCH] Fix behavior, method renames --- .../plugins/config/ServerConfigDocument.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/openliberty/tools/common/plugins/config/ServerConfigDocument.java b/src/main/java/io/openliberty/tools/common/plugins/config/ServerConfigDocument.java index 340c9358..68fc81fd 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/config/ServerConfigDocument.java +++ b/src/main/java/io/openliberty/tools/common/plugins/config/ServerConfigDocument.java @@ -369,7 +369,7 @@ private static void parseInclude(Document doc) throws XPathExpressionException, continue; } - ArrayList inclDocs = getIncludeDoc(includeFileName); + ArrayList inclDocs = getIncludeDocs(includeFileName); for (Document inclDoc : inclDocs) { parseApplication(inclDoc, XPATH_SERVER_APPLICATION); parseApplication(inclDoc, XPATH_SERVER_WEB_APPLICATION); @@ -427,7 +427,7 @@ private static void parseDropinsFile(File file) throws IOException, XPathExpress } } - private static ArrayList getIncludeDoc(String loc) throws IOException, SAXException { + private static ArrayList getIncludeDocs(String loc) throws IOException, SAXException { ArrayList docs = new ArrayList(); Document doc = null; File locFile = null; @@ -442,7 +442,9 @@ private static ArrayList getIncludeDoc(String loc) throws IOException, } else if (loc.startsWith("file:")) { if (isValidURL(loc)) { locFile = new File(loc); - parseDocumentFromFile(locFile, docs); + // While Java URIs support directories, the Liberty include implementation does not support them yet. + doc = parseDocument(locFile); + docs.add(doc); } } else if (loc.startsWith("ftp:")) { // TODO handle ftp protocol @@ -451,7 +453,7 @@ private static ArrayList getIncludeDoc(String loc) throws IOException, // check if absolute file if (locFile.isAbsolute()) { - parseDocumentFromFile(locFile, docs); + parseDocumentFromFileOrDirectory(locFile, docs); } else { // check configDirectory first if exists if (configDirectory != null && configDirectory.exists()) { @@ -461,7 +463,7 @@ private static ArrayList getIncludeDoc(String loc) throws IOException, if (locFile == null || !locFile.exists()) { locFile = new File(getServerXML().getParentFile(), loc); } - parseDocumentFromFile(locFile, docs); + parseDocumentFromFileOrDirectory(locFile, docs); } } @@ -479,7 +481,7 @@ private static ArrayList getIncludeDoc(String loc) throws IOException, * @throws IOException * @throws SAXException */ - private static void parseDocumentFromFile(File file, ArrayList docs) throws FileNotFoundException, IOException, SAXException { + private static void parseDocumentFromFileOrDirectory(File file, ArrayList docs) throws FileNotFoundException, IOException, SAXException { Document doc = null; if (file == null || !file.exists()) { log.warn("Unable to parse from file: " + file.getCanonicalPath()); @@ -617,7 +619,7 @@ private static void parseIncludeVariables(Document doc) throws XPathExpressionEx continue; } - ArrayList inclDocs = getIncludeDoc(includeFileName); + ArrayList inclDocs = getIncludeDocs(includeFileName); for (Document inclDoc : inclDocs) { parseVariablesForBothValues(inclDoc);