Search in sources :

Example 1 with JsonResponseConverter

use of com.jd.httpservice.converters.JsonResponseConverter in project jdchain-core by blockchain-jd-com.

the class ParticipantInactive method update.

public WebResponse update() throws Exception {
    String url = (secure ? "https://" : "http://") + host + ":" + port + "/management/delegate/updateparticipant";
    HttpPost httpPost = new HttpPost(url);
    List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair("ledgerHash", ledger));
    params.add(new BasicNameValuePair("consensusHost", consensusHost));
    params.add(new BasicNameValuePair("consensusPort", consensusPort + ""));
    params.add(new BasicNameValuePair("consensusStorage", consensusStorage + ""));
    params.add(new BasicNameValuePair("consensusSecure", consensusSecure + ""));
    params.add(new BasicNameValuePair("shutdown", shutdown + ""));
    httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
    ServiceEndpoint endpoint = new ServiceEndpoint(host, port, secure);
    if (secure) {
        GmSSLProvider.enableGMSupport(participant.getSSLSecurity().getProtocol());
        endpoint.setSslSecurity(participant.getSSLSecurity());
    } else {
        endpoint.setSslSecurity(new SSLSecurity());
    }
    HttpResponse response = ServiceConnectionManager.buildHttpClient(endpoint).execute(httpPost);
    return (WebResponse) new JsonResponseConverter(WebResponse.class).getResponse(null, response.getEntity().getContent(), null);
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) WebResponse(com.jd.httpservice.utils.web.WebResponse) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) JsonResponseConverter(com.jd.httpservice.converters.JsonResponseConverter) ServiceEndpoint(com.jd.httpservice.agent.ServiceEndpoint) SSLSecurity(utils.net.SSLSecurity)

Example 2 with JsonResponseConverter

use of com.jd.httpservice.converters.JsonResponseConverter in project jdchain-core by blockchain-jd-com.

the class ParticipantInactive method active.

public WebResponse active() throws Exception {
    String url = (secure ? "https://" : "http://") + host + ":" + port + "/management/delegate/activeparticipant";
    HttpPost httpPost = new HttpPost(url);
    List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair("ledgerHash", ledger));
    params.add(new BasicNameValuePair("consensusHost", host));
    params.add(new BasicNameValuePair("consensusPort", consensusPort + ""));
    params.add(new BasicNameValuePair("consensusStorage", consensusStorage));
    params.add(new BasicNameValuePair("consensusSecure", consensusSecure + ""));
    params.add(new BasicNameValuePair("remoteManageHost", synHost));
    params.add(new BasicNameValuePair("remoteManagePort", synPort + ""));
    params.add(new BasicNameValuePair("remoteManageSecure", synSecure + ""));
    params.add(new BasicNameValuePair("shutdown", shutdown + ""));
    httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
    ServiceEndpoint endpoint = new ServiceEndpoint(host, port, secure);
    if (secure) {
        GmSSLProvider.enableGMSupport(participant.getSSLSecurity().getProtocol());
        endpoint.setSslSecurity(participant.getSSLSecurity());
    } else {
        endpoint.setSslSecurity(new SSLSecurity());
    }
    HttpResponse response = ServiceConnectionManager.buildHttpClient(endpoint).execute(httpPost);
    return (WebResponse) new JsonResponseConverter(WebResponse.class).getResponse(null, response.getEntity().getContent(), null);
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) WebResponse(com.jd.httpservice.utils.web.WebResponse) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) JsonResponseConverter(com.jd.httpservice.converters.JsonResponseConverter) ServiceEndpoint(com.jd.httpservice.agent.ServiceEndpoint) SSLSecurity(utils.net.SSLSecurity)

Aggregations

ServiceEndpoint (com.jd.httpservice.agent.ServiceEndpoint)2 JsonResponseConverter (com.jd.httpservice.converters.JsonResponseConverter)2 WebResponse (com.jd.httpservice.utils.web.WebResponse)2 ArrayList (java.util.ArrayList)2 HttpResponse (org.apache.http.HttpResponse)2 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)2 HttpPost (org.apache.http.client.methods.HttpPost)2 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)2 SSLSecurity (utils.net.SSLSecurity)2