Search in sources :

Example 6 with ShutdownManager

use of org.mifos.application.admin.system.ShutdownManager in project head by mifos.

the class ShutdownServiceFacadeWebTier method scheduleShutdown.

@Override
public void scheduleShutdown(HttpServletRequest request, long timeout) {
    ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName());
    shutdownManager.scheduleShutdown(timeout);
}
Also used : ShutdownManager(org.mifos.application.admin.system.ShutdownManager)

Example 7 with ShutdownManager

use of org.mifos.application.admin.system.ShutdownManager in project head by mifos.

the class MifosMockStrutsTestCase method beforeStrutsTest.

@Before
public void beforeStrutsTest() throws Exception {
    mockStruts.setUp();
    if (!strutsConfigSet) {
        setStrutsConfig();
        strutsConfigSet = true;
    }
    getActionServlet().getServletContext().setAttribute(ShutdownManager.class.getName(), new ShutdownManager());
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
}
Also used : SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) ShutdownManager(org.mifos.application.admin.system.ShutdownManager) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Before(org.junit.Before)

Example 8 with ShutdownManager

use of org.mifos.application.admin.system.ShutdownManager 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 9 with ShutdownManager

use of org.mifos.application.admin.system.ShutdownManager in project head by mifos.

the class BaseAction method execute.

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    configureDaoBeans();
    configureServiceFacadeBeans();
    configureLegacyDaoBeans();
    checkLocaleContext(request);
    if (MifosBatchJob.isBatchJobRunningThatRequiresExclusiveAccess()) {
        return logout(mapping, request);
    }
    ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName());
    if (shutdownManager.isShutdownDone()) {
        return shutdown(mapping, request);
    }
    if (shutdownManager.isInShutdownCountdownNotificationThreshold()) {
        request.setAttribute("shutdownIsImminent", true);
    }
    if (null != request.getSession().getAttribute("currentPageUrl")) {
        SessionUtils.setAttribute("backPageUrl", UrlHelper.constructCurrentPageUrl(request), request);
    }
    boolean flag = AccountingRules.getSimpleAccountingStatus();
    request.getSession().setAttribute("accountingActivationStatus", flag);
    TransactionDemarcate annotation = getTransaction(form, request);
    preExecute(form, request, annotation);
    ActionForward forward = super.execute(mapping, form, request, response);
    try {
        request.getSession().setAttribute("previousPageUrl", UrlHelper.constructCurrentPageUrl(request));
    } catch (Exception e) {
        request.setAttribute("previousPageUrl", "");
    }
    // TODO: passing 'true' to postExecute guarantees that the session will
    // be closed still working through resolving issues related to enforcing
    // this postExecute(request, annotation, true);
    postExecute(request, annotation, isCloseSessionAnnotationPresent(form, request));
    return forward;
}
Also used : ShutdownManager(org.mifos.application.admin.system.ShutdownManager) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate) ActionForward(org.apache.struts.action.ActionForward) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) SystemException(org.mifos.framework.exceptions.SystemException) ValueObjectConversionException(org.mifos.framework.exceptions.ValueObjectConversionException) HibernateException(org.hibernate.HibernateException) ServiceException(org.mifos.framework.exceptions.ServiceException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException)

Example 10 with ShutdownManager

use of org.mifos.application.admin.system.ShutdownManager in project head by mifos.

the class ApplicationInitializer method setAttributesOnContext.

public void setAttributesOnContext(ServletContext servletContext) throws TaskSystemException {
    // FIXME: replace with Spring-managed beans
    final MifosScheduler mifosScheduler = new MifosScheduler();
    final ShutdownManager shutdownManager = new ShutdownManager();
    Configuration.getInstance();
    configureAuditLogValues(Localization.getInstance().getConfiguredLocale());
    LocaleSetting configLocale = new LocaleSetting();
    @SuppressWarnings("deprecation") final UserLocale userLocale = new UserLocale(ApplicationContextProvider.getBean(PersonnelServiceFacade.class));
    if (servletContext != null) {
        mifosScheduler.initialize();
        servletContext.setAttribute(MifosScheduler.class.getName(), mifosScheduler);
        servletContext.setAttribute(ShutdownManager.class.getName(), shutdownManager);
        servletContext.setAttribute(LocaleSetting.class.getSimpleName(), configLocale);
        servletContext.setAttribute(UserLocale.class.getSimpleName(), userLocale);
    }
}
Also used : LocaleSetting(org.mifos.config.LocaleSetting) ShutdownManager(org.mifos.application.admin.system.ShutdownManager) PersonnelServiceFacade(org.mifos.application.admin.servicefacade.PersonnelServiceFacade) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler) UserLocale(org.mifos.config.UserLocale)

Aggregations

ShutdownManager (org.mifos.application.admin.system.ShutdownManager)11 HttpSession (javax.servlet.http.HttpSession)4 ServiceException (org.mifos.framework.exceptions.ServiceException)3 UserContext (org.mifos.security.util.UserContext)3 ArrayList (java.util.ArrayList)2 ServletContext (javax.servlet.ServletContext)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ActionForward (org.apache.struts.action.ActionForward)1 HibernateException (org.hibernate.HibernateException)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1 Before (org.junit.Before)1 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)1 LoggedUserDto (org.mifos.application.admin.servicefacade.LoggedUserDto)1 PersonnelServiceFacade (org.mifos.application.admin.servicefacade.PersonnelServiceFacade)1 PersonnelInfo (org.mifos.application.admin.system.PersonnelInfo)1 MifosUserBuilder (org.mifos.builders.MifosUserBuilder)1 LocaleSetting (org.mifos.config.LocaleSetting)1