Example usage for org.apache.commons.httpclient.methods PostMethod setParameter

List of usage examples for org.apache.commons.httpclient.methods PostMethod setParameter

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods PostMethod setParameter.

Prototype

public void setParameter(String paramString1, String paramString2) 

Source Link

Usage

From source file:com.discursive.jccook.httpclient.PostExample.java

public static void main(String[] args) throws HttpException, IOException {

    // Configure Logging
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    HttpClient client = new HttpClient();

    // Create POST method
    String weblintURL = "http://www.discursive.com/cgi-bin/jccook/param_list.cgi";
    PostMethod method = new PostMethod(weblintURL);

    // Set parameters on POST   
    method.setParameter("test1", "Hello World");
    method.addParameter("test2", "This is a Form Submission");
    method.addParameter("Blah", "Whoop");
    method.addParameter(new NameValuePair("Blah", "Whoop2"));

    // Execute and print response
    client.executeMethod(method);/*from  w  ww.  j ava 2  s .c om*/
    String response = method.getResponseBodyAsString();
    System.out.println(response);

    method.releaseConnection();
}

From source file:edu.du.penrose.systems.util.HttpClientUtils_2.java

static PostMethod setNonchangingFields(PostMethod postMethod) {
    postMethod.setParameter("__EVENTTARGET", "");
    postMethod.setParameter("__EVENTARGUMENT", "");
    postMethod.setParameter("CurrentSearchMode", "Bool");
    postMethod.setParameter("FirstFindFieldIdHolder",
            "ctl00_ctl00_BaseFindField_FindField_ctl00_guidedFields_fieldRepeater_ctl01_SearchTerm");
    postMethod.setParameter("FirstFindFieldTagIdHolder",
            "FirstFindFieldTagIdHolder   ctl00_ctl00_BaseFindField_FindField_ctl00_guidedFields_fieldRepeater_ctl01_DbTag");
    postMethod.setParameter("FirstFindFieldInLabelHolder",
            "ctl00_ctl00_BaseFindField_FindField_ctl00_guidedFields_fieldRepeater_ctl01_inLabel");
    postMethod.setParameter("FirstFindFieldRowMeasure",
            "ctl00_ctl00_BaseFindField_FindField_ctl00_guidedFields_fieldRepeater_ctl02_fieldRow");
    postMethod.setParameter("__vid", "1");
    postMethod.setParameter("__CUSTOMVIEWSTATE",
            "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");
    postMethod.setParameter("__ScreenResolution", "1280 : 1024");
    postMethod.setParameter("__VIEWSTATE", "");
    postMethod.setParameter("ajax", "enabled");
    postMethod.setParameter(//from   www. j  av  a  2s  . co m
            "ctl00$ctl00$ToolbarArea$toolbar$toolbarNavControl$folderControl$folderHasItemsTitle",
            "Folder has items");
    postMethod.setParameter(
            "ctl00$ctl00$ToolbarArea$toolbar$toolbarNavControl$folderControl$folderHasNoItemsTitle",
            "Folder is empty");
    postMethod.setParameter(
            "ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl01$SearchTerm", "finance");
    postMethod.setParameter("ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl01$DbTag",
            "");
    postMethod.setParameter("ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl02$Op",
            "and");
    postMethod.setParameter(
            "ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl02$SearchTerm", "");
    postMethod.setParameter("ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl02$DbTag",
            "");
    postMethod.setParameter("ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl03$Op",
            "and");
    postMethod.setParameter(
            "ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl03$SearchTerm", "");
    postMethod.setParameter("ctl00$ctl00$BaseFindField$FindField$ctl00$guidedFields$fieldRepeater$ctl03$DbTag",
            "");
    postMethod.setParameter("ctl00$ctl00$BaseFindField$FindField$ctl00$SearchButton", "Search");
    postMethod.setParameter("searchMode", "Bool");
    postMethod.setParameter("common_DT1", "");
    postMethod.setParameter("common_DT1_FromYear   ", "");
    postMethod.setParameter("common_DT1_ToMonth   ", "");
    postMethod.setParameter("common_DT1_ToYear   ", "");
    postMethod.setParameter("common_SO", "");
    postMethod.setParameter("common_PT82", "");
    postMethod.setParameter("common_PZ1", "");
    postMethod.setParameter("common_LA10", "");
    postMethod.setParameter("common_PG4", "");
    postMethod.setParameter("common_PG4_NumVal   ", "");

    return postMethod;
}

