Search in sources :

Example 51 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project dhis2-core by dhis2.

the class DataIntegrityController method runAsyncDataIntegrity.

//--------------------------------------------------------------------------
// Start asynchronous data integrity task
//--------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')")
@RequestMapping(value = DataIntegrityController.RESOURCE_PATH, method = RequestMethod.POST)
public void runAsyncDataIntegrity(HttpServletResponse response, HttpServletRequest request) {
    TaskId taskId = new TaskId(TaskCategory.DATAINTEGRITY, currentUserService.getCurrentUser());
    notifier.clear(taskId);
    scheduler.executeTask(new DataIntegrityTask(taskId, dataIntegrityService, notifier));
    response.setHeader("Location", ContextUtils.getRootPath(request) + "/system/tasks/" + TaskCategory.DATAINTEGRITY);
    response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) DataIntegrityTask(org.hisp.dhis.dataintegrity.tasks.DataIntegrityTask) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 52 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project dhis2-core by dhis2.

the class DataApprovalController method removeApproval.

// -------------------------------------------------------------------------
// Delete
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_APPROVE_DATA') or hasRole('F_APPROVE_DATA_LOWER_LEVELS')")
@RequestMapping(value = APPROVALS_PATH, method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeApproval(@RequestParam Set<String> ds, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws WebMessageException {
    Set<DataSet> dataSets = parseDataSetsWithWorkflow(ds);
    if (dataSets.size() != ds.size()) {
        throw new WebMessageException(WebMessageUtils.conflict("Illegal data set identifier in this list: " + ds));
    }
    Period period = getAndValidatePeriod(pe);
    OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
    DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
    User user = currentUserService.getCurrentUser();
    List<DataApproval> dataApprovalList = newArrayList();
    for (DataSet dataSet : dataSets) {
        dataApprovalList.addAll(getApprovalsAsList(dataApprovalLevel, dataSet.getWorkflow(), period, organisationUnit, false, new Date(), user));
    }
    dataApprovalService.unapproveData(dataApprovalList);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApproval(org.hisp.dhis.dataapproval.DataApproval) User(org.hisp.dhis.user.User) DataSet(org.hisp.dhis.dataset.DataSet) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) Period(org.hisp.dhis.period.Period) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 53 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project dhis2-core by dhis2.

the class DataApprovalController method acceptApproval.

// -------------------------------------------------------------------------
// Post, acceptance
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_ACCEPT_DATA_LOWER_LEVELS')")
@RequestMapping(value = ACCEPTANCES_PATH, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptApproval(@RequestParam(required = false) String ds, @RequestParam(required = false) String wf, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws WebMessageException {
    DataApprovalWorkflow workflow = getAndValidateWorkflow(ds, wf);
    Period period = getAndValidatePeriod(pe);
    OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
    DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
    User user = currentUserService.getCurrentUser();
    List<DataApproval> dataApprovalList = getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, false, new Date(), user);
    dataApprovalService.acceptData(dataApprovalList);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApproval(org.hisp.dhis.dataapproval.DataApproval) User(org.hisp.dhis.user.User) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 54 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project dhis2-core by dhis2.

the class DataApprovalController method unacceptApproval.

@PreAuthorize("hasRole('ALL') or hasRole('F_ACCEPT_DATA_LOWER_LEVELS')")
@RequestMapping(value = ACCEPTANCES_PATH, method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void unacceptApproval(@RequestParam(required = false) String ds, @RequestParam(required = false) String wf, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws WebMessageException {
    DataApprovalWorkflow workflow = getAndValidateWorkflow(ds, wf);
    Period period = getAndValidatePeriod(pe);
    OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
    DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
    User user = currentUserService.getCurrentUser();
    List<DataApproval> dataApprovalList = getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, false, new Date(), user);
    dataApprovalService.unacceptData(dataApprovalList);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApproval(org.hisp.dhis.dataapproval.DataApproval) User(org.hisp.dhis.user.User) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 55 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project dhis2-core by dhis2.

the class ConfigurationController method removeSelfRegistrationRole.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/selfRegistrationRole", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeSelfRegistrationRole() {
    Configuration config = configurationService.getConfiguration();
    config.setSelfRegistrationRole(null);
    configurationService.setConfiguration(config);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)289 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)234 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)88 ApiOperation (io.swagger.annotations.ApiOperation)70 ModelAndView (org.springframework.web.servlet.ModelAndView)51 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)44 ResponseEntity (org.springframework.http.ResponseEntity)41 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)40 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)36 IOException (java.io.IOException)35 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)34 InputStream (java.io.InputStream)26 Date (java.util.Date)26 ArrayList (java.util.ArrayList)25 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)23 ConfigurationServiceException (org.nhindirect.config.service.ConfigurationServiceException)21 List (java.util.List)17 HttpHeaders (org.springframework.http.HttpHeaders)16 Grid (org.hisp.dhis.common.Grid)14 SearchDomainForm (org.nhindirect.config.ui.form.SearchDomainForm)14