Exemple #1
0
 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;
   }
 }
Exemple #2
0
 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;
   }
 }
Exemple #3
0
 @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();
 }
Exemple #4
0
  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;
  }
Exemple #5
0
 private IssueType createIssueType(String issuetypeName) {
   IssueType newIssueType = new IssueType();
   newIssueType.setName(issuetypeName);
   newIssueType = restAccess.post("/issuetype", newIssueType, IssueType.class);
   return newIssueType;
 }
Exemple #6
0
 private Optional<Project> getProject() {
   return Optional.ofNullable(
       restAccess.get("/project/" + settings.getJiraProjectKey(), Project.class));
 }