use of org.eclipse.che.api.factory.server.scm.exception.ScmBadRequestException in project devspaces-images by redhat-developer.
the class HttpBitbucketServerApiClient method deletePersonalAccessTokens.
@Override
public void deletePersonalAccessTokens(String userSlug, Long tokenId) throws ScmItemNotFoundException, ScmUnauthorizedException, ScmCommunicationException {
URI uri = serverUri.resolve("/rest/access-tokens/1.0/users/" + userSlug + "/" + tokenId);
HttpRequest request = HttpRequest.newBuilder(uri).DELETE().headers(HttpHeaders.AUTHORIZATION, computeAuthorizationHeader("DELETE", uri.toString()), HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).timeout(DEFAULT_HTTP_TIMEOUT).build();
try {
LOG.trace("executeRequest={}", request);
executeRequest(httpClient, request, inputStream -> {
try {
return OM.readValue(inputStream, String.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
} catch (ScmBadRequestException e) {
throw new ScmCommunicationException(e.getMessage(), e);
}
}
use of org.eclipse.che.api.factory.server.scm.exception.ScmBadRequestException in project devspaces-images by redhat-developer.
the class HttpBitbucketServerApiClient method getPersonalAccessToken.
@Override
public BitbucketPersonalAccessToken getPersonalAccessToken(String userSlug, Long tokenId) throws ScmItemNotFoundException, ScmUnauthorizedException, ScmCommunicationException {
URI uri = serverUri.resolve("/rest/access-tokens/1.0/users/" + userSlug + "/" + tokenId);
HttpRequest request = HttpRequest.newBuilder(uri).headers("Authorization", computeAuthorizationHeader("GET", uri.toString()), HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).timeout(DEFAULT_HTTP_TIMEOUT).build();
try {
LOG.trace("executeRequest={}", request);
return executeRequest(httpClient, request, inputStream -> {
try {
return OM.readValue(inputStream, BitbucketPersonalAccessToken.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
} catch (ScmBadRequestException e) {
throw new ScmCommunicationException(e.getMessage(), e);
}
}
Aggregations