@Test public void testContentTypes() throws IOException { log.info("testContentTypes"); PdfThumbnailProvider ptp = new PdfThumbnailProvider(); assertFalse(ptp.applies(imageFile)); assertTrue(ptp.applies(pdfFile)); }
@Override public boolean applies(Resource resource) { return (CMSConstants.NT_FILE.equals(resource.getResourceType()) || JcrConstants.NT_FILE.equals(resource.getResourceType())) && Optional.ofNullable(resource.adaptTo(File.class)) .map(r -> MediaType.PDF.is(MediaType.parse(r.getContentType()))).orElse(false); }
PdfThumbnailProvider implements ThumbnailProvider { @Override public boolean applies(Resource resource) { return (CMSConstants.NT_FILE.equals(resource.getResourceType()) || JcrConstants.NT_FILE.equals(resource.getResourceType())) && Optional.ofNullable(resource.adaptTo(File.class)) .map(r -> MediaType.PDF.is(MediaType.parse(r.getContentType()))).orElse(false); } }
PdfThumbnailProvider implements ThumbnailProvider { @Override public boolean applies(Resource resource) { return (CMSConstants.NT_FILE.equals(resource.getResourceType()) || JcrConstants.NT_FILE.equals(resource.getResourceType())) && Optional.ofNullable(resource.adaptTo(File.class)) .map(r -> MediaType.PDF.is(MediaType.parse(r.getContentType()))).orElse(false); }  }
PdfThumbnailProvider implements ThumbnailProvider { @Override public boolean applies(Resource resource) { return (CMSConstants.NT_FILE.equals(resource.getResourceType()) || JcrConstants.NT_FILE.equals(resource.getResourceType())) && Optional.ofNullable(resource.adaptTo(File.class)) .map(r -> MediaType.PDF.is(MediaType.parse(r.getContentType()))).orElse(false); }  @Override boolean applies(Resource resource); @Override InputStream getThumbnail(Resource resource); }
PdfThumbnailProvider implements ThumbnailProvider { @Override public boolean applies(Resource resource) { return (CMSConstants.NT_FILE.equals(resource.getResourceType()) || JcrConstants.NT_FILE.equals(resource.getResourceType())) && Optional.ofNullable(resource.adaptTo(File.class)) .map(r -> MediaType.PDF.is(MediaType.parse(r.getContentType()))).orElse(false); }  @Override boolean applies(Resource resource); @Override InputStream getThumbnail(Resource resource);  }