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);
}
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);
}
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());
}
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);
}
}
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);
}
}
Aggregations