This is an automated email from the ASF dual-hosted git repository.

vsairam pushed a commit to branch AMBARI-25424-branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit e7ee83767daa1a8145b8d375ad2fe1a7e4d1a871
Author: vsairam <vsai...@cloudera.com>
AuthorDate: Fri Dec 6 19:14:11 2019 +0530

    AMBARI-25424 Failed to edit workflow from Ambari workflow Manager while 
accessing Ambari UI over Knox
---
 .../src/main/resources/ui/app/components/flow-designer.js   | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git 
a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js 
b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
index 2c77b5b..c5d2a45 100644
--- 
a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
+++ 
b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
@@ -350,7 +350,10 @@ export default Ember.Component.extend(FindNodeMixin, 
Validations, {
     var workflowXmlDefered=this.getWorkflowFromHdfs(filePath);
     workflowXmlDefered.promise.then(function(response){
       if(response.type === 'xml'){
-        this.importWorkflowFromString(response.data);
+        var x2js = new X2JS();
+        let resData = x2js.json2xml_str(x2js.xml2json(response.data));
+
+        this.importWorkflowFromString(resData);
       }else {
         this.importWorkflowFromJSON(response.data);
       }
@@ -423,10 +426,10 @@ export default Ember.Component.extend(FindNodeMixin, 
Validations, {
     Ember.$.ajax({
       url: url,
       method: 'GET',
-      dataType: "text",
       beforeSend: function (xhr) {
         xhr.setRequestHeader("X-XSRF-HEADER", 
Math.round(Math.random()*100000));
         xhr.setRequestHeader("X-Requested-By", "Ambari");
+        xhr.setRequestHeader("accept", "text/xml");
       }
     }).done(function(data, status, xhr){
       var type = xhr.getResponseHeader("response-type") === "xml" ? 'xml' : 
'json';
@@ -604,9 +607,11 @@ export default Ember.Component.extend(FindNodeMixin, 
Validations, {
   getWorkflowAsJsonJsoGImpl(){
    try{
     var json=JSOG.stringify(this.get("workflow")), self = this;
-    var actionVersions = 
JSOG.stringify(CommonUtils.toArray(this.get("workflow").schemaVersions.actionVersions));
+    var actionVersions = this.get("workflow").schemaVersions ? 
JSOG.stringify(CommonUtils.toArray(this.get("workflow").schemaVersions.actionVersions))
 : [];
     var workflow = JSOG.parse(json);
-    workflow.schemaVersions.actionVersions = actionVersions
+    if(workflow.schemaVersions) {
+      workflow.schemaVersions.actionVersions = actionVersions
+    }
     return JSOG.stringify(workflow);
   }catch(err){
    console.error(err);

Reply via email to