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:es.carebear.rightmanagement.client.RestClient.java

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

    HttpClient client = new HttpClient();

    PostMethod method = new PostMethod(getServiceBaseURI() + "/client/users/register/" + 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:hydrograph.server.service.HydrographServiceClient.java

public void calltoReadMetastore() throws IOException {

    HttpClient httpClient = new HttpClient();
    //TODO : add connection details while testing only,remove it once done
    String teradatajson = "{\"table\":\"testting2\",\"username\":\"\",\"password\":\"\",\"hostname\":\"\",\"database\":\"\",\"dbtype\":\"\",\"port\":\"\"}";

    PostMethod postMethod = new PostMethod("http://" + HOST_NAME + ":" + PORT + "/readFromMetastore");

    //postMethod.addParameter("request_parameters", redshiftjson);
    postMethod.addParameter("request_parameters", teradatajson);

    int response = httpClient.executeMethod(postMethod);
    InputStream inputStream = postMethod.getResponseBodyAsStream();

    byte[] buffer = new byte[1024 * 1024 * 5];
    String path = null;//from  w w w  .  j  a v a  2s . c  o m
    int length;
    while ((length = inputStream.read(buffer)) > 0) {
        path = new String(buffer);
    }
    System.out.println("Response of service: " + path);
    System.out.println("==================");
}

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

public void getAllUsersWithAccess() throws IOException {
    HttpClient client = new HttpClient();

    PostMethod deleteMethod = new PostMethod(getServiceBaseURI() + "/client/groups/users/" + "User");

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

    int responseCode = client.executeMethod(deleteMethod);

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

    System.out.println(responseCode);

    StringListContainer lc = XMLHelper.fromXML(response, StringListContainer.class);

    lc.getContainer().stream().forEach(w -> {
        System.out.println("ULUMULU" + w);
    });/*from w  w w .  j  a v a  2 s. c  om*/
}

From source file:hydrograph.server.service.HydrographServiceClient.java

public void chcekConnectionStatus() throws IOException {

    HttpClient httpClient = new HttpClient();
    //TODO : add connection details while testing only,remove it once done
    String teradatajson = "{\"username\":\"\",\"password\":\"\",\"hostname\":\"\",\"database\":\"\",\"dbtype\":\"\",\"port\":\"\"}";
    PostMethod postMethod = new PostMethod("http://" + HOST_NAME + ":" + PORT + "/getConnectionStatus");

    //postMethod.addParameter("request_parameters", redshiftjson);
    postMethod.addParameter("request_parameters", teradatajson);

    int response = httpClient.executeMethod(postMethod);
    InputStream inputStream = postMethod.getResponseBodyAsStream();

    byte[] buffer = new byte[1024 * 1024 * 5];
    String path = null;/*from  w ww.j av  a  2  s.  c o  m*/
    int length;
    while ((length = inputStream.read(buffer)) > 0) {
        path = new String(buffer);
    }
    System.out.println("Response of service: " + path);
    System.out.println("==================");
}

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

public void getAllRigthsOfGroups22() throws IOException {
    HttpClient client = new HttpClient();

    PostMethod deleteMethod = new PostMethod(getServiceBaseURI() + "/client/groups/userlist/" + "User");

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

    int responseCode = client.executeMethod(deleteMethod);

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

    System.out.println(responseCode);

    //StringListContainer lc = XMLHelper.fromXML(response, StringListContainer.class);

    //lc.getContainer().stream().forEach(w->{System.out.println(w);});
}

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

public void authTest() throws IOException {
    HttpClient client = new HttpClient();

    PostMethod deleteMethod = new PostMethod(getServiceBaseURI() + "/client/users/change/allowed/" + "Paul");

    deleteMethod.addParameter("authName", "Admin");
    deleteMethod.addParameter("rigthTarget", "User");
    deleteMethod.addParameter("rightMask", "DELETE");

    int responseCode = client.executeMethod(deleteMethod);

    System.out.println(responseCode);
}

From source file:egpi.tes.ahv.servicio.AutenticacionREST.java

/**
 * /*  w  ww. java 2 s.  c  o m*/
 * @param authVO 
 */
public void procesasLogeoServidor(AutenticacionVO authVO) throws ReporteJasperException {

    try {

        if (authVO != null) {

            PostMethod postMethod = new PostMethod(authVO.getServerUrl());
            postMethod.addParameter("j_username", authVO.getUsername());
            postMethod.addParameter("j_password", authVO.getPassword());
            status = client.executeMethod(postMethod);

            System.out.println("status 00 " + status);
            if (status == 200) {
                obj.put("status", String.valueOf(status));
            } else {
                throw new ReporteJasperException(this.properties.getProperty("msg_" + String.valueOf(status)));
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new ReporteJasperException(e.getMessage());
    }

}

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

public void getAllRigthsOfGroups() throws IOException {
    HttpClient client = new HttpClient();

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

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

    int responseCode = client.executeMethod(deleteMethod);

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

    System.out.println(responseCode);

}

From source file:com.jaspersoft.jasperserver.war.common.HeartbeatAwsEc2Contributor.java

@Override
public void contributeToHttpCall(PostMethod post) {
    String awsEc2InstanceType;//from  w w w. j ava  2  s.  co  m
    if (awsEc2MetadataClient.isEc2Instance()) {
        awsEc2InstanceType = awsEc2MetadataClient
                .getEc2InstanceMetadataItem(AwsEc2MetadataClient.INSTANCE_TYPE_RESOURCE);
        post.addParameter("ec2InstanceType", awsEc2InstanceType);
    }
    post.addParameter("ec2Instance", instanceProductTypeResolver.getAwsProductNameForHeartBeat());
}

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

public PostMethod getConnectionStatus(MetaDataDetails metaDataDetails, String host, String port)
        throws NumberFormatException, MalformedURLException {

    URL url = new URL(POST_PROTOCOL, host, Integer.valueOf(port), DebugServiceMethods.TEST_CONNECTION);
    PostMethod postMethod = new PostMethod(url.toString());
    Gson gson = new Gson();
    postMethod.addParameter(DebugServicePostParameters.REQUEST_PARAMETERS, gson.toJson(metaDataDetails));

    LOGGER.debug("Calling service to test connection for database components through url :: " + url);

    return postMethod;
}