return cc;
}
- private Either<ZipOutputStream, ResponseFormat> writeComponentInterface(Component component, ZipOutputStream zip,
- String fileName, boolean isAssociatedComponent) {
- try {
- Either<ToscaRepresentation, ToscaError> componentInterface = toscaExportUtils
- .exportComponentInterface(component, isAssociatedComponent);
- ToscaRepresentation componentInterfaceYaml = componentInterface.left().value();
- String mainYaml = componentInterfaceYaml.getMainYaml();
- String interfaceFileName = DEFINITIONS_PATH + ToscaExportHandler.getInterfaceFilename(fileName);
-
- zip.putNextEntry(new ZipEntry(interfaceFileName));
- zip.write(mainYaml.getBytes());
-
- } catch (Exception e) {
- log.error("#writeComponentInterface - zip writing failed with error: ", e);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
- }
+ private Either<ZipOutputStream, ResponseFormat> writeComponentInterface(
+ Component component,
+ ZipOutputStream zip,
+ String fileName,
+ boolean isAssociatedComponent
+ ) {
+ try {
+ Either<String, ToscaError> mainYaml = toscaExportUtils
+ .exportComponentInterface(component, isAssociatedComponent)
+ .left().map(ToscaRepresentation::getMainYaml);
+
+ // TODO: This should be done outside this function to keep this testable.
+ // We can probably achieve this once the other refactorings related to SDC-2812 are merged
+ String interfaceFileName = DEFINITIONS_PATH + ToscaExportHandler.getInterfaceFilename(fileName);
+ zip.putNextEntry(new ZipEntry(interfaceFileName));
+ zip.write(mainYaml.left().value().getBytes());
- return Either.left(zip);
- }
+ } catch (Exception e) {
+ log.error("#writeComponentInterface - zip writing failed with error: ", e);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ return Either.left(zip);
+ }
private Either<byte[], ActionStatus> getEntryData(String cassandraId, Component childComponent) {
if (cassandraId == null || cassandraId.isEmpty()) {