-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { JobRequestError } from 'shared/types' | ||
import { parseXml } from './parser' | ||
|
||
function errorXmlToJson(xmlString: string): JobRequestError { | ||
let errorElm = parseXml(xmlString, 'error') | ||
let descElms = errorElm.getElementsByTagName('description') | ||
let traceElms = errorElm.getElementsByTagName('trace') | ||
|
||
return { | ||
type: 'JobRequestError', | ||
description: descElms.length > 0 ? descElms[0].textContent?.trim() : '', | ||
trace: traceElms.length > 0 ? traceElms[0].textContent?.trim() : '', | ||
} | ||
} | ||
|
||
export { errorXmlToJson } |
21 changes: 21 additions & 0 deletions
21
src/shared/parser/pipelineXmlConverter/jobResponseToJson.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// a job response could be <job...> or <error... > | ||
// find out which one | ||
|
||
import { errorXmlToJson } from './errorToJson' | ||
import { jobXmlToJson } from './jobToJson' | ||
import { sniffRoot } from './parser' | ||
|
||
function jobResponseXmlToJson(xmlString: string) { | ||
let rootElm = sniffRoot(xmlString) | ||
if (rootElm == 'error') { | ||
return errorXmlToJson(xmlString) | ||
} | ||
else if (rootElm == 'job') { | ||
return jobXmlToJson(xmlString) | ||
} | ||
else { | ||
return {error: true, description: "Unrecognized response"} | ||
} | ||
} | ||
|
||
export { jobResponseXmlToJson } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters