RESTapiCallNode make request without content-type 97/40497/1
authorGanesh Chandrasekaran <ganesh.c@samsung.com>
Mon, 2 Apr 2018 08:29:53 +0000 (17:29 +0900)
committerGanesh Chandrasekaran <ganesh.c@samsung.com>
Mon, 2 Apr 2018 08:48:24 +0000 (17:48 +0900)
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 <ganesh.c@samsung.com>
restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java
restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java

index 776485a..1578ee3 100644 (file)
 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);
     }
 }
index e5c1859..ea2d259 100644 (file)
@@ -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(",");