use of org.apache.http.NameValuePair in project tdi-studio-se by Talend.
the class palodimension method rename.
public void rename(String strDimensionNewName) throws paloexception {
if (null != strDimensionNewName && strDimensionNewName.length() > 0 && !strDimensionName.equals(strDimensionNewName)) {
List<NameValuePair> qparams = new ArrayList<NameValuePair>();
qparams.add(new BasicNameValuePair("sid", this.plConn.getPaloToken()));
qparams.add(new BasicNameValuePair("database", String.valueOf(lDatabaseId)));
qparams.add(new BasicNameValuePair("dimension", String.valueOf(this.iDimensionId)));
qparams.add(new BasicNameValuePair("new_name", strDimensionNewName));
try {
HttpEntity entity = this.plConn.sendToServer(qparams, "/dimension/rename");
CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
csv.setQuoteChar('"');
csv.readNext();
this.strDimensionName = csv.get(1);
csv.close();
entity.consumeContent();
} catch (Exception e) {
throw new paloexception(e.getMessage());
}
}
}
use of org.apache.http.NameValuePair in project voltdb by VoltDB.
the class HTTPUtils method callProcOverJSON.
public static String callProcOverJSON(String procName, ParameterSet pset, String username, String password, boolean preHash, boolean admin, CloseableHttpClient httpclient, HttpPost httppost) throws Exception {
// Call insert
String paramsInJSON = pset.toJSONString();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Procedure", procName));
params.add(new BasicNameValuePair("Parameters", paramsInJSON));
if (username != null) {
params.add(new BasicNameValuePair("User", username));
}
if (password != null) {
if (preHash) {
params.add(new BasicNameValuePair("Hashedpassword", getHashedPasswordForHTTPVar(password)));
} else {
params.add(new BasicNameValuePair("Password", password));
}
}
if (admin) {
params.add(new BasicNameValuePair("admin", "true"));
}
return callProcOverJSONRaw(params, httpclient, httppost);
}
use of org.apache.http.NameValuePair in project selenium-tests by Wikia.
the class CommonUtils method sendPost.
public static String sendPost(String apiUrl, String[][] param) {
try {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(apiUrl);
List<NameValuePair> paramPairs = new ArrayList<NameValuePair>();
for (int i = 0; i < param.length; i++) {
paramPairs.add(new BasicNameValuePair(param[i][0], param[i][1]));
}
httpPost.setEntity(new UrlEncodedFormEntity(paramPairs));
HttpResponse response = null;
response = httpclient.execute(httpPost);
HttpEntity entity = response.getEntity();
return EntityUtils.toString(entity);
} catch (UnsupportedEncodingException e) {
PageObjectLogging.log("sendPost", e, false);
return null;
} catch (ClientProtocolException e) {
PageObjectLogging.log("sendPost", e, false);
return null;
} catch (IOException e) {
PageObjectLogging.log("sendPost", e, false);
return null;
}
}
use of org.apache.http.NameValuePair in project ats-framework by Axway.
the class HttpClient method performPostRequest.
/**
* Perform HTTP POST request based on the host and port specified before
*
* @param requestedHostRelativeUrl location/query without host and port like: "/my_dir/res?myParam=1"
* @param needResponse whether caller needs the contents returned from this request
* @param paramsMap map of parameters to be sent with this POST request
* @throws FileTransferException
*/
public String performPostRequest(String requestedHostRelativeUrl, boolean needResponse, HashMap<String, String> paramsMap) throws FileTransferException {
checkClientInitialized();
final String getUrl = constructGetUrl(requestedHostRelativeUrl);
log.info("Performing POST request to: " + getUrl);
HttpPost postMethod = new HttpPost(getUrl);
addRequestHeaders(postMethod);
if (paramsMap != null && paramsMap.size() > 0) {
List<NameValuePair> parameters = new ArrayList<NameValuePair>(paramsMap.size());
for (Entry<String, String> paramEntry : paramsMap.entrySet()) {
log.info("Add parameter " + paramEntry.getKey() + " and value: " + paramEntry.getValue());
parameters.add(new BasicNameValuePair(paramEntry.getKey(), paramEntry.getValue()));
}
UrlEncodedFormEntity sendEntity = null;
try {
sendEntity = new UrlEncodedFormEntity(parameters, "UTF-8");
} catch (UnsupportedEncodingException ex) {
throw new FileTransferException(ex);
}
postMethod.setEntity(sendEntity);
}
return (String) processHttpRequest(postMethod, needResponse, true);
}
use of org.apache.http.NameValuePair in project UltimateAndroid by cymcsg.
the class HttpUtilsAsync method uploadFiles.
public static void uploadFiles(String url, List<NameValuePair> paramsList, String fileParams, List<File> files, AsyncHttpResponseHandler responseHandler) {
SyncHttpClient syncHttpClient = new SyncHttpClient();
RequestParams params = new RequestParams();
try {
if (BasicUtils.judgeNotNull(paramsList)) {
for (NameValuePair nameValuePair : paramsList) {
params.put(nameValuePair.getName(), nameValuePair.getValue());
}
}
if (BasicUtils.judgeNotNull(files))
params.put(fileParams, files);
} catch (Exception e) {
Logs.e(e, "");
}
syncHttpClient.setTimeout(TIME_OUT);
syncHttpClient.post(url, params, responseHandler);
}
Aggregations