Skip to content

Commit

Permalink
AMBARI-26239: Fix OozieUtils (apache#3894)
Browse files Browse the repository at this point in the history
* AMBARI-26239: Fix OozieUtils
  • Loading branch information
coldless177 authored Nov 25, 2024
1 parent a297895 commit 8df31e5
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public String generateConfigXml(Map<String, String> map) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
Element configElement = doc.createElement("configuration");
Expand Down Expand Up @@ -80,6 +81,7 @@ public String getJobPathPropertyKey(JobType jobType) {
public JobType deduceJobType(String xml) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
DocumentBuilder db = null;

db = dbf.newDocumentBuilder();
Expand All @@ -96,7 +98,7 @@ public JobType deduceJobType(String xml) {
return JobType.BUNDLE;
}
throw new RuntimeException("invalid xml submitted");
} catch (Exception e) {
} catch (ParserConfigurationException | Exception e) {
throw new RuntimeException(e);
}
}
Expand All @@ -114,14 +116,15 @@ public String deduceWorkflowSchemaVersionFromJson(String json) {
public String deduceWorkflowNameFromXml(String xml) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
Document doc = db.parse(is);
String name = doc.getDocumentElement().getAttributeNode("name").getValue();
return name;

} catch (Exception e) {
} catch (ParserConfigurationException | Exception e) {
throw new RuntimeException(e);
}
}
Expand All @@ -130,6 +133,7 @@ public String generateWorkflowXml(String actionNodeXml) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
db = dbf.newDocumentBuilder();
Document doc = db.newDocument();

Expand Down

0 comments on commit 8df31e5

Please sign in to comment.