Search in sources :

Example 36 with ResponseStatus

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

Example 37 with ResponseStatus

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);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) UserAuthorityGroup(org.hisp.dhis.user.UserAuthorityGroup) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 38 with ResponseStatus

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);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 39 with ResponseStatus

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

Example 40 with ResponseStatus

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);
}
Also used : User(org.hisp.dhis.user.User) MetadataImportParams(org.hisp.dhis.dxf2.metadata.MetadataImportParams) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) DeleteAccessDeniedException(org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)149 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)118 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)36 ApiOperation (io.swagger.annotations.ApiOperation)31 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)18 ApiResponses (io.swagger.annotations.ApiResponses)14 User (org.hisp.dhis.user.User)14 Transactional (org.springframework.transaction.annotation.Transactional)14 Date (java.util.Date)13 Configuration (org.hisp.dhis.configuration.Configuration)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 Period (org.hisp.dhis.period.Period)11 ArrayList (java.util.ArrayList)10 QualifiedName (com.netflix.metacat.common.QualifiedName)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)9 Calendar (java.util.Calendar)9 Task (org.flowable.engine.task.Task)8