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

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

Introduction

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

Prototype

public void addParameter(String paramString1, String paramString2) throws IllegalArgumentException 

Source Link

Usage

From source file:hydrograph.ui.communication.debugservice.method.Provider.java

/**
 * Method to get file based on the filter condition
 * @param jsonString Filter condition string
 * @param jobDetails/*w w  w . j  a v a  2 s  .  c om*/
 * @return
 * @throws NumberFormatException
 * @throws MalformedURLException
 */
public PostMethod getFilteredFileMethod(String jsonString, JobDetails jobDetails)
        throws NumberFormatException, MalformedURLException {
    URL url = new URL(POST_PROTOCOL, getHost(jobDetails), getPortNo(jobDetails),
            DebugServiceMethods.GET_FILTERED_FILE_PATH);
    PostMethod postMethod = new PostMethod(url.toString());
    postMethod.addParameter(DebugServicePostParameters.FILTER_JSON_OBJECT, jsonString);

    LOGGER.debug("Calling debug service to get file based on the filter condition through url :: " + url);

    return postMethod;
}

From source file:dashboard.Mixpanel.java

public int postRequest(String encodedDataJSON, String api_key) {
    try {//  w  w w. jav a  2 s. com
        String contents = "";
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod("http://api.mixpanel.com/import");

        // Configure the form parameters
        method.addParameter("data", encodedDataJSON);
        method.addParameter("api_key", api_key);

        // Add more details in the POST response 
        method.addParameter("verbose", "1");

        // Execute the POST method

        int statusCode = client.executeMethod(method);
        contents = method.getResponseBodyAsString();
        method.releaseConnection();

        if (statusCode != 200 || contents.charAt(11) != '1') { // Post to Mixpanel Failed
            System.out.println("Mixpanel Post respone: " + Integer.toString(statusCode) + " - " + contents);
            return 0;
        }
        return 1;
    } catch (Exception e) {
        e.printStackTrace();
        return 0;
    }
}

From source file:hydrograph.ui.communication.debugservice.method.Provider.java

/**
 * //from w w  w .j  a v a  2  s  .c om
 * Get post method to delete csv debug file
 * 
 * @param jobDetails
 * @return {@link PostMethod}
 * @throws NumberFormatException
 * @throws MalformedURLException
 */
public PostMethod getDeleteDebugFileMethod(JobDetails jobDetails)
        throws NumberFormatException, MalformedURLException {

    URL url = new URL(POST_PROTOCOL, getHost(jobDetails), getPortNo(jobDetails),
            DebugServiceMethods.DELETE_DEBUG_CSV_FILE);

    PostMethod postMethod = new PostMethod(url.toString());
    postMethod.addParameter(DebugServicePostParameters.JOB_ID, jobDetails.getUniqueJobID());
    postMethod.addParameter(DebugServicePostParameters.COMPONENT_ID, jobDetails.getComponentID());
    postMethod.addParameter(DebugServicePostParameters.SOCKET_ID, jobDetails.getComponentSocketID());

    LOGGER.debug("Calling debug service for deleting csv debug file url :: " + url);

    return postMethod;
}

From source file:es.carebear.rightmanagement.client.RestClient.java

public void getGroupsTest(String authName) throws IOException {
    HttpClient client = new HttpClient();

    PostMethod deleteMethod = new PostMethod(getServiceBaseURI() + "/client/groups/all/names");

    deleteMethod.addParameter("authName", "Admin");

    int responseCode = client.executeMethod(deleteMethod);

    String response = responseToString(deleteMethod.getResponseBodyAsStream());

    System.out.println(responseCode);

}

From source file:hydrograph.ui.communication.debugservice.method.Provider.java

/**
 * //  w ww.  j  a  va2 s.  c  om
 * Get post method to get csv debug file
 * 
 * @param jobDetails
 * @param fileSize
 * @return {@link PostMethod}
 * @throws NumberFormatException
 * @throws MalformedURLException
 */
