use of org.apache.commons.httpclient.NameValuePair in project tdi-studio-se by Talend.
the class ExchangeUtils method sendPostRequest.
public static String sendPostRequest(String urlAddress, Map<String, String> parameters) throws Exception {
HttpClient httpclient = new HttpClient();
PostMethod postMethod = new PostMethod(urlAddress);
if (parameters != null) {
NameValuePair[] postData = new NameValuePair[parameters.size()];
int i = 0;
for (String key : parameters.keySet()) {
String value = parameters.get(key);
postData[i++] = new NameValuePair(key, value);
}
postMethod.addParameters(postData);
}
httpclient.executeMethod(postMethod);
String response = postMethod.getResponseBodyAsString();
postMethod.releaseConnection();
return response;
}
use of org.apache.commons.httpclient.NameValuePair in project intellij-community by JetBrains.
the class JiraLegacyApi method findTasks.
@NotNull
@Override
public List<Task> findTasks(@NotNull String query, int max) throws Exception {
// Unfortunately, both SOAP and XML-RPC interfaces of JIRA don't allow fetching *all* tasks from server, but
// only filtered by some search term (see http://stackoverflow.com/questions/764282/how-can-jira-soap-api-not-have-this-method).
// JQL was added in SOAP only since JIRA 4.0 (see method JiraSoapService#getIssuesFromJqlSearch() at
// https://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/index.html?com/atlassian/jira/rpc/soap/JiraSoapService.html)
// So due to this limitation and the need to support these old versions of bug tracker (3.0, 4.2) we need the following ugly and hacky
// solution with extracting issues from RSS feed.
GetMethod method = new GetMethod(myRepository.getUrl() + RSS_SEARCH_PATH);
method.setQueryString(new NameValuePair[] { new NameValuePair("tempMax", String.valueOf(max)), new NameValuePair("assignee", TaskUtil.encodeUrl(myRepository.getUsername())), new NameValuePair("reset", "true"), new NameValuePair("sorter/field", "updated"), new NameValuePair("sorter/order", "DESC"), new NameValuePair("pager/start", "0") });
return processRSS(method);
}
use of org.apache.commons.httpclient.NameValuePair in project zaproxy by zaproxy.
the class GenericMethod method removeParameter.
/**
* Removes all parameter with the given paramName and paramValue. If there
* is more than one parameter with the given paramName, only one is
* removed. If there are none, then the request is ignored.
*
* @param paramName The parameter name to remove.
* @param paramValue The parameter value to remove.
*
* @return true if a parameter was removed.
*
* @throws IllegalArgumentException when param name or value are null
*
* @since 2.0
*/
public boolean removeParameter(String paramName, String paramValue) throws IllegalArgumentException {
log.trace("enter PostMethod.removeParameter(String, String)");
if (paramName == null) {
throw new IllegalArgumentException("Parameter name may not be null");
}
if (paramValue == null) {
throw new IllegalArgumentException("Parameter value may not be null");
}
Iterator<NameValuePair> iter = this.params.iterator();
while (iter.hasNext()) {
NameValuePair pair = iter.next();
if (paramName.equals(pair.getName()) && paramValue.equals(pair.getValue())) {
iter.remove();
return true;
}
}
return false;
}
use of org.apache.commons.httpclient.NameValuePair in project spatial-portal by AtlasOfLivingAustralia.
the class PhylogeneticDiversityListResults method evalArea.
private void evalArea(SelectedArea sa) {
try {
Query sq = QueryUtil.queryFromSelectedArea(selectedQuery, sa, null, false, null);
CSVReader r = new CSVReader(new StringReader(sq.speciesList()));
JSONArray ja = new JSONArray();
for (String[] s : r.readAll()) {
ja.add(s[1]);
}
//call pd with specieslist=ja.toString()
String url = CommonData.getSettings().getProperty(CommonData.PHYLOLIST_URL) + "/phylo/getPD";
NameValuePair[] params = new NameValuePair[2];
params[0] = new NameValuePair("noTreeText", StringConstants.TRUE);
params[1] = new NameValuePair("speciesList", ja.toString());
JSONParser jp = new JSONParser();
JSONArray pds = (JSONArray) jp.parse(Util.readUrlPost(url, params));
Map<String, String> pdrow = new HashMap<String, String>();
Map<String, JSONArray> speciesRow = new HashMap<String, JSONArray>();
for (int j = 0; j < pds.size(); j++) {
String tree = "" + ((JSONObject) pds.get(j)).get(StringConstants.STUDY_ID);
pdrow.put(tree, ((JSONObject) pds.get(j)).get("pd").toString());
speciesRow.put(tree, (JSONArray) ((JSONObject) pds.get(j)).get("taxaRecognised"));
//maxPD retrieval
String maxPd = ((JSONObject) pds.get(j)).get("maxPd").toString();
for (int k = 0; k < selectedTrees.size(); k++) {
if (((Map<String, String>) selectedTrees.get(k)).get(StringConstants.STUDY_ID).equals(tree)) {
((Map<String, String>) selectedTrees.get(k)).put("maxPd", maxPd);
}
}
}
areaPds.add(pdrow);
areaSpeciesMatches.add(speciesRow);
} catch (Exception e) {
LOGGER.error("failed processing a pd for a selected area.", e);
}
}
use of org.apache.commons.httpclient.NameValuePair in project zm-mailbox by Zimbra.
the class RawAuth method authenticate.
private void authenticate(String token) throws AuthenticationException, IOException {
Response res = doGet(GET_AUTH, new NameValuePair(APPID, appId), new NameValuePair(TOKEN, token));
cookie = res.getRequiredField(COOKIE);
wssId = res.getRequiredField(WSSID);
String s = res.getRequiredField(EXPIRATION);
try {
expiration = System.currentTimeMillis() + Long.parseLong(s) * Constants.MILLIS_PER_SECOND;
} catch (NumberFormatException e) {
throw new IOException("Invalid integer value for field '" + EXPIRATION + "': " + s);
}
}
Aggregations