Search in sources :

Example 81 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class WorkflowsBuilderService method reinitWorkflow.

public void reinitWorkflow(String workflowName, TopologyContext topologyContext, boolean simplify) {
    Workflow wf = topologyContext.getTopology().getWorkflows().get(workflowName);
    if (wf == null) {
        throw new NotFoundException(String.format("The workflow '%s' can not be found", workflowName));
    }
    if (!wf.isStandard()) {
        throw new BadWorkflowOperationException(String.format("Reinit can not be performed on non standard workflow '%s'", workflowName));
    }
    AbstractWorkflowBuilder builder = getWorkflowBuilder(topologyContext.getDSLVersion(), wf);
    wf = builder.reinit(wf, topologyContext);
    WorkflowUtils.fillHostId(wf, topologyContext);
    if (simplify) {
        postProcessTopologyWorkflows(topologyContext);
    }
}
Also used : Workflow(org.alien4cloud.tosca.model.workflow.Workflow) NotFoundException(alien4cloud.exception.NotFoundException) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException)

Example 82 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class WorkflowsBuilderService method renameStep.

public void renameStep(Topology topology, Csar csar, String workflowName, String stepId, String newStepName) {
    TopologyContext topologyContext = buildTopologyContext(topology, csar);
    Workflow wf = topology.getWorkflows().get(workflowName);
    if (wf == null) {
        throw new NotFoundException(String.format("The workflow '%s' can not be found", workflowName));
    }
    AbstractWorkflowBuilder builder = getWorkflowBuilder(topologyContext.getDSLVersion(), wf);
    builder.renameStep(wf, stepId, newStepName);
    if (log.isDebugEnabled()) {
        log.debug(WorkflowUtils.debugWorkflow(wf));
    }
}
Also used : Workflow(org.alien4cloud.tosca.model.workflow.Workflow) NotFoundException(alien4cloud.exception.NotFoundException)

Example 83 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class WorkflowsBuilderService method connectStepFrom.

public Workflow connectStepFrom(Topology topology, Csar csar, String workflowName, String stepId, String[] stepNames) {
    TopologyContext topologyContext = buildTopologyContext(topology, csar);
    Workflow wf = topology.getWorkflows().get(workflowName);
    if (wf == null) {
        throw new NotFoundException(String.format("The workflow '%s' can not be found", workflowName));
    }
    AbstractWorkflowBuilder builder = getWorkflowBuilder(topologyContext.getDSLVersion(), wf);
    builder.connectStepFrom(wf, stepId, stepNames);
    workflowValidator.validate(topologyContext, wf);
    return wf;
}
Also used : Workflow(org.alien4cloud.tosca.model.workflow.Workflow) NotFoundException(alien4cloud.exception.NotFoundException)

Example 84 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class ToscaContextualAspect method findDependencies.

private Set<CSARDependency> findDependencies(Object[] args) {
    for (Object arg : args) {
        if (arg instanceof Topology) {
            return ((Topology) arg).getDependencies();
        }
        if (arg instanceof Set) {
            Set set = (Set) arg;
            if (set.size() > 0 && set.iterator().next() instanceof CSARDependency) {
                return (Set<CSARDependency>) arg;
            }
        }
        if (arg instanceof AbstractToscaType) {
            AbstractToscaType type = ((AbstractToscaType) arg);
            Csar csar = csarRepositorySearchService.getArchive(type.getArchiveName(), type.getArchiveVersion());
            if (csar == null) {
                throw new NotFoundException("Unable to find dependencies from type as it's archive cannot be found in the repository.");
            }
            Set<CSARDependency> dependencies = csar.getDependencies() == null ? Sets.newHashSet() : csar.getDependencies();
            dependencies.add(new CSARDependency(type.getArchiveName(), type.getArchiveVersion()));
            return dependencies;
        }
    }
    return Sets.<CSARDependency>newHashSet();
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) Set(java.util.Set) AbstractToscaType(org.alien4cloud.tosca.model.types.AbstractToscaType) NotFoundException(alien4cloud.exception.NotFoundException) Topology(org.alien4cloud.tosca.model.templates.Topology) CSARDependency(org.alien4cloud.tosca.model.CSARDependency)

Example 85 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class ApplicationDeploymentController method deploy.

/**
 * Trigger deployment of the application on the current configured PaaS.
 *
 * @param deployApplicationRequest application details for deployment (applicationId + deploymentProperties)
 * @return An empty rest response.
 */
@ApiOperation(value = "Deploys the application on the configured Cloud.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/deployment", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit(bodyHiddenFields = { "secretProviderCredentials" })
public RestResponse<?> deploy(@Valid @RequestBody DeployApplicationRequest deployApplicationRequest) {
    String applicationId = deployApplicationRequest.getApplicationId();
    String environmentId = deployApplicationRequest.getApplicationEnvironmentId();
    Application application = applicationService.checkAndGetApplication(applicationId);
    ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, environmentId);
    if (!environment.getApplicationId().equals(applicationId)) {
        throw new NotFoundException("Unable to find environment with id <" + environmentId + "> for application <" + applicationId + ">");
    }
    // Security check user must be authorized to deploy the environment (or be application manager)
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
    // ensure deployment status is sync with underlying orchestrator
    applicationEnvironmentService.getStatus(environment);
    // check that the environment is not already deployed
    boolean isEnvironmentDeployed = applicationEnvironmentService.isDeployed(environment.getId());
    if (isEnvironmentDeployed) {
        throw new AlreadyExistException("Environment with id <" + environmentId + "> for application <" + applicationId + "> is already deployed");
    }
    // prepare the deployment
    ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
    Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
    return toscaContextualAspect.execInToscaContext(() -> doDeploy(deployApplicationRequest, application, environment, topology), false, topology);
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Topology(org.alien4cloud.tosca.model.templates.Topology) AlreadyExistException(alien4cloud.exception.AlreadyExistException) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) ApplicationTopologyVersion(alien4cloud.model.application.ApplicationTopologyVersion) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

NotFoundException (alien4cloud.exception.NotFoundException)88 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)17 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)12 Map (java.util.Map)10 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)10 AlreadyExistException (alien4cloud.exception.AlreadyExistException)9 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)9 Capability (org.alien4cloud.tosca.model.templates.Capability)9 NodeType (org.alien4cloud.tosca.model.types.NodeType)9 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)8 SubstitutionTarget (org.alien4cloud.tosca.model.templates.SubstitutionTarget)8 Topology (org.alien4cloud.tosca.model.templates.Topology)7 Deployment (alien4cloud.model.deployment.Deployment)6 ApiOperation (io.swagger.annotations.ApiOperation)6 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)6 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)6 InvalidNameException (alien4cloud.exception.InvalidNameException)5 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5