summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap
diff options
context:
space:
mode:
authorNicolasLaplaud <nicolas.laplaud@orange.com>2018-05-02 11:00:04 +0200
committerNicolasLaplaud <nicolas.laplaud@orange.com>2018-05-04 11:06:28 +0200
commit10684b3740dfd38323f617ef2046695e09dbcd30 (patch)
tree04bb4597c8581f4a76744d9d5bf10d8c35d8f96b /src/main/java/org/onap
parenta2a452f0539a7e9b50b2db0091481c37cf5c6589 (diff)
Problems with spaces in AAI requests
- Use java.net.uri instead of String to build parameterized url Change-Id: I11d284dc2c225932df0e1f996df46d018710a2f5 Issue-ID: EXTAPI-59 Signed-off-by: NicolasLaplaud <nicolas.laplaud@orange.com>
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java b/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
index 27fec00..9b777d8 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
@@ -15,10 +15,6 @@
*/
package org.onap.nbi.apis.serviceorder;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
import org.onap.nbi.OnapComponentsUrlPaths;
import org.onap.nbi.apis.serviceorder.model.consumer.SubscriberInfo;
import org.onap.nbi.exceptions.BackendFunctionalException;
@@ -26,15 +22,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
@Service
public class MultiClient {
@@ -162,7 +160,7 @@ public class MultiClient {
Map<String, String> param = new HashMap<>();
param.put("service-type", serviceName);
String callURL = aaiHost + OnapComponentsUrlPaths.AAI_PUT_SERVICE_FOR_CUSTOMER_PATH + serviceName;
- String callUrlFormated = callURL.toString().replace("$customerId", globalSubscriberId);
+ String callUrlFormated = callURL.replace("$customerId", globalSubscriberId);
ResponseEntity<Object> response = putRequest(param, callUrlFormated, buildRequestHeaderForAAI());
if (response != null && response.getStatusCode().equals(HttpStatus.CREATED)) {
return true;
@@ -198,11 +196,11 @@ public class MultiClient {
builder.queryParam(paramName, param.get(paramName));
}
}
- String uriBuilder = builder.build().encode().toUriString();
+ URI uri = builder.build().encode().toUri();
ResponseEntity<Object> response =
- restTemplate.exchange(uriBuilder, HttpMethod.GET, new HttpEntity<>(httpHeaders), Object.class);
+ restTemplate.exchange(uri, HttpMethod.GET, new HttpEntity<>(httpHeaders), Object.class);
LOGGER.debug("response body : " + response.getBody().toString());
LOGGER.info("response status : " + response.getStatusCodeValue());
if (!response.getStatusCode().equals(HttpStatus.OK)) {
@@ -218,4 +216,4 @@ public class MultiClient {
}
-}
+} \ No newline at end of file