public String getAttachmentById(String containerId, Number taskId, Number attachmentId, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); Attachment attachment = userTaskService.getAttachmentById(containerId, taskId.longValue(), attachmentId.longValue()); TaskAttachment taskAttachment = TaskAttachment.builder() .id(attachment.getId()) .name(attachment.getName()) .addedBy(attachment.getAttachedBy().getId()) .addedAt(attachment.getAttachedAt()) .attachmentContentId(attachment.getAttachmentContentId()) .contentType(attachment.getContentType()) .size(attachment.getSize()) .build(); logger.debug("About to marshal task '{}' attachment {} with content {}", taskId, attachmentId, taskAttachment); String response = marshallerHelper.marshal(containerId, marshallingType, taskAttachment); return response; }
public String getAttachmentsByTaskId(String containerId, Number taskId, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); List<Attachment> attachments = userTaskService.getAttachmentsByTaskId(containerId, taskId.longValue()); TaskAttachment[] taskComments = new TaskAttachment[attachments.size()]; int counter = 0; for (Attachment attachment : attachments) { TaskAttachment taskComment = TaskAttachment.builder() .id(attachment.getId()) .name(attachment.getName()) .addedBy(attachment.getAttachedBy().getId()) .addedAt(attachment.getAttachedAt()) .contentType(attachment.getContentType()) .attachmentContentId(attachment.getAttachmentContentId()) .size(attachment.getSize()) .build(); taskComments[counter] = taskComment; counter++; } TaskAttachmentList result = new TaskAttachmentList(taskComments); logger.debug("About to marshal task '{}' attachments {}", taskId, result); String response = marshallerHelper.marshal(containerId, marshallingType, result); return response; }