Example #1
0
 public static void main(String[] args) {
   String uri = "http://76.126.10.142:8080/redmine";
   String apiAccessKey = "3f907ae90b8ce8d5de4c0c5ea9fbc9c678092cfe";
   RedmineManager mgr = RedmineManagerFactory.createWithApiKey(uri, apiAccessKey);
   try {
     //            getUsersAsNotAdmin(mgr);
     // getIssueWithRelations(mgr);
     //			tryCreateIssue(mgr);
     // tryGetIssues(mgr);
     tryGetIssue(mgr.getIssueManager());
     // tryGetAllIssues(mgr);
     // printCurrentUser(mgr);
     // generateXMLForUser();
     // generateXMLForTimeEntry();
     // getSavedQueries(mgr);
     // getProjects(mgr);
     // tryCreateRelation(mgr);
     // tryGetNews(mgr);
     // getProject(mgr);
     // changeIssueStatus(mgr);
     // getVersion(mgr);
     // getStatuses(mgr);
     // tryUpload(mgr);
     //			tryGetRoles(mgr);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Example #2
0
  private static void printCurrentUser(RedmineManager mgr) throws Exception {
    User currentUser = mgr.getCurrentUser();
    logger.debug("user="******"*****@*****.**");
    mgr.update(currentUser);
    logger.debug("updated user");

    User currentUser2 = mgr.getCurrentUser();
    logger.debug("updated user's mail: " + currentUser2.getMail());
  }
Example #3
0
  @SuppressWarnings("unused")
  private static void tryCreateIssue(RedmineManager manager) throws RedmineException {
    Issue issue = new Issue();
    issue.setSubject("test123");
    final Version ver = VersionFactory.create(512);
    issue.setTargetVersion(ver);
    final IssueCategory cat = IssueCategoryFactory.create(673);
    issue.setCategory(cat);

    ProjectManager projectManager = manager.getProjectManager();
    Project projectByKey = projectManager.getProjectByKey("testid");
    issue.setProject(projectByKey);
    manager.getIssueManager().createIssue(issue);
  }
Example #4
0
 private static void tryGetNews(RedmineManager mgr)
     throws IOException, AuthenticationException, RedmineException, NotFoundException {
   List<News> news = mgr.getNews(null);
   for (News aNew : news) {
     System.out.println(aNew);
   }
 }
Example #5
0
 @SuppressWarnings("unused")
 private static void tryUpload(
     RedmineManager mgr, IssueManager issueManager, AttachmentManager attachmentManager)
     throws RedmineException, IOException {
   final byte[] content = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
   final Attachment attach1 =
       attachmentManager.uploadAttachment("test.bin", "application/ternary", content);
   final Issue testIssue = new Issue();
   testIssue.setSubject("This is upload ticket!");
   testIssue.addAttachment(attach1);
   final Project tmpProject = ProjectFactory.create("Upload project", "uploadtmpproject");
   final Project project = mgr.getProjectManager().createProject(tmpProject);
   try {
     final Issue createdIssue = issueManager.createIssue(project.getIdentifier(), testIssue);
     try {
       System.out.println(createdIssue.getAttachments());
     } finally {
       issueManager.deleteIssue(createdIssue.getId());
     }
   } finally {
     mgr.getProjectManager().deleteProject(project.getIdentifier());
   }
 }
Example #6
0
 private static void getSavedQueries(RedmineManager mgr)
     throws IOException, AuthenticationException, NotFoundException, RedmineException {
   List<SavedQuery> savedQueries = mgr.getSavedQueries("test");
   logger.debug("Retrieved queries " + savedQueries);
 }
Example #7
0
 private static void getProjects(RedmineManager mgr)
     throws IOException, AuthenticationException, RedmineException {
   List<Project> projects = mgr.getProjects();
   logger.debug("Retrieved projects " + projects);
 }
Example #8
0
 private static void tryCreateRelation(RedmineManager mgr)
     throws IOException, AuthenticationException, NotFoundException, RedmineException {
   IssueRelation r = mgr.createRelation(49, 50, IssueRelation.TYPE.precedes.toString());
   logger.debug("Created relation " + r);
 }
Example #9
0
 private static void getProject(RedmineManager mgr)
     throws IOException, AuthenticationException, RedmineException, NotFoundException {
   Project test = mgr.getProjectByKey("test");
   System.out.println(test);
 }
Example #10
0
 private static void changeIssueStatus(RedmineManager mgr)
     throws IOException, AuthenticationException, RedmineException, NotFoundException {
   Issue issue = mgr.getIssueById(1771);
   issue.setSubject("new");
   mgr.update(issue);
 }
Example #11
0
 private static void tryGetAllIssues(RedmineManager mgr) throws Exception {
   List<Issue> issues = mgr.getIssues(projectKey, null);
   for (Issue issue : issues) {
     logger.debug(issue.toString());
   }
 }
Example #12
0
 @SuppressWarnings("unused")
 private static void getProject(RedmineManager mgr) throws RedmineException {
   Project test = mgr.getProjectManager().getProjectByKey("test");
   System.out.println(test);
 }
Example #13
0
 private static void getUsersAsNotAdmin(RedmineManager mgr) throws RedmineException {
   System.out.println("Users: " + mgr.getUserManager().getUsers());
 }
Example #14
0
 private static void tryGetRoles(RedmineManager mgr) throws Exception {
   System.out.println(mgr.getUserManager().getRoles());
 }
Example #15
0
 private static void getIssueWithRelations(RedmineManager mgr)
     throws IOException, AuthenticationException, NotFoundException, RedmineException {
   Issue issue = mgr.getIssueById(24580, INCLUDE.relations);
   List<IssueRelation> r = issue.getRelations();
   logger.debug("Retrieved relations " + r);
 }
Example #16
0
 private static void getVersion(RedmineManager mgr)
     throws IOException, AuthenticationException, RedmineException, NotFoundException {
   // see Redmine bug http://www.redmine.org/issues/10241
   Version version = mgr.getVersionById(294);
   System.out.println(version);
 }
Example #17
0
 private static void tryCreateIssue(RedmineManager mgr)
     throws IOException, AuthenticationException, NotFoundException, RedmineException {
   Issue issue = new Issue();
   issue.setSubject("test123");
   mgr.createIssue(projectKey, issue);
 }
Example #18
0
 @SuppressWarnings("unused")
 private static void getProjects(RedmineManager mgr) throws RedmineException {
   List<Project> projects = mgr.getProjectManager().getProjects();
   logger.debug("Retrieved projects " + projects);
 }