use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class DashboardItemController method putDashboardItemShape.
@RequestMapping(value = "/{uid}/shape/{shape}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void putDashboardItemShape(@PathVariable String uid, @PathVariable DashboardItemShape shape, HttpServletRequest request, HttpServletResponse response) throws Exception {
DashboardItem item = dashboardService.getDashboardItem(uid);
if (item == null) {
throw new WebMessageException(WebMessageUtils.notFound("Dashboard item does not exist: " + uid));
}
Dashboard dashboard = dashboardService.getDashboardFromDashboardItem(item);
if (!aclService.canUpdate(currentUserService.getCurrentUser(), dashboard)) {
throw new UpdateAccessDeniedException("You don't have the proper permissions to update this dashboard.");
}
item.setShape(shape);
dashboardService.updateDashboardItem(item);
}
use of org.springframework.web.bind.annotation.ResponseStatus 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.web.bind.annotation.ResponseStatus 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.web.bind.annotation.ResponseStatus 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.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class DataSetController method bumpVersion.
@RequestMapping(value = "/{uid}/version", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void bumpVersion(@PathVariable("uid") String uid) throws Exception {
DataSet dataSet = manager.get(DataSet.class, uid);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.conflict("Data set does not exist: " + uid));
}
dataSet.increaseVersion();
dataSetService.updateDataSet(dataSet);
}
Aggregations