Deprecation fix apache.httpcomponents

fix deprecation due to apache.httpcomponents upgrade and fixing some
code warnings
This commit is contained in:
Sylvain Bugat 2014-11-24 22:02:56 +01:00
parent b3839f089b
commit c1a1f3c365

View file

@ -37,7 +37,6 @@ import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.dom4j.Document;
import org.rundeck.api.RundeckApiException.RundeckApiLoginException;
import org.rundeck.api.RundeckApiException.RundeckApiTokenException;
import org.rundeck.api.parser.ParserHelper;
@ -639,11 +638,11 @@ class ApiCall {
while (true) {
try {
HttpPost postLogin = new HttpPost(location);
List params = new ArrayList();
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("j_username", client.getLogin()));
params.add(new BasicNameValuePair("j_password", client.getPassword()));
params.add(new BasicNameValuePair("action", "login"));
postLogin.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
postLogin.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
HttpResponse response = httpClient.execute(postLogin);
if (response.getStatusLine().getStatusCode() / 100 == 3) {
@ -663,7 +662,7 @@ class ApiCall {
}
try {
String content = EntityUtils.toString(response.getEntity(), HTTP.UTF_8);
String content = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
if (StringUtils.contains(content, "j_security_check")) {
throw new RundeckApiLoginException("Login failed for user " + client.getLogin());
}