use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class AccountabilityResource method getFileHistory.
@GET
@Path("fileHistory")
@Produces(MediaType.APPLICATION_JSON)
public List<FileProvenanceElement> getFileHistory(@QueryParam("fileId") String fileId) {
ServiceTemplateId serviceTemplateId = new ServiceTemplateId(new QName(provenanceId));
String qNameWithComponentVersionOnly = VersionSupport.getQNameWithComponentVersionOnly(serviceTemplateId);
Objects.requireNonNull(fileId);
String fileIdDecoded = EncodingUtil.URLdecode(fileId);
try {
return getAccountabilityManager().getHistory(qNameWithComponentVersionOnly, fileIdDecoded).exceptionally(error -> null).get();
} catch (InterruptedException | ExecutionException | AccountabilityException e) {
LOGGER.error("Cannot history of file {}. Reason: {}", fileId, e.getMessage());
throw createException(e);
}
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class CsarExporterTest method csarFilesHaveImmutableStorageAddresses.
@Test
// todo check how to enable
@Disabled
public void csarFilesHaveImmutableStorageAddresses() throws Exception {
Map<String, Object> exportConfiguration = new HashMap<>();
exportConfiguration.put(STORE_IMMUTABLY.name(), null);
try (InputStream inputStream = this.createOutputAndInputStream("origin/plain", new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithAllReqCapVariants", false), exportConfiguration);
ZipInputStream zis = new ZipInputStream(inputStream)) {
ManifestContents manifestContents = parseManifest(zis);
assertNotNull(manifestContents);
for (String section : manifestContents.getSectionNames()) {
assertNotNull(manifestContents.getAttributesForSection(section).get(TOSCAMetaFileAttributes.IMMUTABLE_ADDRESS));
}
}
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class CsarExporterTest method testPutCsarInBlockchainAndImmutableStorage.
@Test
@Disabled
public // todo check how to enable
void testPutCsarInBlockchainAndImmutableStorage() throws Exception {
setRevisionTo("origin/plain");
CsarExporter exporter = new CsarExporter(repository);
DefinitionsChildId id = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithAllReqCapVariants", false);
ByteArrayOutputStream os = new ByteArrayOutputStream();
CompletableFuture<String> future = exporter.writeCsarAndSaveManifestInProvenanceLayer(id, os);
String transactionHash = future.get();
assertNotNull(transactionHash);
try (InputStream inputStream = new ByteArrayInputStream(os.toByteArray());
ZipInputStream zis = new ZipInputStream(inputStream)) {
ManifestContents manifestContents = parseManifest(zis);
assertNotNull(manifestContents);
for (String section : manifestContents.getSectionNames()) {
assertNotNull(manifestContents.getAttributesForSection(section).get(TOSCAMetaFileAttributes.IMMUTABLE_ADDRESS));
}
}
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class CsarExporterTest method testCsarFilesAreMentionedInTheManifest.
@Test
public void testCsarFilesAreMentionedInTheManifest() throws Exception {
Map<String, Object> exportConfiguration = new HashMap<>();
exportConfiguration.put(INCLUDE_HASHES.name(), null);
try (InputStream inputStream = this.createOutputAndInputStream("origin/plain", new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithAllReqCapVariants", false), exportConfiguration);
ZipInputStream zis = new ZipInputStream(inputStream)) {
ZipEntry entry;
List<String> elementsList = new ArrayList<>();
ManifestContents manifestContents = null;
while ((entry = zis.getNextEntry()) != null) {
String name = entry.getName();
elementsList.add(name);
assertNotNull(name);
assertFalse(name.contains("\\"), "name contains backslashes");
if ("TOSCA-Metadata/TOSCA.meta".equals(name)) {
byte[] bytes = IOUtils.toByteArray(zis);
String s = new String(bytes, StandardCharsets.UTF_8);
manifestContents = new RecoveringManifestParser().parse(s);
}
}
assertNotNull(manifestContents);
for (String section : manifestContents.getSectionNames()) {
// ensures that the file is contained in the archive
assertTrue(elementsList.remove(section), "Contains element " + section);
}
// ensures that the manifest was part of the archive
assertTrue(elementsList.remove("TOSCA-Metadata/TOSCA.meta"));
// ensures that every file in the archive is listed in the manifest
assertEquals(0, elementsList.size());
}
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class DriverInjectionTest method injectDriver.
@Test
public void injectDriver() throws Exception {
setRevisionTo("d8ee55deecf37f5052d27807df691a7b70ec50f2");
ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
TTopologyTemplate tTopologyTemplate = DriverInjection.injectDriver(topologyTemplate);
TNodeTemplate nodeTemplateWithAbstractDA = tTopologyTemplate.getNodeTemplate("shetland_pony");
List<TDeploymentArtifact> deploymentArtifacts = nodeTemplateWithAbstractDA.getDeploymentArtifacts();
List<String> deploymentArtifactNames = new ArrayList<>();
deploymentArtifacts.stream().forEach(da -> deploymentArtifactNames.add(da.getName()));
TRelationshipTemplate relationshipTemplate = tTopologyTemplate.getRelationshipTemplate("con_71");
assertEquals(2, deploymentArtifacts.size());
assertTrue(deploymentArtifactNames.contains("WesternEquipment_Pony"));
assertTrue(deploymentArtifactNames.contains("DressageEquipment_Pony"));
assertEquals("org.test.dressagedriver", ModelUtilities.getPropertiesKV(relationshipTemplate).get("Driver"));
}
Aggregations