Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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?

0 votes


Accepted answer

Permanent link

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

0 votes


2 other answers

Permanent link

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

0 votes


Permanent link

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.

0 votes

Comments

Do you use any other headers then those?

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

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

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 11,052
× 522

Question asked: Mar 19 '18, 2:08 p.m.

Question was seen: 3,793 times

Last updated: Apr 11 '18, 5:55 a.m.

Confirmation Cancel Confirm