aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/onap/so/client/RestRequest.java5
-rw-r--r--common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java9
-rw-r--r--common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java12
3 files changed, 24 insertions, 2 deletions
diff --git a/common/src/main/java/org/onap/so/client/RestRequest.java b/common/src/main/java/org/onap/so/client/RestRequest.java
index 6f0d71cabf..3864f2e5cc 100644
--- a/common/src/main/java/org/onap/so/client/RestRequest.java
+++ b/common/src/main/java/org/onap/so/client/RestRequest.java
@@ -25,6 +25,7 @@ package org.onap.so.client;
import java.util.Optional;
import java.util.concurrent.Callable;
+import javax.ws.rs.HttpMethod;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
@@ -60,8 +61,8 @@ public class RestRequest implements Callable<Response> {
response = this.client.getBuilder().accept(this.client.getAccept()).delete();
} else {
- response = this.client.getBuilder().header("X-HTTP-Method-Override", "DELETE").accept(this.client.getAccept())
- .post(Entity.entity(entity, this.client.getContentType()));
+ response = this.client.getBuilder().accept(this.client.getAccept())
+ .build(HttpMethod.DELETE, Entity.entity(entity, this.client.getContentType())).invoke();
}
} else if ("PUT".equals(method)) {
response = this.client.getBuilder().accept(this.client.getAccept()).put(Entity.entity(entity, this.client.getContentType()));
diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java
index 7fb5adcb5b..a3d16175bc 100644
--- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java
+++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java
@@ -87,5 +87,14 @@ public interface HttpRestServiceProvider {
*/
<T> ResponseEntity<T> putHttpRequest(final Object object, final String url, final Class<T> clazz);
+ /**
+ * Execute the HTTP DELETE to the given URI template
+ *
+ * @param url the URL
+ * @param clazz the type of the return value
+ * @return Returns the {@link ResponseEntity}.
+ */
+ public <T> ResponseEntity<T> deleteHttpRequest(final String url, final Class<T> clazz);
+
}
diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
index d3cc1747a3..029431c86e 100644
--- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
+++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
@@ -133,6 +133,18 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider {
}
}
+ @Override
+ public <T> ResponseEntity<T> deleteHttpRequest(final String url, final Class<T> clazz) {
+ try {
+ final HttpEntity<?> request = new HttpEntity<>(getHttpHeaders());
+ return restTemplate.exchange(url, HttpMethod.DELETE, request, clazz);
+
+ } catch (final RestClientException restClientException) {
+ LOGGER.error("Unable to invoke HTTP DELETE using url: " + url, restClientException);
+ throw new InvalidRestRequestException("Unable to invoke HTTP DELETE using URL: " + url, restClientException);
+ }
+ }
+
private HttpHeaders getHttpHeaders() {
return httpHeadersProvider.getHttpHeaders();
}