use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class OutputCommandMaintenanceTx method load.
// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
* Retrieve the domain object.
*/
private OutputCommand load(UOW uow, OutputCommandMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
OutputCommand domain = null;
Criteria criteria = new Criteria();
criteria.setTable(OutputCommandMeta.getName());
// .//GEN-END:_loadUpdate_1_be
// Add custom criteria//GEN-FIRST:_loadUpdate_1
// .//GEN-LAST:_loadUpdate_1
// .//GEN-BEGIN:_loadUpdate_2_be
criteria.addCriteria(OutputCommandMeta.OUTPUT_COMMAND_ID, input.getOutputCommandId());
criteria.setLocking(Criteria.LOCKING_PARANOID);
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext())
domain = (OutputCommand) itr.next();
// .//GEN-BEGIN:_loadUpdate_3_be
if (domain == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new DomainObjectNotFoundException(OutputCommandMeta.getLabelToken()));
throw appExps;
}
return domain;
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class OutputCommandViewerComponent method doInquiry.
// .//GEN-END:_display_2_be
// .//GEN-BEGIN:_inquiry_1_be
private void doInquiry() throws ApplicationExceptions, FrameworkException {
OutputCommandViewerInDto inputDto = new OutputCommandViewerInDto();
// .//GEN-END:_inquiry_1_be
// Add custom code before building the input dto //GEN-FIRST:_inquiry_1
// .//GEN-LAST:_inquiry_1
// .//GEN-BEGIN:_inquiry_2_be
inputDto.setOutputCommandId(m_outputCommandId);
inputDto.setHeaderDto(createHeaderDto());
// create the Tx
if (m_tx == null)
m_tx = (IOutputCommandViewer) Factory.createObject(IOutputCommandViewer.class);
// .//GEN-END:_inquiry_2_be
// Add custom code before invoking the Tx //GEN-FIRST:_inquiry_2
// .//GEN-LAST:_inquiry_2
// .//GEN-BEGIN:_inquiry_3_be
// now get the details
m_outputDto = m_tx.read(inputDto);
// uncache the widgets
getUserSession().getWidgetCache(getComponentId()).clear();
// throw an exception if the output is null
if (m_outputDto == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new DomainObjectNotFoundException(OutputCommandMeta.getLabelToken()));
throw appExps;
}
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class TransactionDependencySweeper method updateTransaction.
/**
* Updated missed Transaction records
* @param tdv
* @param databean
*/
private void updateTransaction(TransactionSweeperView tdv, TransactionDependencySweeper databean) {
UOW innerUow = null;
try {
innerUow = new UOW();
Transaction transaction = Transaction.findByPK(innerUow, tdv.getId());
if (transaction == null) {
log.info("Transaction '" + tdv.getId() + "' not found; cannot update it's status to O");
throw new DomainObjectNotFoundException(TransactionDependencyMeta.getLabelToken());
} else {
transaction.setStatus(Transaction.Status.O.toString());
transactionMessageDAO.save(innerUow, transaction);
innerUow.commit();
}
} catch (Exception e) {
// Write to business event log
MDC.put(BusinessEventLogMeta.SCHEDULED_TASK_ID, databean.getScheduleTaskId());
MDC.put(BusinessEventLogMeta.LOGGED_BY, databean.getLoggedBy());
log.error("Exception thrown during update of Transaction record" + e);
} finally {
if (innerUow != null) {
try {
innerUow.rollback();
} catch (Exception e) {
log.error("Unable to rollback inner UOW in updating Transaction");
}
}
}
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class TransactionDependencySweeper method updateTransactionDependency.
/**
* Updates missed Transaction Dependency records
* @param tdsv
* @param databean
*/
private void updateTransactionDependency(TransactionDependencySweeperView tdsv, TransactionDependencySweeper databean) {
UOW innerUow = null;
try {
innerUow = new UOW();
TransactionDependency transactionDependency = TransactionDependency.findByPK(innerUow, tdsv.getTransactionId(), tdsv.getDependsOnId());
if (transactionDependency == null) {
log.info("TransactionDependency '" + tdsv.getTransactionId() + "/" + tdsv.getDependsOnId() + "' not found; cannot update it's status to S");
throw new DomainObjectNotFoundException(TransactionDependencyMeta.getLabelToken());
} else {
transactionDependency.setStatus(TransactionDependency.Status.S.toString());
transactionMessageDAO.save(innerUow, transactionDependency);
innerUow.commit();
}
} catch (Exception e) {
// Write to business event log
// Sets Log4J's MDC to enable BusinessEventLogging
MDC.put(BusinessEventLogMeta.SCHEDULED_TASK_ID, databean.getScheduleTaskId());
MDC.put(BusinessEventLogMeta.LOGGED_BY, databean.getLoggedBy());
log.error("Exception thrown during update of Transaction Dependency record" + e);
} finally {
if (innerUow != null) {
try {
innerUow.rollback();
} catch (Exception e) {
log.error("Unable to rollback inner UOW in updating Transaction Dependency");
}
}
}
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class TransactionEngine method updateTransactionStatusToError.
/**
* Retrieves the Transaction and update it's status to E.
* NOTE: The processing happens within the scope of a local new UOW.
*
* @param id the Transaction Id.
* @param exception the cause for the error.
* @throws FrameworkException Indicates some system error.
* @throws ApplicationExceptions Indicates application error(s).
*/
public void updateTransactionStatusToError(String id, Exception exception) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
uow = new UOW();
Transaction transaction = getTransaction(uow, id);
if (transaction == null) {
log.error("Transaction '" + id + "' not found; cannot update it's status to E");
throw new DomainObjectNotFoundException(TransactionMeta.getLabelToken());
} else {
if (log.isDebugEnabled()) {
log.debug("Updating Transaction '" + transaction.getId() + "' to status E");
}
transaction.stampError(exception);
getTransactionDAO().save(uow, transaction);
uow.commit();
try {
sendFailureNotification(transaction, exception);
} catch (Exception e) {
log.error("Error in sending transaction failure notification", e);
}
}
} catch (Exception e) {
log.error("Failed to set failed transaction id " + id + " to E", e);
throw ExceptionHelper.throwAFR(e);
} finally {
if (uow != null) {
uow.rollback();
}
}
}
Aggregations