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);
}
}
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));
}
}
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;
}
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();
}
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);
}
Aggregations