Search in sources :

Example 1 with BasicProject

use of com.atlassian.jira.rest.client.api.domain.BasicProject in project opennms by OpenNMS.

the class ListProjectsCommand method doExecute.

@Override
protected void doExecute(JiraRestClient jiraRestClient) throws Exception {
    Iterable<BasicProject> basicProjects = jiraRestClient.getProjectClient().getAllProjects().get();
    if (!basicProjects.iterator().hasNext()) {
        System.out.println("No projects available or visible to the current user");
    } else {
        System.out.println(String.format(DEFAULT_ROW_FORMAT, "Key", "Name", "Description"));
        for (BasicProject eachProject : basicProjects) {
            String description = jiraRestClient.getProjectClient().getProject(eachProject.getKey()).get().getDescription();
            System.out.println(String.format(DEFAULT_ROW_FORMAT, eachProject.getKey(), eachProject.getName(), description == null ? "" : removeNewLines(description)));
        }
    }
}
Also used : BasicProject(com.atlassian.jira.rest.client.api.domain.BasicProject)

Example 2 with BasicProject

use of com.atlassian.jira.rest.client.api.domain.BasicProject in project jira-plugin by jenkinsci.

the class JiraRestService method getProjectsKeys.

public List<String> getProjectsKeys() {
    Iterable<BasicProject> projects = Collections.emptyList();
    try {
        projects = jiraRestClient.getProjectClient().getAllProjects().get(timeout, TimeUnit.SECONDS);
    } catch (Exception e) {
        LOGGER.log(WARNING, "Jira REST client get project keys error. cause: " + e.getMessage(), e);
    }
    final List<String> keys = new ArrayList<>();
    for (BasicProject project : projects) {
        keys.add(project.getKey());
    }
    return keys;
}
Also used : ArrayList(java.util.ArrayList) BasicProject(com.atlassian.jira.rest.client.api.domain.BasicProject) TimeoutException(java.util.concurrent.TimeoutException) RestClientException(com.atlassian.jira.rest.client.api.RestClientException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

BasicProject (com.atlassian.jira.rest.client.api.domain.BasicProject)2 RestClientException (com.atlassian.jira.rest.client.api.RestClientException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 TimeoutException (java.util.concurrent.TimeoutException)1