}
return result ;
}
public AttachmentResponse createAttachmentResponse(Attachment attachment, String serverRootUrl) {
AttachmentResponse result = new AttachmentResponse();
result.setId(attachment.getId());
result.setName(attachment.getName());
result.setDescription(attachment.getDescription());
result.setType(attachment.getType());
result.setUserId(attachment.getUserId());
if (attachment.getUrl() == null && attachment.getTaskId() != null) {
// Attachment content can be streamed
result.setContentUrl(formatUrl(serverRootUrl, RestUrls.URL_TASK_ATTACHMENT_DATA, attachment.getTaskId(), attachment.getId()));
} else {
result.setExternalUrl(attachment.getUrl());
}
if (attachment.getTaskId() != null) {
result.setUrl(formatUrl(serverRootUrl, RestUrls.URL_TASK_ATTACHMENT, attachment.getTaskId(), attachment.getId()));
result.setTaskUrl(formatUrl(serverRootUrl, RestUrls.URL_TASK, attachment.getTaskId()));
}
if (attachment.getProcessInstanceId() != null) {
result.setProcessInstanceUrl(formatUrl(serverRootUrl, RestUrls.URL_PROCESS_INSTANCE, attachment.getProcessInstanceId()));
}
return result ;
}