Search in sources :

Example 86 with BasicNameValuePair

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());
        }
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 87 with BasicNameValuePair

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);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 88 with BasicNameValuePair

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();
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair)

Example 89 with BasicNameValuePair

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;
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpPost(org.apache.http.client.methods.HttpPost) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) UnsupportedEncodingException(java.io.UnsupportedEncodingException) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) IOException(java.io.IOException) ClientProtocolException(org.apache.http.client.ClientProtocolException) BasicNameValuePair(org.apache.http.message.BasicNameValuePair)

Example 90 with BasicNameValuePair

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();
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NewsRobHttpClient(com.newsrob.download.NewsRobHttpClient) HttpResponse(org.apache.http.HttpResponse) Timing(com.newsrob.util.Timing) LinkedList(java.util.LinkedList)

Aggregations

BasicNameValuePair (org.apache.http.message.BasicNameValuePair)289 NameValuePair (org.apache.http.NameValuePair)199 ArrayList (java.util.ArrayList)187 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)101 HttpPost (org.apache.http.client.methods.HttpPost)87 HttpResponse (org.apache.http.HttpResponse)77 HttpEntity (org.apache.http.HttpEntity)58 IOException (java.io.IOException)55 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)33 Test (org.junit.Test)32 HttpGet (org.apache.http.client.methods.HttpGet)29 ClientProtocolException (org.apache.http.client.ClientProtocolException)28 CSVReader (com.talend.csv.CSVReader)27 HttpClient (org.apache.http.client.HttpClient)25 UnsupportedEncodingException (java.io.UnsupportedEncodingException)23 HashMap (java.util.HashMap)20 JSONObject (org.json.JSONObject)20 Map (java.util.Map)19 URI (java.net.URI)16 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)15