From 77699951d2611c1803c7df6424f1283756d3785e Mon Sep 17 00:00:00 2001 From: gpawel <gpawel> Date: Thu, 3 May 2012 08:18:15 +0000 Subject: [PATCH] bugfix: NPE in thumbnails generation SVN: 25146 --- .../dss/etl/Hdf5ThumbnailGenerator.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/Hdf5ThumbnailGenerator.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/Hdf5ThumbnailGenerator.java index 91e3ccb1b2e..3a5c3daa774 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/Hdf5ThumbnailGenerator.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/Hdf5ThumbnailGenerator.java @@ -347,9 +347,7 @@ public class Hdf5ThumbnailGenerator implements IHDF5WriterClient { if ((imageDataSetStructure.getChannelColorComponents() != null && imageDataSetStructure .getChannelColorComponents().size() > 0) - || transformationsForChannels.get(imageFileInfo.getChannelCode()).containsKey( - thumbnailsStorageFormat.getTransformationCode(imageFileInfo - .getChannelCode()))) + || isTransformationAvailable(imageFileInfo.getChannelCode())) { List<ThumbnailData> thumbnails = new ArrayList<ThumbnailData>(); for (String channelCode : getChannelsToProcess(imageFileInfo.getChannelCode())) @@ -379,6 +377,16 @@ public class Hdf5ThumbnailGenerator implements IHDF5WriterClient } } + private boolean isTransformationAvailable(String channelCode) + { + Map<String, ImageTransformation> transformationsForChannel = + transformationsForChannels.get(channelCode); + + return transformationsForChannel != null + && transformationsForChannel.containsKey(thumbnailsStorageFormat + .getTransformationCode(channelCode)); + } + private List<ThumbnailData> generateThumbnailInternally(ImageFileInfo imageFileInfo, String imageIdOrNull, ByteArrayOutputStream bufferOutputStream) throws IOException { @@ -467,9 +475,12 @@ public class Hdf5ThumbnailGenerator implements IHDF5WriterClient thumbnailsStorageFormat.getTransformationCode(channelCode); if (transformationCodeOrNull != null) { + Map<String, ImageTransformation> transformationsForChannel = + transformationsForChannels.get(channelCode); + ImageTransformation it = - transformationsForChannels.get(channelCode).get( - transformationCodeOrNull.toUpperCase()); + transformationsForChannel == null ? null : transformationsForChannel + .get(transformationCodeOrNull.toUpperCase()); if (it != null) { return it.getImageTransformerFactory().createTransformer(); -- GitLab