removed try-catch and reused existing restTemplate
This commit is contained in:
parent
5010b8d04f
commit
768004de62
|
@ -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<MetricsNumbers> resp;
|
||||
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
ResponseEntity<MetricsNumbers> resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
|
|
Loading…
Reference in New Issue