r2861 - in trunk/pollen-business/src/main/java/org/chorem/pollen/business: services utils
Author: jruchaud Date: 2010-02-09 15:30:00 +0100 (Tue, 09 Feb 2010) New Revision: 2861 Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java Log: #116 Fermeture de la transaction dans le bloc finally Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -60,7 +60,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -72,6 +71,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -90,7 +91,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -101,6 +101,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -65,7 +65,6 @@ topiaId = choiceEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -75,20 +74,22 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return ""; + } finally { + ContextUtil.doFinally(transaction); } } @Override public List<Choice> createChoices(List<ChoiceDTO> choices, String pollId, - TopiaContext trans) { + TopiaContext transaction) { if (choices.isEmpty() || pollId.length() == 0) { return null; } List<Choice> result = null; try { - choiceDAO = PollenModelDAOHelper.getChoiceDAO(trans); - converter.setTransaction(trans); + choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction); + converter.setTransaction(transaction); result = new ArrayList<Choice>(); for (ChoiceDTO choice : choices) { @@ -101,7 +102,7 @@ return result; } catch (TopiaException e) { - ContextUtil.doCatch(e, trans); + ContextUtil.doCatch(e, transaction); return null; } } @@ -124,7 +125,6 @@ transaction.commitTransaction(); resu = true; } - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + choiceDTO.getId()); @@ -134,6 +134,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -149,7 +151,6 @@ choiceDAO.delete(choiceEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + choiceId); @@ -159,6 +160,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -179,7 +182,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -190,6 +192,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -213,7 +217,6 @@ results = converter.createChoiceDTOs(choiceEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -224,6 +227,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -250,7 +255,6 @@ results = converter.createChoiceDTOs(choiceEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -261,6 +265,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -69,7 +69,6 @@ topiaId = commentEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -79,20 +78,22 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return ""; + } finally { + ContextUtil.doFinally(transaction); } } @Override public List<Comment> createComments(List<CommentDTO> comments, - String pollId, TopiaContext trans) { + String pollId, TopiaContext transaction) { if (comments.isEmpty() || pollId.length() == 0) { return null; } List<Comment> result = null; try { - commentDAO = PollenModelDAOHelper.getCommentDAO(trans); - converter.setTransaction(trans); + commentDAO = PollenModelDAOHelper.getCommentDAO(transaction); + converter.setTransaction(transaction); result = new ArrayList<Comment>(); for (CommentDTO comment : comments) { @@ -104,7 +105,7 @@ return result; } catch (TopiaException e) { - ContextUtil.doCatch(e, trans); + ContextUtil.doCatch(e, transaction); return null; } } @@ -124,7 +125,6 @@ commentDAO.update(commentEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + comment.getId()); @@ -134,6 +134,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -149,7 +151,6 @@ commentDAO.delete(commentEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + commentId); @@ -159,6 +160,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -179,7 +182,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -190,6 +192,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -216,7 +220,6 @@ results = converter.createCommentDTOs(commentEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -227,6 +230,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -90,7 +90,6 @@ topiaId = votingListEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -100,21 +99,23 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return ""; + } finally { + ContextUtil.doFinally(transaction); } } @Override public List<VotingList> createVotingLists(List<VotingListDTO> votingLists, - String pollId, TopiaContext trans) { + String pollId, TopiaContext transaction) { if (votingLists.isEmpty() || pollId.length() == 0) { return null; } List<VotingList> result = null; try { - votingListDAO = PollenModelDAOHelper.getVotingListDAO(trans); + votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction); - votingListConverter.setTransaction(trans); + votingListConverter.setTransaction(transaction); result = new ArrayList<VotingList>(); for (VotingListDTO votingList : votingLists) { @@ -141,7 +142,7 @@ return result; } catch (TopiaException e) { - ContextUtil.doCatch(e, trans); + ContextUtil.doCatch(e, transaction); return null; } } @@ -161,7 +162,6 @@ votingListDAO.update(entity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + votingList.getId()); @@ -171,6 +171,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -186,7 +188,6 @@ votingListDAO.delete(entity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + votingListId); @@ -196,6 +197,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -218,7 +221,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -229,6 +231,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -249,7 +253,6 @@ .createVotingListDTOs(votingListEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -260,6 +263,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -288,7 +293,6 @@ .createVotingListDTOs(votingListEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -299,6 +303,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -327,7 +333,6 @@ topiaId = entity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -337,20 +342,22 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return ""; + } finally { + ContextUtil.doFinally(transaction); } } @Override public boolean createPersonLists(List<PersonListDTO> personLists, - String userId, TopiaContext trans) { + String userId, TopiaContext transaction) { if (personLists.isEmpty() || userId.length() == 0) { return false; } try { - personListDAO = PollenModelDAOHelper.getPersonListDAO(trans); + personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction); - personListConverter.setTransaction(trans); + personListConverter.setTransaction(transaction); for (PersonListDTO personList : personLists) { PersonList entity = personListDAO.create(); @@ -361,7 +368,7 @@ account.setPersonListId(entity.getTopiaId()); } entity.setPollAccount(spa.createPollAccounts(personList - .getPollAccountDTOs(), trans)); + .getPollAccountDTOs(), transaction)); personList.setUserId(userId); personListConverter @@ -370,7 +377,7 @@ return true; } catch (TopiaException e) { - ContextUtil.doCatch(e, trans); + ContextUtil.doCatch(e, transaction); return false; } } @@ -409,7 +416,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + personList.getId()); @@ -419,6 +425,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -434,7 +442,6 @@ personListDAO.delete(entity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + personListId); @@ -444,6 +451,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -468,7 +477,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug(personListEntities.size() @@ -479,6 +487,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -501,7 +511,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -512,6 +521,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -532,7 +543,6 @@ .createPersonListDTOs(personListEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -543,6 +553,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -566,7 +578,6 @@ .createPersonListDTOs(personListEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -577,6 +588,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -605,7 +618,6 @@ .createPersonListDTOs(personListEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -616,6 +628,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -74,7 +74,6 @@ topiaId = pollAccountEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -83,6 +82,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -110,7 +111,6 @@ topiaId = pollAccountEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -120,21 +120,23 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @Override public List<PollAccount> createPollAccounts( - List<PollAccountDTO> pollAccounts, TopiaContext trans) { + List<PollAccountDTO> pollAccounts, TopiaContext transaction) { if (pollAccounts.isEmpty()) { return null; } List<PollAccount> result = null; try { - pollAccountDAO = PollenModelDAOHelper.getPollAccountDAO(trans); + pollAccountDAO = PollenModelDAOHelper.getPollAccountDAO(transaction); - converter.setTransaction(trans); + converter.setTransaction(transaction); result = new ArrayList<PollAccount>(); for (PollAccountDTO pollAccount : pollAccounts) { @@ -151,7 +153,7 @@ return result; } catch (TopiaException e) { - ContextUtil.doCatch(e, trans); + ContextUtil.doCatch(e, transaction); return null; } } @@ -168,7 +170,6 @@ .findByTopiaId(pollAccountId); pollAccountDAO.delete(pollAccountEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + pollAccountId); @@ -178,6 +179,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -203,8 +206,6 @@ resu = true; } - transaction.closeContext(); - if (log.isDebugEnabled()) { log.debug("Entity updated: " + pollAccountDTO.getId()); } @@ -213,6 +214,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -235,7 +238,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -246,6 +248,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -268,7 +272,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -279,6 +282,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -301,7 +306,6 @@ results = converter.createPollAccountDTOs(pollAccountEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -312,6 +316,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -341,7 +347,6 @@ results = converter.createPollAccountDTOs(pollAccountEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -352,6 +357,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -118,7 +118,6 @@ .getPreventRuleDTOs(), topiaId, transaction)); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("creator after creation: " + pollEntity.getCreator()); @@ -131,6 +130,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return ""; + } finally { + ContextUtil.doFinally(transaction); } } @@ -153,7 +154,6 @@ pollDAO.update(pollEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + pollDTO.getId()); @@ -163,6 +163,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -178,7 +180,6 @@ pollDAO.delete(pollEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + pollId); @@ -188,6 +189,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -208,7 +211,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -219,6 +221,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -239,7 +243,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -250,6 +253,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -269,7 +274,6 @@ results = converter.createPollDTOs(pollEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -280,6 +284,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -303,7 +309,6 @@ results = converter.createPollDTOs(pollEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -314,6 +319,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -340,7 +347,6 @@ .createPollDTOs(new ArrayList<Poll>(pollEntities)); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -351,6 +357,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -392,7 +400,6 @@ .createPollDTOs(new ArrayList<Poll>(pollEntities)); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -403,6 +410,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -433,7 +442,6 @@ results = converter.createPollDTOs(pollEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -444,6 +452,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -470,7 +480,6 @@ results = converter.createPollDTOs(pollEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -481,6 +490,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -503,7 +514,6 @@ pollEntity.update(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + pollId); @@ -513,6 +523,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -66,7 +66,6 @@ topiaId = preventRuleEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -76,21 +75,23 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return ""; + } finally { + ContextUtil.doFinally(transaction); } } @Override public List<PreventRule> createPreventRules( - List<PreventRuleDTO> preventRules, String pollId, TopiaContext trans) { + List<PreventRuleDTO> preventRules, String pollId, TopiaContext transaction) { if (preventRules.isEmpty() || pollId.length() == 0) { return null; } List<PreventRule> result = null; try { - preventRuleDAO = PollenModelDAOHelper.getPreventRuleDAO(trans); + preventRuleDAO = PollenModelDAOHelper.getPreventRuleDAO(transaction); - converter.setTransaction(trans); + converter.setTransaction(transaction); result = new ArrayList<PreventRule>(); for (PreventRuleDTO preventRule : preventRules) { @@ -104,7 +105,7 @@ return result; } catch (TopiaException e) { - ContextUtil.doCatch(e, trans); + ContextUtil.doCatch(e, transaction); return null; } } @@ -130,7 +131,6 @@ transaction.commitTransaction(); resu = true; } - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + preventRuleDTO.getId()); @@ -140,6 +140,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -157,7 +159,6 @@ preventRuleDAO.delete(preventRuleEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + preventRuleId); @@ -167,6 +168,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -189,7 +192,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -200,6 +202,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -229,7 +233,6 @@ results = converter.createPreventRuleDTOs(preventRuleEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -240,6 +243,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -132,7 +132,6 @@ // Conversion et trie des résultats List<ResultDTO> list = converter.createResultDTOs(ePoll); - transaction.closeContext(); VoteCountingType voteCountingType = EnumController .getVoteCountingType(ePoll); @@ -176,6 +175,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -234,7 +235,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); // Transformation du sondage PollExportDTO pollExport = new PollExportDTO(); @@ -254,6 +254,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -67,7 +67,6 @@ topiaId = userEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -77,6 +76,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -92,7 +93,6 @@ userDAO.delete(userEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + userEntity.getTopiaId()); @@ -102,6 +102,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -116,7 +118,6 @@ UserAccount userEntity = userDAO.findByTopiaId(user.getId()); userDAO.delete(userEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + userEntity.getTopiaId()); @@ -126,6 +127,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -146,7 +149,6 @@ } transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity found: " @@ -157,6 +159,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -183,7 +187,6 @@ results = converter.createUserDTOs(userEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -194,6 +197,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -212,7 +217,6 @@ userDAO.update(userEntity); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + user.getId()); @@ -222,8 +226,9 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } - } @Override @@ -239,7 +244,6 @@ userEntity.setPassword(newPassword); userEntity.update(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + user.getId()); @@ -249,6 +253,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -264,8 +270,6 @@ userExists = false; } - transaction.closeContext(); - if (log.isDebugEnabled()) { log.debug("Entity exists for the login " + login + ": " + userExists); @@ -273,6 +277,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return true; + } finally { + ContextUtil.doFinally(transaction); } return userExists; } @@ -289,8 +295,6 @@ userExists = false; } - transaction.closeContext(); - if (log.isDebugEnabled()) { log.debug("Entity exists for the email " + email + ": " + userExists); @@ -298,6 +302,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return true; + } finally { + ContextUtil.doFinally(transaction); } return userExists; } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -109,7 +109,6 @@ topiaId = voteEntity.getTopiaId(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity created: " + topiaId); @@ -119,6 +118,8 @@ } catch (Exception eee) { ContextUtil.doCatch(eee, transaction, "Problem when creating vote with pollAccount"); return null; + } finally { + ContextUtil.doFinally(transaction); } } @@ -135,7 +136,6 @@ voteEntity.update(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity updated: " + voteDTO.getId()); @@ -145,6 +145,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -159,7 +161,6 @@ voteEntity.delete(); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entity deleted: " + voteId); @@ -169,6 +170,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return false; + } finally { + ContextUtil.doFinally(transaction); } } @@ -196,7 +199,6 @@ results = converter.createVoteDTOs(voteEntities); transaction.commitTransaction(); - transaction.closeContext(); if (log.isDebugEnabled()) { log.debug("Entities found: " @@ -207,6 +209,8 @@ } catch (TopiaException e) { ContextUtil.doCatch(e, transaction); return null; + } finally { + ContextUtil.doFinally(transaction); } } } \ No newline at end of file Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java 2010-02-09 13:53:44 UTC (rev 2860) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java 2010-02-09 14:30:00 UTC (rev 2861) @@ -314,15 +314,22 @@ if (log.isErrorEnabled()) { log.error("Échec lors du rollback de la transaction", ex); } - } finally { - try { - transaction.closeContext(); - } catch (TopiaException ex) { - if (log.isErrorEnabled()) { - log.error( - "Échec lors de la fermeture de la transaction", - ex); - } + } + } + } + + /** + * Méthode exécutée dans tous les cas pour libérer la transaction. + * + * @param transaction transaction en cours + */ + public static void doFinally(TopiaContext transaction) { + if (transaction != null) { + try { + transaction.closeContext(); + } catch (TopiaException ex) { + if (log.isErrorEnabled()) { + log.error("Échec lors de la fermeture de la transaction", ex); } } }
participants (1)
-
jruchaud@users.chorem.org