Swizzle
  1. Swizzle
  2. SWIZZLE-15

I have problems when creating issue from java

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: swizzle-jira
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I have problems when creating issue from java...
      could help or give an example me that can serve to me?
      that libraries would have to include?
      where with himself?
      thanks.

      in the following example createissue does not work to me, but it does login and it leaves the following error:

      java.lang.ClassCastException
      at org.codehaus.swizzle.jira.Jira.createIssue(Jira.java:151)
      at XML.JiraExample.main(JiraExample.java:71)
      Exception in thread "main"

      EXAMPLE:
      import org.codehaus.swizzle.jira.Issue;
      import org.codehaus.swizzle.jira.Jira;
      import org.codehaus.swizzle.jira.Project;

      import java.util.List;
      import java.util.Vector;
      import java.util.Date;

      public class JiraExample {

      public static final String JIRA_URI = ClientConstants.JIRA_URI;
      public static final String RPC_PATH = ClientConstants.RPC_PATH;
      public static final String USER_NAME = ClientConstants.LOGIN_NAME;
      public static final String PASSWORD = ClientConstants.LOGIN_PASSWORD;

      public static void main(String[] args) throws Exception {
      Jira jira = new Jira(JIRA_URI + RPC_PATH);
      jira.login(USER_NAME, PASSWORD);

      // What projects are available?
      List projects = jira.getProjects();
      for (int i = 0; i < projects.size(); i++)

      { Project project = (Project) projects.get(i); String id = Integer.toString(project.getId()); String key = project.getKey(); String name = project.getName(); String lead = project.getLead(); String projectUrl = project.getProjectUrl(); System.out.println(pad(id, 10) + pad(key, 10) + " " + pad(name, 20) + " " + pad(lead, 30) + " " + pad(projectUrl, 30)); }

      System.out.println("--------------------------------------------------------------------------------------");
      // Any issues with EJBs?
      List issues = jira.getIssuesFromTextSearch(ClientConstants.SEARCH_TERM);
      for (int i = 0; i < issues.size(); i++)

      { Issue issue = (Issue) issues.get(i); String assignee = issue.getAssignee().toString(); String description = issue.getDescription(); String key = issue.getKey(); System.out.println(pad(key, 15) + " " + pad(description, 40) + " " + pad(assignee, 30)); }

      System.out.println("--------------------------------------------------------------------------------------");
      // Create an issue for GBUILD
      Issue issue = new Issue();

      issue.setAssignee(jira.getUser(USER_NAME));
      issue.setProject(jira.getProject("GOM"));
      issue.setDescription("Esta es una prueba de crear un Issue desde java XML - Description");
      //issue.setReporter(jira.getUser(USER_NAME));
      issue.setSummary("Esta es una prueba de crear un Issue desde java XML - Summary");
      issue.setType(jira.getIssueType(1));
      issue.setStatus(jira.getStatus(10040));
      issue.setPriority(jira.getPriority(3));
      issue.setCreated(new Date());

      /*List components = jira.getComponents("Interfaces");
      issue.setComponents(components);*/
      // issue.setFixVersions(jira.getVersions("GOM_02.03.00.12"));

      Vector VectorAffectsVersions = new Vector(1);
      VectorAffectsVersions.add("GOM_02.03.00.12");
      issue.setAffectsVersions(VectorAffectsVersions);

      Issue addedIssue = jira.createIssue(issue);
      //Issue addedIssue = jira.updateIssue("GOM-1122",issue);

      String key = addedIssue.getKey();
      String description = addedIssue.getDescription();
      String assignee = addedIssue.getAssignee().toString();

      System.out.println(pad(key, 15) + " " + pad(description, 40) + " " + pad(assignee, 30));
      }

      public static String pad(String str, int width) {
      str = (str == null) ? "" : str;
      for (int i = str.length(); i < width; i++)

      { str += " "; }

      return str.substring(0, width);
      }
      }

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            David Blevins
            Reporter:
            Andrés Felipe Artuz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: