Search in sources :

Example 6 with NotFoundException

use of com.sequenceiq.redbeams.exception.NotFoundException in project cloudbreak by hortonworks.

the class DatabaseServerV4Controller method updateClusterCrn.

@Override
@InternalOnly
public void updateClusterCrn(String environmentCrn, String currentClusterCrn, String newClusterCrn, @InitiatorUserCrn String initiatorUserCrn) {
    DatabaseServerConfig databaseServerConfig = databaseServerConfigService.findByEnvironmentCrnAndClusterCrn(environmentCrn, currentClusterCrn).orElseThrow(() -> new NotFoundException(String.format("No %s found with cluster CRN '%s' in environment '%s'", DatabaseServerConfig.class.getSimpleName(), currentClusterCrn, environmentCrn)));
    databaseServerConfig.setClusterCrn(newClusterCrn);
    databaseServerConfigService.update(databaseServerConfig);
}
Also used : DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) NotFoundException(com.sequenceiq.redbeams.exception.NotFoundException) InternalOnly(com.sequenceiq.authorization.annotation.InternalOnly)

Aggregations

NotFoundException (com.sequenceiq.redbeams.exception.NotFoundException)6 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)4 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)2 Test (org.junit.Test)2 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)1 DatabaseConfig (com.sequenceiq.redbeams.domain.DatabaseConfig)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1