r2153 - trunk/wao-services/src/main/java/fr/ifremer/wao/services/service
Author: bleny Date: 2014-07-16 11:56:58 +0200 (Wed, 16 Jul 2014) New Revision: 2153 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2153 Log: prevent npe of main observer field is not filled in contact form Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-07-15 13:01:47 UTC (rev 2152) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-07-16 09:56:58 UTC (rev 2153) @@ -475,10 +475,13 @@ public void preValidate(UpdateContactCommand updateContactCommand) { String mainObserverId = updateContactCommand.getMainObserverId(); + if (StringUtils.isBlank(mainObserverId)) { + updateContactCommand.getContact().setMainObserver(null); + } else { + WaoUser mainObserver = getWaoUserDao().forTopiaIdEquals(mainObserverId).findUnique(); + updateContactCommand.getContact().setMainObserver(mainObserver); + } - WaoUser mainObserver = getWaoUserDao().forTopiaIdEquals(mainObserverId).findUnique(); - updateContactCommand.getContact().setMainObserver(mainObserver); - List<WaoUser> secondaryObservers = getWaoUserDao().forTopiaIdIn(updateContactCommand.getSecondaryObserverIds()).findAll(); updateContactCommand.getContact().setSecondaryObservers(new HashSet<>(secondaryObservers));
participants (1)
-
bleny@users.forge.codelutin.com