From source file:kevin.gvmsgarch.App.java

private static String getToken(String email, String password) throws HttpException, IOException {
    HttpClient client = new HttpClient();
    String retval = null;//from  w w  w .j a  va 2 s.c o m
    PostMethod post = new PostMethod("https://google.com/accounts/ClientLogin");

    post.setParameter("accountType", "GOOGLE");
    post.setParameter("Email", email);
    post.setParameter("Passwd", password);
    post.setParameter("service", "grandcentral");
    post.setParameter("source", "gvmsgarchiver");

    int rcode = -1;
    rcode = client.executeMethod(post);
    if (rcode != 200) {
        throw new RuntimeException("Bad response code: " + rcode);
    }

    BufferedReader sr = new BufferedReader(
            new StringReader(makeStringFromStream(post.getResponseBodyAsStream())));
    String line = null;
    while ((line = sr.readLine()) != null) {
        if (line.startsWith("Auth")) {
            int eq = line.indexOf("=");
            retval = line.substring(eq + 1);
        }
    }
    return retval;
}

From source file:net.bioclipse.opentox.api.MolecularDescriptorAlgorithm.java

public static String calculate(String service, String descriptor, String dataSetURI, IProgressMonitor monitor)
        throws HttpException, IOException, InterruptedException, GeneralSecurityException {
    if (monitor == null)
        monitor = new NullProgressMonitor();

    HttpClient client = new HttpClient();
    dataSetURI = Dataset.normalizeURI(dataSetURI);
    PostMethod method = new PostMethod(descriptor);

    HttpMethodHelper.addMethodHeaders(method, new HashMap<String, String>() {
        {/*w  ww .jav  a  2  s .  co m*/
            put("Accept", "text/uri-list");
        }
    });
    method.setParameter("dataset_uri", dataSetURI);
    method.setParameter("dataset_service", service + "dataset");
    logger.debug("Calculating: " + descriptor);
    logger.debug("  with data set: " + dataSetURI);
    client.executeMethod(method);
    int status = method.getStatusCode();
    logger.debug("  -> return status: " + status);
    String dataset = "";
    // FIXME: I should really start using the RDF response...
    String responseString = method.getResponseBodyAsString();
    int tailing = 1;
    if (status == 200 || status == 202) {
        if (responseString.contains("/task/")) {
            // OK, we got a task... let's wait until it is done
            String task = responseString;
            logger.debug("OK, we got a task assigned: " + task);
            Thread.sleep(andABit(500)); // let's be friendly, and wait 1 sec
            TaskState state = Task.getState(task);
            while (!state.isFinished() && !monitor.isCanceled()) {
                // let's be friendly, and wait 2 secs and a bit and increase
                // that time after each wait
                int waitingTime = andABit(2000 * tailing);
                logger.debug("Waiting " + waitingTime + "ms.");
                waitUnlessInterrupted(waitingTime, monitor);
                state = Task.getState(task);
                if (state.isRedirected()) {
                    task = state.getResults();
                    logger.debug("  new task, new task!!: " + task);
                }
                // but wait at most 20 secs and a bit
                if (tailing < 10)
                    tailing++;
            }
            if (monitor.isCanceled())
                Task.delete(task);
            // OK, it should be finished now
            dataset = state.getResults();
        } else {
            // OK, that was quick!
            dataset = responseString;
        }
    } else if (status == 401) {
        throw new GeneralSecurityException("Not authenticated");
    } else if (status == 403) {
        throw new GeneralSecurityException("Not authorized");
    } else {
        throw new IllegalStateException("Service error: " + status);
    }
    method.releaseConnection();
    dataset = dataset.replaceAll("\n", "");
    return dataset;
}

