use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class RuntimeController method validateOperation.
private void validateOperation(Interface interfass, OperationExecRequest operationRequest, Set<CSARDependency> dependencies) throws ConstraintFunctionalException {
Operation operation = interfass.getOperations().get(operationRequest.getOperationName());
if (operation == null) {
throw new NotFoundException("Operation [" + operationRequest.getOperationName() + "] is not defined in the interface [" + operationRequest.getInterfaceName() + "] of the node [" + operationRequest.getNodeTemplateName() + "]");
}
// validate parameters (value/type and required value)
validateParameters(interfass, operationRequest, dependencies);
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class RuntimeController method validateCommand.
private void validateCommand(OperationExecRequest operationRequest, Topology topology) throws ConstraintFunctionalException {
NodeTemplate nodeTemplate = TopologyUtils.getNodeTemplate(topology.getId(), operationRequest.getNodeTemplateName(), TopologyUtils.getNodeTemplates(topology));
NodeType indexedNodeType = toscaTypeSearchService.getRequiredElementInDependencies(NodeType.class, nodeTemplate.getType(), topology.getDependencies());
Map<String, Interface> interfaces = IndexedModelUtils.mergeInterfaces(indexedNodeType.getInterfaces(), nodeTemplate.getInterfaces());
if (interfaces == null || interfaces.get(operationRequest.getInterfaceName()) == null) {
throw new NotFoundException("Interface [" + operationRequest.getInterfaceName() + "] not found in the node template [" + operationRequest.getNodeTemplateName() + "] related to [" + indexedNodeType.getId() + "]");
}
Interface interfass = interfaces.get(operationRequest.getInterfaceName());
validateOperation(interfass, operationRequest, topology.getDependencies());
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class RuntimeController method getDeployedTopology.
/**
* Get runtime (deployed) topology of an application on a specific environment
*
* @param applicationId application id for which to get the topology
* @param applicationEnvironmentId application environment for which to get the topology through the version
* @return {@link RestResponse}<{@link TopologyDTO}> containing the requested runtime {@link Topology} and the
* {@link NodeType} related to his {@link NodeTemplate}s
*/
@ApiOperation(value = "Get runtime (deployed) topology of an application on a specific cloud.")
@RequestMapping(value = "/{applicationId:.+?}/environment/{applicationEnvironmentId:.+?}/topology", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<TopologyDTO> getDeployedTopology(@ApiParam(value = "Id of the application for which to get deployed topology.", required = true) @PathVariable String applicationId, @ApiParam(value = "Id of the environment for which to get deployed topology.", required = true) @PathVariable String applicationEnvironmentId) {
ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, applicationEnvironmentId);
if (!environment.getApplicationId().equals(applicationId)) {
throw new NotFoundException("Unable to find environment with id <" + applicationEnvironmentId + "> for application <" + applicationId + ">");
}
// Security check user must be authorized to deploy the environment (or be application manager)
AuthorizationUtil.checkAuthorizationForEnvironment(applicationService.getOrFail(applicationId), environment);
Deployment deployment = deploymentService.getActiveDeploymentOrFail(environment.getId());
DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
return RestResponseBuilder.<TopologyDTO>builder().data(topologyDTOBuilder.initTopologyDTO(deploymentTopology, new TopologyDTO())).build();
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class WorkflowEventHandler method checkDeploymentAuthorization.
private void checkDeploymentAuthorization(Authentication authentication, User a4cUser, String deploymentId) {
Deployment deployment = alienDAO.findById(Deployment.class, deploymentId);
switch(deployment.getSourceType()) {
case APPLICATION:
// check if the user has right for the environment associated with the deployment.
ApplicationEnvironment environment = alienDAO.findById(ApplicationEnvironment.class, deployment.getEnvironmentId());
if (environment == null) {
log.error("Environment with id [{}] do not exist any more for deployment [{}]", deployment.getEnvironmentId(), deployment.getId());
throw new NotFoundException("Environment with id [" + deployment.getEnvironmentId() + "] do not exist any more for deployment [" + deployment.getId() + "]");
}
AuthorizationUtil.checkAuthorization(a4cUser, environment, ApplicationRole.APPLICATION_MANAGER, ApplicationEnvironmentRole.values());
break;
case CSAR:
AuthorizationUtil.checkHasOneRoleIn(authentication, Role.COMPONENTS_MANAGER);
}
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class WorkflowPostProcessor method finalizeParsedWorkflows.
/**
* Called after yaml parsing.
*/
private void finalizeParsedWorkflows(TopologyContext topologyContext, Node node) {
if (MapUtils.isEmpty(topologyContext.getTopology().getWorkflows())) {
return;
}
normalizeWorkflowNames(topologyContext.getTopology().getWorkflows());
for (Workflow wf : topologyContext.getTopology().getWorkflows().values()) {
wf.setStandard(WorkflowUtils.isStandardWorkflow(wf));
if (wf.getSteps() != null) {
for (WorkflowStep step : wf.getSteps().values()) {
if (step.getOnSuccess() != null) {
Iterator<String> followingIds = step.getOnSuccess().iterator();
while (followingIds.hasNext()) {
String followingId = followingIds.next();
WorkflowStep followingStep = wf.getSteps().get(followingId);
if (followingStep == null) {
followingIds.remove();
ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.WARNING, ErrorCode.UNKNWON_WORKFLOW_STEP, null, getSafeNodeStartMark(node), null, getSafeNodeEndMark(node), followingId));
} else {
followingStep.addPreceding(step.getName());
}
}
}
}
}
try {
WorkflowUtils.fillHostId(wf, topologyContext);
} catch (NotFoundException e) {
log.trace("Not found exception during fill host id occurs when a relationship specified in workflow does not exist. This exception is ignored as the workflow validation trigger errors for such situations.", e);
}
int errorCount = workflowBuilderService.validateWorkflow(topologyContext, wf);
if (errorCount > 0) {
processWorkflowErrors(wf, wf.getErrors(), node);
}
}
}
Aggregations