/**
   * Writes a "create project" request.
   *
   * @param writer project writer.
   * @param project project to create.
   * @throws IllegalArgumentException if some project fields are not configured.
   * @throws JSONException if IO error occurs.
   */
  public static void writeProject(JSONWriter writer, Project project)
      throws IllegalArgumentException, JSONException {
    /* Validate project */
    if (project.getName() == null)
      throw new IllegalArgumentException("Project name must be set to create a new project");
    if (project.getIdentifier() == null)
      throw new IllegalArgumentException("Project identifier must be set to create a new project");

    writeProject(project, writer);
  }
 public static void writeProject(Project project, final JSONWriter writer) throws JSONException {
   JsonOutput.addIfNotNull(writer, "id", project.getId());
   JsonOutput.addIfNotNull(writer, "identifier", project.getIdentifier());
   JsonOutput.addIfNotNull(writer, "name", project.getName());
   JsonOutput.addIfNotNull(writer, "description", project.getDescription());
   JsonOutput.addIfNotNull(writer, "homepage", project.getHomepage());
   addIfNotNullFull(writer, "created_on", project.getCreatedOn());
   addIfNotNullFull(writer, "updated_on", project.getUpdatedOn());
   JsonOutput.addIfNotNull(writer, "parent_id", project.getParentId());
   JsonOutput.addArrayIfNotNull(writer, "trackers", project.getTrackers(), TRACKER_WRITER);
 }
Ejemplo n.º 3
0
  public boolean addProject(final Project project, final RedmineRepositoryConfig config)
      throws IOException, SAXException {
    LOGGER.info("Redmine add Project: " + project.getName());
    _redmineProject = new com.taskadapter.redmineapi.bean.Project();
    _redmineProject.setName(project.getName());
    _redmineProject.setIdentifier(getRedmineId(project));
    _redmineProject.setDescription(project.getDescription());

    try {
      _redmineProject = _mgr.createProject(_redmineProject);
      return true;
    } catch (RedmineException e) {
      e.printStackTrace();
      return false;
    }
  }
Ejemplo n.º 4
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());
   }
 }