Search in sources :

Example 11 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')")
@PostMapping("/selfRegistrationOrgUnit")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setSelfRegistrationOrgUnit(@RequestBody String uid) throws NotFoundException {
    uid = trim(uid);
    OrganisationUnit orgunit = identifiableObjectManager.get(OrganisationUnit.class, uid);
    if (orgunit == null) {
        throw new NotFoundException("Organisation unit", uid);
    }
    Configuration configuration = configurationService.getConfiguration();
    configuration.setSelfRegistrationOrgUnit(orgunit);
    configurationService.setConfiguration(configuration);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Configuration(org.hisp.dhis.configuration.Configuration) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 12 with NotFoundException

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

the class ConfigurationController method setSystemUpdateNotificationRecipients.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@PostMapping("/systemUpdateNotificationRecipients")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setSystemUpdateNotificationRecipients(@RequestBody String uid) throws NotFoundException {
    uid = trim(uid);
    UserGroup group = identifiableObjectManager.get(UserGroup.class, uid);
    if (group == null) {
        throw new NotFoundException("User group", uid);
    }
    Configuration configuration = configurationService.getConfiguration();
    configuration.setSystemUpdateNotificationRecipients(group);
    configurationService.setConfiguration(configuration);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) UserGroup(org.hisp.dhis.user.UserGroup) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 13 with NotFoundException

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

the class ConfigurationController method setInfrastructuralIndicators.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@PostMapping("/infrastructuralIndicators")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setInfrastructuralIndicators(@RequestBody String uid) throws NotFoundException {
    uid = trim(uid);
    IndicatorGroup group = identifiableObjectManager.get(IndicatorGroup.class, uid);
    if (group == null) {
        throw new NotFoundException("Indicator group", uid);
    }
    Configuration configuration = configurationService.getConfiguration();
    configuration.setInfrastructuralIndicators(group);
    configurationService.setConfiguration(configuration);
}
Also used : IndicatorGroup(org.hisp.dhis.indicator.IndicatorGroup) Configuration(org.hisp.dhis.configuration.Configuration) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 14 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')")
@PostMapping("/offlineOrganisationUnitLevel")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setOfflineOrganisationUnitLevel(@RequestBody String uid) throws NotFoundException {
    uid = trim(uid);
    OrganisationUnitLevel organisationUnitLevel = identifiableObjectManager.get(OrganisationUnitLevel.class, uid);
    if (organisationUnitLevel == null) {
        throw new NotFoundException("Organisation unit level", uid);
    }
    Configuration configuration = configurationService.getConfiguration();
    configuration.setOfflineOrganisationUnitLevel(organisationUnitLevel);
    configurationService.setConfiguration(configuration);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 15 with NotFoundException

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

the class ConfigurationController method setFacilityOrgUnitLevel.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@PostMapping("/facilityOrgUnitLevel")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setFacilityOrgUnitLevel(@RequestBody String uid) throws NotFoundException {
    uid = trim(uid);
    OrganisationUnitLevel level = identifiableObjectManager.get(OrganisationUnitLevel.class, uid);
    if (level == null) {
        throw new NotFoundException("Organisation unit level", uid);
    }
    Configuration configuration = configurationService.getConfiguration();
    configuration.setFacilityOrgUnitLevel(level);
    configurationService.setConfiguration(configuration);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

NotFoundException (org.hisp.dhis.webapi.controller.exception.NotFoundException)16 PostMapping (org.springframework.web.bind.annotation.PostMapping)11 Configuration (org.hisp.dhis.configuration.Configuration)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)10 PotentialDuplicate (org.hisp.dhis.deduplication.PotentialDuplicate)4 PotentialDuplicateConflictException (org.hisp.dhis.deduplication.PotentialDuplicateConflictException)4 BadRequestException (org.hisp.dhis.webapi.controller.exception.BadRequestException)4 ConflictException (org.hisp.dhis.webapi.controller.exception.ConflictException)4 OperationNotAllowedException (org.hisp.dhis.webapi.controller.exception.OperationNotAllowedException)4 Test (org.junit.jupiter.api.Test)4 List (java.util.List)2 RequiredArgsConstructor (lombok.RequiredArgsConstructor)2 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)2 User (org.hisp.dhis.user.User)2 UserGroup (org.hisp.dhis.user.UserGroup)2 Joiner (com.google.common.base.Joiner)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Deque (java.util.Deque)1