Search in sources :

Example 1 with FrameworkRuntimeException

use of org.mifos.framework.exceptions.FrameworkRuntimeException in project head by mifos.

the class LoanAccountActionForm method validateRedoLoanPayments.

private void validateRedoLoanPayments(HttpServletRequest request, ActionErrors errors, MifosCurrency currency) {
    Locale locale = getUserContext(request).getPreferredLocale();
    try {
        CustomerBO customer = getCustomer(request);
        List<PaymentDataHtmlBean> validPaymentBeans = getValidatablePaymentBeans();
        for (PaymentDataHtmlBean bean : validPaymentBeans) {
            validatePaymentDataHtmlBean(errors, currency, locale, customer, bean);
        }
        validatePaymentDatesOrdering(validPaymentBeans, errors);
        validateMaxPayableAmount(request, errors);
    } catch (InvalidDateException invalidDate) {
        errors.add(LoanExceptionConstants.INVALIDTRANSACTIONDATE, new ActionMessage(LoanExceptionConstants.INVALIDTRANSACTIONDATE));
    } catch (FrameworkRuntimeException invalidDate) {
        errors.add(LoanExceptionConstants.INVALIDTRANSACTIONDATE, new ActionMessage(LoanExceptionConstants.INVALIDTRANSACTIONDATE));
    } catch (MeetingException e) {
        errors.add(ExceptionConstants.FRAMEWORKRUNTIMEEXCEPTION, new ActionMessage(ExceptionConstants.FRAMEWORKRUNTIMEEXCEPTION));
    } catch (PageExpiredException e) {
        errors.add(ExceptionConstants.PAGEEXPIREDEXCEPTION, new ActionMessage(ExceptionConstants.PAGEEXPIREDEXCEPTION));
    } catch (PersistenceException e) {
        errors.add(ExceptionConstants.FRAMEWORKRUNTIMEEXCEPTION, new ActionMessage(ExceptionConstants.FRAMEWORKRUNTIMEEXCEPTION));
    }
}
Also used : Locale(java.util.Locale) FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) PaymentDataHtmlBean(org.mifos.accounts.loan.struts.uihelpers.PaymentDataHtmlBean) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerBO(org.mifos.customers.business.CustomerBO)

Example 2 with FrameworkRuntimeException

use of org.mifos.framework.exceptions.FrameworkRuntimeException in project head by mifos.

the class DateUtils method getDate.

public static Date getDate(String value, Locale dateLocale, String formatStr) {
    if (value != null && !value.equals("")) {
        try {
            SimpleDateFormat format = new SimpleDateFormat(formatStr, dateLocale);
            format.setLenient(false);
            return format.parse(value);
        } catch (Exception e) {
            throw new FrameworkRuntimeException(e);
        }
    }
    return null;
}
Also used : FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException) SimpleDateFormat(java.text.SimpleDateFormat) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ParseException(java.text.ParseException) FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException)

Example 3 with FrameworkRuntimeException

use of org.mifos.framework.exceptions.FrameworkRuntimeException in project head by mifos.

the class DateUtils method getUserLocaleDate.

public static String getUserLocaleDate(String databaseDate) {
    if (internalLocale != null && databaseDate != null && !databaseDate.equals("")) {
        try {
            SimpleDateFormat shortFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, internalLocale);
            String userfmt = convertToCurrentDateFormat(shortFormat.toPattern());
            return convertDbToUserFmt(databaseDate, userfmt);
        } catch (FrameworkRuntimeException e) {
            throw e;
        } catch (Exception e) {
            System.out.println("databaseDate=" + databaseDate + ", locale=" + internalLocale);
            throw new FrameworkRuntimeException(e);
        }
    } else {
        return "";
    }
}
Also used : FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException) SimpleDateFormat(java.text.SimpleDateFormat) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ParseException(java.text.ParseException) FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException)

Example 4 with FrameworkRuntimeException

use of org.mifos.framework.exceptions.FrameworkRuntimeException in project head by mifos.

the class DateUtils method getLocaleDate.

public static java.sql.Date getLocaleDate(String value) {
    if (internalLocale != null && value != null && !value.equals("")) {
        try {
            SimpleDateFormat shortFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, internalLocale);
            shortFormat.setLenient(false);
            String userPattern = shortFormat.toPattern();
            String dbDate = convertUserToDbFmt(value, userPattern);
            return java.sql.Date.valueOf(dbDate);
        } catch (RuntimeException alreadyRuntime) {
            throw alreadyRuntime;
        } catch (Exception e) {
            throw new FrameworkRuntimeException(e);
        }
    } else {
        return null;
    }
}
Also used : FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException) FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException) SimpleDateFormat(java.text.SimpleDateFormat) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ParseException(java.text.ParseException) FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException)

Example 5 with FrameworkRuntimeException

use of org.mifos.framework.exceptions.FrameworkRuntimeException in project head by mifos.

the class DateUtils method getUserLocaleDate.

public static String getUserLocaleDate(Locale locale, String databaseDate) {
    // the following line is for 1.1 release and will be removed when date
    // is localized
    locale = internalLocale;
    if (locale != null && databaseDate != null && !databaseDate.equals("")) {
        try {
            SimpleDateFormat shortFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale);
            String userfmt = convertToCurrentDateFormat(shortFormat.toPattern());
            return convertDbToUserFmt(databaseDate, userfmt);
        } catch (FrameworkRuntimeException e) {
            throw e;
        } catch (Exception e) {
            System.out.println("databaseDate=" + databaseDate + ", locale=" + locale);
            throw new FrameworkRuntimeException(e);
        }
    } else {
        return "";
    }
}
Also used : FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException) SimpleDateFormat(java.text.SimpleDateFormat) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ParseException(java.text.ParseException) FrameworkRuntimeException(org.mifos.framework.exceptions.FrameworkRuntimeException)

Aggregations

InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)5 FrameworkRuntimeException (org.mifos.framework.exceptions.FrameworkRuntimeException)5 ParseException (java.text.ParseException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Locale (java.util.Locale)1 ActionMessage (org.apache.struts.action.ActionMessage)1 PaymentDataHtmlBean (org.mifos.accounts.loan.struts.uihelpers.PaymentDataHtmlBean)1 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1