diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java index 208364a..8db462e 100644 --- a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java +++ b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java @@ -105,9 +105,18 @@ public class YoutrackAPI { return new DefaultHttpClient(cm); } - private static boolean isBlank(String string) + private static boolean isBlank(String str) { - return string != null && string.trim().length() > 0; + int strLen; + if (str == null || (strLen = str.length()) == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if ((!Character.isWhitespace(str.charAt(i)))) { + return false; + } + } + return true; } // --------------------------- CONSTRUCTORS --------------------------- @@ -153,16 +162,16 @@ public class YoutrackAPI { final HttpPost request = new HttpPost(serviceLocation + "/rest/issue/" + issueId + "/execute"); final List parameters = new ArrayList(); parameters.add(new BasicNameValuePair("command", command)); - if (isBlank(comment)) { + if (!isBlank(comment)) { parameters.add(new BasicNameValuePair("comment", comment)); } - if (isBlank(group)) { + if (!isBlank(group)) { parameters.add(new BasicNameValuePair("group", group)); } if (disableNotifications != null) { parameters.add(new BasicNameValuePair("disableNotifications", disableNotifications.toString())); } - if (isBlank(runAs)) { + if (!isBlank(runAs)) { parameters.add(new BasicNameValuePair("runAs", runAs)); } request.setEntity(new UrlEncodedFormEntity(parameters)); @@ -297,42 +306,6 @@ public class YoutrackAPI { return wrappedIssues; } - public void setTotalBilledHours(String issueSignature, Long billedHours) - { - //QA-SUGGESTION this method should not be in this project, remove it from this class - final URI uri; - try { - uri = new URIBuilder(serviceLocation + "/rest/issue/" + issueSignature + "/execute").build(); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - try { - final HttpPost request = new HttpPost(uri); - request.getParams().setParameter("command", "Billed hours " + billedHours); - execute(request); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public void setTotalIssueDuration(String issueSignature, Long issueTotalDuration) - { - //QA-SUGGESTION this method should not be in this project, remove it from this class - final URI uri; - try { - uri = new URIBuilder(serviceLocation + "/rest/issue/" + issueSignature + "/execute").build(); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - try { - final HttpPost request = new HttpPost(uri); - request.getParams().setParameter("command", "Real completion time " + issueTotalDuration).setParameter("disableNotifications", true); - execute(request); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - private HttpPut createPutRequest(URI uri, BasicNameValuePair... nameValuePair) throws UnsupportedEncodingException { final HttpPut request = new HttpPut(uri);