final class ApiThrowables { static final int BAD_REQUEST = 400; static final int NOT_FOUND = 404; public static ApiException newCourseIdNotFound(String courseId) { return new ApiException(2, NOT_FOUND,"Course with ID [" + courseId + "] does not exist."); } public static ApiException newBadCourseId(String courseId) { return new ApiException(2, BAD_REQUEST,"Course ID [" + courseId + "] is not valid."); } }
private <T> T getProfileByPublicUrl(String url, String fields, Class<T> type) { try { URI uri = URIBuilder.fromUri(BASE_URL + "url=" + URLEncoder.encode(url, "UTF-8") + fields).build(); return restOperations.exchange(uri, HttpMethod.GET, new HttpEntity<String>(""), type).getBody(); } catch (UnsupportedEncodingException unlikely) { unlikely.printStackTrace(); throw new ApiException("linkedin", "Unlikely unsupported encoding error", unlikely); } }
private <T> T getProfileByPublicUrl(String url, String fields, Class<T> type) { try { URI uri = URIBuilder.fromUri(BASE_URL + "url=" + URLEncoder.encode(url, "UTF-8") + fields).build(); return restOperations.exchange(uri, HttpMethod.GET, new HttpEntity<String>(""), type).getBody(); } catch (UnsupportedEncodingException unlikely) { unlikely.printStackTrace(); throw new ApiException("linkedin", "Unlikely unsupported encoding error", unlikely); } }
if (statusCode != HttpStatus.SC_OK) { status = "ApiError"; throw new ApiException();