use of org.alien4cloud.tosca.editor.exception.PropertyValueException in project alien4cloud by alien4cloud.
the class UpdateCapabilityPropertyValueProcessor method process.
@Override
@SneakyThrows
public void process(Csar csar, Topology topology, UpdateCapabilityPropertyValueOperation operation) {
String propertyName = operation.getPropertyName();
Object propertyValue = operation.getPropertyValue();
Map<String, NodeTemplate> nodeTemplates = TopologyUtils.getNodeTemplates(topology);
NodeTemplate nodeTemplate = TopologyUtils.getNodeTemplate(topology.getId(), operation.getNodeName(), nodeTemplates);
Capability capability = nodeTemplate.getCapabilities().get(operation.getCapabilityName());
CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, capability.getType());
if (!capabilityType.getProperties().containsKey(propertyName)) {
throw new NotFoundException("Property <" + propertyName + "> doesn't exists for node <" + operation.getNodeName() + "> of type <" + capabilityType + ">");
}
log.debug("Updating property [ {} ] of the capability [ {} ] for the Node template [ {} ] from the topology [ {} ]: changing value from [{}] to [{}].", propertyName, capability.getType(), operation.getNodeName(), topology.getId(), capabilityType.getProperties().get(propertyName), propertyValue);
try {
propertyService.setCapabilityPropertyValue(capability, capabilityType.getProperties().get(propertyName), propertyName, propertyValue);
} catch (ConstraintFunctionalException e) {
throw new PropertyValueException("Error when setting node " + operation.getNodeName() + " property.", e, propertyName, propertyValue);
}
}
use of org.alien4cloud.tosca.editor.exception.PropertyValueException in project alien4cloud by alien4cloud.
the class UpdateNodePropertyValueProcessor method process.
@Override
public void process(Csar csar, Topology topology, UpdateNodePropertyValueOperation operation) {
Map<String, NodeTemplate> nodeTemplates = TopologyUtils.getNodeTemplates(topology);
NodeTemplate nodeTemp = TopologyUtils.getNodeTemplate(topology.getId(), operation.getNodeName(), nodeTemplates);
String propertyName = operation.getPropertyName();
Object propertyValue = operation.getPropertyValue();
NodeType node = ToscaContext.getOrFail(NodeType.class, nodeTemp.getType());
PropertyDefinition propertyDefinition = node.getProperties().get(propertyName);
if (propertyDefinition == null) {
throw new NotFoundException("Property <" + propertyName + "> doesn't exists for node <" + operation.getNodeName() + "> of type <" + nodeTemp.getType() + ">");
}
log.debug("Updating property [ {} ] of the Node template [ {} ] from the topology [ {} ]: changing value from [{}] to [{}].", propertyName, operation.getNodeName(), topology.getId(), nodeTemp.getProperties().get(propertyName), propertyValue);
try {
propertyService.setPropertyValue(nodeTemp, propertyDefinition, propertyName, propertyValue);
} catch (ConstraintFunctionalException e) {
throw new PropertyValueException("Error when setting node " + operation.getNodeName() + " property.", e, propertyName, propertyValue);
}
}
use of org.alien4cloud.tosca.editor.exception.PropertyValueException in project alien4cloud by alien4cloud.
the class UpdatePolicyPropertyValueProcessor method process.
@Override
protected void process(Csar csar, Topology topology, UpdatePolicyPropertyValueOperation operation, PolicyTemplate policyTemplate) {
PolicyType policyType = ToscaContext.getOrFail(PolicyType.class, policyTemplate.getType());
PropertyDefinition propertyDefinition = AlienUtils.getOrFail(policyType.getProperties(), operation.getPropertyName(), "Property [ {} ] doesn't exists in type [ {} ] for policy [ {} ].", operation.getPropertyName(), policyTemplate.getType(), operation.getPolicyName());
log.debug("Updating property [ {} ] of the policy template [ {} ] from the topology [ {} ]: changing value from [{}] to [{}].", operation.getPropertyName(), operation.getPolicyName(), topology.getId(), policyTemplate.getProperties().get(operation.getPropertyName()), operation.getPropertyValue());
try {
propertyService.setPropertyValue(policyTemplate, propertyDefinition, operation.getPropertyName(), operation.getPropertyValue());
} catch (ConstraintFunctionalException e) {
throw new PropertyValueException("Error when setting policy " + operation.getPolicyName() + " property.", e, operation.getPropertyName(), operation.getPropertyValue());
}
}
use of org.alien4cloud.tosca.editor.exception.PropertyValueException in project alien4cloud by alien4cloud.
the class UpdateRelationshipPropertyValueProcessor method process.
@Override
public void process(Csar csar, Topology topology, UpdateRelationshipPropertyValueOperation operation) {
NodeTemplate nodeTemplate = AlienUtils.getOrFail(topology.getNodeTemplates(), operation.getNodeName(), "The node with name [ {} ] cannot be found in the topology.", operation.getNodeName());
RelationshipTemplate relationshipTemplate = AlienUtils.getOrFail(nodeTemplate.getRelationships(), operation.getRelationshipName(), "The relationship with name [ {} ] cannot be found in the node [ {} ].", operation.getRelationshipName(), operation.getNodeName());
RelationshipType relationshipType = ToscaContext.getOrFail(RelationshipType.class, relationshipTemplate.getType());
PropertyDefinition propertyDefinition = AlienUtils.getOrFail(relationshipType.getProperties(), operation.getPropertyName(), "Property [ {} ] doesn't exists in type [ {} ] for relationship [ {} ] of node [ {} ].", operation.getPropertyName(), relationshipTemplate.getType(), operation.getRelationshipName(), operation.getNodeName());
log.debug("Updating property [ {} ] of the relationship [ {} ] for the Node template [ {} ] from the topology [ {} ]: changing value from [{}] to [{}].", operation.getPropertyName(), relationshipType, operation.getNodeName(), topology.getId(), relationshipType.getProperties().get(operation.getPropertyName()), operation.getPropertyValue());
try {
propertyService.setPropertyValue(relationshipTemplate, propertyDefinition, operation.getPropertyName(), operation.getPropertyValue());
} catch (ConstraintFunctionalException e) {
throw new PropertyValueException("Error when setting relationship " + operation.getNodeName() + "." + operation.getRelationshipName() + " property.", e, operation.getPropertyName(), operation.getPropertyValue());
}
}
Aggregations