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
32cf4cad
Commit
32cf4cad
authored
Jan 30, 2017
by
Greg Messner
Browse files
More Javadoc fixes.
parent
1fa86252
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/AbstractApi.java
View file @
32cf4cad
...
@@ -229,7 +229,7 @@ public abstract class AbstractApi {
...
@@ -229,7 +229,7 @@ public abstract class AbstractApi {
* @param response response
* @param response response
* @param expected expected respone status
* @param expected expected respone status
* @return original response if the response status is expected
* @return original response if the response status is expected
* @throws GitLabApiException i
n case of unexpected response status
* @throws GitLabApiException i
f HTTP status is not as expected
*/
*/
protected
Response
validate
(
Response
response
,
Response
.
Status
expected
)
throws
GitLabApiException
{
protected
Response
validate
(
Response
response
,
Response
.
Status
expected
)
throws
GitLabApiException
{
if
(
response
.
getStatus
()
!=
expected
.
getStatusCode
())
{
if
(
response
.
getStatus
()
!=
expected
.
getStatusCode
())
{
...
@@ -242,9 +242,8 @@ public abstract class AbstractApi {
...
@@ -242,9 +242,8 @@ public abstract class AbstractApi {
/**
/**
* Wraps exception if needed
* Wraps exception if needed
*
*
* @param thrown exception
* @param thrown the exception that should be wrapped
* @return never returns
* @throws GitLabApiException containing the cause or GitLab API specific message
* @throws GitLabApiException always
*/
*/
protected
GitLabApiException
handle
(
Exception
thrown
)
throws
GitLabApiException
{
protected
GitLabApiException
handle
(
Exception
thrown
)
throws
GitLabApiException
{
...
...
src/main/java/com/messners/gitlab/api/CommitsApi.java
View file @
32cf4cad
...
@@ -22,8 +22,8 @@ public class CommitsApi extends AbstractApi {
...
@@ -22,8 +22,8 @@ public class CommitsApi extends AbstractApi {
* GET /projects/:id/repository/commits
* GET /projects/:id/repository/commits
*
*
* @param projectId the project ID to get the list of commits for
* @param projectId the project ID to get the list of commits for
* @return a
L
ist
<Commit>
containing the commits for the specified project ID
* @return a
l
ist containing the commits for the specified project ID
* @throws GitLabApiException
* @throws GitLabApiException
GitLabApiException if any exception occurs during execution
*/
*/
public
List
<
Commit
>
getCommits
(
int
projectId
)
throws
GitLabApiException
{
public
List
<
Commit
>
getCommits
(
int
projectId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"commits"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"commits"
);
...
@@ -39,7 +39,7 @@ public class CommitsApi extends AbstractApi {
...
@@ -39,7 +39,7 @@ public class CommitsApi extends AbstractApi {
* @param projectId the project ID that the commit belongs to
* @param projectId the project ID that the commit belongs to
* @param sha a commit hash or name of a branch or tag
* @param sha a commit hash or name of a branch or tag
* @return the Commit instance for the specified project ID/sha pair
* @return the Commit instance for the specified project ID/sha pair
* @throws GitLabApiException
* @throws GitLabApiException
GitLabApiException if any exception occurs during execution
*/
*/
public
Commit
getCommits
(
int
projectId
,
String
sha
)
throws
GitLabApiException
{
public
Commit
getCommits
(
int
projectId
,
String
sha
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"commits"
,
sha
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"commits"
,
sha
);
...
@@ -54,7 +54,7 @@ public class CommitsApi extends AbstractApi {
...
@@ -54,7 +54,7 @@ public class CommitsApi extends AbstractApi {
* @param projectId the project ID that the commit belongs to
* @param projectId the project ID that the commit belongs to
* @param sha a commit hash or name of a branch or tag
* @param sha a commit hash or name of a branch or tag
* @return the Diff instance for the specified project ID/sha pair
* @return the Diff instance for the specified project ID/sha pair
* @throws GitLabApiException
* @throws GitLabApiException
GitLabApiException if any exception occurs during execution
*/
*/
public
Diff
getDiff
(
int
projectId
,
String
sha
)
throws
GitLabApiException
{
public
Diff
getDiff
(
int
projectId
,
String
sha
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"commits"
,
sha
,
"diff"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"commits"
,
sha
,
"diff"
);
...
...
src/main/java/com/messners/gitlab/api/GitLabApi.java
View file @
32cf4cad
...
@@ -24,6 +24,7 @@ public class GitLabApi {
...
@@ -24,6 +24,7 @@ public class GitLabApi {
* @param username user name for which private token should be obtained
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @param password password for a given {@code username}
* @return new {@code GitLabApi} instance configured for a user-specific token
* @return new {@code GitLabApi} instance configured for a user-specific token
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
*/
static
public
GitLabApi
create
(
String
url
,
String
username
,
String
password
)
throws
GitLabApiException
{
static
public
GitLabApi
create
(
String
url
,
String
username
,
String
password
)
throws
GitLabApiException
{
String
token
=
new
SessionApi
(
new
GitLabApi
(
url
,
null
)).
login
(
username
,
null
,
password
).
getPrivateToken
();
String
token
=
new
SessionApi
(
new
GitLabApi
(
url
,
null
)).
login
(
username
,
null
,
password
).
getPrivateToken
();
...
@@ -34,8 +35,8 @@ public class GitLabApi {
...
@@ -34,8 +35,8 @@ public class GitLabApi {
* Constructs a GitLabApi instance set up to interact with the GitLab server
* Constructs a GitLabApi instance set up to interact with the GitLab server
* specified by hostUrl.
* specified by hostUrl.
*
*
* @param hostUrl
* @param hostUrl
the URL of the GitLab server
* @param privateToken
* @param privateToken
to private token to use for access to the API
*/
*/
public
GitLabApi
(
String
hostUrl
,
String
privateToken
)
{
public
GitLabApi
(
String
hostUrl
,
String
privateToken
)
{
apiClient
=
new
GitLabApiClient
(
hostUrl
,
privateToken
);
apiClient
=
new
GitLabApiClient
(
hostUrl
,
privateToken
);
...
...
src/main/java/com/messners/gitlab/api/GitLabApiClient.java
View file @
32cf4cad
...
@@ -73,11 +73,9 @@ public class GitLabApiClient {
...
@@ -73,11 +73,9 @@ public class GitLabApiClient {
/**
/**
* Sets up the Jersey system ignore SSL certificate errors or not.
* Sets up the Jersey system ignore SSL certificate errors or not.
*
*
* <p>
* WARNING: Setting this to true will affect ALL uses of HttpsURLConnection and Jersey.
* <strong>WARNING: Setting this to true will affect ALL uses of HttpsURLConnection and Jersey.<strong>
* <p>
*
*
* @param ignoreCertificateErrors
* @param ignoreCertificateErrors
if true will set up the Jersey system ignore SSL certificate errors
*/
*/
public
void
setIgnoreCerificateErrors
(
boolean
ignoreCertificateErrors
)
{
public
void
setIgnoreCerificateErrors
(
boolean
ignoreCertificateErrors
)
{
...
@@ -143,7 +141,7 @@ public class GitLabApiClient {
...
@@ -143,7 +141,7 @@ public class GitLabApiClient {
/**
/**
* Construct a REST URL with the specified path arguments.
* Construct a REST URL with the specified path arguments.
*
*
* @param pathArgs
* @param pathArgs
ariable list of arguments used to build the URI
* @return a REST URL with the specified path arguments
* @return a REST URL with the specified path arguments
* @throws IOException
* @throws IOException
*/
*/
...
@@ -165,8 +163,8 @@ public class GitLabApiClient {
...
@@ -165,8 +163,8 @@ public class GitLabApiClient {
* Perform an HTTP GET call with the specified query parameters and path objects, returning
* Perform an HTTP GET call with the specified query parameters and path objects, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param queryParams
* @param queryParams
multivalue map of request parameters
* @param pathArgs
* @param pathArgs
variable list of arguments used to build the URI
* @return a ClientResponse instance with the data returned from the endpoint
* @return a ClientResponse instance with the data returned from the endpoint
* @throws IOException
* @throws IOException
*/
*/
...
@@ -179,8 +177,8 @@ public class GitLabApiClient {
...
@@ -179,8 +177,8 @@ public class GitLabApiClient {
* Perform an HTTP GET call with the specified query parameters and URL, returning
* Perform an HTTP GET call with the specified query parameters and URL, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param queryParams
* @param queryParams
multivalue map of request parameters
* @param url
* @param url
the fully formed path to the GitLab API endpoint
* @return a ClientResponse instance with the data returned from the endpoint
* @return a ClientResponse instance with the data returned from the endpoint
*/
*/
protected
Response
get
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
protected
Response
get
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
...
@@ -191,8 +189,8 @@ public class GitLabApiClient {
...
@@ -191,8 +189,8 @@ public class GitLabApiClient {
* Perform an HTTP POST call with the specified form data and path objects, returning
* Perform an HTTP POST call with the specified form data and path objects, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param formData
* @param formData
the Form containing the name/value pairs
* @param pathArgs
* @param pathArgs
variable list of arguments used to build the URI
* @return a ClientResponse instance with the data returned from the endpoint
* @return a ClientResponse instance with the data returned from the endpoint
* @throws IOException
* @throws IOException
*/
*/
...
@@ -205,9 +203,9 @@ public class GitLabApiClient {
...
@@ -205,9 +203,9 @@ public class GitLabApiClient {
* Perform an HTTP POST call with the specified form data and path objects, returning
* Perform an HTTP POST call with the specified form data and path objects, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param
formData
* @param
queryParams multivalue map of request parameters
* @param pathArgs
* @param pathArgs
variable list of arguments used to build the URI
* @return a
Client
Response instance with the data returned from the endpoint
* @return a Response instance with the data returned from the endpoint
* @throws IOException
* @throws IOException
*/
*/
protected
Response
post
(
MultivaluedMap
<
String
,
String
>
queryParams
,
Object
...
pathArgs
)
throws
IOException
{
protected
Response
post
(
MultivaluedMap
<
String
,
String
>
queryParams
,
Object
...
pathArgs
)
throws
IOException
{
...
@@ -219,8 +217,8 @@ public class GitLabApiClient {
...
@@ -219,8 +217,8 @@ public class GitLabApiClient {
* Perform an HTTP POST call with the specified form data and URL, returning
* Perform an HTTP POST call with the specified form data and URL, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param formData
* @param formData
the Form containing the name/value pairs
* @param url
* @param url
the fully formed path to the GitLab API endpoint
* @return a ClientResponse instance with the data returned from the endpoint
* @return a ClientResponse instance with the data returned from the endpoint
*/
*/
protected
Response
post
(
Form
formData
,
URL
url
)
{
protected
Response
post
(
Form
formData
,
URL
url
)
{
...
@@ -230,9 +228,9 @@ public class GitLabApiClient {
...
@@ -230,9 +228,9 @@ public class GitLabApiClient {
/**
/**
* Perform an HTTP POST call with the specified form data and URL, returning
* Perform an HTTP POST call with the specified form data and URL, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param
formData
* @param
queryParams multivalue map of request parametersformData the Form containing the name/value pairs
* @param url
* @param url
the fully formed path to the GitLab API endpoint
* @return a ClientResponse instance with the data returned from the endpoint
* @return a ClientResponse instance with the data returned from the endpoint
*/
*/
protected
Response
post
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
protected
Response
post
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
...
@@ -243,8 +241,8 @@ public class GitLabApiClient {
...
@@ -243,8 +241,8 @@ public class GitLabApiClient {
* Perform an HTTP PUT call with the specified form data and path objects, returning
* Perform an HTTP PUT call with the specified form data and path objects, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param queryParams
* @param queryParams
multivalue map of request parameters
* @param pathArgs
* @param pathArgs
variable list of arguments used to build the URI
* @return a ClientResponse instance with the data returned from the endpoint
* @return a ClientResponse instance with the data returned from the endpoint
* @throws IOException
* @throws IOException
*/
*/
...
@@ -256,9 +254,9 @@ public class GitLabApiClient {
...
@@ -256,9 +254,9 @@ public class GitLabApiClient {
/**
/**
* Perform an HTTP PUT call with the specified form data and URL, returning
* Perform an HTTP PUT call with the specified form data and URL, returning
* a ClientResponse instance with the data returned from the endpoint.
* a ClientResponse instance with the data returned from the endpoint.
*
*
* @param queryParams
* @param queryParams
multivalue map of request parameters
* @param url
* @param url
the fully formed path to the GitLab API endpoint
* @return a ClientResponse instance with the data returned from the endpoint
* @return a ClientResponse instance with the data returned from the endpoint
*/
*/
protected
Response
put
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
protected
Response
put
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
...
@@ -269,8 +267,8 @@ public class GitLabApiClient {
...
@@ -269,8 +267,8 @@ public class GitLabApiClient {
* Perform an HTTP DELETE call with the specified form data and path objects, returning
* Perform an HTTP DELETE call with the specified form data and path objects, returning
* a Response instance with the data returned from the endpoint.
* a Response instance with the data returned from the endpoint.
*
*
* @param queryParams
* @param queryParams
multivalue map of request parameters
* @param pathArgs
* @param pathArgs
variable list of arguments used to build the URI
* @return a Response instance with the data returned from the endpoint
* @return a Response instance with the data returned from the endpoint
* @throws IOException
* @throws IOException
*/
*/
...
@@ -282,8 +280,8 @@ public class GitLabApiClient {
...
@@ -282,8 +280,8 @@ public class GitLabApiClient {
* Perform an HTTP DELETE call with the specified form data and URL, returning
* Perform an HTTP DELETE call with the specified form data and URL, returning
* a Response instance with the data returned from the endpoint.
* a Response instance with the data returned from the endpoint.
*
*
* @param queryParams
* @param queryParams
multivalue map of request parameters
* @param url
* @param url
the fully formed path to the GitLab API endpoint
* @return a Response instance with the data returned from the endpoint
* @return a Response instance with the data returned from the endpoint
*/
*/
protected
Response
delete
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
protected
Response
delete
(
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
{
...
...
src/test/java/com/messners/gitlab/api/TestGitLabApiBeans.java
View file @
32cf4cad
...
@@ -6,14 +6,15 @@ import java.io.IOException;
...
@@ -6,14 +6,15 @@ import java.io.IOException;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.List
;
import
java.util.List
;
import
org.codehaus.jackson.JsonNode
;
import
org.codehaus.jackson.JsonParseException
;
import
org.codehaus.jackson.map.JsonMappingException
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.codehaus.jackson.type.TypeReference
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.Test
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.JsonMappingException
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.messners.gitlab.api.models.Branch
;
import
com.messners.gitlab.api.models.Branch
;
import
com.messners.gitlab.api.models.Diff
;
import
com.messners.gitlab.api.models.Diff
;
import
com.messners.gitlab.api.models.Event
;
import
com.messners.gitlab.api.models.Event
;
...
...
src/test/java/com/messners/gitlab/api/TestGitLabApiEvents.java
View file @
32cf4cad
...
@@ -5,13 +5,13 @@ import static org.junit.Assert.assertTrue;
...
@@ -5,13 +5,13 @@ import static org.junit.Assert.assertTrue;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
org.codehaus.jackson.JsonNode
;
import
org.codehaus.jackson.JsonParseException
;
import
org.codehaus.jackson.map.JsonMappingException
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.Test
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.databind.JsonMappingException
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.messners.gitlab.api.webhook.EventObject
;
import
com.messners.gitlab.api.webhook.EventObject
;
import
com.messners.gitlab.api.webhook.PushEvent
;
import
com.messners.gitlab.api.webhook.PushEvent
;
...
...
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