aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-05-01 11:59:31 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-05 08:15:05 +0000
commit06b84593bea8b963266f8d2a8a62dce9feeb2181 (patch)
treeed7bae91c9f6c61fa9e2e7cb5f3bb533b6c603a2 /catalog-be/src/main
parent762a1a320d92ca7415265066dbe4dfd7df91c2ec (diff)
Refactor CsarUtil::getFromCassandra
Signed-off-by: Francis Toth <francis.toth@yoppworks.com> Change-Id: I510d1d7fb4f4a7d7152fd5ea6d4d5ff61deea23a Issue-ID: SDC-2812
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java17
1 files changed, 6 insertions, 11 deletions
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<byte[], ActionStatus> getFromCassandra(String cassandraId) {
- Either<DAOArtifactData, CassandraOperationStatus> 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) {