public List findIssues()

in src/main/java/org/apache/sling/tooling/lc/jira/IssueFinder.java [45:82]


    public List<Issue> findIssues(List<String> issueKeys) throws IOException{
        
        if ( issueKeys.isEmpty() ) {
            return Collections.emptyList();
        }
        
        HttpClient client = new DefaultHttpClient();
        
        HttpGet get;
        try {
            URIBuilder builder = new URIBuilder("https://issues.apache.org/jira/rest/api/2/search")
                    .addParameter("jql", "key in (" + String.join(",", issueKeys) + ")")
                    .addParameter("fields", "key,summary");
            
            get = new HttpGet(builder.build());
        } catch (URISyntaxException e) {
            // never happens
            throw new RuntimeException(e);
        }
        
        HttpResponse response = client.execute(get);
        try {
            if ( response.getStatusLine().getStatusCode() != 200 ) { 
                throw new IOException("Search call returned status " + response.getStatusLine().getStatusCode());
            }
            
            try ( Reader reader = new InputStreamReader(response.getEntity().getContent(), "UTF-8") ) {
                Response apiResponse = new Gson().fromJson(reader, Response.class);
                List<Issue> issues = apiResponse.getIssues();
                Collections.sort(issues);
                return issues;
                
            }
        } finally {
            HttpClientUtils.closeQuietly(client);
        }
        
    }