public PostMethod getDebugFileMethod(JobDetails jobDetails, String fileSize)
        throws NumberFormatException, MalformedURLException {

    URL url = new URL(POST_PROTOCOL, getHost(jobDetails), getPortNo(jobDetails),
            DebugServiceMethods.GET_DEBUG_FILE_PATH);

    PostMethod postMethod = new PostMethod(url.toString());
    postMethod.addParameter(DebugServicePostParameters.JOB_ID, jobDetails.getUniqueJobID());
    postMethod.addParameter(DebugServicePostParameters.COMPONENT_ID, jobDetails.getComponentID());
    postMethod.addParameter(DebugServicePostParameters.SOCKET_ID, jobDetails.getComponentSocketID());
    postMethod.addParameter(DebugServicePostParameters.BASE_PATH, jobDetails.getBasepath());
    postMethod.addParameter(DebugServicePostParameters.USER_ID, jobDetails.getUsername());
    postMethod.addParameter(DebugServicePostParameters.DEBUG_SERVICE_PWD, jobDetails.getPassword());
    postMethod.addParameter(DebugServicePostParameters.FILE_SIZE, fileSize);
    postMethod.addParameter(DebugServicePostParameters.HOST_NAME, getHost(jobDetails));

    LOGGER.debug("Calling debug service to get csv debug file from url :: " + url);

    return postMethod;
}

From source file:es.carebear.rightmanagement.client.RestClient.java

public void getOwnZeuch() throws IOException {
    HttpClient client = new HttpClient();
    PostMethod postMethod = new PostMethod(getServiceBaseURI() + "/client/groups/all/rights/" + "User");
    postMethod.addParameter("authName", "Admin");
    int responseCode = client.executeMethod(postMethod);
    System.out.println(responseCode);
}

From source file:es.carebear.rightmanagement.client.RestClient.java

public void deleteTest(String authName, String target) throws IOException {
    HttpClient client = new HttpClient();

    PostMethod deleteMethod = new PostMethod(getServiceBaseURI() + "/client/users/delete/" + target);

    deleteMethod.addParameter("authName", "Admin");

    int responseCode = client.executeMethod(deleteMethod);

    System.out.println(responseCode);
}

From source file:es.carebear.rightmanagement.client.RestClient.java

public User logInTest(String username, String password) throws IOException {

    HttpClient client = new HttpClient();

    PostMethod method = new PostMethod(getServiceBaseURI() + "/client/users/login/" + username);

    method.addParameter("password", password);

    System.out.println(method.getPath());

    int responseCode = client.executeMethod(method);

    String response = responseToString(method.getResponseBodyAsStream());

    System.out.println(response);

    return XMLHelper.fromXML(response, User.class);
}

From source file:ccc.api.http.SiteBrowserImpl.java

@Override
public String previewTemplate(ResourceSummary rs, String body) {
    final PostMethod post = new PostMethod(_previewTemplateUrl + rs.getAbsolutePath());
    post.addParameter("hiddenbody", body);
    return invoke(post);
}

From source file:hydrograph.ui.communication.debugservice.method.Provider.java

/**
 * /*from  ww w .  j av a 2  s. c  o  m*/
 * Get post method to delete basepath debug files
 * 
 * @param host
 * @param port
 * @param unique job ID
 * @param base path
 * @param User
 * @param password
 * @param isRemote 
 * @return {@link PostMethod}
 * @throws NumberFormatException
 * @throws MalformedURLException
 */
public PostMethod getDeleteBasePathFileMethod(String host, String port, String uniqJobID, String basePath,
        String user, String password, boolean isRemote) throws NumberFormatException, MalformedURLException {

    if (isRemote) {

        port = PlatformUI.getPreferenceStore().getString(PreferenceConstants.REMOTE_PORT_NO);
        if (StringUtils.isBlank(port)) {
            port = PreferenceConstants.DEFAULT_PORT_NO;
        }

        if (PlatformUI.getPreferenceStore().getBoolean(PreferenceConstants.USE_REMOTE_CONFIGURATION)) {
            host = PlatformUI.getPreferenceStore().getString(PreferenceConstants.REMOTE_HOST);
        }
    }

    URL url = new URL(POST_PROTOCOL, host, Integer.valueOf(port), DebugServiceMethods.DELETE_BASEPATH_FILES);

    PostMethod postMethod = new PostMethod(url.toString());
    postMethod.addParameter(DebugServicePostParameters.JOB_ID, uniqJobID);
    postMethod.addParameter(DebugServicePostParameters.BASE_PATH, basePath);
    postMethod.addParameter(DebugServicePostParameters.USER_ID, user);
    postMethod.addParameter(DebugServicePostParameters.DEBUG_SERVICE_PWD, password);

    LOGGER.debug("Calling debug service to delete basepath debug files through url :: " + url);

    return postMethod;
}