X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=appc-adapters%2Fappc-chef-adapter%2Fappc-chef-adapter-bundle%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fadapter%2Fchef%2Fchefclient%2Fimpl%2FChefRequestBuilder.java;h=c2501e334d82139c2efc74b40dc6310ef8ded276;hb=06a8e46e6beb8538d75b27b8cb7d82e3bcab0a2d;hp=a2248438a2654ae1de0d13a0f3aafc0307612d86;hpb=df1c3a5b0862a881a1159e5c350eae7982bb9663;p=appc.git diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefRequestBuilder.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefRequestBuilder.java index a2248438a..c2501e334 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefRequestBuilder.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/impl/ChefRequestBuilder.java @@ -3,6 +3,7 @@ * ONAP : APPC * ================================================================================ * Copyright (C) 2018 Nokia. All rights reserved. + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,8 +34,7 @@ import org.apache.http.entity.StringEntity; final class ChefRequestBuilder { - private ChefRequestBuilder() { - } + private ChefRequestBuilder() {} static OngoingRequestBuilder newRequestTo(String endPoint) { return new OngoingRequestBuilder(endPoint); @@ -68,21 +68,22 @@ final class ChefRequestBuilder { public OngoingRequestBuilder httpPost(String body) { HttpPost httpPost = new HttpPost(); - toEntity(body); + httpPost.setEntity(toEntity(body)); httpRequestBase = httpPost; return this; } public OngoingRequestBuilder httpPut(String body) { HttpPut httpPut = new HttpPut(); - toEntity(body); + httpPut.setEntity(toEntity(body)); httpRequestBase = httpPut; return this; } - private void toEntity(String body) { + private StringEntity toEntity(String body) { StringEntity stringEntity = new StringEntity(body, "UTF-8"); stringEntity.setContentType("application/json"); + return stringEntity; } public OngoingRequestBuilder withHeaders(ImmutableMap headers) { @@ -93,13 +94,11 @@ final class ChefRequestBuilder { public HttpRequestBase build() throws URISyntaxException { setRequestUri(); setRequestHeaders(); - return httpRequestBase; } private void setRequestUri() throws URISyntaxException { - URI fullPath = new URIBuilder(endPoint) - .setPath(path).build(); + URI fullPath = new URIBuilder(endPoint).setPath(path).build(); httpRequestBase.setURI(fullPath); }