diff --git a/pom.xml b/pom.xml index f1f9b07a..f0c3e1f9 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ net.rcarz jira-client - 0.6-SNAPSHOT + 0.9-SNAPSHOT jar jira-client diff --git a/src/main/java/net/rcarz/jiraclient/Field.java b/src/main/java/net/rcarz/jiraclient/Field.java index 29a28414..1b75de8f 100644 --- a/src/main/java/net/rcarz/jiraclient/Field.java +++ b/src/main/java/net/rcarz/jiraclient/Field.java @@ -626,9 +626,14 @@ public static JSONArray toArray(Iterable iter, String type, String custom) throw type.equals("string") && custom != null && (custom.equals("com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes") || custom.equals("com.atlassian.jira.plugin.system.customfieldtypes:multiselect")))) { - realResult = new JSONObject(); - ((JSONObject)realResult).put(ValueType.VALUE.toString(), realValue.toString()); + if (realValue instanceof ValueTuple) { + ValueTuple tuple = (ValueTuple)realValue; + ((JSONObject)realResult).put(tuple.type, tuple.value.toString()); + } else { + ((JSONObject)realResult).put(ValueType.VALUE.toString(), realValue.toString()); + } + } else if (type.equals("string")) realResult = realValue.toString(); diff --git a/src/main/java/net/rcarz/jiraclient/JiraClient.java b/src/main/java/net/rcarz/jiraclient/JiraClient.java index 276b8d7c..4e5d4543 100644 --- a/src/main/java/net/rcarz/jiraclient/JiraClient.java +++ b/src/main/java/net/rcarz/jiraclient/JiraClient.java @@ -34,14 +34,16 @@ import net.sf.json.JSON; import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import java.util.logging.Logger; /** * A simple JIRA REST client. */ public class JiraClient { - private RestClient restclient = null; - private String username = null; + private RestClient restclient = null; + private String username = null; + private static Logger logger = Logger.getLogger("JiraClient"); /** * Creates a JIRA client. @@ -468,6 +470,7 @@ public List getProjects() throws JiraException { try { URI uri = restclient.buildURI(Resource.getBaseUri() + "project"); JSON response = restclient.get(uri); + logger.info("JIRA - RESPONSE " + response.toString()); JSONArray projectsArray = JSONArray.fromObject(response); List projects = new ArrayList(projectsArray.size()); diff --git a/src/main/java/net/rcarz/jiraclient/RestClient.java b/src/main/java/net/rcarz/jiraclient/RestClient.java index e0ccceab..58277d65 100644 --- a/src/main/java/net/rcarz/jiraclient/RestClient.java +++ b/src/main/java/net/rcarz/jiraclient/RestClient.java @@ -53,6 +53,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Map; +import java.util.logging.Logger; /** * A simple REST client that speaks JSON. @@ -63,15 +64,17 @@ public class RestClient { private ICredentials creds = null; private URI uri = null; - /** - * Creates a REST client instance with a URI. - * - * @param httpclient Underlying HTTP client to use - * @param uri Base URI of the remote REST service - */ - public RestClient(HttpClient httpclient, URI uri) { - this(httpclient, null, uri); - } + private static Logger logger = Logger.getLogger("RestClient"); + + /** + * Creates a REST client instance with a URI. + * + * @param httpclient Underlying HTTP client to use + * @param uri Base URI of the remote REST service + */ + public RestClient(HttpClient httpclient, URI uri) { + this(httpclient, null, uri); + } /** * Creates an authenticated REST client instance with a URI. @@ -128,6 +131,9 @@ private JSON request(HttpRequestBase req) throws RestException, IOException { creds.authenticate(req); HttpResponse resp = httpClient.execute(req); + logger.info("REST - RESPONSE" + resp.toString()); + logger.info("RESPONSE HEADERS : " + resp.getAllHeaders()); + logger.info("STATUS CODE: " + resp.getStatusLine().getStatusCode()); HttpEntity ent = resp.getEntity(); StringBuilder result = new StringBuilder(); @@ -139,6 +145,7 @@ private JSON request(HttpRequestBase req) throws RestException, IOException { if (encoding == null) { Header contentTypeHeader = resp.getFirstHeader("Content-Type"); + logger.info("ContentTypeHeader : " + contentTypeHeader); HeaderElement[] contentTypeElements = contentTypeHeader.getElements(); for (HeaderElement he : contentTypeElements) { NameValuePair nvp = he.getParameterByName("charset"); @@ -170,6 +177,7 @@ private JSON request(HttpRequestBase req) throws RestException, IOException { if (sl.getStatusCode() >= 300) throw new RestException(sl.getReasonPhrase(), sl.getStatusCode(), result.toString(), resp.getAllHeaders()); + logger.info("Rest Client Result: " + result ); return result.length() > 0 ? JSONSerializer.toJSON(result.toString()): null; } diff --git a/src/main/java/net/rcarz/jiraclient/TimeTracking.java b/src/main/java/net/rcarz/jiraclient/TimeTracking.java index 4a18f495..d3a7eaa9 100644 --- a/src/main/java/net/rcarz/jiraclient/TimeTracking.java +++ b/src/main/java/net/rcarz/jiraclient/TimeTracking.java @@ -71,10 +71,10 @@ protected JSONObject toJsonObject() { if (remainingEstimate != null) object.put("remainingEstimate", remainingEstimate); - if (originalEstimateSeconds >= 0) + if (originalEstimateSeconds != null && originalEstimateSeconds >= 0) object.put("originalEstimateSeconds", originalEstimateSeconds); - if (remainingEstimateSeconds >= 0) + if (remainingEstimateSeconds != null && remainingEstimateSeconds >= 0) object.put("remainingEstimateSeconds", remainingEstimateSeconds); return object;