Skip to content

Commit

Permalink
Added basic exception handling for the additional JQL string argument…
Browse files Browse the repository at this point in the history
… that will ignore the supplied JQL if it is either incorrect or yields no results when combined with the project and fix version. This warning is also logged.
  • Loading branch information
developer1 authored and developer1 committed Jul 9, 2013
1 parent 794a158 commit 66aa195
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions src/net/foxopen/jira/changelog/JiraAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,48 @@ public void fetchVersionDetails(String projectKey, String versionLabel)
if (vi == null) {
LinkedList<String> issueList = new LinkedList<String>();
Logger.log("Obtaining issues related to '" + v.getName() + "' via JIRA API.");
SearchResult sr = restClient.getSearchClient().searchJql("project = '" + projectKey + "' and fixVersion = '" + v.getName() + "'" + jql_, pm);
SearchResult sr = null;
try {
sr = restClient.getSearchClient().searchJql("project = '" + projectKey + "' and fixVersion = '" + v.getName() + "'" + jql_, pm);

for (BasicIssue bi : sr.getIssues()) {
Logger.log("Obtaining further issue details for issue '" + bi.getKey() + "' via JIRA API.");
Issue i = restClient.getIssueClient().getIssue(bi.getKey(), pm);
for (BasicIssue bi : sr.getIssues()) {
Logger.log("Obtaining further issue details for issue '" + bi.getKey() + "' via JIRA API.");
Issue i = restClient.getIssueClient().getIssue(bi.getKey(), pm);

// Add this issue
String changelogDescription;
try {
changelogDescription = i.getFieldByName("Changelog Description").getValue().toString();
} catch (NullPointerException npe) {
// Changelog Description doesn't exist as a field for this issue so just default to the summary.
changelogDescription = i.getSummary();
// Add this issue
String changelogDescription;
try {
changelogDescription = i.getFieldByName("Changelog Description").getValue().toString();
} catch (NullPointerException npe) {
// Changelog Description doesn't exist as a field for this issue so just default to the summary.
changelogDescription = i.getSummary();
}
issueList.add("[" + i.getKey() + "] " + changelogDescription);
}
issueList.add("[" + i.getKey() + "] " + changelogDescription);
}

vi = new VersionInfo(v.getName(), v.getDescription(), versionReleaseDate.toDate(), issueList);
if (cache_ != null) {
cache_.cache(vi);
} catch (RestClientException jqlErr) {
Logger.log("The additional JQL string supplied was either invalid or returned no results. Ignoring additional JQL.");
sr = restClient.getSearchClient().searchJql("project = '" + projectKey + "' and fixVersion = '" + v.getName() + "'" + jql_, pm);
for (BasicIssue bi : sr.getIssues()) {
Logger.log("Obtaining further issue details for issue '" + bi.getKey() + "' via JIRA API.");
Issue i = restClient.getIssueClient().getIssue(bi.getKey(), pm);

// Add this issue
String changelogDescription;
try {
changelogDescription = i.getFieldByName("Changelog Description").getValue().toString();
} catch (NullPointerException npe) {
// Changelog Description doesn't exist as a field for this issue so just default to the summary.
changelogDescription = i.getSummary();
}
issueList.add("[" + i.getKey() + "] " + changelogDescription);
}
} finally {
vi = new VersionInfo(v.getName(), v.getDescription(), versionReleaseDate.toDate(), issueList);
if (cache_ != null) {
cache_.cache(vi);
}
versionList_.add(vi);
}
versionList_.add(vi);
} else {
versionList_.add(vi);
}
Expand Down

0 comments on commit 66aa195

Please sign in to comment.