BF [2785633] - Adding a Notice in Alert Processor

Surround transaction with try/catch
This commit is contained in:
Carlos Ruiz 2009-05-09 01:31:58 +00:00
parent d39d2a0869
commit 46c49edca8
1 changed files with 24 additions and 17 deletions

View File

@ -263,8 +263,10 @@ public class AlertProcessor extends AdempiereServer
}
}
Trx trx = Trx.get(Trx.createTrxName("AP_NU"), true);
if (user.isNotificationNote()) {
Trx trx = null;
try {
trx = Trx.get(Trx.createTrxName("AP_NU"), true);
// Notice
int AD_Message_ID = 52244; /* Hardcoded message=notes */
MNote note = new MNote(getCtx(), AD_Message_ID, user_id, trx.getTrxName());
@ -279,9 +281,14 @@ public class AlertProcessor extends AdempiereServer
attachment.setTextMsg(message);
attachment.saveEx();
countMail++;
}
trx.commit();
trx.close();
} catch (Throwable e) {
if (trx != null) trx.rollback();
} finally {
if (trx != null) trx.close();
}
}
}
return countMail;
}