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);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class DataSetController method updateCustomDataEntryFormJson.
@RequestMapping(value = "/{uid}/form", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiVersion(value = DhisApiVersion.ALL, exclude = DhisApiVersion.V23)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateCustomDataEntryFormJson(@PathVariable("uid") String uid, HttpServletRequest request) throws WebMessageException {
DataSet dataSet = dataSetService.getDataSet(uid);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.notFound("DataSet not found for uid: " + uid));
}
DataEntryForm form = dataSet.getDataEntryForm();
DataEntryForm newForm;
try {
newForm = renderService.fromJson(request.getInputStream(), DataEntryForm.class);
} catch (IOException e) {
throw new WebMessageException(WebMessageUtils.badRequest("Failed to parse request", e.getMessage()));
}
if (form == null) {
if (!newForm.hasForm()) {
throw new WebMessageException(WebMessageUtils.badRequest("Missing required parameter 'htmlCode'"));
}
newForm.setName(dataSet.getName());
dataEntryFormService.addDataEntryForm(newForm);
dataSet.setDataEntryForm(newForm);
} else {
if (newForm.getHtmlCode() != null) {
form.setHtmlCode(dataEntryFormService.prepareDataEntryFormForSave(newForm.getHtmlCode()));
}
if (newForm.getStyle() != null) {
form.setStyle(newForm.getStyle());
}
dataEntryFormService.updateDataEntryForm(form);
}
dataSet.increaseVersion();
dataSetService.updateDataSet(dataSet);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class DataSetController method updateCustomDataEntryFormHtml.
@RequestMapping(value = { "/{uid}/customDataEntryForm", "/{uid}/form" }, method = { RequestMethod.PUT, RequestMethod.POST }, consumes = "text/html")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateCustomDataEntryFormHtml(@PathVariable("uid") String uid, @RequestBody String formContent, HttpServletResponse response) throws Exception {
DataSet dataSet = dataSetService.getDataSet(uid);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.notFound("DataSet not found for uid: " + uid));
}
DataEntryForm form = dataSet.getDataEntryForm();
if (form == null) {
form = new DataEntryForm(dataSet.getName(), DisplayDensity.NORMAL, formContent);
dataEntryFormService.addDataEntryForm(form);
dataSet.setDataEntryForm(form);
} else {
form.setHtmlCode(formContent);
dataEntryFormService.updateDataEntryForm(form);
}
dataSet.increaseVersion();
dataSetService.updateDataSet(dataSet);
}
use of org.springframework.web.bind.annotation.ResponseStatus 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);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class ConfigurationController method setFeedbackRecipients.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/feedbackRecipients", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setFeedbackRecipients(@RequestBody String uid) throws NotFoundException {
UserGroup group = identifiableObjectManager.get(UserGroup.class, uid);
if (group == null) {
throw new NotFoundException("User group", uid);
}
Configuration config = configurationService.getConfiguration();
config.setFeedbackRecipients(group);
configurationService.setConfiguration(config);
}
Aggregations