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

View File

@ -1,7 +1,7 @@
package eu.dnetlib.repo.manager.service;
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.RepositorySummaryInfo;
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!");
try {
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repoId);
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
MetricsNumbers metricsNumbers = repositoryService.getMetricsInfoForRepository(repoId).getMetricsNumbers();
repositorySummaryInfo.setTotalDownloads(metricsNumbers.getTotalDownloads());
repositorySummaryInfo.setTotalViews(metricsNumbers.getTotalViews());
} catch (RepositoryServiceException e) {
logger.error("Exception getting metrics info for repository: {}, {} ", repoId, repoOfficialName, e);
}

View File

@ -776,12 +776,10 @@ 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);