From 7453d6716c32dde4c373753f0233f7f1b4e16a21 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 31 Jan 2017 04:33:12 -0800 Subject: Fix FileNotFoundException in SDNC adapter When SDNC returns HTTP 4XX code, there could be a FileNotFoundException that prevents the adpater to send back the answer to BPMN engine. Change-Id: I0f8ef5eaf95140a5d044e294f882412c8aaa4b53 Signed-off-by: Determe, Sebastien (sd378r) --- .../mso/adapters/sdnc/impl/SDNCRestClient.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java index 00d7c5a144..6ad9a6d1f5 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java @@ -48,7 +48,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - import org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest; import org.openecomp.mso.adapters.sdnc.client.CallbackHeader; import org.openecomp.mso.adapters.sdnc.client.SDNCAdapterCallbackRequest; @@ -179,15 +178,16 @@ public class SDNCRestClient implements Runnable { sdncResp.setRespCode(con.getResponseCode()); sdncResp.setRespMsg(con.getResponseMessage()); - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - - String inputLine; - //Not parsing the response -it contains a responseHdr section and data section - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + if (con.getResponseCode()>= 200 && con.getResponseCode()<=299) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + //Not parsing the response -it contains a responseHdr section and data section + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); } - in.close(); - + sdncResp.setSdncRespXml(response.toString()); msoLogger.info(MessageEnum.RA_RESPONSE_FROM_SDNC, sdncResp.toString(), "SDNC", ""); return(sdncResp); -- cgit 1.2.3-korg