1
0
Fork 0

add method List<User> getAssignableUsers()

master
Maik Schuerer 2016-07-05 16:36:45 +02:00
parent c9220cb17e
commit 003f2b135f
1 changed files with 21 additions and 0 deletions

View File

@ -19,8 +19,11 @@
package net.rcarz.jiraclient;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.rcarz.jiraclient.Resource.getBaseUri;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
@ -130,6 +133,24 @@ public class Project extends Resource {
return Field.getResourceArray(Project.class, result, restclient);
}
public List<User> getAssignableUsers() throws JiraException {
JSON result = null;
try {
Map<String, String> queryParams = new HashMap<String, String>();
queryParams.put("project", this.key);
URI searchUri = restclient.buildURI(getBaseUri() + "user/assignable/search", queryParams);
result = restclient.get(searchUri);
} catch (Exception ex) {
throw new JiraException("Failed to retrieve assignable users", ex);
}
if (!(result instanceof JSONArray))
throw new JiraException("JSON payload is malformed");
return Field.getResourceArray(User.class, result, restclient);
}
@Override
public String toString() {
return getName();