[Suiviobsmer-commits] r567 - trunk/wao-business/src/main/java/fr/ifremer/wao/service
Author: fdesbois Date: 2010-06-28 09:10:30 +0000 (Mon, 28 Jun 2010) New Revision: 567 Log: Ano #2356 : Add fix to avoid saving contact with null sampleRow Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-06-27 06:12:23 UTC (rev 566) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-06-28 09:10:30 UTC (rev 567) @@ -189,21 +189,8 @@ Contact contact, boolean delete) throws TopiaException, NullSampleMonthException { - // Ano #2287 Temporary fix to avoid saving a null observer - if (contact.getObserver() == null) { - // Throw a NullPointerException to avoid saving null observer - Throwable exception = - new NullPointerException("observer can't be null to save" + - " the contact"); - - if (log.isWarnEnabled()) { - log.warn("observer null when saving contact", exception); - } - // This message will be displayed to Client - throw new WaoException(exception, - "L'observateur n'a pas été renseigné correctement pour " + - "la sauvegarde du contact"); - } + checkObserver(contact); + checkSampleRow(contact); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -227,6 +214,42 @@ transaction.commitTransaction(); } + protected void checkObserver(Contact contact) throws WaoException { + // Ano #2287 Temporary fix to avoid saving a null observer + if (contact.getObserver() == null) { + // Throw a NullPointerException to avoid saving null observer + Throwable exception = + new NullPointerException("observer can't be null to save" + + " the contact"); + + if (log.isWarnEnabled()) { + log.warn("observer null when saving contact", exception); + } + // This message will be displayed to Client + throw new WaoException(exception, + "L'observateur n'a pas été renseigné correctement pour " + + "la sauvegarde du contact"); + } + } + + protected void checkSampleRow(Contact contact) throws WaoException { + // Ano #2356 Temporary fix to avoid saving a null sampleRow + if (contact.getSampleRow() == null) { + // Throw a NullPointerException to avoid saving null sampleRow + Throwable exception = + new NullPointerException("sampleRow can't be null to save" + + " the contact"); + + if (log.isWarnEnabled()) { + log.warn("sampleRow null when saving contact", exception); + } + // This message will be displayed to Client + throw new WaoException(exception, + "La ligne du plan d'échantillonnage n'a pas été renseigné" + + " correctement pour la sauvegarde du contact"); + } + } + /** * Create or Update a Contact from {@code source} to {@code destination}. * The sampleMonth referenced to this contact will be automatically updated
participants (1)
-
fdesbois@users.labs.libre-entreprise.org