Search in sources :

Example 6 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException in project head by mifos.

the class PasswordRules method getPasswordHistoryCountFromConfig.

private static int getPasswordHistoryCountFromConfig() throws ConfigurationException {
    int passwordHistoryCount = 6;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(PASSWORD_HISTORY_COUNT)) {
        passwordHistoryCount = Integer.parseInt(configMgr.getString(PASSWORD_HISTORY_COUNT));
    }
    if (passwordHistoryCount < 1 || passwordHistoryCount > 20) {
        throw new ConfigurationException("The PasswordRules.PasswordHistoryCount defined in the " + MifosConfigurationManager.DEFAULT_CONFIG_PROPS_FILENAME + " must be a number between 0 and 20.");
    }
    return passwordHistoryCount;
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 7 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException in project head by mifos.

the class PasswordRules method getMinPasswordLengthFromConfig.

private static int getMinPasswordLengthFromConfig() throws ConfigurationException {
    int minPasswordLength = 6;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(MIN_PASSWORD_LENGTH)) {
        minPasswordLength = Integer.parseInt(configMgr.getString(MIN_PASSWORD_LENGTH));
    }
    if (minPasswordLength < 3 || minPasswordLength > 20) {
        throw new ConfigurationException("The PasswordRules.MinPasswordLength defined in the " + MifosConfigurationManager.DEFAULT_CONFIG_PROPS_FILENAME + " must be a number between 3 and 20.");
    }
    return minPasswordLength;
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 8 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException in project head by mifos.

the class ProcessFlowRules method initLoanPendingApprovalState.

private static void initLoanPendingApprovalState() throws ConfigurationException {
    LegacyAccountDao ap = ApplicationContextProvider.getBean(LegacyAccountDao.class);
    AccountStateEntity ase = ap.loadPersistentObject(AccountStateEntity.class, AccountState.LOAN_PENDING_APPROVAL.getValue());
    boolean fromDb = isLoanPendingApprovalStateEnabledOnDatabaseConfig(ase);
    boolean fromCfg = isLoanPendingApprovalStateEnabled();
    if (databaseAndCustomConfigurationAreNotTheSame(fromDb, fromCfg)) {
        int count = ApplicationContextProvider.getBean(LegacyLoanDao.class).countOfLoanAccounts();
        if (count > 0) {
            String errMsg = getBadOverrideMsg(LOAN_PENDING_APPROVAL, "Records for loans in the 'pending approval' state" + " may already exist.");
            throw new ConfigurationException(errMsg);
        }
        makeDatabaseConfigurationMatchPropertiesFileConfiguration(ap, ase, fromCfg);
    }
}
Also used : LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao)

Example 9 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrievePossibleGuarantors.

public List<CustomerSearchResultDto> retrievePossibleGuarantors(CustomerSearchDto customerSearchDto, boolean isNewGLIMCreation, Integer clientId, Integer loanId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        List<CustomerSearchResultDto> pagedDetails = new ArrayList<CustomerSearchResultDto>();
        QueryResult customerForSavings = customerPersistence.searchGroupClient(customerSearchDto.getSearchTerm(), userContext.getId(), isNewGLIMCreation);
        int position = (customerSearchDto.getPage() - 1) * customerSearchDto.getPageSize();
        List<AccountSearchResultsDto> pagedResults = customerForSavings.get(position, customerSearchDto.getPageSize());
        int i = 1;
        for (AccountSearchResultsDto customerBO : pagedResults) {
            if (CustomerLevel.getLevel(customerBO.getLevelId()) == CustomerLevel.CLIENT && customerBO.getClientId() != clientId && isApplicableForGuaranty(customerBO, loanId)) {
                CustomerSearchResultDto customer = new CustomerSearchResultDto();
                customer.setCustomerId(customerBO.getClientId());
                customer.setBranchName(customerBO.getOfficeName());
                customer.setGlobalId(customerBO.getGlobelNo());
                customer.setSearchIndex(i);
                customer.setCenterName(StringUtils.defaultIfEmpty(customerBO.getCenterName(), "--"));
                customer.setGroupName(StringUtils.defaultIfEmpty(customerBO.getGroupName(), "--"));
                customer.setClientName(customerBO.getClientName());
                pagedDetails.add(customer);
            }
            i++;
        }
        return pagedDetails;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    } catch (HibernateSearchException e) {
        throw new MifosRuntimeException(e);
    } catch (ConfigurationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) QueryResult(org.mifos.framework.hibernate.helper.QueryResult) AccountSearchResultsDto(org.mifos.accounts.util.helpers.AccountSearchResultsDto) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerSearchResultDto(org.mifos.dto.domain.CustomerSearchResultDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 10 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException in project head by mifos.

the class MessageLookup method lookup.

public String lookup(String lookupKey) {
    String msg;
    try {
        String textMessage = getLabel(lookupKey);
        // we should return the default message from the properties file
        if (StringUtils.isEmpty(textMessage)) {
            Locale locale = personnelServiceFacade.getUserPreferredLocale();
            msg = replaceSubstitutions(messageSource.getMessage(lookupKey, null, lookupKey, locale));
        } else {
            msg = replaceSubstitutions(textMessage);
        }
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
    return msg;
}
Also used : Locale(java.util.Locale) ConfigurationException(org.mifos.config.exceptions.ConfigurationException)

Aggregations

ConfigurationException (org.mifos.config.exceptions.ConfigurationException)18 MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)8 IOException (java.io.IOException)3 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 ArrayList (java.util.ArrayList)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2 FinancialException (org.mifos.accounts.financial.exceptions.FinancialException)2 LegacyLoanDao (org.mifos.accounts.loan.persistance.LegacyLoanDao)2 AccountSearchResultsDto (org.mifos.accounts.util.helpers.AccountSearchResultsDto)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)2 CustomerDao (org.mifos.customers.persistence.CustomerDao)2 CustomerSearchResultDto (org.mifos.dto.domain.CustomerSearchResultDto)2 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)2 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)2 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 Locale (java.util.Locale)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1