diff options
author | Chris André <chris.andre@yoppworks.com> | 2020-06-02 11:37:03 -0400 |
---|---|---|
committer | Chris André <chris.andre@yoppworks.com> | 2020-06-02 12:07:24 -0400 |
commit | 8a5f3aebc6b5681c5c44307b7a0cdf868802e790 (patch) | |
tree | ce61daf692f495e5fa8241cc69d7cffd40d3892f /catalog-be | |
parent | 64ff2b9fa9eca541603a8e2f2bd08bf24de25338 (diff) |
ArtifactsBusinessLogic refactor to remove NullPointerException
- Reformatted `downloadResourceInstanceArtifactByUUIDs`
- Fixed Sonar-related warning regarding a NPE in `validateInput`
Issue-ID: SDC-2979
Signed-off-by: Chris Andre <chris.andre@yoppworks.com>
Change-Id: I5a62daabcc436f28fba1f09317c5723281df15bf
Diffstat (limited to 'catalog-be')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 1db7d447f6..a91497356b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -1142,7 +1142,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (isDeploymentArtifact(artifactInfo)) { if (componentType != ComponentTypeEnum.RESOURCE_INSTANCE) { final String artifactName = artifactInfo.getArtifactName(); - if (operation.isCreateOrLink() || !artifactName.equalsIgnoreCase(existingArtifactInfo.getArtifactName())) { + final String existingArtifactName = + (existingArtifactInfo == null) ? null : existingArtifactInfo.getArtifactName(); + + if (operation.isCreateOrLink() + || ((artifactName != null) && !artifactName.equalsIgnoreCase(existingArtifactName))) { validateSingleDeploymentArtifactName(artifactName, parentComponent); } } @@ -3833,8 +3837,12 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { public byte[] downloadResourceInstanceArtifactByUUIDs(ComponentTypeEnum componentType, String componentUuid, String resourceInstanceName, String artifactUUID) { ComponentInstance resourceInstance = getRelatedComponentInstance(componentType, componentUuid, resourceInstanceName); - return downloadArtifact(resourceInstance == null ? null : resourceInstance.getDeploymentArtifacts(), - artifactUUID, resourceInstance.getName()); + + if (resourceInstance != null) { + return downloadArtifact(resourceInstance.getDeploymentArtifacts(), artifactUUID, resourceInstance.getName()); + } else { + return downloadArtifact(null, artifactUUID, null); + } } /** |