Search in sources :

Example 31 with NotFoundException

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;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 32 with NotFoundException

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());
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 33 with NotFoundException

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;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 34 with NotFoundException

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)

Example 35 with NotFoundException

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;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup)

Aggregations

NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)50 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)9 Stack (com.sequenceiq.cloudbreak.domain.Stack)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)5 ProxyConfig (com.sequenceiq.cloudbreak.domain.ProxyConfig)5 ClusterTemplate (com.sequenceiq.cloudbreak.domain.ClusterTemplate)4 ConstraintTemplate (com.sequenceiq.cloudbreak.domain.ConstraintTemplate)4 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)4 Template (com.sequenceiq.cloudbreak.domain.Template)4 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)3 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)2 AutoscaleStackResponse (com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse)2 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)2 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)2 SecurityGroup (com.sequenceiq.cloudbreak.domain.SecurityGroup)2 CertificateResponse (com.sequenceiq.cloudbreak.api.model.CertificateResponse)1 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1