Search in sources :

Example 1 with GenericDirectoryId

use of org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId in project winery by eclipse.

the class NodeTypeResource method uploadArtifact.

@Path("artifacts/{name}")
public GenericFileResource uploadArtifact(@PathParam("name") String name) {
    DirectoryId dir = new GenericDirectoryId(this.getId(), IdNames.FILES_DIRECTORY);
    DirectoryId files = new GenericDirectoryId(dir, name);
    return new GenericFileResource(files);
}
Also used : GenericFileResource(org.eclipse.winery.repository.rest.resources._support.GenericFileResource) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) GenericDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId) GenericDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId) Path(javax.ws.rs.Path)

Example 2 with GenericDirectoryId

use of org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId in project winery by eclipse.

the class NodeTemplateResource method postYamlArtifactFile.

@Path("yamlartifacts/{artifactId}")
public GenericFileResource postYamlArtifactFile(@PathParam("artifactId") String id) {
    DirectoryId serviceTemplateYamlArtifactsDir = new GenericDirectoryId(getServiceTemplateResource().getId(), IdNames.FILES_DIRECTORY);
    DirectoryId nodeTemplateYamlArtifactsDir = new GenericDirectoryId(serviceTemplateYamlArtifactsDir, nodeTemplate.getId());
    DirectoryId yamlArtifactFilesDirectoryId = new GenericDirectoryId(nodeTemplateYamlArtifactsDir, id);
    return new GenericFileResource(yamlArtifactFilesDirectoryId);
}
Also used : GenericFileResource(org.eclipse.winery.repository.rest.resources._support.GenericFileResource) GenericDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) GenericDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId) Path(javax.ws.rs.Path)

Example 3 with GenericDirectoryId

use of org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId in project winery by eclipse.

the class YamlCsarImporter method importArtifacts.

private void importArtifacts(Path rootPath, TExtensibleElements ci, DefinitionsChildId wid, TOSCAMetaFile tmf, final List<String> errors) {
    if (ci instanceof TServiceTemplate) {
        TServiceTemplate st = (TServiceTemplate) ci;
        if (st.getTopologyTemplate() != null) {
            st.getTopologyTemplate().getNodeTemplates().forEach(node -> {
                if (Objects.nonNull(node.getArtifacts()) && !node.getArtifacts().isEmpty()) {
                    node.getArtifacts().stream().map(this::fixForwardSlash).filter(a -> this.isImportable(rootPath, a)).forEach(a -> {
                        DirectoryId stFilesDir = new GenericDirectoryId(wid, IdNames.FILES_DIRECTORY);
                        DirectoryId ntFilesDir = new GenericDirectoryId(stFilesDir, node.getId());
                        DirectoryId artifactDir = new GenericDirectoryId(ntFilesDir, a.getName());
                        importArtifact(rootPath, a, artifactDir, tmf, errors);
                        fixArtifactRefName(rootPath, a);
                    });
                }
            });
        }
    } else if (ci instanceof TNodeType) {
        TNodeType nt = (TNodeType) ci;
        fixOperationImplFileRef(nt);
        if (Objects.nonNull(nt.getArtifacts()) && !nt.getArtifacts().isEmpty()) {
            nt.getArtifacts().stream().map(this::fixForwardSlash).filter(a -> this.isImportable(rootPath, a)).forEach(a -> {
                DirectoryId typeFilesDir = new GenericDirectoryId(wid, IdNames.FILES_DIRECTORY);
                DirectoryId artifactDir = new GenericDirectoryId(typeFilesDir, a.getName());
                importArtifact(rootPath, a, artifactDir, tmf, errors);
                fixArtifactRefName(rootPath, a);
            });
        }
    }
}
Also used : TArtifact(org.eclipse.winery.model.tosca.TArtifact) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) LoggerFactory(org.slf4j.LoggerFactory) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) HashSet(java.util.HashSet) IdNames(org.eclipse.winery.model.ids.IdNames) YamlRepository(org.eclipse.winery.repository.yaml.YamlRepository) BackendUtils(org.eclipse.winery.repository.backend.BackendUtils) Map(java.util.Map) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId) Util(org.eclipse.winery.repository.common.Util) Path(java.nio.file.Path) TImport(org.eclipse.winery.model.tosca.TImport) Filename(org.eclipse.winery.repository.backend.constants.Filename) VisualAppearanceId(org.eclipse.winery.repository.datatypes.ids.elements.VisualAppearanceId) YamlTOSCAMetaFileParser(org.eclipse.winery.model.csar.toscametafile.YamlTOSCAMetaFileParser) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) Logger(org.slf4j.Logger) Files(java.nio.file.Files) RepositoryFileReference(org.eclipse.winery.repository.common.RepositoryFileReference) FromCanonical(org.eclipse.winery.repository.yaml.converter.FromCanonical) Set(java.util.Set) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) RepositoryFactory(org.eclipse.winery.repository.backend.RepositoryFactory) Objects(java.util.Objects) YamlWriter(org.eclipse.winery.repository.converter.writer.YamlWriter) List(java.util.List) ToCanonical(org.eclipse.winery.repository.yaml.converter.ToCanonical) TExtensibleElements(org.eclipse.winery.model.tosca.TExtensibleElements) GitBasedRepository(org.eclipse.winery.repository.backend.filebased.GitBasedRepository) MultiException(org.eclipse.winery.model.converter.support.exception.MultiException) Namespaces(org.eclipse.winery.model.converter.support.Namespaces) IRepository(org.eclipse.winery.repository.backend.IRepository) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) Optional(java.util.Optional) ModelUtilities(org.eclipse.winery.model.tosca.utils.ModelUtilities) TOSCAMetaFile(org.eclipse.winery.model.csar.toscametafile.TOSCAMetaFile) YamlReader(org.eclipse.winery.repository.converter.reader.YamlReader) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) GenericDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) GenericDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId) GenericDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) TNodeType(org.eclipse.winery.model.tosca.TNodeType)

Aggregations

DirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId)3 GenericDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId)3 Path (javax.ws.rs.Path)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Namespaces (org.eclipse.winery.model.converter.support.Namespaces)1 MultiException (org.eclipse.winery.model.converter.support.exception.MultiException)1 TOSCAMetaFile (org.eclipse.winery.model.csar.toscametafile.TOSCAMetaFile)1 YamlTOSCAMetaFileParser (org.eclipse.winery.model.csar.toscametafile.YamlTOSCAMetaFileParser)1