Search in sources :

Example 1 with Olingo2AppImpl

use of org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl in project camel by apache.

the class Olingo2Component method createOlingo2App.

private Olingo2AppWrapper createOlingo2App(Olingo2Configuration configuration) {
    Object clientBuilder = configuration.getHttpAsyncClientBuilder();
    if (clientBuilder == null) {
        HttpAsyncClientBuilder asyncClientBuilder = HttpAsyncClientBuilder.create();
        // apply simple configuration properties
        final RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
        requestConfigBuilder.setConnectTimeout(configuration.getConnectTimeout());
        requestConfigBuilder.setSocketTimeout(configuration.getSocketTimeout());
        final HttpHost proxy = configuration.getProxy();
        if (proxy != null) {
            requestConfigBuilder.setProxy(proxy);
        }
        // set default request config
        asyncClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
        SSLContextParameters sslContextParameters = configuration.getSslContextParameters();
        if (sslContextParameters == null) {
            // use defaults if not specified
            sslContextParameters = new SSLContextParameters();
        }
        try {
            asyncClientBuilder.setSSLContext(sslContextParameters.createSSLContext(getCamelContext()));
        } catch (GeneralSecurityException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        } catch (IOException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    }
    Olingo2AppImpl olingo2App;
    if (clientBuilder == null || clientBuilder instanceof HttpAsyncClientBuilder) {
        olingo2App = new Olingo2AppImpl(configuration.getServiceUri(), (HttpAsyncClientBuilder) clientBuilder);
    } else {
        olingo2App = new Olingo2AppImpl(configuration.getServiceUri(), (HttpClientBuilder) clientBuilder);
    }
    apiProxy = new Olingo2AppWrapper(olingo2App);
    apiProxy.getOlingo2App().setContentType(configuration.getContentType());
    apiProxy.getOlingo2App().setHttpHeaders(configuration.getHttpHeaders());
    return apiProxy;
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) Olingo2AppImpl(org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl) HttpHost(org.apache.http.HttpHost) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) HttpAsyncClientBuilder(org.apache.http.impl.nio.client.HttpAsyncClientBuilder) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 2 with Olingo2AppImpl

use of org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl in project camel by apache.

the class Olingo2AppAPITest method setupClient.

protected static void setupClient() throws Exception {
    olingoApp = new Olingo2AppImpl(TEST_SERVICE_URL + "/");
    olingoApp.setContentType(TEST_FORMAT_STRING);
    LOG.info("Read Edm ");
    final TestOlingo2ResponseHandler<Edm> responseHandler = new TestOlingo2ResponseHandler<Edm>();
    olingoApp.read(null, Olingo2AppImpl.METADATA, null, responseHandler);
    edm = responseHandler.await();
    LOG.info("Read default EntityContainer:  {}", responseHandler.await().getDefaultEntityContainer().getName());
    edmEntitySetMap = new HashMap<String, EdmEntitySet>();
    for (EdmEntitySet ees : edm.getEntitySets()) {
        edmEntitySetMap.put(ees.getName(), ees);
    }
    // wait for generated data to be registered in server
    Thread.sleep(2000);
}
Also used : Olingo2AppImpl(org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl) EdmEntitySet(org.apache.olingo.odata2.api.edm.EdmEntitySet) Edm(org.apache.olingo.odata2.api.edm.Edm)

Aggregations

Olingo2AppImpl (org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl)2 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)1 HttpHost (org.apache.http.HttpHost)1 RequestConfig (org.apache.http.client.config.RequestConfig)1 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)1 HttpAsyncClientBuilder (org.apache.http.impl.nio.client.HttpAsyncClientBuilder)1 Edm (org.apache.olingo.odata2.api.edm.Edm)1 EdmEntitySet (org.apache.olingo.odata2.api.edm.EdmEntitySet)1