use of org.eclipse.winery.repository.export.entries.RemoteRefBasedCsarEntry in project winery by eclipse.
the class YamlExporter method addManifest.
private String addManifest(IRepository repository, DefinitionsChildId id, Map<CsarContentProperties, CsarEntry> refMap, ZipOutputStream out, Map<String, Object> exportConfiguration) throws IOException {
String entryDefinitionsReference = getDefinitionsPathInsideCSAR(repository, id);
out.putNextEntry(new ZipEntry("TOSCA-Metadata/TOSCA.meta"));
StringBuilder stringBuilder = new StringBuilder();
// Setting Versions
stringBuilder.append(TOSCA_META_FILE_VERSION).append(": ").append(TOSCA_META_FILE_VERSION_VALUE).append("\n");
stringBuilder.append(CSAR_VERSION).append(": ").append(CSAR_VERSION_VALUE_FOR_YAML).append("\n");
stringBuilder.append(CREATED_BY).append(": Winery ").append(Environments.getInstance().getVersion()).append("\n");
// Winery currently is unaware of tDefinitions, therefore, we use the
// name of the service template
stringBuilder.append(ENTRY_DEFINITIONS).append(": ").append(entryDefinitionsReference).append("\n");
stringBuilder.append("\n");
assert (refMap.keySet().stream().anyMatch(fileProperties -> fileProperties.getPathInsideCsar().equals(entryDefinitionsReference)));
// Setting other files, mainly files belonging to artifacts
for (Map.Entry<CsarContentProperties, CsarEntry> item : refMap.entrySet()) {
final CsarEntry csarEntry = item.getValue();
final CsarContentProperties fileProperties = item.getKey();
stringBuilder.append(NAME).append(": ").append(fileProperties.getPathInsideCsar()).append("\n");
String mimeType;
if (csarEntry instanceof DocumentBasedCsarEntry) {
mimeType = MimeTypes.MIMETYPE_XSD;
} else if (csarEntry instanceof XMLDefinitionsBasedCsarEntry || csarEntry instanceof YAMLDefinitionsBasedCsarEntry || csarEntry instanceof DefinitionsBasedCsarEntry) {
mimeType = MimeTypes.MIMETYPE_TOSCA_DEFINITIONS;
} else if (csarEntry instanceof RemoteRefBasedCsarEntry) {
mimeType = repository.getMimeType((RemoteRefBasedCsarEntry) csarEntry);
} else {
mimeType = repository.getMimeType(((RepositoryRefBasedCsarEntry) csarEntry).getReference());
}
stringBuilder.append(CONTENT_TYPE).append(": ").append(mimeType).append("\n");
stringBuilder.append("\n");
}
String manifestString = stringBuilder.toString();
out.write(manifestString.getBytes());
out.closeEntry();
return manifestString;
}
use of org.eclipse.winery.repository.export.entries.RemoteRefBasedCsarEntry in project winery by eclipse.
the class YamlToscaExportUtil method putRemoteRefAsReferencedItemInCsar.
/**
* Puts the given reference as item in the CSAR
* <p>
* Thereby, it uses the global variable referencesToPathInCSARMap
*/
protected String putRemoteRefAsReferencedItemInCsar(URL url, String typePath, String artifactName) {
RemoteRefBasedCsarEntry ref = new RemoteRefBasedCsarEntry(url);
String fileName = FilenameUtils.getName(url.getPath());
String type = StringUtils.removeEnd(typePath, "/");
String path = StringUtils.join(Arrays.asList(type, "files", artifactName, fileName), "/");
this.referencesToPathInCSARMap.put(new CsarContentProperties(path), ref);
return path;
}
Aggregations