From c8802583aa9c36942fcca8cea6106c9f5b4dfcf4 Mon Sep 17 00:00:00 2001 From: Bob Carroll Date: Mon, 30 May 2016 13:11:12 -0700 Subject: [PATCH] fixed tabbing --- src/main/java/net/rcarz/jiraclient/Issue.java | 388 +++++++++--------- .../java/net/rcarz/jiraclient/JiraClient.java | 20 +- 2 files changed, 204 insertions(+), 204 deletions(-) diff --git a/src/main/java/net/rcarz/jiraclient/Issue.java b/src/main/java/net/rcarz/jiraclient/Issue.java index 371649d..38dcd81 100644 --- a/src/main/java/net/rcarz/jiraclient/Issue.java +++ b/src/main/java/net/rcarz/jiraclient/Issue.java @@ -528,131 +528,131 @@ public class Issue extends Resource { } - /** + /** * Iterates over all issues in the query by getting the next page of * issues when the iterator reaches the last of the current page. */ private static class IssueIterator implements Iterator { - private Iterator currentPage; - private RestClient restclient; - private Issue nextIssue; + private Iterator currentPage; + private RestClient restclient; + private Issue nextIssue; private Integer maxResults = -1; - private String jql; - private String includedFields; - private String expandFields; - private Integer startAt; - private List issues; - private int total; - + private String jql; + private String includedFields; + private String expandFields; + private Integer startAt; + private List issues; + private int total; + public IssueIterator(RestClient restclient, String jql, String includedFields, String expandFields, Integer maxResults, Integer startAt) throws JiraException { - this.restclient = restclient; - this.jql = jql; - this.includedFields = includedFields; - this.expandFields = expandFields; - this.maxResults = maxResults; - this.startAt = startAt; + this.restclient = restclient; + this.jql = jql; + this.includedFields = includedFields; + this.expandFields = expandFields; + this.maxResults = maxResults; + this.startAt = startAt; + } + + @Override + public boolean hasNext() { + if (nextIssue != null) { + return true; + } + try { + nextIssue = getNextIssue(); + } catch (JiraException e) { + throw new RuntimeException(e); + } + return nextIssue != null; } - - @Override - public boolean hasNext() { - if (nextIssue != null) { - return true; - } - try { - nextIssue = getNextIssue(); - } catch (JiraException e) { - throw new RuntimeException(e); - } - return nextIssue != null; - } - @Override - public Issue next() { - if (! hasNext()) { - throw new NoSuchElementException(); - } - Issue result = nextIssue; - nextIssue = null; - return result; - } + @Override + public Issue next() { + if (! hasNext()) { + throw new NoSuchElementException(); + } + Issue result = nextIssue; + nextIssue = null; + return result; + } - @Override - public void remove() { - throw new UnsupportedOperationException("Method remove() not support for class " + this.getClass().getName()); - } + @Override + public void remove() { + throw new UnsupportedOperationException("Method remove() not support for class " + this.getClass().getName()); + } - /** - * Gets the next issue, returning null if none more available - * Will ask the next set of issues from the server if the end of the current list of issues is reached. - * - * @return the next issue, null if none more available - * @throws JiraException - */ - private Issue getNextIssue() throws JiraException { - // first call - if (currentPage == null) { - currentPage = getNextIssues().iterator(); - if (currentPage == null || !currentPage.hasNext()) { - return null; - } else { - return currentPage.next(); - } - } - - // check if we need to get the next set of issues - if (! currentPage.hasNext()) { - currentPage = getNextIssues().iterator(); - } + /** + * Gets the next issue, returning null if none more available + * Will ask the next set of issues from the server if the end of the current list of issues is reached. + * + * @return the next issue, null if none more available + * @throws JiraException + */ + private Issue getNextIssue() throws JiraException { + // first call + if (currentPage == null) { + currentPage = getNextIssues().iterator(); + if (currentPage == null || !currentPage.hasNext()) { + return null; + } else { + return currentPage.next(); + } + } + + // check if we need to get the next set of issues + if (! currentPage.hasNext()) { + currentPage = getNextIssues().iterator(); + } - // return the next item if available - if (currentPage.hasNext()) { - return currentPage.next(); - } else { - return null; - } - } + // return the next item if available + if (currentPage.hasNext()) { + return currentPage.next(); + } else { + return null; + } + } - /** - * Execute the query to get the next set of issues. - * Also sets the startAt, maxMresults, total and issues fields, - * so that the SearchResult can access them. - * - * @return the next set of issues. - * @throws JiraException - */ - private List getNextIssues() throws JiraException { - if (issues == null) { - startAt = Integer.valueOf(0); - } else { - startAt = startAt + issues.size(); - } + /** + * Execute the query to get the next set of issues. + * Also sets the startAt, maxMresults, total and issues fields, + * so that the SearchResult can access them. + * + * @return the next set of issues. + * @throws JiraException + */ + private List getNextIssues() throws JiraException { + if (issues == null) { + startAt = Integer.valueOf(0); + } else { + startAt = startAt + issues.size(); + } - JSON result = null; + JSON result = null; - try { - URI searchUri = createSearchURI(restclient, jql, includedFields, - expandFields, maxResults, startAt); - result = restclient.get(searchUri); - } catch (Exception ex) { - throw new JiraException("Failed to search issues", ex); - } + try { + URI searchUri = createSearchURI(restclient, jql, includedFields, + expandFields, maxResults, startAt); + result = restclient.get(searchUri); + } catch (Exception ex) { + throw new JiraException("Failed to search issues", ex); + } - if (!(result instanceof JSONObject)) { - throw new JiraException("JSON payload is malformed"); - } + if (!(result instanceof JSONObject)) { + throw new JiraException("JSON payload is malformed"); + } - - Map map = (Map) result; - - this.startAt = Field.getInteger(map.get("startAt")); - this.maxResults = Field.getInteger(map.get("maxResults")); - this.total = Field.getInteger(map.get("total")); - this.issues = Field.getResourceArray(Issue.class, map.get("issues"), restclient); - return issues; - } + + Map map = (Map) result; + + this.startAt = Field.getInteger(map.get("startAt")); + this.maxResults = Field.getInteger(map.get("maxResults")); + this.total = Field.getInteger(map.get("total")); + this.issues = Field.getResourceArray(Issue.class, map.get("issues"), restclient); + return issues; + } } @@ -675,38 +675,38 @@ public class Issue extends Resource { public int max = 0; public int total = 0; public List issues = null; - private RestClient restclient; - private String jql; - private String includedFields; - private String expandFields; - private Integer startAt; - private IssueIterator issueIterator; + private RestClient restclient; + private String jql; + private String includedFields; + private String expandFields; + private Integer startAt; + private IssueIterator issueIterator; - public SearchResult(RestClient restclient, String jql, - String includedFields, String expandFields, Integer maxResults, Integer startAt) throws JiraException { - this.restclient = restclient; - this.jql = jql; - this.includedFields = includedFields; - this.expandFields = expandFields; - initSearchResult(maxResults, start); + public SearchResult(RestClient restclient, String jql, + String includedFields, String expandFields, Integer maxResults, Integer startAt) throws JiraException { + this.restclient = restclient; + this.jql = jql; + this.includedFields = includedFields; + this.expandFields = expandFields; + initSearchResult(maxResults, start); } private void initSearchResult(Integer maxResults, Integer start) throws JiraException { - this.issueIterator = new IssueIterator(restclient, jql, includedFields, expandFields, maxResults, startAt); - this.issueIterator.hasNext(); - this.max = issueIterator.maxResults; - this.start = issueIterator.startAt; - this.issues = issueIterator.issues; - this.total = issueIterator.total; - } + this.issueIterator = new IssueIterator(restclient, jql, includedFields, expandFields, maxResults, startAt); + this.issueIterator.hasNext(); + this.max = issueIterator.maxResults; + this.start = issueIterator.startAt; + this.issues = issueIterator.issues; + this.total = issueIterator.total; + } - /** + /** * All issues found. * * @return All issues found. */ public Iterator iterator() { - return issueIterator; + return issueIterator; } } @@ -860,10 +860,10 @@ public class Issue extends Resource { JSON result = null; try { - Map params = new HashMap(); - params.put("expand", "projects.issuetypes.fields"); - params.put("projectKeys", pval); - params.put("issuetypeNames", itval); + Map params = new HashMap(); + params.put("expand", "projects.issuetypes.fields"); + params.put("projectKeys", pval); + params.put("issuetypeNames", itval); URI createuri = restclient.buildURI( getBaseUri() + "issue/createmeta", params); @@ -918,8 +918,8 @@ public class Issue extends Resource { JSON result = null; try { - Map params = new HashMap(); - params.put("expand", "transitions.fields"); + Map params = new HashMap(); + params.put("expand", "transitions.fields"); URI transuri = restclient.buildURI( getRestUri(key) + "/transitions",params); result = restclient.get(transuri); @@ -1009,24 +1009,24 @@ public class Issue extends Resource { } /** - * Removes an attachments. - * - * @param attachmentId attachment id to remove - * - * @throws JiraException when the attachment removal fails - */ - public void removeAttachment(String attachmentId) throws JiraException { - - if (attachmentId == null) { - throw new NullPointerException("attachmentId may not be null"); - } - - try { - restclient.delete(getBaseUri() + "attachment/" + attachmentId); - } catch (Exception ex) { - throw new JiraException("Failed remove attachment " + attachmentId, ex); - } - } + * Removes an attachments. + * + * @param attachmentId attachment id to remove + * + * @throws JiraException when the attachment removal fails + */ + public void removeAttachment(String attachmentId) throws JiraException { + + if (attachmentId == null) { + throw new NullPointerException("attachmentId may not be null"); + } + + try { + restclient.delete(getBaseUri() + "attachment/" + attachmentId); + } catch (Exception ex) { + throw new JiraException("Failed remove attachment " + attachmentId, ex); + } + } /** * Adds a comment to this issue. @@ -1271,9 +1271,9 @@ public class Issue extends Resource { Map queryParams = new HashMap(); queryParams.put("fields", includedFields); - if (expand != null) { - queryParams.put("expand", expand); - } + if (expand != null) { + queryParams.put("expand", expand); + } return new Issue(restclient, realGet(restclient, key, queryParams)); } @@ -1357,19 +1357,19 @@ public class Issue extends Resource { String includedFields, String expandFields, Integer maxResults, Integer startAt) throws JiraException { - SearchResult sr = new SearchResult(restclient, jql, includedFields, expandFields, maxResults, startAt); + SearchResult sr = new SearchResult(restclient, jql, includedFields, expandFields, maxResults, startAt); return sr; } - private static JSON executeSearch(RestClient restclient, String jql, - String includedFields, String expandFields, Integer maxResults, - Integer startAt) throws JiraException { + private static JSON executeSearch(RestClient restclient, String jql, + String includedFields, String expandFields, Integer maxResults, + Integer startAt) throws JiraException { JSON result = null; try { URI searchUri = createSearchURI(restclient, jql, includedFields, - expandFields, maxResults, startAt); + expandFields, maxResults, startAt); result = restclient.get(searchUri); } catch (Exception ex) { throw new JiraException("Failed to search issues", ex); @@ -1378,42 +1378,42 @@ public class Issue extends Resource { if (!(result instanceof JSONObject)) { throw new JiraException("JSON payload is malformed"); } - return result; - } + return result; + } - /** - * Creates the URI to execute a jql search. - * - * @param restclient - * @param jql - * @param includedFields - * @param expandFields - * @param maxResults - * @param startAt - * @return the URI to execute a jql search. - * @throws URISyntaxException - */ - private static URI createSearchURI(RestClient restclient, String jql, - String includedFields, String expandFields, Integer maxResults, - Integer startAt) throws URISyntaxException { - Map queryParams = new HashMap(); - queryParams.put("jql", jql); - if(maxResults != null){ - queryParams.put("maxResults", String.valueOf(maxResults)); - } - if (includedFields != null) { - queryParams.put("fields", includedFields); - } - if (expandFields != null) { - queryParams.put("expand", expandFields); - } - if (startAt != null) { - queryParams.put("startAt", String.valueOf(startAt)); - } + /** + * Creates the URI to execute a jql search. + * + * @param restclient + * @param jql + * @param includedFields + * @param expandFields + * @param maxResults + * @param startAt + * @return the URI to execute a jql search. + * @throws URISyntaxException + */ + private static URI createSearchURI(RestClient restclient, String jql, + String includedFields, String expandFields, Integer maxResults, + Integer startAt) throws URISyntaxException { + Map queryParams = new HashMap(); + queryParams.put("jql", jql); + if(maxResults != null){ + queryParams.put("maxResults", String.valueOf(maxResults)); + } + if (includedFields != null) { + queryParams.put("fields", includedFields); + } + if (expandFields != null) { + queryParams.put("expand", expandFields); + } + if (startAt != null) { + queryParams.put("startAt", String.valueOf(startAt)); + } - URI searchUri = restclient.buildURI(getBaseUri() + "search", queryParams); - return searchUri; - } + URI searchUri = restclient.buildURI(getBaseUri() + "search", queryParams); + return searchUri; + } /** * Reloads issue data from the JIRA server (issue includes all navigable diff --git a/src/main/java/net/rcarz/jiraclient/JiraClient.java b/src/main/java/net/rcarz/jiraclient/JiraClient.java index 067e4aa..9c81d49 100644 --- a/src/main/java/net/rcarz/jiraclient/JiraClient.java +++ b/src/main/java/net/rcarz/jiraclient/JiraClient.java @@ -61,7 +61,7 @@ public class JiraClient { * @throws JiraException */ public JiraClient(String uri, ICredentials creds) throws JiraException { - this(null, uri, creds); + this(null, uri, creds); } /** @@ -73,19 +73,19 @@ public class JiraClient { * @throws JiraException */ public JiraClient(HttpClient httpClient, String uri, ICredentials creds) throws JiraException { - if (httpClient == null) { - PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(); - connManager.setDefaultMaxPerRoute(20); - connManager.setMaxTotal(40); - httpClient = new DefaultHttpClient(connManager); - } + if (httpClient == null) { + PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(); + connManager.setDefaultMaxPerRoute(20); + connManager.setMaxTotal(40); + httpClient = new DefaultHttpClient(connManager); + } restclient = new RestClient(httpClient, creds, URI.create(uri)); if (creds != null) { username = creds.getLogonName(); - //intialize connection if required - creds.initialize(restclient); + //intialize connection if required + creds.initialize(restclient); } } @@ -368,7 +368,7 @@ public class JiraClient { startAt); } - /** + /** * Retrieve the jira filter with the supplied id. * @param id id of the filter to retreive. * @return The Jira filter with the supplied id