use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class ConfigurationController method setCorsWhitelist.
@SuppressWarnings("unchecked")
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/corsWhitelist", method = RequestMethod.POST, consumes = "application/json")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setCorsWhitelist(@RequestBody String input) throws IOException {
Set<String> corsWhitelist = renderService.fromJson(input, Set.class);
Configuration config = configurationService.getConfiguration();
config.setCorsWhitelist(corsWhitelist);
configurationService.setConfiguration(config);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class ConfigurationController method setSelfRegistrationRole.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/selfRegistrationRole", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setSelfRegistrationRole(@RequestBody String uid) throws NotFoundException {
UserAuthorityGroup userGroup = identifiableObjectManager.get(UserAuthorityGroup.class, uid);
if (userGroup == null) {
throw new NotFoundException("User authority group", uid);
}
Configuration config = configurationService.getConfiguration();
config.setSelfRegistrationRole(userGroup);
configurationService.setConfiguration(config);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class ConfigurationController method setInfrastructuralDataElements.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/infrastructuralDataElements", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setInfrastructuralDataElements(@RequestBody String uid) throws NotFoundException {
DataElementGroup group = identifiableObjectManager.get(DataElementGroup.class, uid);
if (group == null) {
throw new NotFoundException("Data element group", uid);
}
Configuration config = configurationService.getConfiguration();
config.setInfrastructuralDataElements(group);
configurationService.setConfiguration(config);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class ConfigurationController method removeOfflineOrganisationUnitLevel.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/offlineOrganisationUnitLevel", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeOfflineOrganisationUnitLevel() {
Configuration config = configurationService.getConfiguration();
config.setOfflineOrganisationUnitLevel(null);
configurationService.setConfiguration(config);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class AbstractCrudController method deleteObject.
//--------------------------------------------------------------------------
// DELETE
//--------------------------------------------------------------------------
@RequestMapping(value = "/{uid}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK)
public void deleteObject(@PathVariable("uid") String pvUid, HttpServletRequest request, HttpServletResponse response) throws Exception {
List<T> objects = getEntity(pvUid);
if (objects.isEmpty()) {
throw new WebMessageException(WebMessageUtils.notFound(getEntityClass(), pvUid));
}
User user = currentUserService.getCurrentUser();
if (!aclService.canDelete(user, objects.get(0))) {
throw new DeleteAccessDeniedException("You don't have the proper permissions to delete this object.");
}
preDeleteEntity(objects.get(0));
MetadataImportParams params = new MetadataImportParams().setImportReportMode(ImportReportMode.FULL).setUser(user).setImportStrategy(ImportStrategy.DELETE).addObject(objects.get(0));
ImportReport importReport = importService.importMetadata(params);
postDeleteEntity();
webMessageService.send(WebMessageUtils.objectReport(importReport), response, request);
}
Aggregations