Workflow duplicate artifacts in CSAR 39/70939/2
authorpriyanshu <pagarwal@amdocs.com>
Mon, 22 Oct 2018 12:24:45 +0000 (17:54 +0530)
committerAvi Gaffa <avi.gaffa@amdocs.com>
Tue, 23 Oct 2018 07:44:25 +0000 (07:44 +0000)
Old workflow artifacts still packed in csar even if another workflow is assigned to same operation

Change-Id: Iee956903222d1fc1e8c898b4989b2198501554bb
Issue-ID: SDC-1862
Signed-off-by: priyanshu <pagarwal@amdocs.com>
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java

index 03ffdd5..65260c1 100644 (file)
@@ -3162,6 +3162,16 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
         }
 
         String uniqueId = implementationArtifact.getUniqueId();
+        Either<Long, CassandraOperationStatus> artifactCount = artifactCassandraDao.getCountOfArtifactById(uniqueId);
+        if(artifactCount.isLeft()){
+            CassandraOperationStatus cassandraOperationStatus = artifactCassandraDao.deleteArtifact(uniqueId);
+            if(cassandraOperationStatus != CassandraOperationStatus.OK){
+                log.debug("Failed to persist operation {} artifact, error is {}",operation.getName(),cassandraOperationStatus);
+                StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(cassandraOperationStatus);
+                ActionStatus convertedFromStorageResponse = componentsUtils.convertFromStorageResponse(storageStatus);
+                return Either.right(componentsUtils.getResponseFormat(convertedFromStorageResponse));
+            }
+        }
         artifactData.setId(uniqueId);
         CassandraOperationStatus cassandraOperationStatus = artifactCassandraDao.saveArtifact(artifactData);
         if(cassandraOperationStatus != CassandraOperationStatus.OK){