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;
}
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);
}
Aggregations