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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations