use of org.apache.http.message.BasicNameValuePair 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.message.BasicNameValuePair 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.message.BasicNameValuePair in project selenium-tests by Wikia.
the class TemplateContent method push.
public void push(String text, String templateTitle) {
URL_STRING = String.format("%s%s:%s", baseURL, PageContent.TEMPLATE_NAMESPACE, templateTitle);
PARAMS.add(new BasicNameValuePair("text", text));
call();
}
use of org.apache.http.message.BasicNameValuePair 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.message.BasicNameValuePair in project newsrob by marianokamp.
the class GRAnsweredBadRequestException method unsubscribeFeed.
public void unsubscribeFeed(String feedAtomId) throws IOException, NeedsSessionException, ReaderAPIException {
NewsRobHttpClient httpClient = NewsRobHttpClient.newInstance(false, context);
try {
Timing t = new Timing("EntriesRetriever.unsubcribeFeed()", context);
HttpPost editApiRequest = new HttpPost(getGoogleHost() + "/reader/api/0/subscription/edit?client=" + CLIENT_NAME);
LinkedList<NameValuePair> nameValuePairs = new LinkedList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("s", feedAtomId));
nameValuePairs.add(new BasicNameValuePair("ac", "unsubscribe"));
HttpResponse result;
try {
result = submitPostRequest(httpClient, editApiRequest, nameValuePairs, false);
} catch (GRAnsweredBadRequestException e) {
try {
result = submitPostRequest(httpClient, editApiRequest, nameValuePairs, false);
} catch (GRAnsweredBadRequestException e1) {
throw new ReaderAPIException("GR believes it received a bad request.");
}
}
if (HttpStatus.SC_OK == result.getStatusLine().getStatusCode())
// LATER
entryManager.removeFeedFromFeeds2Unsubscribe("tag:google.com,2005:reader/" + feedAtomId);
// Clean
// up
// the
// tag:google
// business
t.stop();
} finally {
httpClient.close();
}
}
Aggregations