Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
a9be1289
Commit
a9be1289
authored
Mar 25, 2017
by
Greg Messner
Browse files
Added support for providing Jersey client properties.
parent
2b9a7b97
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
a9be1289
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
* a separate API class for each concern.
...
...
@@ -51,7 +53,11 @@ public class GitLabApi {
* @param secretToken use this token to validate received payloads
*/
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
);
groupApi
=
new
GroupApi
(
this
);
mergeRequestApi
=
new
MergeRequestApi
(
this
);
...
...
src/main/java/org/gitlab4j/api/GitLabApiClient.java
View file @
a9be1289
...
...
@@ -66,6 +66,19 @@ public class GitLabApiClient {
* @param secretToken use this token to validate received payloads
*/
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
this
.
hostUrl
=
(
hostUrl
.
endsWith
(
"/"
)
?
hostUrl
.
replaceAll
(
"/$"
,
""
)
:
hostUrl
)
+
API_NAMESPACE
;
...
...
@@ -79,6 +92,10 @@ public class GitLabApiClient {
this
.
secretToken
=
secretToken
;
clientConfig
=
new
ClientConfig
();
if
(
clientConfigProperties
!=
null
)
{
clientConfig
.
getProperties
().
putAll
(
clientConfigProperties
);
}
clientConfig
.
register
(
JacksonJson
.
class
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment