Search in sources :

Example 1 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project head by mifos.

the class WebTierAccountServiceFacade method applyMemberAccountHistoricalAdjustment.

/**
     * adjustment for member account payment has to be handled along with parent account payments and other members payments.
     * This method prepares data and run applyHistoricalAdjustment so adjustment will be made for parent payment context.
     */
@Override
@PreAuthorize("isFullyAuthenticated()")
public void applyMemberAccountHistoricalAdjustment(String memberGlobalAccountNum, Integer memberPaymentId, String adjustmentNote, Short personnelId, AdjustedPaymentDto adjustedPaymentDto) {
    try {
        LoanBO memberAccount = (LoanBO) accountBusinessService.findBySystemId(memberGlobalAccountNum);
        LoanBO parentAccount = memberAccount.getParentAccount();
        if (parentAccount == null) {
            throw new AccountException(LoanExceptionConstants.NO_PARENT_ACCOUNT_EXCEPTION);
        }
        AccountPaymentEntity parentPaymentEntity = memberAccount.findParentPaymentByMemberPaymentId(memberPaymentId);
        List<AdjustedPaymentDto> membersAdjustedPaymentDtoList = new ArrayList<AdjustedPaymentDto>();
        for (AccountPaymentEntity memberPayment : parentPaymentEntity.getMemberPayments()) {
            if (memberPayment.getAccount().getAccountId().equals(memberAccount.getAccountId())) {
                membersAdjustedPaymentDtoList.add(new AdjustedPaymentDto(adjustedPaymentDto.getAmount(), adjustedPaymentDto.getPaymentDate(), adjustedPaymentDto.getPaymentType(), memberAccount.getAccountId()));
            } else {
                membersAdjustedPaymentDtoList.add(new AdjustedPaymentDto(memberPayment.getAmount().getAmount().toString(), adjustedPaymentDto.getPaymentDate(), adjustedPaymentDto.getPaymentType(), memberPayment.getAccount().getAccountId()));
            }
        }
        BigDecimal parentAmountSubstraction = memberAccount.findPaymentById(memberPaymentId).getAmount().getAmount().subtract((new BigDecimal(adjustedPaymentDto.getAmount())));
        String newParentAmount = parentPaymentEntity.getAmount().getAmount().subtract(parentAmountSubstraction).toString();
        AdjustedPaymentDto parentAdjustedPaymentDto = new AdjustedPaymentDto(newParentAmount, adjustedPaymentDto.getPaymentDate(), adjustedPaymentDto.getPaymentType(), parentAccount.getAccountId(), membersAdjustedPaymentDtoList);
        this.applyHistoricalAdjustment(parentAccount.getGlobalAccountNum(), parentPaymentEntity.getPaymentId(), adjustmentNote, personnelId, parentAdjustedPaymentDto);
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    } catch (AccountException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) AdjustedPaymentDto(org.mifos.dto.domain.AdjustedPaymentDto) ServiceException(org.mifos.framework.exceptions.ServiceException) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project head by mifos.

the class PentahoReportsServiceImpl method getEtlLastUpdateDate.

@Override
@PreAuthorize("isFullyAuthenticated()")
public Date getEtlLastUpdateDate(HttpServletRequest request) {
    ServletContext context = request.getSession().getServletContext();
    Date lastSucessfulRunEtl = null;
    try {
        List<BatchjobsDto> batchjobs = batchjobsServiceFacade.getBatchjobs(context);
        for (BatchjobsDto batchjob : batchjobs) {
            if (batchjob.getName().equals("ETLReportDWTaskJob")) {
                lastSucessfulRunEtl = batchjob.getLastSuccessfulRun();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return lastSucessfulRunEtl;
}
Also used : ServletContext(javax.servlet.ServletContext) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) Date(java.util.Date) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ReflectionException(org.mifos.reports.pentaho.util.ReflectionException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) IOException(java.io.IOException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project pinpoint by naver.

the class LegacyAgentStatController method getAgentStatV1.

@Deprecated
@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/getAgentStat/v1", method = RequestMethod.GET)
@ResponseBody
public LegacyAgentStatChartGroup getAgentStatV1(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to, @RequestParam(value = "sampleRate", required = false) Integer sampleRate) throws Exception {
    StopWatch watch = new StopWatch();
    watch.start("agentStatService.selectAgentStatList");
    TimeWindow timeWindow = new TimeWindow(new Range(from, to), new TimeWindowSlotCentricSampler());
    LegacyAgentStatChartGroup chartGroup = this.v1Service.selectAgentStatList(agentId, timeWindow);
    watch.stop();
    if (logger.isInfoEnabled()) {
        logger.info("getAgentStatV1(agentId={}, from={}, to={}) : {}ms", agentId, from, to, watch.getLastTaskTimeMillis());
    }
    return chartGroup;
}
Also used : LegacyAgentStatChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.LegacyAgentStatChartGroup) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) StopWatch(org.springframework.util.StopWatch) TimeWindowSlotCentricSampler(com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project pinpoint by naver.

the class LegacyAgentStatController method getAgentStat.

@Deprecated
@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/getAgentStat", method = RequestMethod.GET)
@ResponseBody
public LegacyAgentStatChartGroup getAgentStat(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to, @RequestParam(value = "sampleRate", required = false) Integer sampleRate) throws Exception {
    StopWatch watch = new StopWatch();
    watch.start("agentStatService.selectAgentStatList");
    TimeWindow timeWindow = new TimeWindow(new Range(from, to), new TimeWindowSlotCentricSampler());
    LegacyAgentStatChartGroup chartGroup = this.agentStatService.selectAgentStatList(agentId, timeWindow);
    watch.stop();
    if (logger.isInfoEnabled()) {
        logger.info("getAgentStat(agentId={}, from={}, to={}) : {}ms", agentId, from, to, watch.getLastTaskTimeMillis());
    }
    return chartGroup;
}
Also used : LegacyAgentStatChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.LegacyAgentStatChartGroup) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) StopWatch(org.springframework.util.StopWatch) TimeWindowSlotCentricSampler(com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project pinpoint by naver.

the class AgentStatController method getAgentStatChartList.

@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/chartList", method = RequestMethod.GET)
@ResponseBody
public List<AgentStatChartGroup> getAgentStatChartList(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to) {
    TimeWindowSampler sampler = new TimeWindowSlotCentricSampler();
    TimeWindow timeWindow = new TimeWindow(new Range(from, to), sampler);
    return this.agentStatChartService.selectAgentChartList(agentId, timeWindow);
}
Also used : TimeWindowSampler(com.navercorp.pinpoint.web.util.TimeWindowSampler) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) TimeWindowSlotCentricSampler(com.navercorp.pinpoint.web.util.TimeWindowSlotCentricSampler) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)188 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)174 ModelAndView (org.springframework.web.servlet.ModelAndView)51 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)39 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)36 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)34 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)32 IOException (java.io.IOException)29 InputStream (java.io.InputStream)23 ArrayList (java.util.ArrayList)23 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)23 ConfigurationServiceException (org.nhindirect.config.service.ConfigurationServiceException)21 Date (java.util.Date)15 Grid (org.hisp.dhis.common.Grid)14 SearchDomainForm (org.nhindirect.config.ui.form.SearchDomainForm)14 ApiOperation (io.swagger.annotations.ApiOperation)13 ApiResponses (io.swagger.annotations.ApiResponses)13 Configuration (org.hisp.dhis.configuration.Configuration)13 HttpHeaders (org.springframework.http.HttpHeaders)13 List (java.util.List)12