@Override public Topology createTopologyAsTemplate(String name, String description, String version, String workspace, String fromTopologyId) { NameValidationUtils.validate("topologyTemplateName", name); // Every version of a topology template has a Cloud Service Archive Csar csar = new Csar(name, StringUtils.isNotBlank(version) ? version : VersionUtil.DEFAULT_VERSION_NAME); csar.setWorkspace(workspace); csar.setDelegateType(ArchiveDelegateType.CATALOG.toString()); csar.setToscaDefinitionsVersion(ToscaParser.LATEST_DSL); if (description == null) { csar.setDescription("This archive has been created with alien4cloud."); } else { csar.setDescription("Enclosing archive for topology " + description); } Topology topology; if (fromTopologyId != null) { // "cloning" the topology // TODO Currently, the fromTopologyId is always null. If this implementation needed, please think about initializing the workflow topology = alienDAO.findById(Topology.class, fromTopologyId); } else { topology = new Topology(); // Init the workflow if the topology is totally new workflowBuilderService.initWorkflows(workflowBuilderService.buildTopologyContext(topology, csar)); } topology.setDescription(description); topology.setArchiveName(csar.getName()); topology.setArchiveVersion(csar.getVersion()); topology.setWorkspace(csar.getWorkspace()); archiveIndexer.importNewArchive(csar, topology, null); return topology; }
/** * Post process the archive: For every definition of the model it fills the id fields in the TOSCA elements from the key of the elements map. * * @param parsedArchive The archive to post process */ protected ParsingResult<ArchiveRoot> doProcess(Path archive, ParsingResult<ArchiveRoot> parsedArchive, String workspace) { String hash = FileUtil.deepSHA1(archive); parsedArchive.getResult().getArchive().setHash(hash); parsedArchive.getResult().getArchive().setWorkspace(workspace); // FIXME how should we manage hash for the topology tempalte ? processTopology(parsedArchive.getResult().getArchive().getWorkspace(), parsedArchive); // Injext archive hash in every indexed node type. processTypes(parsedArchive.getResult()); processArtifacts(archive, parsedArchive); processSubstitution(parsedArchive.getResult(), parsedArchive.getContext().getParsingErrors()); return parsedArchive; }
csar.setWorkspace(APP_WORKSPACE_PREFIX + ":" + applicationId); csar.setDelegateId(applicationId); csar.setDelegateType(delegateType);