Skip to content

Commit

Permalink
secureCodeBox#121 Remove Uneccessary Indirect Call to REST Template
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed Jul 3, 2024
1 parent d72ee2f commit 9797207
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.securecodebox.persistence.defectdojo.model.Engagement;
import io.securecodebox.persistence.defectdojo.model.Model;
import io.securecodebox.persistence.defectdojo.model.PaginatedResult;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
Expand Down Expand Up @@ -46,13 +45,10 @@ abstract class GenericDefectDojoService<T extends Model> implements DefectDojoSe
private static final long DEFECT_DOJO_OBJET_LIMIT = 100L;
private final ClientConfig clientConfig;
private final ProxyConfig proxyConfig;

private final RestTemplate restTemplate;
protected ObjectMapper objectMapper;
protected ObjectMapper searchStringMapper;

@Getter // TODO: Remove this getter
private final RestTemplate restTemplate;


/**
* Convenience constructor which initializes {@link #proxyConfig}
*
Expand Down Expand Up @@ -88,7 +84,6 @@ public GenericDefectDojoService(@NonNull ClientConfig clientConfig, @NonNull Pro

@Override
public final T get(long id) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<String> payload = new HttpEntity<>(createAuthorizationHeaders());

final var url = createBaseUrl().resolve(String.valueOf(id));
Expand Down Expand Up @@ -149,7 +144,6 @@ public final Optional<T> searchUnique(@NonNull Map<String, Object> queryParams)

@Override
public final T create(@NonNull T object) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<T> payload = new HttpEntity<>(object, createAuthorizationHeaders());
final ResponseEntity<T> response = restTemplate.exchange(createBaseUrl(), HttpMethod.POST, payload, getModelClass());

Expand All @@ -158,7 +152,6 @@ public final T create(@NonNull T object) {

@Override
public final void delete(long id) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<String> payload = new HttpEntity<>(createAuthorizationHeaders());

final var url = createBaseUrl().resolve(id + "/");
Expand All @@ -167,7 +160,6 @@ public final void delete(long id) {

@Override
public final T update(@NonNull T object, long id) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<T> payload = new HttpEntity<>(object, createAuthorizationHeaders());
final var url = createBaseUrl().resolve(id + "/");
final ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.PUT, payload, getModelClass());
Expand Down Expand Up @@ -226,7 +218,6 @@ private RestTemplate setupRestTemplate() {
}

protected PaginatedResult<T> internalSearch(Map<String, Object> queryParams, long limit, long offset) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<String> payload = new HttpEntity<>(createAuthorizationHeaders());

final var mutableQueryParams = new HashMap<>(queryParams);
Expand Down

0 comments on commit 9797207

Please sign in to comment.