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
a6cb160c
Commit
a6cb160c
authored
Mar 21, 2014
by
Greg Messner
Browse files
Changed handling of unexpected HTTP status.
parent
206dba0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/AbstractApi.java
View file @
a6cb160c
...
...
@@ -34,18 +34,18 @@ public abstract class AbstractApi {
protected
ClientResponse
get
(
ClientResponse
.
Status
expectedStatus
,
MultivaluedMap
<
String
,
String
>
queryParams
,
Object
...
pathArgs
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
get
(
queryParams
,
pathArgs
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
get
(
queryParams
,
pathArgs
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
@@ -62,18 +62,18 @@ public abstract class AbstractApi {
protected
ClientResponse
get
(
ClientResponse
.
Status
expectedStatus
,
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
get
(
queryParams
,
url
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
get
(
queryParams
,
url
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
@@ -89,18 +89,18 @@ public abstract class AbstractApi {
*/
protected
ClientResponse
post
(
ClientResponse
.
Status
expectedStatus
,
Form
formData
,
Object
...
pathArgs
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
post
(
formData
,
pathArgs
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
post
(
formData
,
pathArgs
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
@@ -116,18 +116,18 @@ public abstract class AbstractApi {
*/
protected
ClientResponse
post
(
ClientResponse
.
Status
expectedStatus
,
Form
formData
,
URL
url
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
post
(
formData
,
url
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
post
(
formData
,
url
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
@@ -144,18 +144,18 @@ public abstract class AbstractApi {
*/
protected
ClientResponse
put
(
ClientResponse
.
Status
expectedStatus
,
MultivaluedMap
<
String
,
String
>
queryParams
,
Object
...
pathArgs
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
put
(
queryParams
,
pathArgs
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
put
(
queryParams
,
pathArgs
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
@@ -171,18 +171,18 @@ public abstract class AbstractApi {
*/
protected
ClientResponse
put
(
ClientResponse
.
Status
expectedStatus
,
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
put
(
queryParams
,
url
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
put
(
queryParams
,
url
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
@@ -199,18 +199,18 @@ public abstract class AbstractApi {
protected
ClientResponse
delete
(
ClientResponse
.
Status
expectedStatus
,
MultivaluedMap
<
String
,
String
>
queryParams
,
Object
...
pathArgs
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
delete
(
queryParams
,
pathArgs
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
delete
(
queryParams
,
pathArgs
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
@@ -226,18 +226,18 @@ public abstract class AbstractApi {
*/
protected
ClientResponse
delete
(
ClientResponse
.
Status
expectedStatus
,
MultivaluedMap
<
String
,
String
>
queryParams
,
URL
url
)
throws
GitLabApiException
{
try
{
ClientResponse
response
=
getApiClient
().
delete
(
queryParams
,
url
);
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
ClientResponse
response
=
null
;
try
{
response
=
getApiClient
().
delete
(
queryParams
,
url
);
}
catch
(
Exception
e
)
{
throw
(
new
GitLabApiException
(
e
));
}
if
(
response
.
getStatus
()
!=
expectedStatus
.
getStatusCode
())
{
throw
(
new
GitLabApiException
(
response
));
}
return
(
response
);
}
...
...
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