*/
@Override
public Response updateStatus(final String msg) throws Exception {
LOG.info("Updatting status " + msg);
if (!isVerify) {
throw new SocialAuthException(
"Please call verifyResponse function first to get Access Token");
}
if (msg == null || msg.trim().length() == 0) {
throw new ServerDataException("Status cannot be blank");
}
String message = msg;
if (message.length() > 140) {
LOG.debug("Truncating message up to 140 characters");
message = message.substring(0, 140);
}
String url = UPDATE_STATUS_URL
+ URLEncoder.encode(message, Constants.ENCODING);
Response serviceResponse = null;
try {
serviceResponse = authenticationStrategy.executeFeed(url,
MethodType.POST.toString(), null, null, null);
} catch (Exception e) {
throw new SocialAuthException("Failed to update status on " + url,
e);
}
if (serviceResponse.getStatus() != 200) {
throw new SocialAuthException("Failed to update status on " + url
+ ". Status :" + serviceResponse.getStatus());
}
return serviceResponse;
}