use of org.eclipse.che.commons.json.JsonParseException in project che by eclipse.
the class GitHubOAuthAuthenticator method getJson2.
protected <O> O getJson2(String getUserUrl, Class<O> userClass, Type type) throws OAuthAuthenticationException {
HttpURLConnection urlConnection = null;
InputStream urlInputStream = null;
try {
urlConnection = (HttpURLConnection) new URL(getUserUrl).openConnection();
urlConnection.setRequestProperty("Accept", "application/vnd.github.v3.html+json");
urlInputStream = urlConnection.getInputStream();
return JsonHelper.fromJson(urlInputStream, userClass, type);
} catch (JsonParseException | IOException e) {
throw new OAuthAuthenticationException(e.getMessage(), e);
} finally {
if (urlInputStream != null) {
try {
urlInputStream.close();
} catch (IOException ignored) {
}
}
if (urlConnection != null) {
urlConnection.disconnect();
}
}
}
use of org.eclipse.che.commons.json.JsonParseException in project che by eclipse.
the class OAuthAuthenticator method getJson.
protected <O> O getJson(String getUserUrl, Class<O> userClass) throws OAuthAuthenticationException {
HttpURLConnection urlConnection = null;
InputStream urlInputStream = null;
try {
urlConnection = (HttpURLConnection) new URL(getUserUrl).openConnection();
urlInputStream = urlConnection.getInputStream();
return JsonHelper.fromJson(urlInputStream, userClass, null);
} catch (JsonParseException | IOException e) {
throw new OAuthAuthenticationException(e.getMessage(), e);
} finally {
if (urlInputStream != null) {
try {
urlInputStream.close();
} catch (IOException ignored) {
}
}
if (urlConnection != null) {
urlConnection.disconnect();
}
}
}
Aggregations