Search in sources :

Example 71 with ApplicationException

use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.

the class UserTimeEntryMaintenanceTx method prevalidateCreate.

// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_prevalidateCreate_1_be
/**
 * This method is used to perform prevalidations before creating a new instance of UserTimeEntry.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public UserTimeEntryMaintenancePrevalidateOutDto prevalidateCreate(UserTimeEntryMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + input);
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Do not allow a Duplicate record
        duplicateCheck(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Create the domain object
        UserTimeEntry domain = createDomain(uow, input, true);
        // Perform post create processing
        postCreate(uow, input, domain, true);
        // Build the outbound dto
        UserTimeEntryMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + output);
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) UOW(org.jaffa.persistence.UOW)

Example 72 with ApplicationException

use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.

the class TestSupport method executeValidator.

/**
 * Executes a validator and confirms the correct exception is thrown with the field label
 *
 * @param validator  The validator to execute
 * @param persistent The target object of the validator
 * @param fieldName  The Field Name label
 * @param clazz      The class of the expected exception
 * @throws FrameworkException
 */
protected void executeValidator(RuleValidator validator, Object persistent, String fieldName, Class clazz) throws ApplicationException, FrameworkException {
    String actualLabel = null;
    ApplicationException exception = null;
    try {
        validator.validate(persistent);
    } catch (ApplicationException e) {
        actualLabel = (String) e.getArguments()[0];
        exception = e;
    }
    assertEquals(fieldName, actualLabel);
    assertTrue(clazz.isInstance(exception));
}
Also used : ApplicationException(org.jaffa.exceptions.ApplicationException)

Example 73 with ApplicationException

use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.

the class FormSelectionMaintenanceComponent method validateFields.

protected void validateFields(GridModelRow row, ApplicationExceptions appExps, boolean showForm) throws ApplicationExceptions, FrameworkException {
    String additionalComponent = null;
    CheckBoxModel checkBoxModel = (CheckBoxModel) row.get("select");
    if ((checkBoxModel != null && checkBoxModel.getState()) || showForm) {
        // Check copies are greater then zero
        EditBoxModel mCopies = (EditBoxModel) row.get("copies");
        if (mCopies != null && !showForm) {
            if (mCopies.getValue() != null && mCopies.getValue().length() > 0) {
                int iCopies = Integer.parseInt(mCopies.getValue());
                if (iCopies < 1) {
                    appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
                }
            } else {
                appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
            }
        }
        if (!showForm) {
            // check either printer, email or publish has value
            EditBoxModel mPrinter = (EditBoxModel) row.get("printer");
            EditBoxModel mEmail = (EditBoxModel) row.get("email");
            CheckBoxModel mPublish = (CheckBoxModel) row.get("publish");
            String formName = row.get("formName") != null ? (String) row.get("formName") : "";
            if ((mPrinter.getValue() == null) && (mEmail.getValue() == null) && (mPublish.getState() != true)) {
                appExps.add(new FormSelectionException(FormSelectionException.INVALID_OUTPUT_DESTINATION, formName));
            }
        }
        // Validate AdditionalData exist or not
        try {
            FormSelectionMaintenanceOutRowDto rowDto = (FormSelectionMaintenanceOutRowDto) row.get("object");
            additionalComponent = rowDto.getAdditionalDataComponent();
            if (additionalComponent != null) {
                Component comp = (Component) run(additionalComponent);
                BeanUtils.setProperty(comp, getKey1(), getValue1());
                if (getKey2() != null) {
                    BeanUtils.setProperty(comp, getKey2(), getValue2());
                }
                if (getKey3() != null) {
                    BeanUtils.setProperty(comp, getKey3(), getValue3());
                }
                if (getKey4() != null) {
                    BeanUtils.setProperty(comp, getKey4(), getValue4());
                }
                if (getKey5() != null) {
                    BeanUtils.setProperty(comp, getKey5(), getValue5());
                }
                if (getKey6() != null) {
                    BeanUtils.setProperty(comp, getKey6(), getValue6());
                }
                if (comp instanceof IAdditionalData) {
                    ((IAdditionalData) comp).validate();
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Additional Data Interface not implemented ");
                    }
                }
            }
        } catch (SecurityException se) {
            log.error("SecurityException Occurred ", se);
            appExps.add(new FormSelectionException(FormSelectionException.SECURITY_EXCEPTION));
        } catch (IllegalAccessException e) {
            log.error("IllegalAccessException Occurred ", e);
        } catch (InvocationTargetException e) {
            log.error("InvocationTargetException Occurred ", e);
        } catch (IllegalArgumentException e) {
            log.error("IllegalArgumentException Occurred ", e);
        } catch (ApplicationExceptions applicationException) {
            log.debug("Catch : Application Exception from additional data component");
            if (applicationException != null && applicationException.size() > 0) {
                for (Iterator i = applicationException.iterator(); i.hasNext(); ) {
                    ApplicationException appEx = (ApplicationException) i.next();
                    appExps.add(appEx);
                }
            }
        } catch (FrameworkException frameworkException) {
            throw frameworkException;
        }
    }
}
Also used : FormSelectionException(org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) org.jaffa.components.maint(org.jaffa.components.maint) InvocationTargetException(java.lang.reflect.InvocationTargetException) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel) ApplicationException(org.jaffa.exceptions.ApplicationException) FormSelectionMaintenanceOutRowDto(org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto) EditBoxModel(org.jaffa.presentation.portlet.widgets.model.EditBoxModel) Iterator(java.util.Iterator) IAdditionalData(org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalData) Component(org.jaffa.presentation.portlet.component.Component) RiaWrapperComponent(org.jaffa.presentation.portlet.component.RiaWrapperComponent)

Example 74 with ApplicationException

use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.

the class FormGroupMaintenanceTx method delete.

// .//GEN-END:_update_1_be
// .//GEN-BEGIN:_delete_1_be
/**
 * Deletes an existing instance of FormGroup.
 * @param input The key values for the domain object to be deleted.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 */
public void delete(FormGroupMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // create the UOW
        uow = new UOW();
        // invoke the delete passing the UOW
        delete(input, uow);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully deleted the domain object");
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 75 with ApplicationException

use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.

the class FormGroupMaintenanceTx method prevalidateUpdate.

// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
 * This method is used to perform prevalidations before updating an existing instance of FormGroup.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public FormGroupMaintenancePrevalidateOutDto prevalidateUpdate(FormGroupMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + input);
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        FormGroup domain = load(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, true);
        // Build the outbound dto
        FormGroupMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + output);
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormGroup(org.jaffa.modules.printing.domain.FormGroup) UOW(org.jaffa.persistence.UOW)

Aggregations

ApplicationException (org.jaffa.exceptions.ApplicationException)125 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)114 FrameworkException (org.jaffa.exceptions.FrameworkException)97 UOW (org.jaffa.persistence.UOW)79 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)11 Criteria (org.jaffa.persistence.Criteria)11 Method (java.lang.reflect.Method)10 Iterator (java.util.Iterator)10 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 GraphMapping (org.jaffa.beans.moulding.mapping.GraphMapping)6 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)6 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)6 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)6 User (org.jaffa.applications.jaffa.modules.admin.domain.User)5 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)5 UserTimeEntry (org.jaffa.applications.test.modules.time.domain.UserTimeEntry)5 Attachment (org.jaffa.components.attachment.domain.Attachment)5