From source file:net.bioclipse.opentox.api.ModelAlgorithm.java

@SuppressWarnings("serial")
public static String calculate(String service, String model, String dataSetURI, IProgressMonitor monitor)
        throws HttpException, IOException, InterruptedException, GeneralSecurityException {
    if (monitor == null)
        monitor = new NullProgressMonitor();
    int worked = 0;

    HttpClient client = new HttpClient();
    dataSetURI = Dataset.normalizeURI(dataSetURI);
    PostMethod method = new PostMethod(model);
    HttpMethodHelper.addMethodHeaders(method, new HashMap<String, String>() {
        {/*  w w w .j  a  v a  2  s.c o  m*/
            put("Accept", "text/uri-list");
        }
    });
    method.setParameter("dataset_uri", dataSetURI);
    method.setParameter("dataset_service", service + "dataset");
    client.executeMethod(method);
    int status = method.getStatusCode();
    String dataset = "";
    // FIXME: I should really start using the RDF response...
    String responseString = method.getResponseBodyAsString();
    logger.debug("Status: " + status);
    int tailing = 1;
    if (status == 200 || status == 202) {
        if (responseString.contains("/task/")) {
            // OK, we got a task... let's wait until it is done
            String task = responseString;
            logger.debug("response: " + task);
            Thread.sleep(andABit(500)); // let's be friendly, and wait 1 sec
            TaskState state = Task.getState(task);
            while (!state.isFinished() && !monitor.isCanceled()) {
                int onlineWorked = (int) state.getPercentageCompleted();
                if (onlineWorked > worked) {
                    // work done is difference between done before and online done
                    monitor.worked(onlineWorked - worked);
                    worked = onlineWorked;
                }
                // let's be friendly, and wait 2 secs and a bit and increase
                // that time after each wait
                int waitingTime = andABit(2000 * tailing);
                logger.debug("Waiting " + waitingTime + "ms.");
                waitUnlessInterrupted(waitingTime, monitor);
                state = Task.getState(task);
                if (state.isRedirected()) {
                    task = state.getResults();
                    logger.debug("Got a Task redirect. New task:" + task);
                }
                // but wait at most 20 secs and a bit
                if (tailing < 10)
                    tailing++;
            }
            if (monitor.isCanceled())
                Task.delete(task);
            // OK, it should be finished now
            dataset = state.getResults();
        } else {
            // OK, that was quick!
            dataset = responseString;
            logger.debug("No Task, Data set: " + dataset);
            monitor.worked(100);
        }
    } else if (status == 401) {
        throw new GeneralSecurityException("Not authenticated");
    } else if (status == 403) {
        throw new GeneralSecurityException("Not authorized");
    } else if (status == 404) {
        logger.debug("Model not found (404): " + responseString);
        throw new UnsupportedOperationException("Service not found");
    } else {
        logger.debug("Model error (" + status + "): " + responseString);
        throw new IllegalStateException("Service error: " + status);
    }
    method.releaseConnection();
    dataset = dataset.replaceAll("\n", "");
    return dataset;
}

From source file:edu.du.penrose.systems.util.HttpClientUtils_2.java

static void setResolution(PostMethod postMethod, String formContents) {
    final String SCREEN_RESOLUTION = "__ScreenResolution";

    String[] resolutionStuff = formContents.split(SCREEN_RESOLUTION);

    //      String resolution = resolutionStuff[1].substring(0, resolution[1].indexOf(">") );  // value gets set by javascript.

    postMethod.setParameter(SCREEN_RESOLUTION, "1280 : 1024"); // TBD see above

}

From source file:com.netsteadfast.greenstep.util.SystemExpressionJobUtils.java

