Skip to content

Commit 4c051b5

Browse files
committed
Merge remote-tracking branch 'origin/main' into 6.x
# Conflicts: # src/main/java/org/gitlab4j/api/GitLabApiClient.java
2 parents 982f4b6 + 70ad93e commit 4c051b5

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

Diff for: src/main/java/org/gitlab4j/api/GitLabApi.java

+17-2
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,20 @@ public GitLabApi(String hostUrl, String personalAccessToken, Map<String, Object>
430430
this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, personalAccessToken, null, clientConfigProperties);
431431
}
432432

433+
/**
434+
* Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version.
435+
*
436+
* @param apiVersion the ApiVersion specifying which version of the API to use
437+
* @param hostUrl the URL of the GitLab server
438+
* @param tokenType the type of auth the token is for, PRIVATE or ACCESS
439+
* @param authToken to token to use for access to the API
440+
* @param secretToken use this token to validate received payloads
441+
* @param clientConfigProperties Map instance with additional properties for the Jersey client connection
442+
*/
443+
public GitLabApi(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken, Map<String, Object> clientConfigProperties) {
444+
this(apiVersion, hostUrl, tokenType, authToken, secretToken, clientConfigProperties, false);
445+
}
446+
433447
/**
434448
* Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version.
435449
*
@@ -439,12 +453,13 @@ public GitLabApi(String hostUrl, String personalAccessToken, Map<String, Object>
439453
* @param authToken to token to use for access to the API
440454
* @param secretToken use this token to validate received payloads
441455
* @param clientConfigProperties Map instance with additional properties for the Jersey client connection
456+
* @param debugging log http requests and responses
442457
*/
443-
public GitLabApi(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken, Map<String, Object> clientConfigProperties) {
458+
public GitLabApi(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken, Map<String, Object> clientConfigProperties, boolean debugging) {
444459
this.apiVersion = apiVersion;
445460
this.gitLabServerUrl = hostUrl;
446461
this.clientConfigProperties = clientConfigProperties;
447-
apiClient = new GitLabApiClient(apiVersion, hostUrl, tokenType, authToken, secretToken, clientConfigProperties);
462+
apiClient = new GitLabApiClient(apiVersion, hostUrl, tokenType, authToken, secretToken, clientConfigProperties, debugging);
448463
}
449464

450465
/**

Diff for: src/main/java/org/gitlab4j/api/GitLabApiClient.java

+23
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.function.Supplier;
1515
import java.util.logging.Level;
1616
import java.util.logging.Logger;
17+
1718
import javax.net.ssl.HostnameVerifier;
1819
import javax.net.ssl.SSLContext;
1920
import javax.net.ssl.SSLEngine;
@@ -39,6 +40,7 @@
3940
import org.glassfish.jersey.client.ClientProperties;
4041
import org.glassfish.jersey.client.JerseyClientBuilder;
4142
import org.glassfish.jersey.jackson.JacksonFeature;
43+
import org.glassfish.jersey.logging.LoggingFeature;
4244
import org.glassfish.jersey.media.multipart.BodyPart;
4345
import org.glassfish.jersey.media.multipart.Boundary;
4446
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
@@ -212,6 +214,22 @@ public GitLabApiClient(ApiVersion apiVersion, String hostUrl, String privateToke
212214
* @param clientConfigProperties the properties given to Jersey's clientconfig
213215
*/
214216
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) {
215233

216234
// Remove the trailing "/" from the hostUrl if present
217235
this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl);
@@ -240,6 +258,11 @@ public GitLabApiClient(ApiVersion apiVersion, String hostUrl, TokenType tokenTyp
240258
}
241259
}
242260

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+
243266
// Disable auto-discovery of feature and services lookup, this will force Jersey
244267
// to use the features and services explicitly configured by gitlab4j
245268
clientConfig.property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);

0 commit comments

Comments
 (0)