diff --git a/src/main/java/fi/vm/sade/valinta/kooste/external/resource/HttpClient.java b/src/main/java/fi/vm/sade/valinta/kooste/external/resource/HttpClient.java index 04959aedb..e91e14c72 100644 --- a/src/main/java/fi/vm/sade/valinta/kooste/external/resource/HttpClient.java +++ b/src/main/java/fi/vm/sade/valinta/kooste/external/resource/HttpClient.java @@ -34,6 +34,17 @@ public HttpClient(java.net.http.HttpClient client, Gson gson) { this.gson = gson; } + public CompletableFuture getString(String url, Duration timeout) { + HttpRequest request = + buildWithCallerIdAndCsrfHeaders(HttpRequest.newBuilder(URI.create(url))) + .header("Accept", "application/json") + .GET() + .timeout(timeout) + .build(); + return this.makeRequest(request, null) + .thenApply(this::parseTxt); + } + public CompletableFuture getJson(String url, Duration timeout, Type outputType) { return this.getJson(url, timeout, outputType, null); } diff --git a/src/main/java/fi/vm/sade/valinta/kooste/tarjontaservice/TarjontaServiceResource.java b/src/main/java/fi/vm/sade/valinta/kooste/tarjontaservice/TarjontaServiceResource.java index 8b18e8faf..1e4cdadee 100644 --- a/src/main/java/fi/vm/sade/valinta/kooste/tarjontaservice/TarjontaServiceResource.java +++ b/src/main/java/fi/vm/sade/valinta/kooste/tarjontaservice/TarjontaServiceResource.java @@ -24,7 +24,6 @@ @RestController("TarjontaServiceResource") @RequestMapping("/resources/tarjonta-service") -// @PreAuthorize("isAuthenticated()") @Tag( name = "/tarjonta-service", description = "Proxy-rajapinnat vanhan tarjonnan tietojen hakemiseen") @@ -135,11 +134,11 @@ public CompletableFuture>> find( new com.google.gson.reflect.TypeToken>>() {}.getType()); } - @GetMapping(value = "/search", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8") + @GetMapping(value = "/rest/v1/hakukohde/search", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8") @Operation( summary = "Palauttaa listan hakukohteista annetuilla parametreilla", description = "Palauttaa listan hakukohteista annetuilla parametreilla.") - public CompletableFuture>> search( + public CompletableFuture search( @RequestParam(value = "searchTerms", required = false) String searchTerms, @RequestParam(value = "hakukohteenNimiUri", required = false) String hakukohteenNimiUri, @RequestParam(value = "organisationOid", required = false) List organisationOids, @@ -198,10 +197,8 @@ public CompletableFuture>>getJson( + return this.tarjontaClient.getString( urlConfiguration.url("tarjonta-service.hakukohde.search") + "?" + queryString, - Duration.ofMinutes(5), - new com.google.gson.reflect.TypeToken< - ResultV1RDTO>>() {}.getType()); + Duration.ofMinutes(5)); } }