Example usage for org.apache.commons.httpclient ContentLengthInputStream read

List of usage examples for org.apache.commons.httpclient ContentLengthInputStream read

Introduction

In this page you can find the example usage for org.apache.commons.httpclient ContentLengthInputStream read.

Prototype

public int read() throws IOException 

Source Link

Usage

From source file:org.mule.transport.salesforce.transformers.StreamToUserInput.java

@Override
protected Object doTransform(Object src, String encoding) throws TransformerException {

    ContentLengthInputStream inputStream = (ContentLengthInputStream) src;

    String http = "";

    while (true) {
        int x = -1;
        try {/*from ww  w.jav  a2s.  c o m*/
            x = inputStream.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (x != -1)
            http += String.valueOf((char) x);
        else
            break;
    }

    String[] parsed = new String[3];
    parsed[0] = http.substring(http.indexOf("username=") + 9, http.indexOf("&password"));
    parsed[0] = parsed[0].replace("%40", "@");
    parsed[1] = http.substring(http.indexOf("password=") + 9, http.indexOf("&contactname"));
    parsed[2] = http.substring(http.indexOf("contactname=") + 12, http.length());

    parsed[2] = "SELECT Contact.Firstname, Contact.Lastname, Contact.Department, Contact.Phone, "
            + "Contact.MobilePhone, Contact.Email, Contact.Birthdate FROM Contact" + " WHERE LastName = '"
            + parsed[2] + "'";

    return parsed;

}