diff --git a/libraries/pom.xml b/libraries/pom.xml index 27fff02eb4..01a3e7bd73 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -569,12 +569,22 @@ javax.cache cache-api ${cache.version} - - - com.hazelcast - hazelcast - ${hazelcast.version} - + + + com.hazelcast + hazelcast + ${hazelcast.version} + + + com.atlassian.jira + jira-rest-java-client-core + 4.0.0 + + + com.atlassian.fugue + fugue + 3.0.0-m007 + @@ -590,6 +600,10 @@ bintray http://dl.bintray.com/cuba-platform/main + + atlassian-public + https://packages.atlassian.com/maven/repository/public + 0.7.0 diff --git a/libraries/src/main/java/com/baeldung/jira/JiraClient.java b/libraries/src/main/java/com/baeldung/jira/JiraClient.java new file mode 100644 index 0000000000..26df21c8a9 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/jira/JiraClient.java @@ -0,0 +1,57 @@ +package com.baeldung.jira; + +import com.atlassian.jira.rest.client.api.JiraRestClient; +import com.atlassian.jira.rest.client.api.JiraRestClientFactory; +import com.atlassian.jira.rest.client.api.domain.Issue; +import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +public class JiraClient { + + private static final String USERNAME = "jira.user"; + private static final String PASSWORD = "secret"; + private static final String JIRA_URL = "http://jira.company.com"; + + public static void main(String[] args) { + + final Issue issue = new JiraClient().getIssue("MYKEY-1234"); + System.out.println(issue.getDescription()); + } + + private Issue getIssue(String issueKey) { + JiraRestClient restClient = getJiraRestClient(); + Issue issue = restClient.getIssueClient().getIssue(issueKey).claim(); + + closeRestClient(restClient); + return issue; + } + + private JiraRestClient getJiraRestClient() { + JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory(); + + URI jiraServerUri = getJiraUri(); + return factory + .createWithBasicHttpAuthentication(jiraServerUri, USERNAME, PASSWORD); + } + + private URI getJiraUri() { + URI jiraServerUri = null; + try { + jiraServerUri = new URI(JIRA_URL); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + return jiraServerUri; + } + + private void closeRestClient(JiraRestClient restClient) { + try { + restClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +}