Search in sources :

Example 1 with HttpMethod

use of org.apache.olingo.commons.api.http.HttpMethod in project tdi-studio-se by Talend.

the class DynamicsCRMClient method init.

private void init() throws ServiceUnavailableException {
    odataClient = ODataClientFactory.getClient();
    if (clientConfiguration != null && serviceRootURL != null && serviceRootURL.indexOf("/api/data") > 0) {
        clientConfiguration.setResource(serviceRootURL.substring(0, serviceRootURL.indexOf("/api/data")));
    }
    authResult = getAccessToken();
    httpClientFactory = new DefaultHttpClientFactory() {

        @Override
        public DefaultHttpClient create(final HttpMethod method, final URI uri) {
            if (!clientConfiguration.isReuseHttpClient() || httpClient == null) {
                httpClient = super.create(method, uri);
                HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), clientConfiguration.getTimeout() * 1000);
                HttpConnectionParams.setSoTimeout(httpClient.getParams(), clientConfiguration.getTimeout() * 1000);
                // setup proxy
                setHttpclientProxy(httpClient);
            }
            return httpClient;
        }
    };
    odataClient.getConfiguration().setHttpClientFactory(httpClientFactory);
    httpClient = (DefaultHttpClient) httpClientFactory.create(null, null);
}
Also used : DefaultHttpClientFactory(org.apache.olingo.client.core.http.DefaultHttpClientFactory) URI(java.net.URI) HttpMethod(org.apache.olingo.commons.api.http.HttpMethod) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient)

Aggregations

URI (java.net.URI)1 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)1 DefaultHttpClientFactory (org.apache.olingo.client.core.http.DefaultHttpClientFactory)1 HttpMethod (org.apache.olingo.commons.api.http.HttpMethod)1