private Promise closeIssue()

in src/main/java/org/apache/sling/cli/impl/jira/VersionClient.java [453:472]


    private Promise<Issue> closeIssue(Issue issue, Transition closeTransition) {
        HttpPost post = newPost("issue/" + issue.getId() + "/transitions");
        StringWriter w = new StringWriter();
        try (JsonWriter jw = new Gson().newJsonWriter(w)) {
            jw.beginObject().name("transition").beginObject().name("id").value(closeTransition.getId()).endObject().endObject();
            post.setEntity(new StringEntity(w.toString()));
            try (CloseableHttpClient client = httpClientFactory.newClient()) {
                try (CloseableHttpResponse postResponse = client.execute(post, httpClientFactory.newPreemptiveAuthenticationContext())) {
                    if (postResponse.getStatusLine().getStatusCode() == 204) {
                        return promiseFactory.resolved(issue);
                    } else {
                        return promiseFactory.failed(new RuntimeException(String.format("Unable to close issue %s/browse/%s - got status code %d.",
                         jiraURL, issue.getKey(), postResponse.getStatusLine().getStatusCode())));
                    }
                }
            }
        } catch (IOException e) {
            return promiseFactory.failed(e);
        }
    }