Index: pom.xml =================================================================== diff -u -r661c8050726d083ccdec392664cab06520fa7510 -r5fb5e212ad72e8ff4a11804b60b1831ac8410442 --- pom.xml (.../pom.xml) (revision 661c8050726d083ccdec392664cab06520fa7510) +++ pom.xml (.../pom.xml) (revision 5fb5e212ad72e8ff4a11804b60b1831ac8410442) @@ -10,7 +10,7 @@ 4.0.0 313devgrp java-service-tree-framework-backend-server - 22.11.27 + 22.11.30 pom java-service-tree-framework @@ -151,6 +151,19 @@ https://repo.maven.apache.org/maven2 + + atlassian-public + https://packages.atlassian.com/mvn/maven-external/ + + true + never + warn + + + true + warn + + Index: web-module/pom.xml =================================================================== diff -u -r661c8050726d083ccdec392664cab06520fa7510 -r5fb5e212ad72e8ff4a11804b60b1831ac8410442 --- web-module/pom.xml (.../pom.xml) (revision 661c8050726d083ccdec392664cab06520fa7510) +++ web-module/pom.xml (.../pom.xml) (revision 5fb5e212ad72e8ff4a11804b60b1831ac8410442) @@ -7,7 +7,7 @@ 313devgrp java-service-tree-framework-backend-server - 22.11.27 + 22.11.30 ../pom.xml @@ -94,27 +94,19 @@ com.atlassian.jira jira-rest-java-client-core - 5.1.6 + 2.0.0-m15 - com.atlassian.jira - jira-rest-java-client-api - 5.1.6 + com.mashape.unirest + unirest-java + 1.4.9 - io.atlassian.fugue - fugue - 4.7.2 + org.apache.httpcomponents + httpcore-nio + 4.4.3 - - - io.atlassian.util.concurrent - atlassian-util-concurrent - 4.0.1 - provided - - Index: web-module/src/main/java/egovframework/api/arms/module_pdservicejira/controller/UserPdServiceJiraController.java =================================================================== diff -u -r32b71e2da43218781d51046bf2a9a1cf247deddc -r5fb5e212ad72e8ff4a11804b60b1831ac8410442 --- web-module/src/main/java/egovframework/api/arms/module_pdservicejira/controller/UserPdServiceJiraController.java (.../UserPdServiceJiraController.java) (revision 32b71e2da43218781d51046bf2a9a1cf247deddc) +++ web-module/src/main/java/egovframework/api/arms/module_pdservicejira/controller/UserPdServiceJiraController.java (.../UserPdServiceJiraController.java) (revision 5fb5e212ad72e8ff4a11804b60b1831ac8410442) @@ -11,29 +11,27 @@ */ package egovframework.api.arms.module_pdservicejira.controller; +import com.atlassian.jira.rest.client.api.JiraRestClient; +import com.atlassian.jira.rest.client.api.domain.BasicProject; +import com.atlassian.jira.rest.client.api.domain.Issue; +import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory; +import egovframework.api.arms.module_pdservicejira.model.PdServiceJiraDTO; +import egovframework.api.arms.module_pdservicejira.service.PdServiceJira; +import egovframework.com.ext.jstree.springHibernate.core.controller.SHVAbstractController; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; + import javax.annotation.PostConstruct; -import javax.servlet.http.HttpServletRequest; -import java.util.Comparator; -import java.util.List; -import java.util.NoSuchElementException; +import java.net.URI; -import egovframework.com.ext.jstree.springHibernate.core.controller.SHVAbstractController; - -import egovframework.api.arms.module_pdservicejira.model.PdServiceJiraDTO; -import egovframework.api.arms.module_pdservicejira.service.PdServiceJira; - @Slf4j @Controller @RequestMapping(value = {"/auth-user/api/arms/pdServiceJira"}) @@ -50,4 +48,43 @@ private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @ResponseBody + @RequestMapping(value = "/getProjectList.do", method = RequestMethod.GET) + public ModelAndView getProjectList() throws Exception { + + +// JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory(); +// URI uri = new URI("http://www.313.co.kr/jira"); +// JiraRestClient jiraRestClient = factory.createWithBasicHttpAuthentication(uri, "admin", "flexjava"); +// +// Promise> promise = jiraRestClient.getMetadataClient().getIssueTypes(); +// Iterable issueTypes = promise.claim(); +// for (IssueType it : issueTypes) { +// System.out.println("Type ID = " + it.getId() + ", Name = " + it.getName()); +// } + final AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory(); + final URI jiraServerUri = new URI("http://www.313.co.kr/jira"); + final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "admin", "flexjava"); + final Issue issue = restClient.getIssueClient().getIssue("SP-689").claim(); + logger.debug(issue.toString()); + + Iterable test = restClient.getProjectClient().getAllProjects().claim(); + getTransitionByName(test, "name"); + + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", test); + + return modelAndView; + } + + private BasicProject getTransitionByName(Iterable transitions, String transitionName) { + for (BasicProject transition : transitions) { + logger.debug(transition.toString()); + if (transition.getName().equals(transitionName)) { + return transition; + } + } + return null; + } + } Index: web-module/src/test/java/egovframework/api/arms/module_pdservicejira/ArmsJiraClientTest.java =================================================================== diff -u --- web-module/src/test/java/egovframework/api/arms/module_pdservicejira/ArmsJiraClientTest.java (revision 0) +++ web-module/src/test/java/egovframework/api/arms/module_pdservicejira/ArmsJiraClientTest.java (revision 5fb5e212ad72e8ff4a11804b60b1831ac8410442) @@ -0,0 +1,102 @@ +package egovframework.api.arms.module_pdservicejira; + +import com.atlassian.jira.rest.client.api.JiraRestClient; +import com.atlassian.jira.rest.client.api.domain.Issue; +import com.atlassian.jira.rest.client.api.domain.IssueType; +import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory; +import com.atlassian.util.concurrent.Promise; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.mashape.unirest.http.HttpResponse; +import com.mashape.unirest.http.JsonNode; +import com.mashape.unirest.http.ObjectMapper; +import com.mashape.unirest.http.Unirest; +import com.mashape.unirest.http.exceptions.UnirestException; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +public class ArmsJiraClientTest { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Test + public void jiraTest() throws URISyntaxException, IOException { + final AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory(); + URI jiraServerUri = new URI("http://www.313.co.kr/jira"); + final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "admin", "####"); + try { + + Promise> test = restClient.getMetadataClient().getIssueTypes(); + Iterable type = test.claim(); + for ( IssueType issue : type){ + System.out.println("Issue Name : " + issue.getName() + " , Issue ID : " + issue.getId()); + } + + final Issue issue = restClient.getIssueClient().getIssue("SP-689").claim(); + logger.info("issue=" + issue); + } + finally { + // cleanup the restClient + restClient.close(); + } + } + + @Test + public void create_IssueType() throws UnirestException { + // The payload definition using the Jackson library + + JsonNodeFactory jnf = JsonNodeFactory.instance; + ObjectNode payload = jnf.objectNode(); + { + payload.put("name", "requirement"); + payload.put("description", "arms"); + payload.put("type", "standard"); + payload.put("atl_token", "BU13-CS25-DME9-DDDH|3a94d109d3f161e1c8741267e03261ad3a0e9263|lin"); + } + + // Connect Jackson ObjectMapper to Unirest + + Unirest.setObjectMapper(new ObjectMapper() { + private com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper + = new com.fasterxml.jackson.databind.ObjectMapper(); + + public T readValue(String value, Class valueType) { + try { + return jacksonObjectMapper.readValue(value, valueType); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public String writeValue(Object value) { + try { + logger.info("value =" + value); + logger.info("jacksonObjectMapper.writeValueAsString(value) = " + jacksonObjectMapper.writeValueAsString(value)); + return jacksonObjectMapper.writeValueAsString(value); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + }); + +// This code sample uses the 'Unirest' library: +// http://unirest.io/java.html + HttpResponse response = Unirest + .post("http://www.313.co.kr/jira/rest/api/2/issuetype") + .basicAuth("admin", "####") + .header("Accept", "application/json") + .header("Content-Type", "application/json") + .body(payload) + .asJson(); + + logger.info(response.toString()); + System.out.println(response.getBody()); + } + +}