summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2020-01-10 16:12:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2020-01-13 16:18:34 +0000
commite9b1dfd73a2298cc9679e527ae90a651f5025dd2 (patch)
tree79b9576c6b81802c97891b146f7b779edcc6d445 /ms/blueprintsprocessor/modules
parent3682fdce6cc5b51c364f089cf180d7483f2d7871 (diff)
Add uri-encoding to webclient
Path params are not uri-encoded, which can cause failed rest calls if resolved params include characters such as whitespace Issue-ID: CCSDK-2024 Change-Id: Iac57219260ac94897e09e3cb9d1d5884d86b83ae Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Diffstat (limited to 'ms/blueprintsprocessor/modules')
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt15
1 files changed, 9 insertions, 6 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
index 3c8d92c26..c9c8aab7d 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
@@ -42,9 +42,11 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintIOUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpMethod
+import org.springframework.web.util.UriUtils
import java.io.IOException
import java.io.InputStream
import java.nio.charset.Charset
+import java.nio.charset.StandardCharsets
interface BlueprintWebClientService {
@@ -92,14 +94,15 @@ interface BlueprintWebClientService {
* the difference is in convertToBasicHeaders vs basicHeaders
*/
val convertedHeaders: Array<BasicHeader> = convertToBasicHeaders(headers)
+ val encodedPath = UriUtils.encodePath(path, StandardCharsets.UTF_8.name())
return when (HttpMethod.resolve(methodType)) {
- HttpMethod.DELETE -> delete(path, convertedHeaders, String::class.java)
- HttpMethod.GET -> get(path, convertedHeaders, String::class.java)
- HttpMethod.POST -> post(path, request, convertedHeaders, String::class.java)
- HttpMethod.PUT -> put(path, request, convertedHeaders, String::class.java)
- HttpMethod.PATCH -> patch(path, request, convertedHeaders, String::class.java)
+ HttpMethod.DELETE -> delete(encodedPath, convertedHeaders, String::class.java)
+ HttpMethod.GET -> get(encodedPath, convertedHeaders, String::class.java)
+ HttpMethod.POST -> post(encodedPath, request, convertedHeaders, String::class.java)
+ HttpMethod.PUT -> put(encodedPath, request, convertedHeaders, String::class.java)
+ HttpMethod.PATCH -> patch(encodedPath, request, convertedHeaders, String::class.java)
else -> throw BluePrintProcessorException(
- "Unsupported methodType($methodType) attempted on path($path)"
+ "Unsupported methodType($methodType) attempted on path($encodedPath)"
)
}
}