Search in sources :

Example 41 with NotFoundException

use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.

the class BlueprintService method delete.

public void delete(Long id, IdentityUser user) {
    Blueprint blueprint = blueprintRepository.findByIdInAccount(id, user.getAccount());
    if (blueprint == null) {
        throw new NotFoundException(String.format("Blueprint '%s' not found.", id));
    }
    delete(blueprint);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 42 with NotFoundException

use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.

the class BlueprintService method get.

public Blueprint get(String name, String account) {
    Blueprint blueprint = blueprintRepository.findOneByName(name, account);
    if (blueprint == null) {
        throw new NotFoundException(String.format("Blueprint '%s' not found in %s account.", name, account));
    }
    authorizationService.hasReadPermission(blueprint);
    return blueprint;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 43 with NotFoundException

use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.

the class AmbariClusterService method getClusterJson.

@Override
public String getClusterJson(String ambariIp, Long stackId) {
    try {
        AmbariClient ambariClient = getAmbariClient(stackId);
        String clusterJson = ambariClient.getClusterAsJson();
        if (clusterJson == null) {
            throw new BadRequestException(String.format("Cluster response coming from Ambari server was null. [Ambari Server IP: '%s']", ambariIp));
        }
        return clusterJson;
    } catch (HttpResponseException e) {
        if ("Not Found".equals(e.getMessage())) {
            throw new NotFoundException("Ambari validation not found.", e);
        } else {
            String errorMessage = AmbariClientExceptionUtil.getErrorMessage(e);
            throw new CloudbreakServiceException("Could not get Cluster from Ambari as JSON: " + errorMessage, e);
        }
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) HttpResponseException(groovyx.net.http.HttpResponseException) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 44 with NotFoundException

use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.

the class OrchestratorRecipeExecutor method preTerminationRecipesOnNodes.

public void preTerminationRecipesOnNodes(Stack stack, Set<Node> nodes) throws CloudbreakException {
    if (stack.getCluster() == null) {
        throw new NotFoundException("Cluster does not found, pre-termination will not be run.");
    }
    HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
    GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
    try {
        hostOrchestrator.preTerminationRecipes(gatewayConfig, nodes, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
    } catch (CloudbreakOrchestratorFailedException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 45 with NotFoundException

use of com.sequenceiq.cloudbreak.controller.NotFoundException in project cloudbreak by hortonworks.

the class ClusterTemplateService method getByName.

public ClusterTemplate getByName(String name, IdentityUser user) {
    ClusterTemplate clusterTemplate = clusterTemplateRepository.findByNameInAccount(name, user.getAccount(), user.getUserId());
    if (clusterTemplate == null) {
        throw new NotFoundException(String.format("Blueprint '%s' not found.", name));
    }
    authorizationService.hasReadPermission(clusterTemplate);
    return clusterTemplate;
}
Also used : ClusterTemplate(com.sequenceiq.cloudbreak.domain.ClusterTemplate) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

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