private Profile getProfile() throws Exception {
Profile profile = new Profile();
String url = PROFILE_URL + accessToken.getAttribute("screen_name");
LOG.debug("Obtaining user profile. Profile URL : " + url);
Response serviceResponse = null;
try {
serviceResponse = authenticationStrategy.executeFeed(url);
} catch (Exception e) {
throw new SocialAuthException(
"Failed to retrieve the user profile from " + url, e);
}
if (serviceResponse.getStatus() != 200) {
throw new SocialAuthException(
"Failed to retrieve the user profile from " + url
+ ". Status :" + serviceResponse.getStatus());
}
String result;
try {
result = serviceResponse
.getResponseBodyAsString(Constants.ENCODING);
LOG.debug("User Profile :" + result);
} catch (Exception exc) {
throw new SocialAuthException("Failed to read response from "
+ url, exc);