- Show error-messages for Broker's errors.

- Code polishing.
This commit is contained in:
Lampros Smyrnaios 2023-02-15 18:31:13 +02:00
parent 8f5aed3aab
commit c006c7baa0
3 changed files with 12 additions and 6 deletions

View File

@ -114,6 +114,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<List<BrowseEntry>>() { new ParameterizedTypeReference<List<BrowseEntry>>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
@ -146,6 +147,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<EventsPage>() {} new ParameterizedTypeReference<EventsPage>() {}
); );
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -195,6 +197,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<EventsPage>() { new ParameterizedTypeReference<EventsPage>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -219,6 +222,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() { new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -252,6 +256,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Subscription>() { new ParameterizedTypeReference<Subscription>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
@ -274,6 +279,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Void>() { new ParameterizedTypeReference<Void>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
return new ResponseEntity<>("OK", HttpStatus.OK); return new ResponseEntity<>("OK", HttpStatus.OK);
@ -296,6 +302,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Subscription>() { new ParameterizedTypeReference<Subscription>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -325,6 +332,7 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<EventsPage>() { new ParameterizedTypeReference<EventsPage>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
logger.error(e.getMessage());
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();

View File

@ -1,7 +1,7 @@
package eu.dnetlib.repo.manager.service; package eu.dnetlib.repo.manager.service;
import eu.dnetlib.enabling.datasources.common.AggregationInfo; import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.repo.manager.domain.MetricsInfo; import eu.dnetlib.repo.manager.domain.MetricsNumbers;
import eu.dnetlib.repo.manager.domain.RepositorySnippet; import eu.dnetlib.repo.manager.domain.RepositorySnippet;
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo; import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry; import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
@ -68,9 +68,9 @@ public class DashboardServiceImpl implements DashboardService {
logger.warn("Could not find repo aggregations, after " + (end - start) + "ms!"); logger.warn("Could not find repo aggregations, after " + (end - start) + "ms!");
try { try {
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repoId); MetricsNumbers metricsNumbers = repositoryService.getMetricsInfoForRepository(repoId).getMetricsNumbers();
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads()); repositorySummaryInfo.setTotalDownloads(metricsNumbers.getTotalDownloads());
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews()); repositorySummaryInfo.setTotalViews(metricsNumbers.getTotalViews());
} catch (RepositoryServiceException e) { } catch (RepositoryServiceException e) {
logger.error("Exception getting metrics info for repository: {}, {} ", repoId, repoOfficialName, e); logger.error("Exception getting metrics info for repository: {}, {} ", repoId, repoOfficialName, e);
} }

View File

@ -776,12 +776,10 @@ public class RepositoryServiceImpl implements RepositoryService {
@Override @Override
public MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException { public MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException {
try { try {
MetricsInfo metricsInfo = new MetricsInfo(); MetricsInfo metricsInfo = new MetricsInfo();
metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL); metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL);
metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId))); metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId)));
return metricsInfo; return metricsInfo;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error while getting metrics info for repository: ", e); logger.error("Error while getting metrics info for repository: ", e);
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);