|
14 | 14 | import java.util.function.Supplier;
|
15 | 15 | import java.util.logging.Level;
|
16 | 16 | import java.util.logging.Logger;
|
| 17 | + |
17 | 18 | import javax.net.ssl.HostnameVerifier;
|
18 | 19 | import javax.net.ssl.SSLContext;
|
19 | 20 | import javax.net.ssl.SSLEngine;
|
|
39 | 40 | import org.glassfish.jersey.client.ClientProperties;
|
40 | 41 | import org.glassfish.jersey.client.JerseyClientBuilder;
|
41 | 42 | import org.glassfish.jersey.jackson.JacksonFeature;
|
| 43 | +import org.glassfish.jersey.logging.LoggingFeature; |
42 | 44 | import org.glassfish.jersey.media.multipart.BodyPart;
|
43 | 45 | import org.glassfish.jersey.media.multipart.Boundary;
|
44 | 46 | import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
@@ -212,6 +214,22 @@ public GitLabApiClient(ApiVersion apiVersion, String hostUrl, String privateToke
|
212 | 214 | * @param clientConfigProperties the properties given to Jersey's clientconfig
|
213 | 215 | */
|
214 | 216 | public GitLabApiClient(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken, Map<String, Object> clientConfigProperties) {
|
| 217 | + this(apiVersion, hostUrl, tokenType, authToken, secretToken, clientConfigProperties, false); |
| 218 | + } |
| 219 | + |
| 220 | + /** |
| 221 | + * Construct an instance to communicate with a GitLab API server using the specified GitLab API version, |
| 222 | + * server URL and private token. |
| 223 | + * |
| 224 | + * @param apiVersion the ApiVersion specifying which version of the API to use |
| 225 | + * @param hostUrl the URL to the GitLab API server |
| 226 | + * @param tokenType the type of auth the token is for, PRIVATE or ACCESS |
| 227 | + * @param authToken the private token to authenticate with |
| 228 | + * @param secretToken use this token to validate received payloads |
| 229 | + * @param clientConfigProperties the properties given to Jersey's clientconfig |
| 230 | + * @param debugging log http requests and responses |
| 231 | + */ |
| 232 | + public GitLabApiClient(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken, Map<String, Object> clientConfigProperties, boolean debugging) { |
215 | 233 |
|
216 | 234 | // Remove the trailing "/" from the hostUrl if present
|
217 | 235 | this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl);
|
@@ -240,6 +258,11 @@ public GitLabApiClient(ApiVersion apiVersion, String hostUrl, TokenType tokenTyp
|
240 | 258 | }
|
241 | 259 | }
|
242 | 260 |
|
| 261 | + if (debugging) { |
| 262 | + 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 */)); |
| 263 | + clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); |
| 264 | + } |
| 265 | + |
243 | 266 | // Disable auto-discovery of feature and services lookup, this will force Jersey
|
244 | 267 | // to use the features and services explicitly configured by gitlab4j
|
245 | 268 | clientConfig.property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
|
|
0 commit comments