aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-04-22 11:00:52 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-04-26 11:29:36 +0000
commitc9e4d0ec9f9d3ac9f420c12573964e511baf8831 (patch)
tree08c0b4865440aea45d43e213c92be599d5c31970 /catalog-be/src
parent3bb06374d5b6747d32ea9554259596d0a45fadc2 (diff)
Fix potential NPE in ArtifactsBusinessLogic
Fixes potential NPE in ArtifactsBusinessLogic introduced by SDC-2754. Change-Id: If53915ffc41ddd0dbcf00ea318cdae6f1b5471ad Issue-ID: SDC-2959 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java23
1 files changed, 15 insertions, 8 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 b41d076e2a..f48b3ebbbe 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
@@ -1075,6 +1075,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
final ArtifactDefinition existingArtifactInfo =
findArtifact(parentComponent, componentType, componentId, operation, artifactId);
+ final boolean isCreateOrLinkOperation =
+ ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum());
+ if (!isCreateOrLinkOperation && existingArtifactInfo == null) {
+ throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_NOT_FOUND, artifactId);
+ }
final Component component;
if (parentComponent.getUniqueId().equals(componentId)) {
component = parentComponent;
@@ -1083,8 +1088,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
component = findComponent(componentInstance.getComponentUid());
component.setComponentType(componentType);
}
-
- ignoreUnupdateableFieldsInUpdate(operation, artifactInfo, existingArtifactInfo);
+ if (!isCreateOrLinkOperation) {
+ ignoreUnupdateableFieldsInUpdate(operation, artifactInfo, existingArtifactInfo);
+ }
if (isInformationalArtifact(artifactInfo)) {
validateInformationalArtifact(artifactInfo, component);
}
@@ -1108,8 +1114,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
final ArtifactGroupTypeEnum artifactGroupType =
operationName != null ? ArtifactGroupTypeEnum.LIFE_CYCLE : ArtifactGroupTypeEnum.INFORMATIONAL;
- final boolean isCreateOrLink = ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum());
- if (!isCreateOrLink) {
+ if (!isCreateOrLinkOperation) {
checkAndSetUnUpdatableFields(user, artifactInfo, existingArtifactInfo, artifactGroupType);
} else {
checkCreateFields(user, artifactInfo, artifactGroupType);
@@ -1118,13 +1123,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
composeArtifactId(componentId, artifactId, artifactInfo, interfaceName, operationName);
if (existingArtifactInfo != null) {
artifactInfo.setMandatory(existingArtifactInfo.getMandatory());
- if (!isCreateOrLink) {
+ if (!isCreateOrLinkOperation) {
validateArtifactTypeNotChanged(artifactInfo, existingArtifactInfo);
}
}
// artifactGroupType is not allowed to be updated
- if (!isCreateOrLink) {
+ if (!isCreateOrLinkOperation) {
Either<ArtifactDefinition, ResponseFormat> validateGroupType = validateOrSetArtifactGroupType(artifactInfo, existingArtifactInfo);
if (validateGroupType.isRight()) {
return Either.right(validateGroupType.right().value());
@@ -1138,7 +1143,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (isDeploymentArtifact(artifactInfo)) {
if (componentType != ComponentTypeEnum.RESOURCE_INSTANCE) {
final String artifactName = artifactInfo.getArtifactName();
- if (isCreateOrLink || !artifactName.equalsIgnoreCase(existingArtifactInfo.getArtifactName())) {
+ if (isCreateOrLinkOperation || !artifactName.equalsIgnoreCase(existingArtifactInfo.getArtifactName())) {
validateSingleDeploymentArtifactName(artifactName, parentComponent);
}
}
@@ -1192,7 +1197,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return component.left().value();
}
- private void ignoreUnupdateableFieldsInUpdate(ArtifactOperationInfo operation, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifactInfo) {
+ private void ignoreUnupdateableFieldsInUpdate(final ArtifactOperationInfo operation,
+ final ArtifactDefinition artifactInfo,
+ final ArtifactDefinition currentArtifactInfo) {
if (operation.getArtifactOperationEnum() == ArtifactOperationEnum.UPDATE) {
artifactInfo.setArtifactType(currentArtifactInfo.getArtifactType());
artifactInfo.setArtifactGroupType(currentArtifactInfo.getArtifactGroupType());