From 15cac255955e5bcbb76af8c0e83bbedd795c90c3 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Tue, 22 Oct 2013 01:16:12 +0100 Subject: [PATCH] MIFOSX-715: if the image resource is missing for whatever reason (backup didnt copy filestructure, someone removed file) pass back approp error message from API. --- .../service/ImageReadPlatformServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java index 1d260c46c..18becb349 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/documentmanagement/service/ImageReadPlatformServiceImpl.java @@ -71,7 +71,13 @@ public class ImageReadPlatformServiceImpl implements ImageReadPlatformService { final ImageData imageData = this.jdbcTemplate.queryForObject(sql, imageMapper, new Object[] { clientId }); final ContentRepository contentRepository = this.contentRepositoryFactory.getRepository(imageData.storageType()); - return contentRepository.fetchImage(imageData); + final ImageData result = contentRepository.fetchImage(imageData); + + if (result.getContent() == null) { + throw new ImageNotFoundException("clients", clientId); + } + + return result; } catch (final EmptyResultDataAccessException e) { throw new ImageNotFoundException("clients", clientId); }