Skip to content

Commit

Permalink
DDF-2672 Added Mime Type Aliases to Tika Input Transformer service pr…
Browse files Browse the repository at this point in the history
…operties (codice#1525)
  • Loading branch information
bdeining authored and kcwire committed Jan 6, 2017
1 parent d48811d commit b35cfa1
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -352,21 +352,32 @@ private Hashtable<String, Object> getServiceProperties() {
}

private List<String> getSupportedMimeTypes() {
SortedSet<MediaType> mediaTypes = MediaTypeRegistry.getDefaultRegistry()
.getTypes();
MediaTypeRegistry mediaTypeRegistry = MediaTypeRegistry.getDefaultRegistry();

Set<MediaType> mediaTypes = mediaTypeRegistry.getTypes();
Set<MediaType> mediaTypeAliases = new HashSet<>();
List<String> 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<String> 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));
Expand Down

0 comments on commit b35cfa1

Please sign in to comment.