Search in sources :

Example 76 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class palorule method modifyRule.

public void modifyRule() throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", this.plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("database", String.valueOf(this.lDatabaseId)));
    qparams.add(new BasicNameValuePair("cube", String.valueOf(this.iCubeId)));
    qparams.add(new BasicNameValuePair("rule", String.valueOf(this.lIdentifier)));
    qparams.add(new BasicNameValuePair("definition", strDefinition));
    qparams.add(new BasicNameValuePair("activate", palohelpers.BooleanToString(this.bActivated)));
    qparams.add(new BasicNameValuePair("external_identifier", strExtern_Id));
    qparams.add(new BasicNameValuePair("comment", strComment));
    qparams.add(new BasicNameValuePair("use_identifier", palohelpers.BooleanToString(false)));
    try {
        HttpEntity entity = this.plConn.sendToServer(qparams, "/rule/modify");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        while (csv.readNext()) {
            lIdentifier = palohelpers.StringToInt(csv.get(0));
            strDefinition = csv.get(1);
            strExtern_Id = csv.get(2);
            strComment = csv.get(3);
            lTimeStamp = palohelpers.StringToLong(csv.get(4));
            bActivated = palohelpers.StringToBoolean(csv.get(5));
        }
        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 77 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class palorules method parseRule.

public String parseRule(String strRuleToParse) throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("database", String.valueOf(this.lDatabaseId)));
    qparams.add(new BasicNameValuePair("cube", String.valueOf(this.iCubeId)));
    qparams.add(new BasicNameValuePair("definition", strRuleToParse));
    try {
        StringBuilder sb = new StringBuilder();
        HttpEntity entity = this.plConn.sendToServer(qparams, "/rule/parse");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        while (csv.readNext()) {
            sb.append(csv.get(0));
        }
        csv.close();
        entity.consumeContent();
        return sb.toString();
    } 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 78 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class palorules method deleteRule.

// Deletes the Rule with given External_Id
public void deleteRule(String strExtern_Id) throws paloexception {
    palorule paloRuleToRemove = getRule(strExtern_Id);
    if (null != paloRuleToRemove) {
        List<NameValuePair> qparams = new ArrayList<NameValuePair>();
        qparams.add(new BasicNameValuePair("sid", plConn.getPaloToken()));
        qparams.add(new BasicNameValuePair("database", String.valueOf(this.lDatabaseId)));
        qparams.add(new BasicNameValuePair("cube", String.valueOf(this.iCubeId)));
        qparams.add(new BasicNameValuePair("rule", String.valueOf(paloRuleToRemove.getIdentifier())));
        plConn.sendToServerSingleRC(qparams, "/rule/destroy");
        paloRules.remove(paloRuleToRemove);
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 79 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class RestClient method loginAs.

public void loginAs(String username, String password) {
    try {
        CookieStore cookieStore = new BasicCookieStore();
        httpContext = new BasicHttpContext();
        httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
        String loginURL = "/loginservice";
        // If you misspell a parameter you will get a HTTP 500 error
        List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
        urlParameters.add(new BasicNameValuePair("username", username));
        urlParameters.add(new BasicNameValuePair("password", password));
        urlParameters.add(new BasicNameValuePair("redirect", "false"));
        // UTF-8 is mandatory otherwise you get a NPE
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(urlParameters, "utf-8");
        executePostRequest(loginURL, entity);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : CookieStore(org.apache.http.client.CookieStore) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) BasicHttpContext(org.apache.http.protocol.BasicHttpContext) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) ClientProtocolException(org.apache.http.client.ClientProtocolException) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) IOException(java.io.IOException)

Example 80 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class palocube method save.

public void save() throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", plConn.getPaloToken()));
    qparams.add(new BasicNameValuePair("database", String.valueOf(this.lDatabaseId)));
    qparams.add(new BasicNameValuePair("cube", String.valueOf(this.iCubeId)));
    plConn.sendToServerSingleRC(qparams, "/cube/save");
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

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