From 003f2b135f6ceafac2e602ff9e2daa1b66b2ddbd Mon Sep 17 00:00:00 2001 From: Maik Schuerer Date: Tue, 5 Jul 2016 16:36:45 +0200 Subject: [PATCH] add method List getAssignableUsers() --- .../java/net/rcarz/jiraclient/Project.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/net/rcarz/jiraclient/Project.java b/src/main/java/net/rcarz/jiraclient/Project.java index fb674f6..6a917c4 100644 --- a/src/main/java/net/rcarz/jiraclient/Project.java +++ b/src/main/java/net/rcarz/jiraclient/Project.java @@ -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 getAssignableUsers() throws JiraException { + JSON result = null; + + try { + Map queryParams = new HashMap(); + 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();