You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/11/08 12:04:34 UTC
[incubator-dlab] branch develop updated: DLAB-1246 error message
changed in case when endpoint is not accessible
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/develop by this push:
new a7cd13e DLAB-1246 error message changed in case when endpoint is not accessible
a7cd13e is described below
commit a7cd13e738715531e2eb30998bf4278656da6fe8
Author: bhliva <bo...@epam.com>
AuthorDate: Fri Nov 8 14:01:51 2019 +0200
DLAB-1246 error message changed in case when endpoint is not accessible
---
.../com/epam/dlab/rest/client/RESTService.java | 24 ++++++++--------------
.../service/impl/ExploratoryServiceImpl.java | 12 ++++++-----
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/services/dlab-webapp-common/src/main/java/com/epam/dlab/rest/client/RESTService.java b/services/dlab-webapp-common/src/main/java/com/epam/dlab/rest/client/RESTService.java
index 5008bcd..ab1d29e 100644
--- a/services/dlab-webapp-common/src/main/java/com/epam/dlab/rest/client/RESTService.java
+++ b/services/dlab-webapp-common/src/main/java/com/epam/dlab/rest/client/RESTService.java
@@ -19,14 +19,17 @@
package com.epam.dlab.rest.client;
+import com.epam.dlab.exceptions.DlabException;
import lombok.extern.slf4j.Slf4j;
+import javax.ws.rs.ProcessingException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
+import java.net.ConnectException;
import java.net.URI;
import java.util.Collections;
import java.util.Map;
@@ -52,9 +55,7 @@ public class RESTService {
}
public <T> T get(String path, Class<T> clazz) {
- Invocation.Builder builder = getBuilder(path);
- log.debug("REST get {}", path);
- return builder.get(clazz);
+ return get(path, null, clazz);
}
public <T> T get(URI path, Class<T> clazz) {
@@ -64,22 +65,18 @@ public class RESTService {
.get(clazz);
}
- public <T> T post(String path, Object parameter, Class<T> clazz) {
- Invocation.Builder builder = getBuilder(path);
- log.debug("REST post {}", path);
- return builder.post(Entity.json(parameter), clazz);
- }
-
public <T> T get(String path, String accessToken, Class<T> clazz) {
Invocation.Builder builder = getBuilder(path, accessToken, Collections.emptyMap());
log.debug("REST get secured {} {}", path, accessToken);
return builder.get(clazz);
}
+ public <T> T post(String path, Object parameter, Class<T> clazz) {
+ return post(path, null, parameter, clazz);
+ }
+
public <T> T post(String path, String accessToken, Object parameter, Class<T> clazz) {
- Invocation.Builder builder = getBuilder(path, accessToken, Collections.emptyMap());
- log.debug("REST post secured {} {}", path, accessToken);
- return builder.post(Entity.json(parameter), clazz);
+ return post(path, accessToken, parameter, clazz, Collections.emptyMap());
}
public <T> T post(String path, String accessToken, Object parameter, Class<T> clazz,
@@ -89,9 +86,6 @@ public class RESTService {
return builder.post(Entity.json(parameter), clazz);
}
- private Invocation.Builder getBuilder(String path) {
- return getBuilder(path, null, Collections.emptyMap());
- }
private Invocation.Builder getBuilder(String path, String token, Map<String, Object> queryParams) {
WebTarget webTarget = getWebTarget(path);
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImpl.java
index 9c5594b..500d0fc 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/ExploratoryServiceImpl.java
@@ -121,7 +121,7 @@ public class ExploratoryServiceImpl implements ExploratoryService {
updateExploratoryStatusSilent(userInfo.getName(), exploratory.getName(), FAILED);
}
throw new DlabException("Could not create exploratory environment " + exploratory.getName() + " for user "
- + userInfo.getName() + ": " + t.getLocalizedMessage(), t);
+ + userInfo.getName() + ": " + Optional.ofNullable(t.getCause()).map(Throwable::getMessage).orElse(t.getMessage()), t);
}
}
@@ -248,11 +248,13 @@ public class ExploratoryServiceImpl implements ExploratoryService {
requestId.put(userInfo.getName(), uuid);
return uuid;
} catch (Exception t) {
- log.error("Could not " + action + " exploratory environment {} for user {}", exploratoryName, userInfo
- .getName(), t);
+ log.error("Could not {} exploratory environment {} for user {}",
+ StringUtils.substringAfter(action, "/"), exploratoryName, userInfo.getName(), t);
updateExploratoryStatusSilent(userInfo.getName(), exploratoryName, FAILED);
- throw new DlabException("Could not " + action + " exploratory environment " + exploratoryName + ": " +
- t.getLocalizedMessage(), t);
+ final String errorMsg = String.format("Could not %s exploratory environment %s: %s",
+ StringUtils.substringAfter(action, "/"), exploratoryName,
+ Optional.ofNullable(t.getCause()).map(Throwable::getMessage).orElse(t.getMessage()));
+ throw new DlabException(errorMsg, t);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org