1
0
Fork 0

Merge pull request #30 from witekw/master

Fixed passing parameters in url to the "user" API.
master
Bob Carroll 2014-04-28 20:43:13 -07:00
commit b0305773d6
3 changed files with 29 additions and 2 deletions

View File

@ -574,6 +574,12 @@ public final class Field {
} else if (m.type.equals("string")) {
if (value instanceof List)
return toJsonMap((List)value);
else if (value instanceof ValueTuple) {
JSONObject json = new JSONObject();
ValueTuple tuple = (ValueTuple)value;
json.put(tuple.type, tuple.value.toString());
return json.toString();
}
return value.toString();
} else if (m.type.equals("timetracking")) {

View File

@ -243,6 +243,22 @@ public class RestClient {
return request(new HttpGet(uri));
}
/**
* Executes an HTTP GET with the given path.
*
* @param path Path to be appended to the URI supplied in the construtor
* @param params Map of key value pairs
*
* @return JSON-encoded result or null when there's no content returned
*
* @throws RestException when an HTTP-level error occurs
* @throws IOException when an error reading the response occurs
* @throws URISyntaxException when an error occurred appending the path to the URI
*/
public JSON get(String path, Map<String, String> params) throws RestException, IOException, URISyntaxException {
return get(buildURI(path, params));
}
/**
* Executes an HTTP GET with the given path.
*
@ -255,9 +271,10 @@ public class RestClient {
* @throws URISyntaxException when an error occurred appending the path to the URI
*/
public JSON get(String path) throws RestException, IOException, URISyntaxException {
return get(buildURI(path));
return get(path, null);
}
/**
* Executes an HTTP POST with the given URI and payload.
*

View File

@ -22,6 +22,7 @@ package net.rcarz.jiraclient;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
@ -61,8 +62,11 @@ public class User extends Resource {
JSON result = null;
Map<String, String> params = new HashMap<String, String>();
params.put("username", username);
try {
result = restclient.get(getBaseUri() + "user?username=" + username);
result = restclient.get(getBaseUri() + "user", params);
} catch (Exception ex) {
throw new JiraException("Failed to retrieve user " + username, ex);
}