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>
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);
}
}
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);
}
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(",");