Author: fdesbois Date: 2010-02-09 21:55:10 +0000 (Tue, 09 Feb 2010) New Revision: 340 Modified: trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java Log: Refactor closeContext using finally statement from try/catch Modified: trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties =================================================================== --- trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties 2010-02-09 21:55:10 UTC (rev 340) @@ -17,4 +17,4 @@ suiviobsmer.email.from=admin at wao.org ## Version -suiviobsmer.version=1.0.0 \ No newline at end of file +suiviobsmer.version=1.0 \ No newline at end of file Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2010-02-09 21:55:10 UTC (rev 340) @@ -147,19 +147,19 @@ log.debug("An error occured",eee); } if (!(eee instanceof SuiviObsmerException)) { - if (!(eee instanceof TopiaException)) { + //if (!(eee instanceof TopiaException)) { try { if (transaction != null && !transaction.isClosed()) { if (log.isInfoEnabled()) { log.info("Saving annulation : Transaction rollback"); } transaction.rollbackTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } } catch (TopiaException eeee) { throw new SuiviObsmerException("Fatal topia error when close context", eeee); } - } + //} if (eee instanceof SQLGrammarException && log.isErrorEnabled()) { log.error("SQL executed with error : " + ((SQLGrammarException)eee).getSQL()); } @@ -169,6 +169,16 @@ } } + public static void closeTransaction(TopiaContext transaction) throws SuiviObsmerException { + try { + if (transaction != null) { + transaction.closeContext(); + } + } catch (TopiaException eee) { + throw new SuiviObsmerException("Fatal topia error when close context", eee); + } + } + /** * Generate a random string of "length" character alphanumeric. * @param length number of characters for the final string Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java 2010-02-09 21:55:10 UTC (rev 340) @@ -50,8 +50,9 @@ * @throws SuiviObsmerException */ static void createDefaultAdmin() throws SuiviObsmerException { + TopiaContext transaction = null; try { - TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction(); + transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction(); WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction); @@ -86,9 +87,11 @@ transaction.commitTransaction(); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(null, "Error during database initialization", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -77,12 +77,14 @@ result = state.isFinalState(); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer les informations privées du navire lié à la société " + "'" + company.getName() + "'", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } return result; @@ -109,12 +111,14 @@ TopiaQuery query = dao.createQueryDoneContactsFromDate(this, fromDate); result = query.executeCount(transaction); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer le nombre d'embarquements réels depuis le " + "'" + fromDate + "'", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -71,12 +71,14 @@ result = query.executeCount(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer le nombre d'embarquements réels depuis le " + "'" + fromDate + "' pour la société '" + getCompany().getName() + "'", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -77,11 +77,13 @@ } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible d'enregistrer le nombre de marées réels pour le mois de " + formatMonth() + " [ligne : " + this.getSampleRow().getCode() + "]", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java 2010-02-09 21:55:10 UTC (rev 340) @@ -49,9 +49,11 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.logging.Level; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.time.DurationFormatUtils; import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -319,21 +321,25 @@ info("Nombre de ligne ajouté : " + result, -1); info("Temps d'exécution : " + execTime, -1); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { if (log.isErrorEnabled()) { log.error("Problème lors de l'import du calendrier d'activité", eee); } + exception(eee, currRow); try { - error("exception " + eee.getClass().getSimpleName() + " : " + eee.getMessage(), currRow); - } catch (IOException ex) { - if (log.isErrorEnabled()) { - log.error("IO error", ex); - } - } + transaction.rollbackTransaction(); + } catch (TopiaException te) { + exception(te, currRow); + } } finally { IOUtils.closeQuietly(writer); SuiviObsmerContext.setActivityCalendarImport(false); + try { + transaction.closeContext(); + } catch (TopiaException te) { + exception(te, currRow); + } } } @@ -344,6 +350,16 @@ protected void error(String message, int numRow) throws IOException { writeLog("[ERROR] " + message, numRow); } + + protected void exception(Throwable eee, int numRow) { + try { + error("exception " + eee.getClass().getSimpleName() + " : " + eee.getMessage(), numRow); + } catch (IOException ex) { + if (log.isErrorEnabled()) { + log.error("IO error", ex); + } + } + } protected void info(String message, int numRow) throws IOException { writeLog("[INFO] " + message, numRow); Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -30,6 +30,7 @@ import fr.ifremer.suiviobsmer.SuiviObsmerContext; import fr.ifremer.suiviobsmer.SuiviObsmerException; import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper; +import java.util.logging.Level; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; @@ -101,10 +102,11 @@ } results = dao.findAllMappedByQuery(query, Boat.IMMATRICULATION, Integer.class); - - transaction.closeContext(); + } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -122,10 +124,11 @@ query = createQueryForBoatFilter(query, filter); result = query.executeCount(); - - transaction.closeContext(); + } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -227,13 +230,14 @@ result.setLastContact(contact); } - - transaction.closeContext(); +// transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer les informations du navire " + "immatriculé '" + boatImmatriculation + "'" + " pour la société '" + company.getName() + "'", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -264,13 +268,15 @@ } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { Boat boat = companyBoatInfos.getBoatInfos().getBoat(); Company company = companyBoatInfos.getCompany(); SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou modifier les informations liés au navire " + boat.getImmatriculation() + " pour la société " + company.getName(), eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -299,10 +305,12 @@ boats.add(boat); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "La chaîne d'immatriculations est incorrect ! Chaque immatriculation doit posséder 6 chiffres", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return boats; } @@ -318,9 +326,11 @@ result = dao.findByTopiaId(boatId); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger le navire", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -338,10 +348,12 @@ results = (List<String>)dao.createQuery().addDistinct().setSelect(Boat.NAME).add(Boat.NAME, Op.LIKE, input + "%").execute(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer les navires avec un nom commencant par '" + input + "'", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -457,13 +469,15 @@ log.info("Durée de l'import : " + execTime); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Problème d'import du fichier CSV. Vérifiez l'en-tête du fichier : [ NAVS_COD,CARN_NOM," + "CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]"/* et l'encodage [ UTF-8 ] */ + " Voir documentation pour plus de détails.", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -535,7 +549,7 @@ } result = new FileInputStream(file); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible d'exporter les navires sélectionnés", eee); @@ -543,6 +557,7 @@ if (writer != null) { writer.close(); } + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -602,11 +617,13 @@ company.getName()); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger le dernier calendrier d'activité du navire " + boat.getName() + " (" + boat.getImmatriculation() + ")", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -114,10 +114,12 @@ results = dao.findAllMappedByQuery(query); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de filtrer la liste des contacts", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -135,10 +137,12 @@ result = query.executeCount(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de compter le nombre de contacts filtrés", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -173,10 +177,12 @@ } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de sauvegarder le contact", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -296,7 +302,7 @@ } result = new FileInputStream(file); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible d'exporter les contacts", eee); @@ -304,6 +310,7 @@ if (writer != null) { writer.close(); } + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -492,7 +499,7 @@ transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (ParseException eee) { SuiviObsmerContext.serviceException(transaction, "Erreur ligne " + currRow + " : " + @@ -507,6 +514,8 @@ } SuiviObsmerContext.serviceException(transaction, "Impossible d'importer les contacts", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -66,10 +66,12 @@ results = dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE + " DESC"); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer l'ensemble des news", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -90,10 +92,12 @@ } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer l'ensemble des news", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -80,9 +80,11 @@ results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.FACADE_NAME).execute(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des facades", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -105,9 +107,11 @@ results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.SECTOR_NAME).execute(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des secteurs de pêche", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -140,10 +144,12 @@ results = dao.findAll(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des métiers", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -159,10 +165,12 @@ results = dao.findAll(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des zones de pêche", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -199,12 +207,14 @@ } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Problème d'import du fichier CSV. Vérifiez l'en-tête du fichier : [ PECHE_DIVISION," + "PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de détails.", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -234,10 +234,12 @@ log.debug("commit transaction !"); } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de sauvegarder la ligne d'échantillon", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -314,10 +316,12 @@ result.addRow(row); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -338,10 +342,12 @@ results = (List<String>)query.setSelect("DISTINCT " + SampleRow.PROGRAM_NAME).execute(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des programmes", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -375,10 +381,12 @@ results = dao.findAllByQuery(query); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -394,11 +402,13 @@ result = dao.findByTopiaId(sampleRowId); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger la ligne d'échantillon ayant pour identifiant : " + sampleRowId, eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -416,11 +426,13 @@ dao.delete(row); transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(), eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -432,7 +444,7 @@ return result; } try { - transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction(); + transaction = rootContext.beginTransaction(); Calendar begin = new GregorianCalendar(); begin.setTime(beginDate); @@ -455,11 +467,13 @@ String str = StringUtils.leftPad("" + num, 4, "0"); result = year + "_" + str; - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -574,7 +588,7 @@ transaction.commitTransaction(); } - transaction.closeContext(); + //transaction.closeContext(); } catch (NumberFormatException eee) { SuiviObsmerContext.serviceException(transaction, @@ -588,6 +602,8 @@ SuiviObsmerContext.serviceException(transaction, "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "]", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -37,7 +37,6 @@ import fr.ifremer.suiviobsmer.entity.SampleMonthDAO; import fr.ifremer.suiviobsmer.entity.SampleRow; import fr.ifremer.suiviobsmer.entity.WaoUser; -import fr.ifremer.suiviobsmer.services.ServiceSynthesis; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -131,10 +130,12 @@ } } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -231,11 +232,13 @@ result.setMaxBoardingValue(maxValue.intValue()); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer les données pour le graphique " + "dynamique des efforts de marées", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return result; } @@ -314,7 +317,7 @@ } } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { String msgEnd = ""; if (company != null) { @@ -323,6 +326,8 @@ SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer l'indicateur de non respect du " + "nombre d'observateurs embarqués" + msgEnd, eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -390,7 +395,7 @@ stats.addResult(rowState, rowCount.intValue()); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { String msgEnd = ""; if (company != null) { @@ -399,6 +404,8 @@ SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer les statistiques sur les états des " + "contacts " + msgEnd, eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results.values(); } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java 2010-02-09 01:30:52 UTC (rev 339) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java 2010-02-09 21:55:10 UTC (rev 340) @@ -34,7 +34,6 @@ import fr.ifremer.suiviobsmer.entity.SampleRowLogDAO; import fr.ifremer.suiviobsmer.entity.WaoUser; import fr.ifremer.suiviobsmer.entity.WaoUserDAO; -import fr.ifremer.suiviobsmer.services.ServiceUser; import java.util.ArrayList; import java.util.List; import org.nuiton.topia.TopiaContext; @@ -86,9 +85,11 @@ "Identifiant ou mot de passe incorrects, veuillez réessayer."); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return user; } @@ -131,9 +132,11 @@ } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -210,9 +213,11 @@ } transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -251,9 +256,11 @@ dao.delete(user); transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -273,9 +280,11 @@ dao.update(company); transaction.commitTransaction(); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } } @@ -294,9 +303,11 @@ results = dao.findAll(); } - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; } @@ -317,9 +328,11 @@ results = dao.findAllByQuery(query); - transaction.closeContext(); + //transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee); + } finally { + SuiviObsmerContext.closeTransaction(transaction); } return results; }