Search in sources :

Example 6 with MandatoryFieldException

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

the class FinderForm method doValidateForSaveQuery.

public boolean doValidateForSaveQuery(HttpServletRequest request) {
    boolean retVal = true;
    String value = null;
    value = getDefaultQueryYnWM().getValue();
    if (value != null && value.trim().length() == 0) {
        setDefaultQueryYn(null);
    } else {
        setDefaultQueryYn(new Boolean(value));
    }
    value = getQueryHasShortcutYnWM().getValue();
    if (value != null && value.trim().length() == 0) {
        setQueryHasShortcutYn(null);
    } else {
        setQueryHasShortcutYn(new Boolean(value));
    }
    // Set the selectedQuery
    value = getNewQueryNameWM().getValue();
    if (value == null || value.trim().length() == 0) {
        // setNewQueryName(null);
        raiseError(request, "NewQueryName", new MandatoryFieldException("Query Name"));
        retVal = false;
    } else {
        setNewQueryName(value.trim());
    }
    return retVal;
}
Also used : MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Example 7 with MandatoryFieldException

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

the class UserTimeEntryViewerComponent method display.

// .//GEN-END:_UserTimeEntryViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
 * This retrieves the details for the UserTimeEntry.
 * @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 (getUserName() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(UserTimeEntryMeta.META_USER_NAME.getLabelToken()));
    }
    if (getProjectCode() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(UserTimeEntryMeta.META_PROJECT_CODE.getLabelToken()));
    }
    if (getTask() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(UserTimeEntryMeta.META_TASK.getLabelToken()));
    }
    if (getPeriodStart() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(UserTimeEntryMeta.META_PERIOD_START.getLabelToken()));
    }
    if (getPeriodEnd() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(UserTimeEntryMeta.META_PERIOD_END.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 8 with MandatoryFieldException

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

the class Attachment method validate.

// .//GEN-END:preUpdate_2_be
// All the custom code goes here//GEN-FIRST:custom
/**
 * {@inheritDoc}
 */
@Override
public void validate() throws ApplicationExceptions, FrameworkException {
    IAttachmentData attachmentDataImpl = AttachmentFactory.getAttachmentDataImpl();
    // Ensure that the attachment is specified
    if (attachmentDataImpl == null) {
        if (getOriginalFileName() == null || ("E".equals(getAttachmentType()) && (getData() == null || getData().length == 0)))
            throw new ApplicationExceptions(new MandatoryFieldException(AttachmentMeta.META_ORIGINAL_FILE_NAME.getLabelToken()));
        // Blank out the uploaded data, if any, for a non-embedded attachment
        if (!"E".equals(getAttachmentType()) && getData() != null) {
            if (log.isDebugEnabled())
                log.debug("Ensuring that the uploaded data, if any, is blanked out for a non-embedded attachment");
            try {
                setData(null);
            } catch (ValidationException e) {
                throw new ApplicationExceptions(e);
            }
        }
    }
    // Generate the technical-key, if required
    if (getAttachmentId() == null) {
        try {
            IVoucherGenerator vg = VoucherGeneratorFactory.instance();
            vg.setUow(getUOW());
            vg.setDomainClassName(getClass().getName());
            vg.setFieldName(AttachmentMeta.ATTACHMENT_ID);
            vg.setLabelToken(AttachmentMeta.META_ATTACHMENT_ID.getLabelToken());
            setAttachmentId(vg.generate());
        } catch (ValidationException e) {
            throw new ApplicationExceptions(e);
        }
    }
    if (getDocumentReferenceId() == null && attachmentDataImpl != null) {
        if (log.isDebugEnabled())
            log.debug("Attachment is stored in external data repository");
        try {
            IVoucherGenerator vg = VoucherGeneratorFactory.instance();
            vg.setUow(getUOW());
            vg.setDomainClassName(getClass().getName());
            vg.setFieldName(AttachmentMeta.DOCUMENT_REFERENCE_ID);
            vg.setLabelToken(AttachmentMeta.META_DOCUMENT_REFERENCE_ID.getLabelToken());
            setDocumentReferenceId(vg.generate());
        } catch (ValidationException e) {
            throw new ApplicationExceptions(e);
        }
    }
    if (getDocumentReferenceId() != null && attachmentDataImpl != null) {
        try {
            setAttachmentType("D");
            // Null out attachment data as it is stored in document repository
            setData(null);
        } catch (ValidationException e) {
            throw new ApplicationExceptions(e);
        }
    }
    super.validate();
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException) IVoucherGenerator(org.jaffa.components.voucher.IVoucherGenerator) IAttachmentData(org.jaffa.components.attachment.apis.IAttachmentData)

Example 9 with MandatoryFieldException

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

the class UserMaintenanceForm method passwordFieldCheck.

/**
 * Perform password checks
 */
private boolean passwordFieldCheck(HttpServletRequest request) {
    boolean valid = true;
    String pass1 = getPassword1WM().getValue();
    if (pass1 != null && pass1.length() == 0)
        pass1 = null;
    pass1 = Parser.parseString(pass1);
    String pass2 = getPassword2WM().getValue();
    if (pass2 != null && pass2.length() == 0)
        pass2 = null;
    pass2 = Parser.parseString(pass2);
    if (pass1 == null && ((UserMaintenanceComponent) getComponent()).isCreateMode()) {
        raiseError(request, UserMeta.META_PASSWORD.getLabelToken(), new MandatoryFieldException(UserMeta.META_PASSWORD.getLabelToken()));
        valid = false;
    }
    if (pass2 == null && ((UserMaintenanceComponent) getComponent()).isCreateMode()) {
        raiseError(request, "[label.Jaffa.Admin.User.VerifyPassword]", new MandatoryFieldException("[label.Jaffa.Admin.User.VerifyPassword]"));
        valid = false;
    }
    if ((pass1 != null && !pass1.equals(pass2)) || (pass2 != null && !pass2.equals(pass1))) {
        raiseError(request, UserMeta.META_PASSWORD.getLabelToken(), new ActionMessage("error.Jaffa.Admin.UserMaintenance.InvalidPassword.Different"));
        valid = false;
    }
    return valid;
}
Also used : MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException) ActionMessage(org.apache.struts.action.ActionMessage)

Example 10 with MandatoryFieldException

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

the class UserViewerComponent method display.

// .//GEN-END:_UserViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
 * This retrieves the details for the User.
 * @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 (getUserName() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(UserMeta.META_USER_NAME.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)

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