diff options
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java | 9 | ||||
-rw-r--r-- | common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java | 12 |
2 files changed, 21 insertions, 0 deletions
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 43b2fb4292..282c87a736 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 @@ -68,5 +68,14 @@ public interface HttpRestServiceProvider { */ public <T> ResponseEntity<T> postHttpRequest(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 032df84a98..164d48bc5e 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 @@ -138,6 +138,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(); } |