use of org.kie.server.api.model.instance.TaskAttachmentList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method getTaskAttachmentsByTaskId.
@Override
public List<TaskAttachment> getTaskAttachmentsByTaskId(String containerId, Long taskId) {
TaskAttachmentList attachmentList = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
attachmentList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_ATTACHMENTS_GET_URI, valuesMap), TaskAttachmentList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getAttachmentsByTaskId", marshaller.getFormat().getType(), new Object[] { containerId, taskId })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
attachmentList = deserialize(response.getResult(), TaskAttachmentList.class);
;
}
if (attachmentList.getTasks() != null) {
return Arrays.asList(attachmentList.getTasks());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.TaskAttachmentList in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceBase method getAttachmentsByTaskId.
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;
}
Aggregations