public static SysExprJobLogVO executeJobForManualFromRestServiceUrl(SysExprJobVO sysExprJob, String accountId,
        HttpServletRequest request) throws ServiceException, Exception {
    SysExprJobLogVO result = new SysExprJobLogVO();
    // ? executeJob/ ? ManualJobServiceImpl.java @Path("/executeJob/") ?, ,  url ?
    String url = ApplicationSiteUtils.getBasePath(sysExprJob.getSystem(), request);
    if (!url.endsWith("/")) {
        url += "/";
    }//  ww  w  .j  ava2  s . c  o  m
    //url += "services/jaxrs/executeJob/";
    url += Constants.getCxfWebServiceMainPathName() + Constants.getJAXRSServerFactoryBeanAddress()
            + "executeJob/";
    String encUploadOidStr = SystemExpressionJobUtils.getEncUploadOid(accountId, sysExprJob.getOid());
    url += encUploadOidStr;
    InputStreamReader isr = null;
    BufferedReader reader = null;
    try {
        HttpClient httpClient = new HttpClient();
        PostMethod post = new PostMethod(url);
        /*
          NameValuePair[] data = {
         new NameValuePair("uploadOid", encUploadOidStr)
          };
          post.setRequestBody(data);
          */
        post.setParameter("uploadOid", encUploadOidStr);
        int statusCode = httpClient.executeMethod(post);
        if (statusCode != 200 && statusCode != 202) {
            throw new Exception("error, http status code: " + statusCode);
        }
        isr = new InputStreamReader(post.getResponseBodyAsStream());
        reader = new BufferedReader(isr);
        String line = "";
        StringBuilder str = new StringBuilder();
        while ((line = reader.readLine()) != null) {
            str.append(line);
        }
        ObjectMapper mapper = new ObjectMapper();
        result = mapper.readValue(str.toString(), SysExprJobLogVO.class);
    } catch (IOException e) {
        e.printStackTrace();
        result.setFaultMsg(e.getMessage().toString());
    } catch (Exception e) {
        e.printStackTrace();
        result.setFaultMsg(e.getMessage().toString());
    } finally {
        if (reader != null) {
            reader.close();
        }
        if (isr != null) {
            isr.close();
        }
        reader = null;
        isr = null;
    }
    return result;
}

From source file:eu.crowdrec.contest.sender.RequestSenderORP.java

/**
 * Send a line from a logFile to an HTTP server.
 * /*from  www  . j  a  v a2  s  .c  om*/
 * @param logline the line that should by sent
 * 
 * @param connection the connection to the http server, must not be null
 * 
 * @return the response or null (if an error has been detected)
 */
static private String excutePostWithHttpClient(final String type, final String body, final String serverURL) {

    // define the URL parameter
    String urlParameters = "";

    try {

        urlParameters = String.format("type=%s&body=%s", URLEncoder.encode(type, "UTF-8"),
                URLEncoder.encode(body, "UTF-8"));

    } catch (UnsupportedEncodingException e1) {
        logger.warn(e1.toString());
    }

    PostMethod postMethod = null;
    try {
        StringRequestEntity requestEntity = new StringRequestEntity(urlParameters,
                "application/x-www-form-urlencoded", "UTF-8");

        postMethod = new PostMethod(serverURL);
        postMethod.setParameter("useCache", "false");
        postMethod.setRequestEntity(requestEntity);

        int statusCode = httpClient.executeMethod(postMethod);
        String response = statusCode == 200 ? postMethod.getResponseBodyAsString() : "statusCode:" + statusCode;

        return response.trim();
    } catch (IOException e) {
        logger.warn("receiving response failed, ignored.");
    } finally {
        if (postMethod != null) {
            postMethod.releaseConnection();
        }
    }
    return null;
}

From source file:net.bioclipse.opentox.api.ModelAlgorithm.java

