Issue createIssueInJira(Issue issue) { ClientResponse postResponse = restAccess.post("/issue", issue); if (postResponse.getStatus() == Status.CREATED.getStatusCode()) { return postResponse.getEntity(Issue.class); } else { System.err.println("Problems while creating issue: " + postResponse.getEntity(String.class)); return null; } }
private boolean updateIssueInJira(Issue issue) { ClientResponse postResponse = restAccess.put("/issue/" + issue.getKey(), issue); if (postResponse.getStatus() >= Status.OK.getStatusCode() && postResponse.getStatus() <= Status.PARTIAL_CONTENT.getStatusCode()) { return true; } else { System.err.println("Problems while updating issue: " + postResponse.getEntity(String.class)); return false; } }
@Override public void initialize(Settings settings, StorageEngine store) throws Exception { this.settings = settings; this.store = store; restAccess = new JiraRestAccess( settings.getJiraUrl(), settings.getJiraUser(), settings.getJiraPassword()); ClientResponse response = restAccess.get("/myself"); if (response.getStatus() != Status.OK.getStatusCode()) { throw new RuntimeException("Unable to connect to jira repository: " + response.toString()); } this.projectOptional = getProject(); }
private IssueType getIssueType(String issuetypeName, Project project) { String projectKey = project.getKey(); if (existingIssueTypes == null) { IssueMetadata issueMetadata = restAccess.get( "/issue/createmeta/?expand=projects.issuetypes.fields.", IssueMetadata.class); existingIssueTypes = new HashMap<>(); existingIssueTypes.put( projectKey, issueMetadata.getProject(projectKey).get().getIssuetypes()); } List<IssueType> issuesTypesByProject = existingIssueTypes.get(projectKey); IssueType issueType = getIssueTypeByName(issuetypeName, issuesTypesByProject) .orElse(createIssueType(issuetypeName)); if (!issuesTypesByProject.contains(issueType)) { issuesTypesByProject.add(issueType); } return issueType; }
private IssueType createIssueType(String issuetypeName) { IssueType newIssueType = new IssueType(); newIssueType.setName(issuetypeName); newIssueType = restAccess.post("/issuetype", newIssueType, IssueType.class); return newIssueType; }
private Optional<Project> getProject() { return Optional.ofNullable( restAccess.get("/project/" + settings.getJiraProjectKey(), Project.class)); }