Search in sources :

Example 71 with NotFoundException

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

the class SetSubstitutionCapabilityServiceRelationshipProcessor method process.

@Override
public void process(Csar csar, Topology topology, SetSubstitutionCapabilityServiceRelationshipOperation operation) {
    if (topology.getSubstitutionMapping() == null) {
        throw new NotFoundException("The substitution capability with id <" + operation.getSubstitutionCapabilityId() + "> cannot be found.");
    }
    SubstitutionTarget substitutionTarget = safe(topology.getSubstitutionMapping().getCapabilities()).get(operation.getSubstitutionCapabilityId());
    if (substitutionTarget == null) {
        throw new NotFoundException("The substitution capability with id <" + operation.getSubstitutionCapabilityId() + "> cannot be found.");
    }
    super.process(csar, topology, substitutionTarget, operation.getRelationshipType(), operation.getRelationshipVersion());
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) SubstitutionTarget(org.alien4cloud.tosca.model.templates.SubstitutionTarget)

Example 72 with NotFoundException

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

the class SetSubstitutionRequirementServiceRelationshipProcessor method process.

@Override
public void process(Csar csar, Topology topology, SetSubstitutionRequirementServiceRelationshipOperation operation) {
    if (topology.getSubstitutionMapping() == null) {
        throw new NotFoundException("The substitution requirement with id <" + operation.getSubstitutionRequirementId() + "> cannot be found.");
    }
    SubstitutionTarget substitutionTarget = safe(topology.getSubstitutionMapping().getRequirements()).get(operation.getSubstitutionRequirementId());
    if (substitutionTarget == null) {
        throw new NotFoundException("The substitution requirement with id <" + operation.getSubstitutionRequirementId() + "> cannot be found.");
    }
    super.process(csar, topology, substitutionTarget, operation.getRelationshipType(), operation.getRelationshipVersion());
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) SubstitutionTarget(org.alien4cloud.tosca.model.templates.SubstitutionTarget)

Example 73 with NotFoundException

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

the class AbstractRelationshipProcessor method processNodeOperation.

@Override
protected void processNodeOperation(Csar csar, Topology topology, T operation, NodeTemplate nodeTemplate) {
    RelationshipTemplate relationshipTemplate = safe(nodeTemplate.getRelationships()).get(operation.getRelationshipName());
    if (relationshipTemplate == null) {
        throw new NotFoundException("The relationship with name [" + operation.getRelationshipName() + "] do not exist for the node [" + operation.getNodeName() + "] of the topology [" + topology.getId() + "]");
    }
    processRelationshipOperation(csar, topology, operation, nodeTemplate, relationshipTemplate);
}
Also used : RelationshipTemplate(org.alien4cloud.tosca.model.templates.RelationshipTemplate) NotFoundException(alien4cloud.exception.NotFoundException)

Example 74 with NotFoundException

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

the class UpdateRequirementSubstitutionTypeProcessor method process.

@Override
public void process(Csar csar, Topology topology, UpdateRequirementSubstitutionTypeOperation operation) {
    if (topology.getSubstitutionMapping() == null || topology.getSubstitutionMapping().getSubstitutionType() == null) {
        throw new NotFoundException("No substitution type has been found");
    }
    Map<String, SubstitutionTarget> substitutionRequirements = topology.getSubstitutionMapping().getRequirements();
    if (substitutionRequirements == null) {
        throw new NotFoundException("No substitution requirement has been found");
    }
    SubstitutionTarget target = substitutionRequirements.remove(operation.getSubstitutionRequirementId());
    if (target == null) {
        throw new NotFoundException("No substitution requirement has been found for key " + operation.getSubstitutionRequirementId());
    }
    if (substitutionRequirements.containsKey(operation.getNewRequirementId())) {
        throw new AlreadyExistException(String.format("Can not rename from <%s> to <%s> since requirement <%s> already exists", operation.getSubstitutionRequirementId(), operation.getNewRequirementId(), operation.getNewRequirementId()));
    }
    substitutionRequirements.put(operation.getNewRequirementId(), target);
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) SubstitutionTarget(org.alien4cloud.tosca.model.templates.SubstitutionTarget) AlreadyExistException(alien4cloud.exception.AlreadyExistException)

Example 75 with NotFoundException

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

the class DeploymentEventHandler method checkEnvironmentAuthorization.

private void checkEnvironmentAuthorization(User a4cUser, String environmentId) {
    ApplicationEnvironment environment = alienDAO.findById(ApplicationEnvironment.class, environmentId);
    if (environment == null) {
        log.error("Environment with id [{}] do not exist any more", environmentId);
        throw new NotFoundException("Environment with id [" + environmentId + "] do not exist any more");
    }
    AuthorizationUtil.checkAuthorization(a4cUser, environment, ApplicationRole.APPLICATION_MANAGER, ApplicationEnvironmentRole.values());
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment)

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