@SuppressWarnings("serial")
public static String createModel(String algoURI, String datasetURI, List<String> featureURIs,
        String predictionFeatureURI, IProgressMonitor monitor)
        throws HttpException, IOException, InterruptedException, GeneralSecurityException {
    if (monitor == null)
        monitor = new NullProgressMonitor();
    int worked = 0;

    HttpClient client = new HttpClient();
    PostMethod method = new PostMethod(algoURI);
    HttpMethodHelper.addMethodHeaders(method, new HashMap<String, String>() {
        {/*from w w  w  .j  av a  2 s . c o m*/
            put("Accept", "text/uri-list");
        }
    });
    // add the features etc to the URI
    datasetURI = datasetURI + "?" + asFeatureURIString(featureURIs) + "&max=100";
    logger.debug("create model, datasetURI: " + datasetURI);
    method.setParameter("dataset_uri", datasetURI);
    method.setParameter("prediction_feature", predictionFeatureURI);
    client.executeMethod(method);
    int status = method.getStatusCode();
    String modelURI = "";
    // FIXME: I should really start using the RDF response...
    String responseString = method.getResponseBodyAsString();
    logger.debug("Status: " + status);
    int tailing = 1;
    if (status == 200 || status == 202) {
        if (responseString.contains("/task/")) {
            // OK, we got a task... let's wait until it is done
            String task = responseString;
            logger.debug("response: " + task);
            Thread.sleep(andABit(500)); // let's be friendly, and wait 1 sec
            TaskState state = Task.getState(task);
            while (!state.isFinished() && !monitor.isCanceled()) {
                int onlineWorked = (int) state.getPercentageCompleted();
                if (onlineWorked > worked) {
                    // work done is difference between done before and online done
                    monitor.worked(onlineWorked - worked);
                    worked = onlineWorked;
                }
                // let's be friendly, and wait 2 secs and a bit and increase
                // that time after each wait
                int waitingTime = andABit(2000 * tailing);
                logger.debug("Waiting " + waitingTime + "ms.");
                waitUnlessInterrupted(waitingTime, monitor);
                state = Task.getState(task);
                if (state.isRedirected()) {
                    task = state.getResults();
                    logger.debug("Got a Task redirect. New task:" + task);
                }
                // but wait at most 20 secs and a bit
                if (tailing < 10)
                    tailing++;
            }
            if (monitor.isCanceled())
                Task.delete(task);
            // OK, it should be finished now
            modelURI = state.getResults();
        } else {
            // OK, that was quick!
            modelURI = responseString;
            logger.debug("No Task, Data set: " + modelURI);
            monitor.worked(100);
        }
    } else if (status == 401) {
        throw new GeneralSecurityException("Not authenticated");
    } else if (status == 403) {
        throw new GeneralSecurityException("Not authorized");
    } else if (status == 404) {
        logger.debug("Model not found (404): " + responseString);
        throw new UnsupportedOperationException("Service not found");
    } else {
        logger.debug("Model error (" + status + "): " + responseString);
        throw new IllegalStateException("Service error: " + status);
    }
    method.releaseConnection();
    modelURI = modelURI.replaceAll("\n", "");
    return modelURI;
}

From source file:com.bluexml.xforms.demo.Util.java

/**
 * Authenticates a user with an Alfresco instance.
 * /*from w  w w . j av  a  2 s  .com*/
 * @param host
 *            the address (protocol, hostname, port number) of the host where the BlueXML XForms
 *            webscript is deployed, with NO trailing slash. If NULL, defaults to localhost:8080
 * @param userName
 *            the user name to test, which should be known to Alfresco
 * @param password
 *            the plain text password to test
 * @return true if the authentication succeeded, false if the authentication failed or if an
 *         exception occurred
 */
public static boolean authenticate(String host, String userName, String password) {
    PostMethod post = new PostMethod(host + "service/xforms/auth");

    post.setParameter("username", userName);
    post.setParameter("password", password);

    HttpClient client = new HttpClient();
    try {
        client.executeMethod(post);
    } catch (HttpException e) {
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    String result;
    try {
        result = post.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    if (result == null) {
        return false;
    }
    result = result.trim();
    return result.equals("success");
}