Search in sources :

Example 86 with ServiceException

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

the class RolesPermissionsAction method getLoggedUsers.

private List<String> getLoggedUsers(HttpServletRequest request) {
    List<String> loggedUsers = new ArrayList<String>();
    ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName());
    Collection<HttpSession> sessions = shutdownManager.getActiveSessions();
    PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
    for (HttpSession session : sessions) {
        UserContext userContextFromSession = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT);
        if (userContextFromSession == null) {
            continue;
        }
        PersonnelBO personnel;
        try {
            personnel = personnelBusinessService.getPersonnel(userContextFromSession.getId());
        } catch (ServiceException e) {
            continue;
        }
        loggedUsers.add(personnel.getUserName());
    }
    return loggedUsers;
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) HttpSession(javax.servlet.http.HttpSession) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) ShutdownManager(org.mifos.application.admin.system.ShutdownManager)

Example 87 with ServiceException

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

the class LoanBusinessService method getAppllicablePenalties.

public List<ApplicableCharge> getAppllicablePenalties(Integer accountId, UserContext userContext) throws ServiceException {
    List<ApplicableCharge> applicableChargeList = null;
    try {
        LoanBO loan = getlegacyLoanDao().getAccount(accountId);
        applicableChargeList = getLoanApplicablePenalties(getlegacyLoanDao().getAllApplicablePenalties(accountId), userContext, loan);
    } catch (PersistenceException pe) {
        throw new ServiceException(pe);
    }
    addMiscPenalty(applicableChargeList);
    return applicableChargeList;
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) LoanBO(org.mifos.accounts.loan.business.LoanBO) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 88 with ServiceException

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

the class LoanPrdBusinessServiceTest method testInvalidConnectionThrowsExceptionInGetAllLoanOfferings.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionThrowsExceptionInGetAllLoanOfferings() throws PersistenceException {
    try {
        when(loanPrdPersistence.getAllLoanOfferings(localeId)).thenThrow(new PersistenceException("some exception"));
        loanPrdBusinessService.getAllLoanOfferings(localeId);
        Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 89 with ServiceException

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

the class LoanPrdBusinessServiceTest method testInvalidConnectionThrowsExceptionInGetLoanOffering.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionThrowsExceptionInGetLoanOffering() throws PersistenceException {
    try {
        when(loanPrdPersistence.getLoanOffering(new Short("112"))).thenThrow(new PersistenceException("some exception"));
        loanPrdBusinessService.getLoanOffering(new Short("112"));
        Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 90 with ServiceException

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

the class LoanPrdBusinessServiceTest method testInvalidConnectionThrowsExceptionInGetLoanOfferingWithLocaleId.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionThrowsExceptionInGetLoanOfferingWithLocaleId() throws PersistenceException {
    try {
        when(loanPrdPersistence.getLoanOffering(new Short("112"), localeId)).thenThrow(new PersistenceException("some exception"));
        loanPrdBusinessService.getLoanOffering(new Short("112"), localeId);
        Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Aggregations

ServiceException (org.mifos.framework.exceptions.ServiceException)93 PersistenceException (org.mifos.framework.exceptions.PersistenceException)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)39 Test (org.junit.Test)34 ExpectedException (org.springframework.test.annotation.ExpectedException)29 ArrayList (java.util.ArrayList)24 UserContext (org.mifos.security.util.UserContext)19 AccountBO (org.mifos.accounts.business.AccountBO)17 MifosUser (org.mifos.security.MifosUser)16 LoanBO (org.mifos.accounts.loan.business.LoanBO)15 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)14 AccountException (org.mifos.accounts.exceptions.AccountException)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)13 BusinessRuleException (org.mifos.service.BusinessRuleException)11 Date (java.util.Date)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 BigDecimal (java.math.BigDecimal)6 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)6 DateTimeService (org.mifos.framework.util.DateTimeService)6 LocalDate (org.joda.time.LocalDate)5