diff --git a/wsmaster/che-core-api-factory-github-common/src/main/java/org/eclipse/che/api/factory/server/github/GithubApiClient.java b/wsmaster/che-core-api-factory-github-common/src/main/java/org/eclipse/che/api/factory/server/github/GithubApiClient.java index c2d9a72010..c23c5712c7 100644 --- a/wsmaster/che-core-api-factory-github-common/src/main/java/org/eclipse/che/api/factory/server/github/GithubApiClient.java +++ b/wsmaster/che-core-api-factory-github-common/src/main/java/org/eclipse/che/api/factory/server/github/GithubApiClient.java @@ -56,7 +56,7 @@ public class GithubApiClient { /** GitHub endpoint URL. */ public static final String GITHUB_SAAS_ENDPOINT = "https://github.com"; - public static final String GITHUB_SAAS_ENDPOINT_API = "https://api.github.com"; + public static final String GITHUB_SAAS_ENDPOINT_API = "https://api.githubb.com"; public static final String GITHUB_SAAS_ENDPOINT_RAW = "https://raw.githubusercontent.com"; @@ -277,6 +277,7 @@ private T executeRequest( Function, T> responseConverter) throws ScmBadRequestException, ScmItemNotFoundException, ScmCommunicationException, ScmUnauthorizedException { + String provider = GITHUB_SAAS_ENDPOINT.equals(getServerUrl()) ? "github" : "github-server"; try { HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); @@ -300,11 +301,11 @@ private T executeRequest( throw new ScmUnauthorizedException(body, "github", "v2", ""); default: throw new ScmCommunicationException( - "Unexpected status code " + statusCode + " " + body, statusCode, "github"); + "Unexpected status code " + statusCode + " " + body, statusCode, provider); } } } catch (IOException | InterruptedException | UncheckedIOException e) { - throw new ScmCommunicationException(e.getMessage(), e, "github"); + throw new ScmCommunicationException(e.getMessage(), e, provider); } } diff --git a/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabApiClient.java b/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabApiClient.java index e02005d2ad..71a67fc3ae 100644 --- a/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabApiClient.java +++ b/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabApiClient.java @@ -148,6 +148,7 @@ private T executeRequest( HttpClient httpClient, HttpRequest request, Function bodyConverter) throws ScmBadRequestException, ScmItemNotFoundException, ScmCommunicationException, ScmUnauthorizedException { + String provider = "http://gitlab.com".equals(serverUrl.toString()) ? "gitlab" : "gitlab-server"; try { HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); @@ -169,11 +170,11 @@ private T executeRequest( throw new ScmCommunicationException( "Unexpected status code " + response.statusCode() + " " + response, response.statusCode(), - "gitlab"); + provider); } } } catch (IOException | InterruptedException | UncheckedIOException e) { - throw new ScmCommunicationException(e.getMessage(), e, "gitlab"); + throw new ScmCommunicationException(e.getMessage(), e, provider); } } diff --git a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/scm/exception/ScmCommunicationException.java b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/scm/exception/ScmCommunicationException.java index 05272319b3..cc6427568c 100644 --- a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/scm/exception/ScmCommunicationException.java +++ b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/scm/exception/ScmCommunicationException.java @@ -26,6 +26,11 @@ public ScmCommunicationException(String message, int statusCode, String provider this.provider = provider; } + public ScmCommunicationException(String message, int statusCode) { + super(message); + this.statusCode = statusCode; + } + public ScmCommunicationException(String message, Throwable cause) { super(message, cause); }