private ContentStream getRenditionStream(String repositoryId, Content content, String streamId) { if (!content.isDocument() && !content.isFolder()) { exceptionService.constraint( content.getId(), "getRenditionStream cannnot be invoked to other than document or folder type."); } exceptionService.constraintRenditionStreamDownload(content, streamId); Rendition rendition = contentService.getRendition(repositoryId, streamId); BigInteger length = BigInteger.valueOf(rendition.getLength()); String mimeType = rendition.getMimetype(); InputStream is = rendition.getInputStream(); ContentStream cs = new ContentStreamImpl("preview_" + streamId, length, mimeType, is); return cs; }
public void execute() { if (content.isDocument()) { Future<Boolean> result = parentService .getService() .submit(new DeleteTask(callContext, repositoryId, content, allVersions)); failureIds.put(content.getId(), result); } else if (content.isFolder()) { WrappedExecutorService childrenService = new WrappedExecutorService(Executors.newFixedThreadPool(threadMax), (Folder) content); List<Content> children = contentService.getChildren(repositoryId, content.getId()); if (CollectionUtils.isNotEmpty(children)) { for (Content child : children) { DeleteService deleteService = new DeleteService( this.failureIds, childrenService, callContext, repositoryId, child, allVersions); deleteService.execute(); } } // wait til newService ends childrenService.getService().shutdown(); try { childrenService.getService().awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { log.error(e, e); } // Lastly, delete self Future<Boolean> result = parentService .getService() .submit(new DeleteTask(callContext, repositoryId, content, allVersions)); failureIds.put(content.getId(), result); } }