use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class ProgressService method getLastFlowProgressByResourceCrn.
public SdxProgressResponse getLastFlowProgressByResourceCrn(String resourceCrn) {
SdxProgressResponse response = new SdxProgressResponse();
response.setLastFlowOperation(flowService.getLastFlowProgressByResourceCrn(resourceCrn));
try {
response.setLastInternalFlowOperation(progressV4Endpoint.getLastFlowLogProgressByResourceCrn(resourceCrn));
} catch (NotFoundException notFoundException) {
LOGGER.debug("Stack for datalake '{}' has not found yet. It is acceptable for progress response.", resourceCrn);
}
return response;
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class UserPreferencesService method getUserPreferences.
private UserPreferences getUserPreferences(String userCrn) {
UserPreferences userPreferences;
Optional<UserPreferences> userPreferencesOptional;
LOGGER.debug("User preferences does not exist, creating it with crn '{}'", userCrn);
userPreferences = new UserPreferences(generateExternalId(), generateExternalId(), userCrn);
try {
userPreferences = userPreferencesRepository.save(userPreferences);
} catch (AccessDeniedException | DataIntegrityViolationException e) {
LOGGER.debug("User exists with crn: '{}'", userCrn, e);
userPreferencesOptional = userPreferencesRepository.findByUserCrn(userCrn);
userPreferences = userPreferencesOptional.orElseThrow(() -> new NotFoundException("User does not exists with crn. If you see this error, " + "you've caught something big, because Duplicate exception occurred"));
}
return userPreferences;
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class ClusterServiceRunnerTest method testRedeployGatewayCertificateWhenClusterCouldNotBeFoundByStackId.
@Test
void testRedeployGatewayCertificateWhenClusterCouldNotBeFoundByStackId() {
when(stackService.getByIdWithListsInTransaction(anyLong())).thenReturn(stack);
when(stack.getCluster()).thenReturn(cluster);
when(clusterService.findOneWithLists(anyLong())).thenThrow(new NotFoundException("Cluster could not be found"));
Assertions.assertThrows(NotFoundException.class, () -> underTest.redeployGatewayCertificate(0L));
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class StructuredSynchronizerJobTest method testUnscheduleJobWhenStackServiceThrowsNotFoundException.
@Test
public void testUnscheduleJobWhenStackServiceThrowsNotFoundException() throws JobExecutionException {
when(stackService.get(anyLong())).thenThrow(new NotFoundException("Stack not found"));
underTest.executeTracedJob(jobExecutionContext);
verify(syncJobService, times(1)).unschedule("1");
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class EnvironmentLoadBalancerService method updateLoadBalancerInEnvironmentAndStacks.
public FlowIdentifier updateLoadBalancerInEnvironmentAndStacks(EnvironmentDto environmentDto, EnvironmentLoadBalancerDto environmentLbDto) {
requireNonNull(environmentDto);
requireNonNull(environmentLbDto);
loadBalancerEntitlementService.validateNetworkForEndpointGateway(environmentDto.getCloudPlatform(), environmentDto.getName(), environmentLbDto.getEndpointAccessGateway());
if (!isLoadBalancerEnabledForDatalake(ThreadBasedUserCrnProvider.getAccountId(), environmentDto.getCloudPlatform(), environmentLbDto.getEndpointAccessGateway())) {
throw new BadRequestException("Neither Endpoint Gateway nor Data Lake load balancer is enabled. Nothing to do.");
}
LOGGER.debug("Trying to find environment based on name {}, CRN {}", environmentDto.getName(), environmentDto.getResourceCrn());
String accountId = Crn.safeFromString(environmentDto.getResourceCrn()).getAccountId();
Environment environment = environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(environmentDto.getResourceCrn(), accountId).orElseThrow(() -> new NotFoundException(String.format("Could not find environment '%s' using crn '%s'", environmentDto.getName(), environmentDto.getResourceCrn())));
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
return reactorFlowManager.triggerLoadBalancerUpdateFlow(environmentDto, environment.getId(), environment.getName(), environment.getResourceCrn(), environmentLbDto.getEndpointAccessGateway(), environmentLbDto.getEndpointGatewaySubnetIds(), userCrn);
}
Aggregations