public void deleteAttachment(long taskId, long attachmentId) { Task task = persistenceContext.findTask(taskId); Attachment attachment = persistenceContext.removeAttachmentFromTask(task, attachmentId); Content content = persistenceContext.findContent(attachment.getAttachmentContentId()); persistenceContext.removeContent(content); }
long firstAttachContentId = firstAttach.getAttachmentContentId(); Content firstAttachContent = taskService.getContentById(firstAttachContentId); String firstDocString = (String)ContentMarshallerHelper.unmarshall(firstAttachContent.getContent(), null); long secondAttachContentId = secondAttach.getAttachmentContentId(); Content secondAttachContent = taskService.getContentById(secondAttachContentId); String secondDocString = (String)ContentMarshallerHelper.unmarshall(secondAttachContent.getContent(), null);
attach.setAttachedBy(createUser(((JaxbAttachment) jaxbAttach).getAttachedById())); attach.setSize(jaxbAttach.getSize()); attach.setAttachmentContentId(jaxbAttach.getAttachmentContentId()); attachments.add(attach);
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; }
assertEquals("john", attachment.getAttachedBy().getId()); assertEquals("my attachment", attachment.getName()); assertNotNull(attachment.getAttachmentContentId());
genAttach.setAttachedBy(attach.getAttachedBy().getId()); genAttach.setSize(attach.getSize()); genAttach.setAttachmentContentId(attach.getAttachmentContentId()); genTaskData.getAttachments().add(genAttach);