Skip to content

Commit

Permalink
rewrite findUsers method.
Browse files Browse the repository at this point in the history
  • Loading branch information
六幻 committed May 13, 2015
1 parent 604c838 commit 409e5ea
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/main/java/com/messners/gitlab/api/UserApi.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.messners.gitlab.api;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import com.messners.gitlab.api.models.User;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;

import com.messners.gitlab.api.models.User;

public class UserApi extends AbstractApi {

UserApi (GitLabApi gitLabApi) {
Expand Down Expand Up @@ -79,18 +76,10 @@ public User getUser (int userId) throws GitLabApiException {
* @throws GitLabApiException
*/
public List<User> findUsers(String emailOrUsername) throws GitLabApiException {
URL url;
try {
url = new URL(getApiClient().getApiUrl("users").toString()+"?search="+emailOrUsername);
} catch (MalformedURLException e) {
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>>() {}));
Form formData = new Form();
addFormParam(formData, "search", emailOrUsername, true);
Response response = get(Response.Status.OK, formData.asMap(), "users");
return (response.readEntity(new GenericType<List<User>>() {}));
}

/**
Expand Down

0 comments on commit 409e5ea

Please sign in to comment.