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