Fix NPE when deleting interface operation 96/133096/3
authorMichaelMorris <michael.morris@est.tech>
Tue, 31 Jan 2023 15:23:35 +0000 (15:23 +0000)
committerVasyl Razinkov <vasyl.razinkov@est.tech>
Thu, 2 Feb 2023 12:20:28 +0000 (12:20 +0000)
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-4364
Change-Id: If4072bd37e2fd361a59eb5c3e503c152c93b5d96

catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java

index 69f7ee0..fa93e8b 100644 (file)
@@ -130,8 +130,9 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
                 if (validateDeleteOperationContainsNoMappedOutputResponse.isRight()) {
                     return Either.right(validateDeleteOperationContainsNoMappedOutputResponse.right().value());
                 }
-                String artifactUniqueId = storedOperation.getImplementation().getUniqueId();
-                if (artifactUniqueId != null && !InterfaceOperationUtils.isArtifactInUse(storedComponent, operationId, artifactUniqueId)) {
+                final ArtifactDataDefinition implementation = storedOperation.getImplementation();
+                if (implementation != null && implementation.getUniqueId() != null && !InterfaceOperationUtils.isArtifactInUse(storedComponent, operationId, implementation.getUniqueId())) {
+                    final String artifactUniqueId = implementation.getUniqueId();
                     Either<ArtifactDefinition, StorageOperationStatus> getArtifactEither = artifactToscaOperation
                         .getArtifactById(storedComponent.getUniqueId(), artifactUniqueId);
                     if (getArtifactEither.isLeft()) {
@@ -142,7 +143,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
                             janusGraphDao.rollback();
                             ResponseFormat responseFormatByArtifactId = componentsUtils
                                 .getResponseFormatByArtifactId(componentsUtils.convertFromStorageResponse(removeArifactFromComponent.right().value()),
-                                    storedOperation.getImplementation().getArtifactDisplayName());
+                                        implementation.getArtifactDisplayName());
                             return Either.right(responseFormatByArtifactId);
                         }
                         CassandraOperationStatus cassandraStatus = artifactCassandraDao.deleteArtifact(artifactUniqueId);
@@ -150,7 +151,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
                             janusGraphDao.rollback();
                             ResponseFormat responseFormatByArtifactId = componentsUtils.getResponseFormatByArtifactId(
                                 componentsUtils.convertFromStorageResponse(componentsUtils.convertToStorageOperationStatus(cassandraStatus)),
-                                storedOperation.getImplementation().getArtifactDisplayName());
+                                implementation.getArtifactDisplayName());
                             return Either.right(responseFormatByArtifactId);
                         }
                     }