in src/main/java/org/apache/sling/cli/impl/jira/VersionClient.java [424:451]
private Promise<Transition> getCloseTransition(Issue issue) {
HttpGet get = newGet("issue/" + issue.getId() + "/transitions");
try {
try (CloseableHttpClient client = httpClientFactory.newClient()) {
try (CloseableHttpResponse getResponse = client.execute(get, httpClientFactory.newPreemptiveAuthenticationContext())) {
try (InputStream getContent = getResponse.getEntity().getContent();
InputStreamReader getReader = new InputStreamReader(getContent)) {
if (getResponse.getStatusLine().getStatusCode() != 200) {
throw newException(getResponse, getReader);
}
Gson gson = new Gson();
List<Transition> transitions = gson.fromJson(getReader, TransitionsResponse.class).getTransitions();
Optional<Transition> transition = transitions.stream().filter(t -> "Close Issue".equals(t.getName())).findFirst();
if (transition.isPresent()) {
return promiseFactory.resolved(transition.get());
} else {
return promiseFactory
.failed(new IllegalStateException(String.format("Issue %s/browse/%s cannot be closed - missing Close " +
"transition.", jiraURL,
issue.getKey())));
}
}
}
}
} catch (Exception e) {
return promiseFactory.failed(e);
}
}