returnType, boolean isBodyNullable) throws ApiException {
+ return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType, isBodyNullable);
+ }
+
+ /**
+ * Build the Client used to make HTTP requests.
+ *
+ * @return Client
+ */
+ protected Client buildHttpClient() {
+ // recreate the client config to pickup changes
+ clientConfig = getDefaultClientConfig();
+
+ ClientBuilder clientBuilder = ClientBuilder.newBuilder();
+ clientBuilder = clientBuilder.withConfig(clientConfig);
+ customizeClientBuilder(clientBuilder);
+ return clientBuilder.build();
+ }
+
+ /**
+ * Get the default client config.
+ *
+ * @return Client config
+ */
+ public ClientConfig getDefaultClientConfig() {
+ ClientConfig clientConfig = new ClientConfig();
+ clientConfig.register(MultiPartFeature.class);
+ clientConfig.register(json);
+ clientConfig.register(JacksonFeature.class);
+ clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
+ // turn off compliance validation to be able to send payloads with DELETE calls
+ clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
+ if (debugging) {
+ clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
+ clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
+ // Set logger to ALL
+ java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL);
+ } else {
+ // suppress warnings for payloads with DELETE calls:
+ java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
- /**
- * Get the default client config.
- *
- * @return Client config
- */
- public ClientConfig getDefaultClientConfig() {
- ClientConfig clientConfig = new ClientConfig();
- clientConfig.register(MultiPartFeature.class);
- clientConfig.register(json);
- clientConfig.register(JacksonFeature.class);
- clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
- // turn off compliance validation to be able to send payloads with DELETE calls
- clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
- if (debugging) {
- clientConfig.register(
- new LoggingFeature(
- java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME),
- java.util.logging.Level.INFO,
- LoggingFeature.Verbosity.PAYLOAD_ANY,
- 1024 * 50 /* Log payloads up to 50K */));
- clientConfig.property(
- LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
- // Set logger to ALL
- java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME)
- .setLevel(java.util.logging.Level.ALL);
- } else {
- // suppress warnings for payloads with DELETE calls:
- java.util.logging.Logger.getLogger("org.glassfish.jersey.client")
- .setLevel(java.util.logging.Level.SEVERE);
+ return clientConfig;
+ }
+
+ /**
+ * Customize the client builder.
+ *
+ * This method can be overridden to customize the API client. For example, this can be used to:
+ * 1. Set the hostname verifier to be used by the client to verify the endpoint's hostname
+ * against its identification information.
+ * 2. Set the client-side key store.
+ * 3. Set the SSL context that will be used when creating secured transport connections to
+ * server endpoints from web targets created by the client instance that is using this SSL context.
+ * 4. Set the client-side trust store.
+ *
+ * To completely disable certificate validation (at your own risk), you can
+ * override this method and invoke disableCertificateValidation(clientBuilder).
+ *
+ * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object.
+ */
+ protected void customizeClientBuilder(ClientBuilder clientBuilder) {
+ // No-op extension point
+ }
+
+ /**
+ * Disable X.509 certificate validation in TLS connections.
+ *
+ * Please note that trusting all certificates is extremely risky.
+ * This may be useful in a development environment with self-signed certificates.
+ *
+ * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object.
+ * @throws java.security.KeyManagementException if any.
+ * @throws java.security.NoSuchAlgorithmException if any.
+ */
+ protected void disableCertificateValidation(ClientBuilder clientBuilder) throws KeyManagementException, NoSuchAlgorithmException {
+ TrustManager[] trustAllCerts = new X509TrustManager[] {
+ new X509TrustManager() {
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
}
-
- return clientConfig;
- }
-
- /**
- * Customize the client builder.
- *
- * This method can be overridden to customize the API client. For example, this can be used
- * to: 1. Set the hostname verifier to be used by the client to verify the endpoint's hostname
- * against its identification information. 2. Set the client-side key store. 3. Set the SSL
- * context that will be used when creating secured transport connections to server endpoints
- * from web targets created by the client instance that is using this SSL context. 4. Set the
- * client-side trust store.
- *
- *
To completely disable certificate validation (at your own risk), you can override this
- * method and invoke disableCertificateValidation(clientBuilder).
- *
- * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object.
- */
- protected void customizeClientBuilder(ClientBuilder clientBuilder) {
- // No-op extension point
- }
-
- /**
- * Disable X.509 certificate validation in TLS connections.
- *
- *
Please note that trusting all certificates is extremely risky. This may be useful in a
- * development environment with self-signed certificates.
- *
- * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object.
- * @throws java.security.KeyManagementException if any.
- * @throws java.security.NoSuchAlgorithmException if any.
- */
- protected void disableCertificateValidation(ClientBuilder clientBuilder)
- throws KeyManagementException, NoSuchAlgorithmException {
- TrustManager[] trustAllCerts =
- new X509TrustManager[] {
- new X509TrustManager() {
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
-
- @Override
- public void checkClientTrusted(X509Certificate[] certs, String authType) {}
-
- @Override
- public void checkServerTrusted(X509Certificate[] certs, String authType) {}
- }
- };
- SSLContext sslContext = SSLContext.getInstance("TLS");
- sslContext.init(null, trustAllCerts, new SecureRandom());
- clientBuilder.sslContext(sslContext);
- }
-
- /**
- * Build the response headers.
- *
- * @param response a {@link javax.ws.rs.core.Response} object.
- * @return a {@link java.util.Map} of response headers.
- */
- protected Map> buildResponseHeaders(Response response) {
- Map> responseHeaders = new HashMap<>();
- for (Entry> entry : response.getHeaders().entrySet()) {
- List