diff --git a/src/main/java/io/securecodebox/persistence/defectdojo/service/GenericDefectDojoService.java b/src/main/java/io/securecodebox/persistence/defectdojo/service/GenericDefectDojoService.java index 6665f13..80d6070 100644 --- a/src/main/java/io/securecodebox/persistence/defectdojo/service/GenericDefectDojoService.java +++ b/src/main/java/io/securecodebox/persistence/defectdojo/service/GenericDefectDojoService.java @@ -70,7 +70,7 @@ public final T get(long id) { var restTemplate = this.getRestTemplate(); HttpEntity payload = new HttpEntity<>(getDefectDojoAuthorizationHeaders()); - final var url = this.clientConfig.getUrl() + API_PREFIX + this.getUrlPath() + "/" + id; + final var url = createBaseUrl() + id; log.debug("Requesting URL: {}", url); ResponseEntity response = restTemplate.exchange( url, @@ -132,7 +132,7 @@ public final T create(@NonNull T object) { var restTemplate = this.getRestTemplate(); HttpEntity payload = new HttpEntity<>(object, getDefectDojoAuthorizationHeaders()); - ResponseEntity response = restTemplate.exchange(this.clientConfig.getUrl() + API_PREFIX + getUrlPath() + "/", HttpMethod.POST, payload, getModelClass()); + ResponseEntity response = restTemplate.exchange(createBaseUrl(), HttpMethod.POST, payload, getModelClass()); return response.getBody(); } @@ -141,7 +141,7 @@ public final void delete(long id) { var restTemplate = this.getRestTemplate(); HttpEntity payload = new HttpEntity<>(getDefectDojoAuthorizationHeaders()); - restTemplate.exchange(this.clientConfig.getUrl() + API_PREFIX + getUrlPath() + "/" + id + "/", HttpMethod.DELETE, payload, String.class); + restTemplate.exchange(createBaseUrl() + id + "/", HttpMethod.DELETE, payload, String.class); } @Override @@ -149,7 +149,7 @@ public final T update(@NonNull T object, long id) { var restTemplate = this.getRestTemplate(); HttpEntity payload = new HttpEntity<>(object, getDefectDojoAuthorizationHeaders()); - ResponseEntity response = restTemplate.exchange(this.clientConfig.getUrl() + API_PREFIX + getUrlPath() + "/" + id + "/", HttpMethod.PUT, payload, getModelClass()); + ResponseEntity response = restTemplate.exchange(createBaseUrl() + id + "/", HttpMethod.PUT, payload, getModelClass()); return response.getBody(); } @@ -175,6 +175,10 @@ public final T update(@NonNull T object, long id) { */ protected abstract PaginatedResult deserializeList(@NonNull String response); + private String createBaseUrl() { + return this.clientConfig.getUrl() + API_PREFIX + getUrlPath() + "/"; + } + /** * @return The DefectDojo Authentication Header */ @@ -211,7 +215,7 @@ protected PaginatedResult internalSearch(Map queryParams, lon multiValueMap.set(entry.getKey(), String.valueOf(entry.getValue())); } - final var url = this.clientConfig.getUrl() + API_PREFIX + this.getUrlPath() + "/"; + final var url = createBaseUrl(); final UriComponentsBuilder builder; try { builder = UriComponentsBuilder