Search in sources :

Example 16 with MandatoryFieldException

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

the class SOAEventParam method validate.

// .//GEN-END:performPreDeleteReferentialIntegrity_1_be
// .//GEN-BEGIN:3_be
/**
 * @clientCardinality 0..*
 * @supplierCardinality 1
 * @clientQualifier eventId
 * @supplierQualifier eventId
 * @link association
 */
/*#SOAEvent lnkSOAEvent;*/
// .//GEN-END:3_be
// All the custom code goes here//GEN-FIRST:custom
/**
 * {@inheritDoc}
 */
@Override
public void validate() throws ApplicationExceptions, FrameworkException {
    // Ensure that the eventId is specified
    if (getEventId() == null)
        throw new ApplicationExceptions(new MandatoryFieldException(SOAEventParamMeta.META_EVENT_ID.getLabelToken()));
    // Log a WARNing message if the paramter is not documented in soa-events.xml
    if (getName() != null && isModified(SOAEventParamMeta.NAME)) {
        try {
            SOAEvent soaEvent = getSOAEventObject();
            SoaEventInfo soaEventInfo = ConfigurationService.getInstance().getSoaEventInfo(soaEvent.getEventName());
            if (soaEventInfo != null) {
                boolean foundParam = false;
                for (Param param : soaEventInfo.getParam()) {
                    if (getName().equals(param.getName())) {
                        foundParam = true;
                        break;
                    }
                }
                if (!foundParam)
                    log.warn("SOA Event Parameter'" + soaEvent.getEventName() + ": " + getName() + "' should be documented in soa-events.xml");
            }
        } catch (ValidationException e) {
            throw new ApplicationExceptions(e);
        }
    }
    super.validate();
}
Also used : SoaEventInfo(org.jaffa.soa.services.configdomain.SoaEventInfo) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException) Param(org.jaffa.soa.services.configdomain.Param) SOAEvent(org.jaffa.soa.domain.SOAEvent)

Example 17 with MandatoryFieldException

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

the class PersistentHelper method checkMandatoryFields.

/**
 * This will check all the mandatory fields of the persistent object.
 * It utilises the corresponding Meta class for determining the mandatory fields.
 * @param object The persistent object.
 * @throws ApplicationExceptions Will contain a collection of MandatoryFieldExceptions for the all the mandatory fields which do not have values.
 * @throws FrameworkException If any framework error occurs.
 */
public static void checkMandatoryFields(IPersistent object) throws ApplicationExceptions, FrameworkException {
    try {
        FieldMetaData[] fields = getMandatoryFields(object.getClass().getName());
        if (fields != null && fields.length > 0) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            for (int i = 0; i < fields.length; i++) {
                FieldMetaData fieldMetaData = fields[i];
                Object fieldValue = BeanHelper.getField(object, fieldMetaData.getName());
                if (fieldValue == null || (fieldValue instanceof String && ((String) fieldValue).length() == 0)) {
                    if (log.isDebugEnabled())
                        log.debug("Mandatory validation failed for the field " + fieldMetaData.getName());
                    appExps.add(new MandatoryFieldException(fieldMetaData.getLabelToken()));
                }
            }
            if (appExps.size() > 0)
                throw appExps;
        }
    } catch (ClassNotFoundException e) {
        String str = "Exception thrown while validating the domain object " + object;
        log.error(str, e);
        throw new DomainObjectValidationException(null, e);
    } catch (NoSuchMethodException e) {
        String str = "Exception thrown while validating the domain object " + object;
        log.error(str, e);
        throw new DomainObjectValidationException(null, e);
    } catch (IllegalAccessException e) {
        String str = "Exception thrown while validating the domain object " + object;
        log.error(str, e);
        throw new DomainObjectValidationException(null, e);
    } catch (InvocationTargetException e) {
        String str = "Exception thrown while validating the domain object " + object;
        log.error(str, e);
        throw new DomainObjectValidationException(null, e);
    }
}
Also used : FieldMetaData(org.jaffa.metadata.FieldMetaData) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException) DomainObjectValidationException(org.jaffa.persistence.exceptions.DomainObjectValidationException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 18 with MandatoryFieldException

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

the class AttachmentViewerComponent method display.

// .//GEN-END:_AttachmentViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
 * This retrieves the details for the Attachment.
 * @throws ApplicationExceptions This will be thrown in case any invalid data has been set, or if no data has been set.
 * @throws FrameworkException Indicates some system error.
 * @return The FormKey for the View screen.
 */
public FormKey display() throws ApplicationExceptions, FrameworkException {
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_display_2_be
    if (getAttachmentId() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(AttachmentMeta.META_ATTACHMENT_ID.getLabelToken()));
    }
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    doInquiry();
    return getViewerFormKey();
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Example 19 with MandatoryFieldException

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

the class MandatoryFieldValidator method validate.

/**
 * The RulesEngine will invoke this method to perform the field validation.
 * @throws ValidationException if any validation rule fails.
 * @throws FrameworkException if any framework error occurs.
 */
public void validate() throws ValidationException, FrameworkException {
    Object value = getValue();
    if (value == null || (value instanceof String && ((String) value).trim().length() == 0)) {
        MandatoryFieldException e = new MandatoryFieldException(getLabelToken());
        log.error(null, e);
        throw e;
    }
}
Also used : MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Example 20 with MandatoryFieldException

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

the class FormGroupMaintenanceComponent method doCreate.

// .//GEN-END:_retrieveFormUsage_1_be
// .//GEN-BEGIN:_doCreate_1_be
/**
 * This will invoke the create method on the transaction to create a new domain object.
 * @throws ApplicationExceptions Indicates some functional error.
 * @throws FrameworkException Indicates some system error.
 */
protected void doCreate() throws ApplicationExceptions, FrameworkException {
    FormGroupMaintenanceCreateInDto input = new FormGroupMaintenanceCreateInDto();
    if (getFormType() == null || getFormType().trim().equals("")) {
        throw new ApplicationExceptions(new MandatoryFieldException(FormGroupMeta.META_FORM_TYPE.getLabelToken()));
    }
    // .//GEN-LAST:_doCreate_1
    // .//GEN-BEGIN:_doCreate_2_be
    input.setHeaderDto(getHeaderDto());
    input.setFormName(getFormName());
    input.setDescription(getDescription());
    input.setFormType(getFormType());
    FormGroupMaintenanceRetrieveOutDto output = createTx().create(input);
    loadRetrieveOutDto(output);
// .//GEN-END:_doCreate_2_be
// Add custom code//GEN-FIRST:_doCreate_2
// .//GEN-LAST:_doCreate_2
// .//GEN-BEGIN:_doCreate_3_be
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Aggregations

MandatoryFieldException (org.jaffa.datatypes.exceptions.MandatoryFieldException)31 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)22 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ActionMessage (org.apache.struts.action.ActionMessage)2 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)2 Iterator (java.util.Iterator)1 IAttachmentData (org.jaffa.components.attachment.apis.IAttachmentData)1 IVoucherGenerator (org.jaffa.components.voucher.IVoucherGenerator)1 org.jaffa.datatypes (org.jaffa.datatypes)1 ApplicationException (org.jaffa.exceptions.ApplicationException)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 FieldMetaData (org.jaffa.metadata.FieldMetaData)1 FormSelectionMaintenanceInDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceInDto)1 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)1 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)1 DomainObjectValidationException (org.jaffa.persistence.exceptions.DomainObjectValidationException)1 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)1 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)1 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)1 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)1