[ 
https://issues.apache.org/jira/browse/OOZIE-3083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16316591#comment-16316591
 ] 

Attila Sasvari commented on OOZIE-3083:
---------------------------------------

Thanks [~gezapeti]. I tested your patch and {{curl 
'http://localhost:11000/oozie/v2/admin/build-version'}} returned 
{code}
{"buildVersion":"5.0.0-beta1","buildInfo":"{\"build.time\":\"${build.time}\",\"vc.url\":\"${vc.url}\",\"build.user\":\"asasvari\",\"vc.revision\":\"${vc.revision}\",\"build.version\":\"5.0.0-beta1\"}"}
{code}
{{buildInfo}} is not a JSON object, it is a string. This is caused by 
{{json.put(JsonTags.BUILD_INFO, 
JSONValue.toJSONString(BuildInfo.getBuildInfo()));}}.; the JSON object 
converted to a string that is not what is needed here.

In {{BaseAdminServlet.doGet()}}, you could simply do something like 
{{json.put(JsonTags.BUILD_INFO,  BuildInfo.getBuildInfo());}}}, which would 
return:
{code}
{"buildVersion":"5.0.0-beta1","buildInfo":{"build.version":"5.0.0-beta1","vc.url":"https:\/\/github.com\/apache\/oozie.git","vc.revision":"master@dde1284","build.time":"2018.01.08-16:15:03GMT","build.user":"asasvari"}}
{code}
({{json.writeJSONString()}} knows how to serialize the embedded object in the 
JSONObject we pass to {{sendJsonResponse()}})

In Javascript, you can then parse this with with {{JSON.parse()}}. Escaped 
slashes are handled as expected; {{JSON.parse(response).buildInfo\["vc.url"]}} 
returns "https://github.com/apache/oozie.git"; (note: because the key contains a 
dot, the dot operator cannot be use to select "vc.url").

> Make improved version Info backward compatible
> ----------------------------------------------
>
>                 Key: OOZIE-3083
>                 URL: https://issues.apache.org/jira/browse/OOZIE-3083
>             Project: Oozie
>          Issue Type: Bug
>            Reporter: Peter Cseh
>            Assignee: Peter Cseh
>         Attachments: OOZIE-3083.001.patch, OOZIE-3083.002.patch, 
> OOZIE-3083.003.patch
>
>
> OOZIE-2004 changed the format of the version info output considerably.
> We should change it back to a more compatible format.
> It could be something like
> {code}
> {"buildVersion":"5.0.0-SNAPSHOT", "buildInfo":"{build.time=${build.time}, 
> vc.url=${vc.url}, build.user=asasvari, vc.revision=${vc.revision}"}
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to