Commit 409e5ea8 authored by 六幻's avatar 六幻
Browse files

rewrite findUsers method.

parent 604c8388
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>>() {}));
} }
/** /**
......
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