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
409e5ea8
Commit
409e5ea8
authored
May 13, 2015
by
六幻
Browse files
rewrite findUsers method.
parent
604c8388
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/UserApi.java
View file @
409e5ea8
package
com.messners.gitlab.api
;
package
com.messners.gitlab.api
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.List
;
import
com.messners.gitlab.api.models.User
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
com.messners.gitlab.api.models.User
;
public
class
UserApi
extends
AbstractApi
{
public
class
UserApi
extends
AbstractApi
{
UserApi
(
GitLabApi
gitLabApi
)
{
UserApi
(
GitLabApi
gitLabApi
)
{
...
@@ -79,18 +76,10 @@ public class UserApi extends AbstractApi {
...
@@ -79,18 +76,10 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
List
<
User
>
findUsers
(
String
emailOrUsername
)
throws
GitLabApiException
{
public
List
<
User
>
findUsers
(
String
emailOrUsername
)
throws
GitLabApiException
{
URL
url
;
Form
formData
=
new
Form
();
try
{
addFormParam
(
formData
,
"search"
,
emailOrUsername
,
true
);
url
=
new
URL
(
getApiClient
().
getApiUrl
(
"users"
).
toString
()+
"?search="
+
emailOrUsername
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
);
}
catch
(
MalformedURLException
e
)
{
return
(
response
.
readEntity
(
new
GenericType
<
List
<
User
>>()
{}));
e
.
printStackTrace
();
return
null
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
null
;
}
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
url
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
User
>>()
{}));
}
}
/**
/**
...
...
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