From 768004de62fdea8a9630346252d79d37b4c735c5 Mon Sep 17 00:00:00 2001 From: Konstantinos Spyrou Date: Mon, 23 Sep 2024 12:15:32 +0300 Subject: [PATCH] removed try-catch and reused existing restTemplate --- .../service/RepositoryServiceImpl.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java index e92f524..202cc39 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java @@ -774,16 +774,11 @@ public class RepositoryServiceImpl implements RepositoryService { } @Override - public MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException { - try { - MetricsInfo metricsInfo = new MetricsInfo(); - metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL); - metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId))); - return metricsInfo; - } catch (Exception e) { - logger.error("Error while getting metrics info for repository: ", e); - throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); - } + public MetricsInfo getMetricsInfoForRepository(String repoId) { + MetricsInfo metricsInfo = new MetricsInfo(); + metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL); + metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId))); + return metricsInfo; } @Override @@ -853,13 +848,8 @@ public class RepositoryServiceImpl implements RepositoryService { //build the uri params UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usageStatisticsNumbersBaseURL + openAIREID + "/clicks"); - //create new template engine - RestTemplate template = new RestTemplate(); - template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); - ResponseEntity resp; - //communicate with endpoint - resp = template.exchange( + ResponseEntity resp = restTemplate.exchange( builder.build().encode().toUri(), HttpMethod.GET, null,