use of org.eclipse.winery.repository.yaml.converter.ToCanonical in project winery by eclipse.
the class YamlRepository method convertToDefinitions.
/**
* Reads service template from target path and converts it to XML Definition
*
* @param targetPath target path of service template
* @param id id of requested Definition
* @param targetNamespace targetNamespace of requested Definition
* @return xml definitions
*/
private TDefinitions convertToDefinitions(Path targetPath, String id, String targetNamespace) throws IOException, MultiException {
YTServiceTemplate serviceTemplate = readServiceTemplate(targetPath);
ToCanonical converter = new ToCanonical(this);
return converter.convert(serviceTemplate, id, targetNamespace, targetPath.endsWith("ServiceTemplate.tosca"));
}
use of org.eclipse.winery.repository.yaml.converter.ToCanonical in project winery by eclipse.
the class YamlCsarImporter method parseDefinitionsElement.
@Override
protected Optional<TDefinitions> parseDefinitionsElement(Path entryDefinitionsPath, final List<String> errors) {
YamlReader reader = new YamlReader();
YTServiceTemplate serviceTemplate;
try {
serviceTemplate = reader.parse(new FileInputStream(entryDefinitionsPath.toFile()));
String name = serviceTemplate.getMetadata().get("name");
if (name == null) {
// fallback to filename
name = entryDefinitionsPath.toString().substring(entryDefinitionsPath.toString().indexOf("__") + 2, entryDefinitionsPath.toString().indexOf(".tosca"));
}
ToCanonical converter = new ToCanonical(targetRepository);
return Optional.of(converter.convert(serviceTemplate, name, serviceTemplate.getMetadata().get("targetNamespace"), true));
} catch (MultiException | FileNotFoundException e) {
e.printStackTrace();
LOGGER.error("Could not read the given entry definition " + e.getMessage());
}
return Optional.empty();
}
Aggregations