Search in sources :

Example 26 with DomainObjectNotFoundException

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;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) OutputCommand(org.jaffa.modules.printing.domain.OutputCommand) Criteria(org.jaffa.persistence.Criteria)

Example 27 with DomainObjectNotFoundException

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;
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) IOutputCommandViewer(org.jaffa.modules.printing.components.outputcommandviewer.IOutputCommandViewer) OutputCommandViewerInDto(org.jaffa.modules.printing.components.outputcommandviewer.dto.OutputCommandViewerInDto)

Example 28 with DomainObjectNotFoundException

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");
            }
        }
    }
}
Also used : Transaction(org.jaffa.transaction.domain.Transaction) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) UOW(org.jaffa.persistence.UOW) FrameworkException(org.jaffa.exceptions.FrameworkException) ApplicationException(org.jaffa.exceptions.ApplicationException) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException)

Example 29 with DomainObjectNotFoundException

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");
            }
        }
    }
}
Also used : DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) UOW(org.jaffa.persistence.UOW) TransactionDependency(org.jaffa.transaction.domain.TransactionDependency) FrameworkException(org.jaffa.exceptions.FrameworkException) ApplicationException(org.jaffa.exceptions.ApplicationException) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException)

Example 30 with DomainObjectNotFoundException

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();
        }
    }
}
Also used : Transaction(org.jaffa.transaction.domain.Transaction) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) UOW(org.jaffa.persistence.UOW) DomainObjectChangedException(org.jaffa.exceptions.DomainObjectChangedException) FrameworkException(org.jaffa.exceptions.FrameworkException) MessagingException(javax.mail.MessagingException) ApplicationException(org.jaffa.exceptions.ApplicationException) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException)

Aggregations

DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)62 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)57 Criteria (org.jaffa.persistence.Criteria)39 FrameworkException (org.jaffa.exceptions.FrameworkException)10 ApplicationException (org.jaffa.exceptions.ApplicationException)9 Method (java.lang.reflect.Method)6 UOW (org.jaffa.persistence.UOW)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Iterator (java.util.Iterator)5 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 IPersistent (org.jaffa.persistence.IPersistent)5 MultipleDomainObjectsFoundException (org.jaffa.exceptions.MultipleDomainObjectsFoundException)4 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)4 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)4 HashMap (java.util.HashMap)3 User (org.jaffa.applications.jaffa.modules.admin.domain.User)3 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)3 UserTimeEntry (org.jaffa.applications.test.modules.time.domain.UserTimeEntry)3 GraphMapping (org.jaffa.beans.moulding.mapping.GraphMapping)3