From 06b84593bea8b963266f8d2a8a62dce9feeb2181 Mon Sep 17 00:00:00 2001 From: Francis Toth Date: Fri, 1 May 2020 11:59:31 -0400 Subject: Refactor CsarUtil::getFromCassandra Signed-off-by: Francis Toth Change-Id: I510d1d7fb4f4a7d7152fd5ea6d4d5ff61deea23a Issue-ID: SDC-2812 --- .../main/java/org/openecomp/sdc/be/tosca/CsarUtils.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java index 47a84789f1..bb388fe311 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java @@ -652,17 +652,12 @@ public class CsarUtils { } private Either getFromCassandra(String cassandraId) { - Either artifactResponse = artifactCassandraDao.getArtifact(cassandraId); - - if (artifactResponse.isRight()) { - log.debug("Failed to fetch artifact from Cassandra by id {} error {} ", cassandraId, artifactResponse.right().value()); - - StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(artifactResponse.right().value()); - ActionStatus convertedFromStorageResponse = componentsUtils.convertFromStorageResponse(storageStatus); - return Either.right(convertedFromStorageResponse); - } - DAOArtifactData artifactData = artifactResponse.left().value(); - return Either.left(artifactData.getDataAsArray()); + return artifactCassandraDao.getArtifact(cassandraId) + .right().map(cos -> { + log.debug("Failed to fetch artifact from Cassandra by id {} error {} ", cassandraId, cos); + StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(cos); + return componentsUtils.convertFromStorageResponse(storageStatus); + }).left().map(DAOArtifactData::getDataAsArray); } private String createCsarBlock0(String metaFileVersion, String toscaConformanceLevel) { -- cgit 1.2.3-korg