summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2022-04-14 15:19:07 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2022-04-21 11:50:55 +0000
commit18950cf448def2f5b8493724c1b01b1292672c1d (patch)
tree2aa34998f96d23b6d47d2bcaed2404ccfba7d54b
parent117fb0e50d4b83f2f3faa7c372458ef539c63664 (diff)
Enable identification of system deployed VFCs
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3972 Change-Id: Ia3513020f508275827b34111c6eb2921204d9320
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java249
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java1
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java3
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java1
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java4
10 files changed, 29 insertions, 242 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 8c6e9cb2a2..0681dd495e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -148,7 +148,7 @@ public class ResourceImportManager {
lifecycleChangeInfo.setUserRemarks("certification on import");
Function<Resource, Boolean> validator = resource -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, createNewVersion,
- needLock, null, null, false, null, null, false);
+ needLock, null, null, false, null, null, false);
}
public void importAllNormativeResource(final String resourcesYaml, final NodeTypesMetadataList nodeTypesMetadataList, final User user,
@@ -215,6 +215,7 @@ public class ResourceImportManager {
setMetaDataFromJson(resourceMetaData, resource);
populateResourceFromYaml(resourceYml, resource);
validationFunction.apply(resource);
+ resource.getComponentMetadataDefinition().getMetadataDataDefinition().setNormative(resourceMetaData.isNormative());
checkResourceExists(createNewVersion, csarInfo, resource);
resource = resourceBusinessLogic
.createOrUpdateResourceByImport(resource, creator, true, isInTransaction, needLock, csarInfo, nodeName, isNested).left;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
index 02f96ad09e..7c300b310d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
@@ -292,6 +292,7 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
if (resourceInfoObject == null) {
isValid = false;
} else {
+ resourceInfoObject.setNormative(!resourceAuthorityEnum.isUserTypeResource());
if (!resourceAuthorityEnum.isBackEndImport()) {
isValid = resourceInfoObject.getPayloadName() != null && !resourceInfoObject.getPayloadName().isEmpty();
//only resource name is checked
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
index 6f20e2d469..80b5cf09bc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
@@ -155,7 +155,7 @@ public class ResourceImportManagerTest {
testSetConstantMetaData(resource);
testSetMetaDataFromJson(resource, resourceMD);
-
+
testSetDerivedFrom(resource);
testSetProperties(resource);
@@ -432,6 +432,7 @@ public class ResourceImportManagerTest {
resourceMD.setTags(Collections.singletonList("BlockStorage"));
resourceMD.setDescription("Represents a server-local block storage device (i.e., not shared) offering evenly sized blocks of data from which raw storage volumes can be created.");
resourceMD.setResourceVendorModelNumber("vendorReleaseNumber");
+ resourceMD.setNormative(true);
return resourceMD;
}
@@ -538,7 +539,7 @@ public class ResourceImportManagerTest {
for (String tag : resource.getTags()) {
assertTrue(resourceMD.getTags().contains(tag));
}
-
+ assertEquals(resourceMD.isNormative(), resource.getComponentMetadataDefinition().getMetadataDataDefinition().isNormative());
}
private void testSetConstantMetaData(Resource resource) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java
index da83b8f41b..ced62ac55f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java
@@ -43,6 +43,7 @@ public class NodeTypeMetadata {
private String vendorRelease;
private String resourceVendorModelNumber;
private String resourceType = ResourceTypeEnum.VFC.getValue();
+ private boolean isNormative = true;
private List<String> tags;
private List<CategoryDefinition> categories;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java
index dcb01169c6..e853b64f93 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java
@@ -21,12 +21,14 @@ package org.openecomp.sdc.be.model;
import java.util.ArrayList;
import java.util.List;
+import lombok.Data;
import lombok.NoArgsConstructor;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.common.api.UploadArtifactInfo;
@NoArgsConstructor
+@Data
public class UploadResourceInfo {
private String payloadData;
@@ -35,9 +37,16 @@ public class UploadResourceInfo {
private List<String> tags;
private List<CategoryDefinition> categories;
private List<UploadArtifactInfo> artifactList;
- private String contactId, name, resourceIconPath, icon, vendorName, vendorRelease, resourceVendorModelNumber;
+ private String contactId;
+ private String name;
+ private String resourceIconPath;
+ private String icon;
+ private String vendorName;
+ private String vendorRelease;
+ private String resourceVendorModelNumber;
private String resourceType = "VFC";
private String model;
+ private boolean isNormative;
public UploadResourceInfo(String payload, String payloadName, String description, String category, List<String> tags,
List<UploadArtifactInfo> artifactsList, String modelName) {
@@ -61,249 +70,11 @@ public class UploadResourceInfo {
}
}
- public String getPayloadData() {
- return payloadData;
- }
-
- public void setPayloadData(String payload) {
- this.payloadData = payload;
- }
-
- public String getPayloadName() {
- return payloadName;
- }
-
- public void setPayloadName(String payloadName) {
- this.payloadName = payloadName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<String> getTags() {
- return tags;
- }
-
- public void setTags(List<String> tags) {
- this.tags = tags;
- }
-
- public List<UploadArtifactInfo> getArtifactList() {
- return artifactList;
- }
-
- public void setArtifactList(List<UploadArtifactInfo> artifactsList) {
- this.artifactList = artifactsList;
- }
-
- public String getModel() {
- return model;
- }
-
- public void setModel(final String model) {
- this.model = model;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((artifactList == null) ? 0 : artifactList.hashCode());
- result = prime * result + ((contactId == null) ? 0 : contactId.hashCode());
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((icon == null) ? 0 : icon.hashCode());
- result = prime * result + ((payloadData == null) ? 0 : payloadData.hashCode());
- result = prime * result + ((payloadName == null) ? 0 : payloadName.hashCode());
- result = prime * result + ((resourceIconPath == null) ? 0 : resourceIconPath.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((tags == null) ? 0 : tags.hashCode());
- result = prime * result + ((vendorName == null) ? 0 : vendorName.hashCode());
- result = prime * result + ((vendorRelease == null) ? 0 : vendorRelease.hashCode());
- result = prime * result + ((model == null) ? 0 : model.hashCode());
- result = prime * result + ((resourceVendorModelNumber == null) ? 0 : resourceVendorModelNumber.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- UploadResourceInfo other = (UploadResourceInfo) obj;
- if (artifactList == null) {
- if (other.artifactList != null) {
- return false;
- }
- } else if (!artifactList.equals(other.artifactList)) {
- return false;
- }
- if (contactId == null) {
- if (other.contactId != null) {
- return false;
- }
- } else if (!contactId.equals(other.contactId)) {
- return false;
- }
- if (description == null) {
- if (other.description != null) {
- return false;
- }
- } else if (!description.equals(other.description)) {
- return false;
- }
- if (icon == null) {
- if (other.icon != null) {
- return false;
- }
- } else if (!icon.equals(other.icon)) {
- return false;
- }
- if (payloadData == null) {
- if (other.payloadData != null) {
- return false;
- }
- } else if (!payloadData.equals(other.payloadData)) {
- return false;
- }
- if (payloadName == null) {
- if (other.payloadName != null) {
- return false;
- }
- } else if (!payloadName.equals(other.payloadName)) {
- return false;
- }
- if (resourceIconPath == null) {
- if (other.resourceIconPath != null) {
- return false;
- }
- } else if (!resourceIconPath.equals(other.resourceIconPath)) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (tags == null) {
- if (other.tags != null) {
- return false;
- }
- } else if (!tags.equals(other.tags)) {
- return false;
- }
- if (model == null) {
- if (other.model != null) {
- return false;
- }
- } else if (!model.equals(other.model)) {
- return false;
- }
- if (vendorName == null) {
- if (other.vendorName != null) {
- return false;
- }
- } else if (!vendorName.equals(other.vendorName)) {
- return false;
- }
- if (resourceVendorModelNumber == null) {
- if (other.resourceVendorModelNumber != null) {
- return false;
- }
- } else if (!resourceVendorModelNumber.equals(other.resourceVendorModelNumber)) {
- return false;
- }
- if (vendorRelease == null) {
- if (other.vendorRelease != null) {
- return false;
- }
- } else if (!vendorRelease.equals(other.vendorRelease)) {
- return false;
- }
- return true;
- }
-
- public String getContactId() {
- return contactId;
- }
-
- public void setContactId(String userId) {
- this.contactId = userId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String resourceName) {
- this.name = resourceName;
- }
-
// Icon when using UI import otherwise resourceIconPath
public String getResourceIconPath() {
return (resourceIconPath != null) ? resourceIconPath : icon;
}
- public void setResourceIconPath(String resourceIconPath) {
- this.resourceIconPath = resourceIconPath;
- }
-
- public String getVendorName() {
- return vendorName;
- }
-
- public void setVendorName(String vendorName) {
- this.vendorName = vendorName;
- }
-
- public String getVendorRelease() {
- return vendorRelease;
- }
-
- public void setVendorRelease(String vendorRelease) {
- this.vendorRelease = vendorRelease;
- }
-
- public String getResourceVendorModelNumber() {
- return resourceVendorModelNumber;
- }
-
- public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
- this.resourceVendorModelNumber = resourceVendorModelNumber;
- }
-
- public void setIcon(String icon) {
- this.icon = icon;
- }
-
- public String getResourceType() {
- return resourceType;
- }
-
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
- }
-
- public List<CategoryDefinition> getCategories() {
- return categories;
- }
-
- public void setCategories(List<CategoryDefinition> categories) {
- this.categories = categories;
- }
-
public void addSubCategory(String category, String subCategory) {
if (category != null || subCategory != null) {
if (categories == null) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
index 16d225a2b2..6dfaebc947 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
@@ -743,6 +743,8 @@ public class ModelConverter {
} else {
resource.setResourceVendorModelNumber("");
}
+ Boolean isNormative = toscaElement.getMetadataValue(JsonPresentationFields.NORMATIVE) == null ? false : (Boolean) toscaElement.getMetadataValue(JsonPresentationFields.NORMATIVE);
+ resource.getComponentMetadataDefinition().getMetadataDataDefinition().setNormative(isNormative);
} else if (component.getComponentType() == ComponentTypeEnum.SERVICE) {
Service service = (Service) component;
if (((String) toscaElement.getMetadataValue(JsonPresentationFields.SERVICE_TYPE)) != null) {
@@ -1308,6 +1310,7 @@ public class ModelConverter {
} else {
toscaElement.setMetadataValue(JsonPresentationFields.RESOURCE_VENDOR_MODEL_NUMBER, "");
}
+ toscaElement.setMetadataValue(JsonPresentationFields.NORMATIVE, ((Resource) component).getComponentMetadataDefinition().getMetadataDataDefinition().isNormative());
} else if (component.getComponentType() == ComponentTypeEnum.SERVICE) {
// field isn't mandatory , but shouldn't be null(should be an empty string instead)
if (((Service) component).getServiceType() != null) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java
index feef044b7f..20730814a6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java
@@ -46,6 +46,7 @@ public class NodeTypeMetadataMapper {
uploadResourceInfo.setResourceType(nodeTypeMetadata.getResourceType());
uploadResourceInfo.setTags(nodeTypeMetadata.getTags());
uploadResourceInfo.setCategories(nodeTypeMetadata.getCategories());
+ uploadResourceInfo.setNormative(nodeTypeMetadata.isNormative());
return uploadResourceInfo;
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java
index d6588e96e1..4b94adb829 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java
@@ -74,6 +74,7 @@ public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinitio
private Boolean isVspArchived = false;
private Map<String, String> categorySpecificMetadata;
private String model;
+ private boolean normative = false;
protected ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
this.uniqueId = other.getUniqueId();
@@ -102,6 +103,7 @@ public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinitio
this.archiveTime = other.getArchiveTime();
this.categorySpecificMetadata = other.getCategorySpecificMetadata();
this.model = other.getModel();
+ this.normative = other.isNormative();
}
protected ComponentMetadataDataDefinition(JsonPresentationFieldsExtractor extractor) {
@@ -129,6 +131,7 @@ public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinitio
this.isVspArchived = extractor.isVspArchived();
this.archiveTime = extractor.getArchiveTime();
this.model = extractor.getModel();
+ this.normative = extractor.isNormative() == null ? false: extractor.isNormative();
}
public void setUniqueId(String uniqueId) {
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index a3acb42343..6e845a0a8f 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -70,6 +70,7 @@ public enum JsonPresentationFields {
DERIVED_FROM_GENERIC_VERSION("derivedFromGenericVersion", null),
SERVICE_FUNCTION("serviceFunction", null),
MODEL("model", null),
+ NORMATIVE("normative", null),
DATA_TYPES("data_types", GraphPropertyEnum.DATA_TYPES),
////Inputs
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java
index a0b2143a5f..f497066572 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java
@@ -173,4 +173,8 @@ public class JsonPresentationFieldsExtractor {
public String getModel() {
return (String) properties.get(JsonPresentationFields.MODEL.getPresentation());
}
+
+ public Boolean isNormative() {
+ return (Boolean) properties.get(JsonPresentationFields.NORMATIVE.getPresentation());
+ }
}