Search in sources :

Example 1 with DirectoryId

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

the class BackendUtils method synchronizeReferences.

public static void synchronizeReferences(ArtifactTemplateId id) throws IOException {
    TArtifactTemplate template = RepositoryFactory.getRepository().getElement(id);
    DirectoryId fileDir = new ArtifactTemplateFilesDirectoryId(id);
    SortedSet<RepositoryFileReference> files = RepositoryFactory.getRepository().getContainedFiles(fileDir);
    if (files.isEmpty()) {
        // clear artifact references
        template.setArtifactReferences(null);
    } else {
        TArtifactTemplate.ArtifactReferences artifactReferences = new TArtifactTemplate.ArtifactReferences();
        template.setArtifactReferences(artifactReferences);
        List<TArtifactReference> artRefList = artifactReferences.getArtifactReference();
        for (RepositoryFileReference ref : files) {
            // determine path
            // path relative from the root of the CSAR is ok (COS01, line 2663)
            // double encoded - see ADR-0003
            String path = Util.getUrlPath(ref);
            // put path into data structure
            // we do not use Include/Exclude as we directly reference a concrete file
            TArtifactReference artRef = new TArtifactReference();
            artRef.setReference(path);
            artRefList.add(artRef);
        }
    }
    BackendUtils.persist(id, template);
}
Also used : ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TArtifactReference(org.eclipse.winery.model.tosca.TArtifactReference)

Example 2 with DirectoryId

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

the class YamlArtifactsSynchronizer method deleteNodeTemplate.

private void deleteNodeTemplate(TNodeTemplate nodeTemplate) throws IOException {
    DirectoryId artifactsDirectory = BackendUtils.getYamlArtifactsDirectoryOfNodeTemplate(this.serviceTemplateId, nodeTemplate.getId());
    repository.forceDelete(artifactsDirectory);
}
Also used : DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId)

Example 3 with DirectoryId

use of org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId 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 4 with DirectoryId

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

the class XmlRepositoryTest method getContainedFilesProducedCorrectPath.

@Test
public void getContainedFilesProducedCorrectPath() throws Exception {
    ArtifactTemplateId artifactTemplateWithFilesAndSourcesId = new ArtifactTemplateId("http://plain.winery.opentosca.org/artifacttemplates", "ArtifactTemplateWithFilesAndSources", false);
    DirectoryId fileDir = new ArtifactTemplateFilesDirectoryId(artifactTemplateWithFilesAndSourcesId);
    SortedSet<RepositoryFileReference> files = repository.getContainedFiles(fileDir);
    for (RepositoryFileReference ref : files) {
        assertFalse(ref.getSubDirectory().isPresent() && ref.getSubDirectory().get().toString().equals(""), "File " + ref.toString() + " contains empty sub directory");
    }
}
Also used : ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) ArtifactTemplateSourceDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateSourceDirectoryId) ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) RepositoryFileReference(org.eclipse.winery.repository.common.RepositoryFileReference) Test(org.junit.jupiter.api.Test)

Example 5 with DirectoryId

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

the class FilebasedRepositoryTest method getContainedFilesProducedCorrectPath.

@Test
public void getContainedFilesProducedCorrectPath() throws Exception {
    ArtifactTemplateId artifactTemplateWithFilesAndSourcesId = new ArtifactTemplateId("http://plain.winery.opentosca.org/artifacttemplates", "ArtifactTemplateWithFilesAndSources", false);
    DirectoryId fileDir = new ArtifactTemplateFilesDirectoryId(artifactTemplateWithFilesAndSourcesId);
    SortedSet<RepositoryFileReference> files = repository.getContainedFiles(fileDir);
    for (RepositoryFileReference ref : files) {
        Assert.assertFalse("File " + ref.toString() + " contains empty sub directory", ref.getSubDirectory().isPresent() && ref.getSubDirectory().get().toString().equals(""));
    }
}
Also used : ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) ArtifactTemplateSourceDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateSourceDirectoryId) ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) Test(org.junit.Test)

Aggregations

DirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId)16 ArtifactTemplateFilesDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId)7 RepositoryFileReference (org.eclipse.winery.common.RepositoryFileReference)4 RepositoryFileReference (org.eclipse.winery.repository.common.RepositoryFileReference)4 ArtifactTemplateSourceDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateSourceDirectoryId)4 GenericDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.GenericDirectoryId)4 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 Map (java.util.Map)3 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)3 TArtifactReference (org.eclipse.winery.model.tosca.TArtifactReference)3 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)3 URI (java.net.URI)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 ArtifactTemplateId (org.eclipse.winery.common.ids.definitions.ArtifactTemplateId)2 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)2 TExtensibleElements (org.eclipse.winery.model.tosca.TExtensibleElements)2 BackendUtils (org.eclipse.winery.repository.backend.BackendUtils)2