Search in sources :

Example 6 with NotFoundException

use of org.hisp.dhis.webapi.controller.exception.NotFoundException in project dhis2-core by dhis2.

the class ConfigurationController method setOfflineOrganisationUnitLevel.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/offlineOrganisationUnitLevel", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setOfflineOrganisationUnitLevel(@RequestBody String uid) throws NotFoundException {
    OrganisationUnitLevel organisationUnitLevel = identifiableObjectManager.get(OrganisationUnitLevel.class, uid);
    if (organisationUnitLevel == null) {
        throw new NotFoundException("Organisation unit level", uid);
    }
    Configuration config = configurationService.getConfiguration();
    config.setOfflineOrganisationUnitLevel(organisationUnitLevel);
    configurationService.setConfiguration(config);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) 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 7 with NotFoundException

use of org.hisp.dhis.webapi.controller.exception.NotFoundException in project dhis2-core by dhis2.

the class ConfigurationController method setSelfRegistrationOrgUnit.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/selfRegistrationOrgUnit", method = RequestMethod.POST)
public void setSelfRegistrationOrgUnit(@RequestBody String uid) throws NotFoundException {
    OrganisationUnit orgunit = identifiableObjectManager.get(OrganisationUnit.class, uid);
    if (orgunit == null) {
        throw new NotFoundException("Organisation unit", uid);
    }
    Configuration config = configurationService.getConfiguration();
    config.setSelfRegistrationOrgUnit(orgunit);
    configurationService.setConfiguration(config);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Configuration(org.hisp.dhis.configuration.Configuration) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Configuration (org.hisp.dhis.configuration.Configuration)7 NotFoundException (org.hisp.dhis.webapi.controller.exception.NotFoundException)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)6 DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)1 IndicatorGroup (org.hisp.dhis.indicator.IndicatorGroup)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)1 PeriodType (org.hisp.dhis.period.PeriodType)1 UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)1 UserGroup (org.hisp.dhis.user.UserGroup)1