From 69d4f353a276d13ecdd9fd7414cfc2e29c5c3baa Mon Sep 17 00:00:00 2001 From: Pooja Singhal Date: Mon, 8 Jul 2019 11:17:06 +0530 Subject: [PATCH 1/3] adding check for ValueTuple in custom types also --- pom.xml | 2 +- src/main/java/net/rcarz/jiraclient/Field.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index f1f9b07a..0ba88909 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ net.rcarz jira-client - 0.6-SNAPSHOT + 0.7-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(); From dfd3a883df1654ef57bb898049629140b9464a42 Mon Sep 17 00:00:00 2001 From: Dhruv Upadhyay Date: Tue, 19 May 2020 22:57:10 +0530 Subject: [PATCH 2/3] log additon --- pom.xml | 2 +- .../java/net/rcarz/jiraclient/JiraClient.java | 7 +++-- .../java/net/rcarz/jiraclient/RestClient.java | 26 ++++++++++++------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 0ba88909..9dbff3a4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ net.rcarz jira-client - 0.7-SNAPSHOT + 0.8-SNAPSHOT jar jira-client 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; } From 244ad2aadc9c728b4cf2b88e17f9a35ddb62bac2 Mon Sep 17 00:00:00 2001 From: Alexandr Gorodetki Date: Fri, 18 Sep 2020 12:32:21 +0200 Subject: [PATCH 3/3] [CDC-9423]: fixed NPE within TimeTracking --- pom.xml | 2 +- src/main/java/net/rcarz/jiraclient/TimeTracking.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9dbff3a4..f0c3e1f9 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ net.rcarz jira-client - 0.8-SNAPSHOT + 0.9-SNAPSHOT jar jira-client 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;