Commit 157c44658ceb217a146ecf0691e8f9b98f2e5a2a
1 parent
0afc634d
Remove setTotalBilledHours and setTotalIssueDuration methods.
Adjust implementation of isBlank method.
Showing
1 changed file
with
14 additions
and
41 deletions
@@ -105,9 +105,18 @@ public class YoutrackAPI { | @@ -105,9 +105,18 @@ public class YoutrackAPI { | ||
105 | return new DefaultHttpClient(cm); | 105 | return new DefaultHttpClient(cm); |
106 | } | 106 | } |
107 | 107 | ||
108 | - private static boolean isBlank(String string) | 108 | + private static boolean isBlank(String str) |
109 | { | 109 | { |
110 | - return string != null && string.trim().length() > 0; | 110 | + int strLen; |
111 | + if (str == null || (strLen = str.length()) == 0) { | ||
112 | + return true; | ||
113 | + } | ||
114 | + for (int i = 0; i < strLen; i++) { | ||
115 | + if ((!Character.isWhitespace(str.charAt(i)))) { | ||
116 | + return false; | ||
117 | + } | ||
118 | + } | ||
119 | + return true; | ||
111 | } | 120 | } |
112 | 121 | ||
113 | // --------------------------- CONSTRUCTORS --------------------------- | 122 | // --------------------------- CONSTRUCTORS --------------------------- |
@@ -153,16 +162,16 @@ public class YoutrackAPI { | @@ -153,16 +162,16 @@ public class YoutrackAPI { | ||
153 | final HttpPost request = new HttpPost(serviceLocation + "/rest/issue/" + issueId + "/execute"); | 162 | final HttpPost request = new HttpPost(serviceLocation + "/rest/issue/" + issueId + "/execute"); |
154 | final List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>(); | 163 | final List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>(); |
155 | parameters.add(new BasicNameValuePair("command", command)); | 164 | parameters.add(new BasicNameValuePair("command", command)); |
156 | - if (isBlank(comment)) { | 165 | + if (!isBlank(comment)) { |
157 | parameters.add(new BasicNameValuePair("comment", comment)); | 166 | parameters.add(new BasicNameValuePair("comment", comment)); |
158 | } | 167 | } |
159 | - if (isBlank(group)) { | 168 | + if (!isBlank(group)) { |
160 | parameters.add(new BasicNameValuePair("group", group)); | 169 | parameters.add(new BasicNameValuePair("group", group)); |
161 | } | 170 | } |
162 | if (disableNotifications != null) { | 171 | if (disableNotifications != null) { |
163 | parameters.add(new BasicNameValuePair("disableNotifications", disableNotifications.toString())); | 172 | parameters.add(new BasicNameValuePair("disableNotifications", disableNotifications.toString())); |
164 | } | 173 | } |
165 | - if (isBlank(runAs)) { | 174 | + if (!isBlank(runAs)) { |
166 | parameters.add(new BasicNameValuePair("runAs", runAs)); | 175 | parameters.add(new BasicNameValuePair("runAs", runAs)); |
167 | } | 176 | } |
168 | request.setEntity(new UrlEncodedFormEntity(parameters)); | 177 | request.setEntity(new UrlEncodedFormEntity(parameters)); |
@@ -297,42 +306,6 @@ public class YoutrackAPI { | @@ -297,42 +306,6 @@ public class YoutrackAPI { | ||
297 | return wrappedIssues; | 306 | return wrappedIssues; |
298 | } | 307 | } |
299 | 308 | ||
300 | - public void setTotalBilledHours(String issueSignature, Long billedHours) | ||
301 | - { | ||
302 | - //QA-SUGGESTION this method should not be in this project, remove it from this class | ||
303 | - final URI uri; | ||
304 | - try { | ||
305 | - uri = new URIBuilder(serviceLocation + "/rest/issue/" + issueSignature + "/execute").build(); | ||
306 | - } catch (URISyntaxException e) { | ||
307 | - throw new RuntimeException(e); | ||
308 | - } | ||
309 | - try { | ||
310 | - final HttpPost request = new HttpPost(uri); | ||
311 | - request.getParams().setParameter("command", "Billed hours " + billedHours); | ||
312 | - execute(request); | ||
313 | - } catch (IOException e) { | ||
314 | - throw new RuntimeException(e); | ||
315 | - } | ||
316 | - } | ||
317 | - | ||
318 | - public void setTotalIssueDuration(String issueSignature, Long issueTotalDuration) | ||
319 | - { | ||
320 | - //QA-SUGGESTION this method should not be in this project, remove it from this class | ||
321 | - final URI uri; | ||
322 | - try { | ||
323 | - uri = new URIBuilder(serviceLocation + "/rest/issue/" + issueSignature + "/execute").build(); | ||
324 | - } catch (URISyntaxException e) { | ||
325 | - throw new RuntimeException(e); | ||
326 | - } | ||
327 | - try { | ||
328 | - final HttpPost request = new HttpPost(uri); | ||
329 | - request.getParams().setParameter("command", "Real completion time " + issueTotalDuration).setParameter("disableNotifications", true); | ||
330 | - execute(request); | ||
331 | - } catch (IOException e) { | ||
332 | - throw new RuntimeException(e); | ||
333 | - } | ||
334 | - } | ||
335 | - | ||
336 | private HttpPut createPutRequest(URI uri, BasicNameValuePair... nameValuePair) throws UnsupportedEncodingException | 309 | private HttpPut createPutRequest(URI uri, BasicNameValuePair... nameValuePair) throws UnsupportedEncodingException |
337 | { | 310 | { |
338 | final HttpPut request = new HttpPut(uri); | 311 | final HttpPut request = new HttpPut(uri); |
Please
register
or
login
to post a comment