Search in sources :

Example 1 with Configuration

use of org.hisp.dhis.configuration.Configuration 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);
}
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 2 with Configuration

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

Example 3 with Configuration

use of org.hisp.dhis.configuration.Configuration 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 4 with Configuration

use of org.hisp.dhis.configuration.Configuration 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 5 with Configuration

use of org.hisp.dhis.configuration.Configuration 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)

Aggregations

Configuration (org.hisp.dhis.configuration.Configuration)17 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)12 NotFoundException (org.hisp.dhis.webapi.controller.exception.NotFoundException)7 UserGroup (org.hisp.dhis.user.UserGroup)2 Date (java.util.Date)1 DhisSpringTest (org.hisp.dhis.DhisSpringTest)1 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 User (org.hisp.dhis.user.User)1 UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)1 Test (org.junit.Test)1 HttpStatus (org.springframework.http.HttpStatus)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1 HttpServerErrorException (org.springframework.web.client.HttpServerErrorException)1 ResourceAccessException (org.springframework.web.client.ResourceAccessException)1