You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by of...@apache.org on 2020/04/09 08:37:46 UTC
[incubator-dlab] branch DLAB-1571 updated: fixed exception output
This is an automated email from the ASF dual-hosted git repository.
ofuks pushed a commit to branch DLAB-1571
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1571 by this push:
new 7f26141 fixed exception output
7f26141 is described below
commit 7f261415a3f66d3ec049eff43c2c3cfc14f52d7d
Author: Oleh Fuks <ol...@gmail.com>
AuthorDate: Thu Apr 9 11:37:17 2020 +0300
fixed exception output
---
.../service/impl/BillingServiceImpl.java | 41 ++++++++++++----------
.../service/impl/EndpointServiceImpl.java | 2 +-
2 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java
index c54d624..41dbeb4 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java
@@ -147,26 +147,20 @@ public class BillingServiceImpl implements BillingService {
}
public void updateRemoteBillingData(UserInfo userInfo) {
- try {
- List<EndpointDTO> endpoints = endpointService.getEndpoints();
- if (CollectionUtils.isEmpty(endpoints)) {
- log.error("Cannot update billing info. There are no endpoints");
- throw new DlabException("Cannot update billing info. There are no endpoints");
- }
+ List<EndpointDTO> endpoints = endpointService.getEndpoints();
+ if (CollectionUtils.isEmpty(endpoints)) {
+ log.error("Cannot update billing info. There are no endpoints");
+ throw new DlabException("Cannot update billing info. There are no endpoints");
+ }
- Map<EndpointDTO, List<BillingData>> billingDataMap = endpoints
- .stream()
- .collect(Collectors.toMap(e -> e, e -> provisioningService.get(getBillingUrl(e.getUrl(), BILLING_PATH), userInfo.getAccessToken(),
- new GenericType<List<BillingData>>() {
- })));
+ Map<EndpointDTO, List<BillingData>> billingDataMap = endpoints
+ .stream()
+ .collect(Collectors.toMap(e -> e, e -> getBillingData(userInfo, e)));
- billingDataMap.forEach((endpointDTO, billingData) -> {
- log.info("Updating billing information for endpoint {}", endpointDTO.getName());
- updateBillingData(userInfo, endpointDTO, billingData);
- });
- } catch (DlabException e) {
- log.error("Cannot retrieve billing information for {}", e.getMessage());
- }
+ billingDataMap.forEach((endpointDTO, billingData) -> {
+ log.info("Updating billing information for endpoint {}", endpointDTO.getName());
+ updateBillingData(userInfo, endpointDTO, billingData);
+ });
}
private Map<String, BillingReportLine> getBillableResources(UserInfo userInfo) {
@@ -246,6 +240,17 @@ public class BillingServiceImpl implements BillingService {
billingDAO.save(billingReportLines);
}
+ private List<BillingData> getBillingData(UserInfo userInfo, EndpointDTO e) {
+ try {
+ return provisioningService.get(getBillingUrl(e.getUrl(), BILLING_PATH), userInfo.getAccessToken(),
+ new GenericType<List<BillingData>>() {
+ });
+ } catch (Exception ex) {
+ log.error("Cannot retrieve billing information for {}. {}", e.getName(), ex.getMessage());
+ return Collections.emptyList();
+ }
+ }
+
private String getBillingUrl(String endpointUrl, String path) {
URI uri;
try {
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java
index 9c71f76..645f84b 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EndpointServiceImpl.java
@@ -138,7 +138,7 @@ public class EndpointServiceImpl implements EndpointService {
cloudProvider = response.readEntity(CloudProvider.class);
} catch (Exception e) {
log.error("Cannot connect to url '{}'. {}", url, e.getMessage());
- throw new DlabException(String.format("Cannot connect to url '%s'", url), e);
+ throw new DlabException(String.format("Cannot connect to url '%s'. %s", url, e.getMessage()));
}
if (response.getStatus() != 200) {
log.warn("Endpoint url {} is not valid", url);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org