From b35cfa1452115d39dc92bd2a4f58944e61775d3b Mon Sep 17 00:00:00 2001 From: Benjamin Deininger Date: Fri, 6 Jan 2017 09:04:15 -0700 Subject: [PATCH] DDF-2672 Added Mime Type Aliases to Tika Input Transformer service properties (#1525) --- .../input/tika/TikaInputTransformer.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/catalog/transformer/catalog-transformer-tika-input/src/main/java/ddf/catalog/transformer/input/tika/TikaInputTransformer.java b/catalog/transformer/catalog-transformer-tika-input/src/main/java/ddf/catalog/transformer/input/tika/TikaInputTransformer.java index 263c61f3196e..2e57acdd69e1 100644 --- a/catalog/transformer/catalog-transformer-tika-input/src/main/java/ddf/catalog/transformer/input/tika/TikaInputTransformer.java +++ b/catalog/transformer/catalog-transformer-tika-input/src/main/java/ddf/catalog/transformer/input/tika/TikaInputTransformer.java @@ -26,12 +26,12 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.SortedSet; import java.util.TreeMap; import java.util.stream.Collectors; @@ -352,21 +352,32 @@ private Hashtable getServiceProperties() { } private List getSupportedMimeTypes() { - SortedSet mediaTypes = MediaTypeRegistry.getDefaultRegistry() - .getTypes(); + MediaTypeRegistry mediaTypeRegistry = MediaTypeRegistry.getDefaultRegistry(); + + Set mediaTypes = mediaTypeRegistry.getTypes(); + Set mediaTypeAliases = new HashSet<>(); List mimeTypes = new ArrayList<>(mediaTypes.size()); for (MediaType mediaType : mediaTypes) { - String mimeType = mediaType.getType() + "/" + mediaType.getSubtype(); - mimeTypes.add(mimeType); + addMediaTypetoMimeTypes(mediaType, mimeTypes); + mediaTypeAliases.addAll(mediaTypeRegistry.getAliases(mediaType)); + } + + for (MediaType mediaType : mediaTypeAliases) { + addMediaTypetoMimeTypes(mediaType, mimeTypes); } + mimeTypes.add("image/jp2"); - mimeTypes.add("image/bmp"); LOGGER.debug("supported mime types: {}", mimeTypes); return mimeTypes; } + private void addMediaTypetoMimeTypes(MediaType mediaType, List mimeTypes) { + String mimeType = mediaType.getType() + "/" + mediaType.getSubtype(); + mimeTypes.add(mimeType); + } + private void createThumbnail(InputStream input, Metacard metacard) { try { Image image = ImageIO.read(new CloseShieldInputStream(input));