From 09031e372568052390f514ad37efa919299153a4 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Mon, 2 Apr 2018 17:29:53 +0900 Subject: RESTapiCallNode make request without content-type currently the RESTAPI adaptor doesn't make a REST request with empty Content-type, this change is to help the adaptor to make request with no Content-type, currently defaulting to application/json. This is to avoid, when some servers throw 415 Unsupported Media Type error, when they dont support JSON response. Issue-ID: CCSDK-232 Change-Id: I19fbb949f0aad4ea7ca91d6afcac06a5b7f8deed Signed-off-by: Ganesh Chandrasekaran --- .../src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java | 4 +++- .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'restapi-call-node/provider/src/main/java/org/onap') diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java index 776485af..1578ee32 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java @@ -22,13 +22,15 @@ package org.onap.ccsdk.sli.plugins.restapicall; public enum Format { - JSON, XML; + JSON, XML, NONE; public static Format fromString(String s) { if ("json".equalsIgnoreCase(s)) return JSON; if ("xml".equalsIgnoreCase(s)) return XML; + if ("none".equalsIgnoreCase(s)) + return NONE; throw new IllegalArgumentException("Invalid value for format: " + s); } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index e5c18596..ea2d259b 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -437,7 +437,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Client client = Client.create(config); client.setConnectTimeout(5000); - if (p.restapiUser != null) + if (p.restapiUser != null && p.restapiPassword != null) client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); WebResource webResource = client.resource(p.restapiUrl); @@ -457,6 +457,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); + if(p.format == Format.NONE){ + webResourceBuilder = webResource.header("",""); + } if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { String[] keyValuePairs = p.customHttpHeaders.split(","); -- cgit 1.2.3-korg