Search in sources :

Example 16 with ResourceBundle

use of java.util.ResourceBundle in project head by mifos.

the class UTF8Control method newBundle.

public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) ResourceBundle(java.util.ResourceBundle) PropertyResourceBundle(java.util.PropertyResourceBundle) URL(java.net.URL) URLConnection(java.net.URLConnection) PropertyResourceBundle(java.util.PropertyResourceBundle)

Example 17 with ResourceBundle

use of java.util.ResourceBundle in project head by mifos.

the class ViewStageTransactionActionForm method mandatoryCheckForAudit.

private ActionErrors mandatoryCheckForAudit(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    String audit = resources.getString(SimpleAccountingConstants.AUDIT);
    String audit_comments = resources.getString(SimpleAccountingConstants.AUDIT_COMMENTS);
    ActionErrors errors = new ActionErrors();
    if (getAudit() == null || "".equals(getAudit())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, audit));
    } else if (getAuditComments() == null || "".equals(getAuditComments())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, audit_comments));
    }
    return errors;
}
Also used : Locale(java.util.Locale) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle) ActionErrors(org.apache.struts.action.ActionErrors)

Example 18 with ResourceBundle

use of java.util.ResourceBundle in project head by mifos.

the class VoucherBranchMappingActionForm method trxnDateValidate.

private ActionErrors trxnDateValidate(ActionErrors errors, Locale locale) {
    if (StringUtils.isNotBlank(getTransactiondate()) && !DateUtils.isValidDate(getTransactiondate())) {
        ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
        String trxnDate = resources.getString(SimpleAccountingConstants.TRXNDATE);
        errors.add(SimpleAccountingConstants.INVALID_TRXN_DATE, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxnDate));
    }
    return errors;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Example 19 with ResourceBundle

use of java.util.ResourceBundle in project head by mifos.

the class VoucherBranchMappingActionForm method mandatoryCheck.

private ActionErrors mandatoryCheck(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    ActionErrors errors = new ActionErrors();
    String branchname = resources.getString(SimpleAccountingConstants.BRANCH_NAME);
    String Amount = resources.getString(SimpleAccountingConstants.AMOUNT);
    String trxn_Type = resources.getString(SimpleAccountingConstants.TRXNTYPE);
    String main_Account = resources.getString(SimpleAccountingConstants.MAIN_ACCOUNT);
    String Notes = resources.getString(SimpleAccountingConstants.TRXN_NOTES);
    String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
    String[] amts = getAmount();
    String[] trannotes = getTransactionnotes();
    // String[] canames=getCoaname();
    List<CoaNamesDto> coaNamesDtolist = new ArrayList<CoaNamesDto>();
    if (amts.length < 0 || "".equals(amts)) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
    }
    for (int i = 0; i < amts.length; i++) {
        if (amts[i].equalsIgnoreCase("0")) {
            errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
        }
    }
    if (trannotes == null || "".equals(trannotes)) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Notes));
    }
    {
        for (int i = 0; i < getAmount().length; i++) {
            CoaNamesDto coanamesob = new CoaNamesDto();
            coanamesob.setAmount(amts[i]);
            coanamesob.setTrxnnotes(trannotes[i]);
            // coanamesob.setCoaName(canames[i]);
            coaNamesDtolist.add(coanamesob);
        }
    }
    java.sql.Date currentDate = null;
    try {
        currentDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), DateUtils.getCurrentDate(userContext.getPreferredLocale()));
    } catch (InvalidDateException ide) {
        errors.add(SimpleAccountingConstants.INVALIDDATE, new ActionMessage(SimpleAccountingConstants.INVALIDDATE));
    }
    java.sql.Date trxnDate = null;
    if (getTransactiondate() == null || "".equals(getTransactiondate())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, trxn_Date));
    } else if (getTransactiondate() != null && !getTransactiondate().equals("") && !DateUtils.isValidDate(getTransactiondate())) {
        errors = trxnDateValidate(errors, locale);
    } else if (DateUtils.isValidDate(getTransactiondate())) {
        try {
            trxnDate = DateUtils.getDateAsSentFromBrowser(getTransactiondate());
        } catch (InvalidDateException ide) {
            errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxn_Date));
        }
        if (trxnDate.compareTo(currentDate) > 0) {
            errors.add(SimpleAccountingConstants.INVALID_FUTURE, new ActionMessage(SimpleAccountingConstants.INVALID_FUTURE, trxn_Date));
        }
    }
    if (getBranch() == null || "".equals(getBranch())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, branchname));
    }
    if (transactiontype == null || "".equals(transactiontype.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, trxn_Type));
    }
    if (mainAccount == null || "".equals(mainAccount.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, main_Account));
    }
    return errors;
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) ActionErrors(org.apache.struts.action.ActionErrors) CoaNamesDto(org.mifos.dto.domain.CoaNamesDto) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Example 20 with ResourceBundle

use of java.util.ResourceBundle in project head by mifos.

the class ConsolidatedTransactionActionForm method mandatoryCheck.

private ActionErrors mandatoryCheck(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
    String officeId = resources.getString(SimpleAccountingConstants.OFFICE);
    ActionErrors errors = new ActionErrors();
    if (branch == null || "".equals(branch.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, officeId));
    }
    return errors;
}
Also used : Locale(java.util.Locale) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle) ActionErrors(org.apache.struts.action.ActionErrors)

Aggregations

ResourceBundle (java.util.ResourceBundle)605 Locale (java.util.Locale)80 MissingResourceException (java.util.MissingResourceException)80 HashMap (java.util.HashMap)41 ArrayList (java.util.ArrayList)36 ActionMessage (org.apache.struts.action.ActionMessage)29 Test (org.junit.Test)29 File (java.io.File)27 IOException (java.io.IOException)27 Enumeration (java.util.Enumeration)24 PropertyResourceBundle (java.util.PropertyResourceBundle)22 Preferences (java.util.prefs.Preferences)20 URL (java.net.URL)19 Map (java.util.Map)19 HashSet (java.util.HashSet)17 Set (java.util.Set)16 Iterator (java.util.Iterator)15 ListResourceBundle (java.util.ListResourceBundle)14 Engine (jgnash.engine.Engine)14 SSOException (com.iplanet.sso.SSOException)13