public static void writeIssue(Issue issue, final JSONWriter writer) throws JSONException { JsonOutput.addIfNotNull(writer, "id", issue.getId()); JsonOutput.addIfNotNull(writer, "subject", issue.getSubject()); JsonOutput.addIfNotNull(writer, "parent_issue_id", issue.getParentId()); JsonOutput.addIfNotNull(writer, "estimated_hours", issue.getEstimatedHours()); JsonOutput.addIfNotNull(writer, "spent_hours", issue.getSpentHours()); if (issue.getAssignee() != null) JsonOutput.addIfNotNull(writer, "assigned_to_id", issue.getAssignee().getId()); JsonOutput.addIfNotNull(writer, "priority_id", issue.getPriorityId()); JsonOutput.addIfNotNull(writer, "done_ratio", issue.getDoneRatio()); if (issue.getProject() != null) JsonOutput.addIfNotNull(writer, "project_id", issue.getProject().getIdentifier()); if (issue.getAuthor() != null) JsonOutput.addIfNotNull(writer, "author_id", issue.getAuthor().getId()); addShort2(writer, "start_date", issue.getStartDate()); addIfNotNullShort2(writer, "due_date", issue.getDueDate()); if (issue.getTracker() != null) JsonOutput.addIfNotNull(writer, "tracker_id", issue.getTracker().getId()); JsonOutput.addIfNotNull(writer, "description", issue.getDescription()); addIfNotNullFull(writer, "created_on", issue.getCreatedOn()); addIfNotNullFull(writer, "updated_on", issue.getUpdatedOn()); JsonOutput.addIfNotNull(writer, "status_id", issue.getStatusId()); if (issue.getTargetVersion() != null) JsonOutput.addIfNotNull(writer, "fixed_version_id", issue.getTargetVersion().getId()); if (issue.getCategory() != null) JsonOutput.addIfNotNull(writer, "category_id", issue.getCategory().getId()); JsonOutput.addIfNotNull(writer, "notes", issue.getNotes()); writeCustomFields(writer, issue.getCustomFields()); if (issue.getAttachments() != null && issue.getAttachments().size() > 0) { final List<Attachment> uploads = new ArrayList<Attachment>(); for (Attachment attach : issue.getAttachments()) if (attach.getToken() != null) uploads.add(attach); JsonOutput.addArrayIfNotEmpty(writer, "uploads", uploads, UPLOAD_WRITER); } /* * Journals and Relations cannot be set for an issue during creation or * updates. */ }
public static void writeUpload(JSONWriter writer, Attachment attachment) throws JSONException { JsonOutput.addIfNotNull(writer, "token", attachment.getToken()); JsonOutput.addIfNotNull(writer, "filename", attachment.getFileName()); JsonOutput.addIfNotNull(writer, "content_type", attachment.getContentType()); JsonOutput.addIfNotNull(writer, "description", attachment.getDescription()); }