use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class DeleteInputProcessor method processInputOperation.
@Override
protected void processInputOperation(Csar csar, Topology topology, DeleteInputOperation operation, Map<String, PropertyDefinition> inputs) {
if (!inputs.containsKey(operation.getInputName())) {
throw new NotFoundException("Input " + operation.getInputName() + "not found in topology");
}
for (NodeTemplate nodeTemplate : safe(topology.getNodeTemplates()).values()) {
NodeType nodeType = ToscaContext.get(NodeType.class, nodeTemplate.getType());
removeInputIdInProperties(nodeTemplate.getProperties(), nodeType.getProperties(), operation.getInputName());
if (nodeTemplate.getRelationships() != null) {
for (RelationshipTemplate relationshipTemplate : nodeTemplate.getRelationships().values()) {
RelationshipType relationshipType = ToscaContext.get(RelationshipType.class, relationshipTemplate.getType());
removeInputIdInProperties(relationshipTemplate.getProperties(), relationshipType.getProperties(), operation.getInputName());
}
}
if (nodeTemplate.getCapabilities() != null) {
for (Capability capability : nodeTemplate.getCapabilities().values()) {
CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, capability.getType());
removeInputIdInProperties(capability.getProperties(), capabilityType.getProperties(), operation.getInputName());
}
}
}
deletePreConfiguredInput(csar, topology, operation);
inputs.remove(operation.getInputName());
log.debug("Remove the input " + operation.getInputName() + " from the topology " + topology.getId());
}
use of alien4cloud.exception.NotFoundException 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 alien4cloud.exception.NotFoundException 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 alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class CsarFileRepository method getExpandedCSAR.
@Override
public Path getExpandedCSAR(String name, String version) {
Path csarDir = rootPath.resolve(name).resolve(version);
Path expandedPath = csarDir.resolve("expanded");
if (Files.exists(expandedPath)) {
return expandedPath;
}
throw new NotFoundException("CSAR: " + name + ", Version: " + version + " not found in the repository.");
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class CsarFileRepository method getCSAR.
@Override
public Path getCSAR(String name, String version) {
Path csarDir = rootPath.resolve(name).resolve(version);
Path expandedPath = csarDir.resolve("expanded");
Path zippedPath = csarDir.resolve(name.concat("-").concat(version).concat("." + CSAR_EXTENSION));
if (Files.exists(zippedPath)) {
return zippedPath;
} else if (Files.exists(expandedPath)) {
// the csar wasn't stored as a zip file. Zip the expanded dir then
try {
FileUtil.zip(expandedPath, zippedPath);
return zippedPath;
} catch (IOException e) {
log.error("Failed to zip directory " + expandedPath, e);
throw new NotFoundException("CSAR: " + name + ", Version: " + version + " not found in the repository.");
}
}
throw new NotFoundException("CSAR: " + name + ", Version: " + version + " not found in the repository.");
}
Aggregations