Commit a9be1289 authored by Greg Messner's avatar Greg Messner
Browse files

Added support for providing Jersey client properties.

parent 2b9a7b97
package org.gitlab4j.api; package org.gitlab4j.api;
import java.util.Map;
/** /**
* This class is provides a simplified interface to a GitLab API server, and divides the API up into * This class is provides a simplified interface to a GitLab API server, and divides the API up into
* a separate API class for each concern. * a separate API class for each concern.
...@@ -51,7 +53,11 @@ public class GitLabApi { ...@@ -51,7 +53,11 @@ public class GitLabApi {
* @param secretToken use this token to validate received payloads * @param secretToken use this token to validate received payloads
*/ */
public GitLabApi(String hostUrl, String privateToken, String secretToken) { public GitLabApi(String hostUrl, String privateToken, String secretToken) {
apiClient = new GitLabApiClient(hostUrl, privateToken, secretToken); this(hostUrl, privateToken, secretToken, null);
}
public GitLabApi(String hostUrl, String privateToken, String secretToken, Map<String, Object> clientConfigProperties) {
apiClient = new GitLabApiClient(hostUrl, privateToken, secretToken, clientConfigProperties);
commitsApi = new CommitsApi(this); commitsApi = new CommitsApi(this);
groupApi = new GroupApi(this); groupApi = new GroupApi(this);
mergeRequestApi = new MergeRequestApi(this); mergeRequestApi = new MergeRequestApi(this);
......
...@@ -66,6 +66,19 @@ public class GitLabApiClient { ...@@ -66,6 +66,19 @@ public class GitLabApiClient {
* @param secretToken use this token to validate received payloads * @param secretToken use this token to validate received payloads
*/ */
public GitLabApiClient(String hostUrl, String privateToken, String secretToken) { public GitLabApiClient(String hostUrl, String privateToken, String secretToken) {
this(hostUrl, privateToken, secretToken, null);
}
/**
* Construct an instance to communicate with a GitLab API server using the specified
* server URL and private token.
*
* @param hostUrl the URL to the GitLab API server
* @param privateToken the private token to authenticate with
* @param secretToken use this token to validate received payloads
* @param clientConfigProperties the properties given to Jersey's clientconfig
*/
public GitLabApiClient(String hostUrl, String privateToken, String secretToken, Map<String, Object> clientConfigProperties) {
// Remove the trailing "/" from the hostUrl if present // Remove the trailing "/" from the hostUrl if present
this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl) + API_NAMESPACE; this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl) + API_NAMESPACE;
...@@ -79,6 +92,10 @@ public class GitLabApiClient { ...@@ -79,6 +92,10 @@ public class GitLabApiClient {
this.secretToken = secretToken; this.secretToken = secretToken;
clientConfig = new ClientConfig(); clientConfig = new ClientConfig();
if (clientConfigProperties != null) {
clientConfig.getProperties().putAll(clientConfigProperties);
}
clientConfig.register(JacksonJson.class); clientConfig.register(JacksonJson.class);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment