Search in sources :

Example 1 with LogUtils

use of org.mifos.framework.business.LogUtils in project head by mifos.

the class BaseAction method preExecute.

protected void preExecute(ActionForm actionForm, HttpServletRequest request, TransactionDemarcate annotation) throws SystemException, ApplicationException {
    if (null != request.getParameter(Constants.CURRENTFLOWKEY)) {
        request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
    }
    preHandleTransaction(request, annotation);
    UserContext userContext = (UserContext) request.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
    Locale locale = getLocale(userContext);
    if (!skipActionFormToBusinessObjectConversion(request.getParameter("method"))) {
        try {
            AbstractBusinessObject businessObject = getBusinessObjectFromSession(request);
            ConversionUtil.populateBusinessObject(actionForm, businessObject, locale);
        } catch (ValueObjectConversionException e) {
            logger.debug("Value object conversion exception while validating BusinessObject: " + new LogUtils().getStackTrace(e));
        }
    }
}
Also used : Locale(java.util.Locale) AbstractBusinessObject(org.mifos.framework.business.AbstractBusinessObject) UserContext(org.mifos.security.util.UserContext) LogUtils(org.mifos.framework.business.LogUtils) ValueObjectConversionException(org.mifos.framework.exceptions.ValueObjectConversionException)

Example 2 with LogUtils

use of org.mifos.framework.business.LogUtils in project head by mifos.

the class BatchjobsController method processFormSubmit.

// for default AccessDeniedException feedback
@SuppressWarnings("PMD.AvoidRethrowingException")
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(HttpServletRequest request, @RequestParam(value = SUSPEND_PARAM, required = false) String suspend, @RequestParam(value = RUN_PARAM, required = false) String run, SessionStatus status) throws AccessDeniedException {
    List<String> errorMessages = new ArrayList<String>();
    if (StringUtils.isNotBlank(suspend)) {
        ServletContext context = request.getSession().getServletContext();
        String[] doSuspend = request.getParameterValues("SUSPEND");
        if (doSuspend != null) {
            try {
                batchjobsServiceFacade.suspend(context, doSuspend[0]);
            } catch (AccessDeniedException e) {
                throw e;
            } catch (Exception e) {
                errorMessages.add("Could not change Scheduler status. " + new LogUtils().getStackTrace(e));
            }
        }
    } else if (StringUtils.isNotBlank(run)) {
        rawJobList = request.getParameterValues("ONDEMAND");
        if (rawJobList == null) {
            rawJobList = new String[0];
        } else {
            ServletContext context = request.getSession().getServletContext();
            try {
                batchjobsServiceFacade.runSelectedTasks(context, rawJobList);
            } catch (AccessDeniedException e) {
                throw e;
            } catch (Exception e) {
                errorMessages.add("Could not run selected Tasks. " + new LogUtils().getStackTrace(e));
            }
        }
    }
    status.setComplete();
    return produceModelAndView(request, errorMessages);
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) ArrayList(java.util.ArrayList) ServletContext(javax.servlet.ServletContext) LogUtils(org.mifos.framework.business.LogUtils) AccessDeniedException(org.springframework.security.access.AccessDeniedException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LogUtils (org.mifos.framework.business.LogUtils)2 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 ServletContext (javax.servlet.ServletContext)1 AbstractBusinessObject (org.mifos.framework.business.AbstractBusinessObject)1 ValueObjectConversionException (org.mifos.framework.exceptions.ValueObjectConversionException)1 UserContext (org.mifos.security.util.UserContext)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1