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 (131517) | 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) {
            response.getEntity().consumeContent();
            throw new HttpResponseException(response.getStatusLine()
                    .getStatusCode(), response.getStatusLine()
                    .getReasonPhrase());
        }
      
        String moduleStr = EntityUtils.toString(response.getEntity());
       
        response.getEntity().consumeContent();
        JSONArray jsonArray = new JSONArray(moduleStr);


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

[{
  "uri": "https://almtest.rtp.raleigh.ibm.com/rm/resources/_a7V9wSiTEei0FZBpM_jKog/structure",
  "type": "dng_module:Binding",
  "component": "https://almtest.rtp.raleigh.ibm.com/rm/cm/component/_77fFICenEei0FZBpM_jKog",
  "type": "dng_module:Binding",
  "isStructureRoot": "true",
  "module": "https://almtest.rtp.raleigh.ibm.com/rm/resources/_a7V9wSiTEei0FZBpM_jKog",
  "boundArtifact": "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",
  "childBindings": ["https://almtest.rtp.raleigh.ibm.com/rm/resources/MB_8bc272efe08d43bab784d0f221390fee", "https://almtest.rtp.raleigh.ibm.com/rm/resources/MB_00d017f1e253498c9b28fc71efc5bc95"]
}, {

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.
JAZZ DEVELOPER

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 (131517) | 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.5k614) | 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.


Comments
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.