use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.
the class StackService method getPrivateStackJsonByName.
public StackResponse getPrivateStackJsonByName(String name, IdentityUser identityUser, Collection<String> entries) {
Stack stack = stackRepository.findByNameInUserWithLists(name, identityUser.getUserId());
if (stack == null) {
throw new NotFoundException(String.format(STACK_NOT_FOUND_EXCEPTION_FORMAT_TEXT, name));
}
StackResponse stackResponse = conversionService.convert(stack, StackResponse.class);
stackResponse = stackResponseDecorator.decorate(stackResponse, stack, entries);
return stackResponse;
}
use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.
the class StackService method removeInstance.
public void removeInstance(@Nonnull IdentityUser user, Long stackId, String instanceId) {
requireNonNull(user);
Stack stack = get(stackId);
InstanceMetaData metaData = instanceMetaDataRepository.findByInstanceId(stackId, instanceId);
if (metaData == null) {
throw new NotFoundException(String.format("Metadata for instance %s has not found.", instanceId));
} else {
downscaleValidatorService.checkInstanceIsTheAmbariServerOrNot(metaData.getPublicIp(), metaData.getInstanceMetadataType());
downscaleValidatorService.checkUserHasRightToTerminateInstance(stack.isPublicInAccount(), stack.getOwner(), user.getUserId(), stackId);
flowManager.triggerStackRemoveInstance(stackId, metaData.getInstanceGroupName(), metaData.getDiscoveryFQDN());
}
}
use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.
the class StackService method get.
public Stack get(Long id) {
Stack stack = stackRepository.findOne(id);
if (stack == null) {
throw new NotFoundException(String.format(STACK_NOT_FOUND_EXCEPTION_FORMAT_TEXT, id));
}
authorizationService.hasReadPermission(stack);
return stack;
}
use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.
the class StackService method updateMetaDataStatus.
public InstanceMetaData updateMetaDataStatus(Long id, String hostName, InstanceStatus status) {
InstanceMetaData metaData = instanceMetaDataRepository.findHostInStack(id, hostName);
if (metaData == null) {
throw new NotFoundException(String.format("Metadata not found on stack:'%s' with hostname: '%s'.", id, hostName));
}
metaData.setInstanceStatus(status);
return instanceMetaDataRepository.save(metaData);
}
use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.
the class SecurityGroupService method get.
public SecurityGroup get(Long id) {
SecurityGroup securityGroup = groupRepository.findById(id);
if (securityGroup == null) {
throw new NotFoundException(String.format("SecurityGroup '%s' not found", id));
}
authorizationService.hasReadPermission(securityGroup);
return securityGroup;
}
Aggregations