Search in sources :

Example 61 with RepositoryFileReference

use of org.eclipse.winery.repository.common.RepositoryFileReference in project winery by eclipse.

the class GenericFileResource method deleteFile.

@DELETE
@Path("/{fileName}")
public Response deleteFile(@PathParam("fileName") String fileName, @QueryParam("path") String path) {
    path = Objects.isNull(path) ? "" : path;
    RepositoryFileReference ref = this.fileName2fileRef(fileName, path, true);
    return RestUtils.delete(ref);
}
Also used : RepositoryFileReference(org.eclipse.winery.repository.common.RepositoryFileReference) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 62 with RepositoryFileReference

use of org.eclipse.winery.repository.common.RepositoryFileReference in project winery by eclipse.

the class GenericFileResource method getFile.

@GET
@Path("/{fileName}")
public Response getFile(@PathParam("fileName") String fileName, @HeaderParam("If-Modified-Since") String modified, @QueryParam("path") String path) {
    path = Objects.isNull(path) ? "" : path;
    RepositoryFileReference ref = this.fileName2fileRef(fileName, path, true);
    return RestUtils.returnRepoPath(ref, modified);
}
Also used : RepositoryFileReference(org.eclipse.winery.repository.common.RepositoryFileReference) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 63 with RepositoryFileReference

use of org.eclipse.winery.repository.common.RepositoryFileReference in project winery by eclipse.

the class XmlRepositoryTest method containedFilesRecursesIntoSubDirectories.

@Test
public void containedFilesRecursesIntoSubDirectories() throws Exception {
    this.setRevisionTo("5cda0035a773a9c405a70759731be3977f37e3f3");
    ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId("http://winery.opentosca.org/test/artifacttemplates/fruits", "baobab-ArtifactTemplate-Peel", false);
    ArtifactTemplateFilesDirectoryId directoryId = new ArtifactTemplateFilesDirectoryId(artifactTemplateId);
    final SortedSet<RepositoryFileReference> containedFiles = repository.getContainedFiles(directoryId);
    // TODO: real content (relative paths, ...) not checked
    assertEquals(3, containedFiles.size());
}
Also used : ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) RepositoryFileReference(org.eclipse.winery.repository.common.RepositoryFileReference) Test(org.junit.jupiter.api.Test)

Example 64 with RepositoryFileReference

use of org.eclipse.winery.repository.common.RepositoryFileReference in project winery by eclipse.

the class CsarImporter method storeDefinitions.

public static void storeDefinitions(IRepository repository, DefinitionsChildId id, TDefinitions defs) {
    RepositoryFileReference ref = BackendUtils.getRefOfDefinitions(id);
    String s = BackendUtils.getXMLAsString(defs, true, repository);
    try {
        repository.putContentToFile(ref, s, MediaTypes.MEDIATYPE_TOSCA_DEFINITIONS);
    } catch (IllegalArgumentException | IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : RepositoryFileReference(org.eclipse.winery.repository.common.RepositoryFileReference) IOException(java.io.IOException)

Example 65 with RepositoryFileReference

use of org.eclipse.winery.repository.common.RepositoryFileReference in project winery by eclipse.

the class CsarImporter method importAllFiles.

/**
 * Imports all given files from the file system to the repository
 *
 * @param rootPath    used to make the path p relative in order to determine the mime type and the
 *                    RepositoryFileReference
 * @param files       list of all files
 * @param directoryId the id of the directory of the artifact template the files to attach to
 * @param tmf         the TOSCAMetaFile object used to determine the mimetype. Must not be null.
 * @param errors      list where import errors should be stored to
 */
protected void importAllFiles(Path rootPath, Collection<Path> files, DirectoryId directoryId, TOSCAMetaFile tmf, final List<String> errors) {
    // remove the filePathInsideRepo to correctly store the files in the files folder inside an artifact template
    // otherwise, the files are saved in the sub directory of the artifact template
    // this is required, to enable the cycle CSAR export, clean , import CSAR
    String pathInsideRepo = Util.getPathInsideRepo(directoryId);
    for (Path p : files) {
        if (!Files.exists(p)) {
            errors.add(String.format("File %1$s does not exist", p));
            return;
        }
        // directoryId already identifies the subdirectory
        RepositoryFileReference fileReference = new RepositoryFileReference(directoryId, p.getFileName().toString());
        importFile(p, fileReference, tmf, rootPath, errors);
    }
}
Also used : Path(java.nio.file.Path) RepositoryFileReference(org.eclipse.winery.repository.common.RepositoryFileReference)

Aggregations

RepositoryFileReference (org.eclipse.winery.repository.common.RepositoryFileReference)79 IOException (java.io.IOException)33 Path (java.nio.file.Path)24 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)17 QName (javax.xml.namespace.QName)14 ArtifactTemplateFilesDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId)14 InputStream (java.io.InputStream)13 ArrayList (java.util.ArrayList)12 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)12 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)9 Test (org.junit.jupiter.api.Test)9 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)8 PlanId (org.eclipse.winery.model.ids.elements.PlanId)8 PlansId (org.eclipse.winery.model.ids.elements.PlansId)8 IRepository (org.eclipse.winery.repository.backend.IRepository)8 MediaType (org.apache.tika.mime.MediaType)7 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)7 BufferedInputStream (java.io.BufferedInputStream)6 HashMap (java.util.HashMap)6 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)6