if (!contentItem.isContentAvailable()) { throw new FlowableException("No data available for content item " + contentItemId);
public void getRawContent(String contentId, HttpServletResponse response) { ContentItem contentItem = contentService.createContentItemQuery().id(contentId).singleResult(); if (contentItem == null) { throw new NotFoundException("No content found with id: " + contentId); } if (!contentItem.isContentAvailable()) { throw new NotFoundException("Raw content not yet available for id: " + contentId); } if (!permissionService.canDownloadContent(SecurityUtils.getCurrentUserObject(), contentItem)) { throw new NotPermittedException("You are not allowed to read the content with id: " + contentId); } // Set correct mine-type if (contentItem.getMimeType() != null) { response.setContentType(contentItem.getMimeType()); } // Write content response try (InputStream inputstream = contentService.getContentItemData(contentId)) { IOUtils.copy(inputstream, response.getOutputStream()); } catch (IOException e) { throw new InternalServerErrorException("Error while writing raw content data for content: " + contentId, e); } }
public ContentItemResponse(ContentItem contentItem, String url) { setId(contentItem.getId()); setName(contentItem.getName()); setMimeType(contentItem.getMimeType()); setTaskId(contentItem.getTaskId()); setProcessInstanceId(contentItem.getProcessInstanceId()); setContentStoreId(contentItem.getContentStoreId()); setContentStoreName(contentItem.getContentStoreName()); setContentAvailable(contentItem.isContentAvailable()); setTenantId(contentItem.getTenantId()); setCreated(contentItem.getCreated()); setCreatedBy(contentItem.getCreatedBy()); setLastModified(contentItem.getLastModified()); setLastModifiedBy(contentItem.getLastModifiedBy()); setUrl(url); }