@Test public void testContentTypes() throws IOException { log.info("testContentTypes"); ImageThumbnailProvider itp = new ImageThumbnailProvider(); assertTrue(itp.applies(imageFile)); assertFalse(itp.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(f -> MediaType.parse(f.getContentType()).is(MediaType.ANY_IMAGE_TYPE)).orElse(false); }
ImageThumbnailProvider 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(f -> MediaType.parse(f.getContentType()).is(MediaType.ANY_IMAGE_TYPE)).orElse(false); } }
ImageThumbnailProvider 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(f -> MediaType.parse(f.getContentType()).is(MediaType.ANY_IMAGE_TYPE)).orElse(false); }  }
ImageThumbnailProvider 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(f -> MediaType.parse(f.getContentType()).is(MediaType.ANY_IMAGE_TYPE)).orElse(false); }  @Override boolean applies(Resource resource); @Override InputStream getThumbnail(Resource resource); }
ImageThumbnailProvider 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(f -> MediaType.parse(f.getContentType()).is(MediaType.ANY_IMAGE_TYPE)).orElse(false); }  @Override boolean applies(Resource resource); @Override InputStream getThumbnail(Resource resource);  }