It's all about the answers!

Ask a question

Why there is two "type": "dng_module:Binding" in JSON when retrieving a Module structure?

Pierre Bentkowski (96517) | asked Mar 19 '18, 2:08 p.m.

I used the following  to retrieve the Module structure:

private JSONArray getModuleStruct() throws Exception  {
        String structureURI = this.moduleURI + "/structure";
        HttpGet get = new HttpGet(structureURI);
        get.addHeader("DoorsRP-Request-Type", "public 2.0");
        get.addHeader("Accept", "application/json");
        HttpResponse response = HttpUtils.sendGetForSecureDocument(clm_props.getServerURL(), get, clm_props.getCLMlogin(), clm_props.getCLMpassword(), httpclient, clm_props.getJazzURL());
        if (response.getStatusLine().getStatusCode() != 200) {
            throw new HttpResponseException(response.getStatusLine()
                    .getStatusCode(), response.getStatusLine()
        String moduleStr = EntityUtils.toString(response.getEntity());
        JSONArray jsonArray = new JSONArray(moduleStr);

The new JSONArray(moduleStr); fail because the Strign contains two times the "dng_module:Binding"

  "uri": "",
  "type": "dng_module:Binding",
  "component": "",
  "type": "dng_module:Binding",
  "isStructureRoot": "true",
  "module": "",
  "boundArtifact": "",
  "childBindings": ["", ""]
}, {

Is the issue is the JSONArray too scrict, or the API is generating the extra "type": "dng_module:Binding" by mistake?

Accepted answer

permanent link
Chris McGraw (211) | answered Apr 11 '18, 5:55 a.m.

I have confirmed this is a defect. I have opened the following work item to track: Public Module Structure representation returns 2 "type" entries for root Binding.

Pierre Bentkowski selected this answer as the correct answer

2 other answers

permanent link
Pierre Bentkowski (96517) | answered Mar 19 '18, 2:11 p.m.

Work around:

Prior to call
    JSONArray jsonArray = new JSONArray(moduleStr);

I clean the String

String pattern = ".dng_module:Binding.\n";
    moduleStr = moduleStr.replaceFirst(pattern, "");

I still think the response should be clean

permanent link
Donald Nong (14.5k414) | answered Mar 20 '18, 2:50 a.m.
edited Mar 20 '18, 8:18 p.m.

I try it in my own environment with both DNG 6.0.5 and 6.0.5 iFix003a and can see only one line of "type" : "dng_module:Binding" for each element, except for the root element. So it does appear to be a defect.

Pierre Bentkowski commented Mar 20 '18, 9:45 a.m.

Do you use any other headers then those?

get.addHeader("DoorsRP-Request-Type", "public 2.0");
get.addHeader("Accept", "application/json");

Donald Nong commented Mar 20 '18, 8:20 p.m.

I use the same headers. I have edited my response as I can actually see the same symptom.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.