aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java27
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java45
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java147
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java19
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java8
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java744
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java5
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java1
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java3
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java5
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java14
14 files changed, 441 insertions, 610 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
index 47a08ea70e..676c3b45c0 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
@@ -28,6 +28,7 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
@@ -174,9 +175,8 @@ public class SdcSchemaFileImport {
yaml.setName(fileName);
//Initialize the yaml contents
- Map<String, Object> data = new LinkedHashMap<>();
-
- data.put("tosca_definitions_version", TOSCA_VERSION);
+ final Map<String, Object> data = new LinkedHashMap<>();
+ data.put(ToscaTagNamesEnum.TOSCA_VERSION.getElementName(), TOSCA_VERSION);
if (importFileList.length > 0) {
data.put("imports", importFileList);
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 dfd7c6c58d..7e26cb329f 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
@@ -23,6 +23,7 @@
package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
@@ -752,13 +753,27 @@ public class ResourceImportManager {
}
- private void setMetaDataFromJson(UploadResourceInfo resourceMetaData, Resource resource) {
+ private void setMetaDataFromJson(final UploadResourceInfo resourceMetaData, final Resource resource) {
this.populateResourceMetadata(resourceMetaData, resource);
resource.setCreatorUserId(resourceMetaData.getContactId());
- List<CategoryDefinition> categories = resourceMetaData.getCategories();
+
+ final String payloadData = resourceMetaData.getPayloadData();
+ if (payloadData != null) {
+ resource.setToscaVersion(getToscaVersion(payloadData));
+ }
+
+ final List<CategoryDefinition> categories = resourceMetaData.getCategories();
calculateResourceIsAbstract(resource, categories);
}
+ private String getToscaVersion(final String payloadData) {
+ final String decodedPayload = new String(Base64.decodeBase64(payloadData));
+ final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(decodedPayload);
+ final Either<String, ResultStatusEnum> findFirstToscaStringElement =
+ ImportUtils.findFirstToscaStringElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
+ return findFirstToscaStringElement.left().value();
+ }
+
private void calculateResourceIsAbstract(Resource resource, List<CategoryDefinition> categories) {
if (categories != null && !categories.isEmpty()) {
CategoryDefinition categoryDef = categories.get(0);
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 580fb737ec..fb1290310d 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
@@ -87,7 +87,13 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
private static final Logger log = Logger.getLogger(AbstractValidationsServlet.class);
private static final String TOSCA_SIMPLE_YAML_PREFIX = "tosca_simple_yaml_";
- private static final List<String> TOSCA_DEFINITION_VERSIONS = Arrays.asList(TOSCA_SIMPLE_YAML_PREFIX + "1_0_0", TOSCA_SIMPLE_YAML_PREFIX + "1_1_0", "tosca_simple_profile_for_nfv_1_0_0", TOSCA_SIMPLE_YAML_PREFIX + "1_0", TOSCA_SIMPLE_YAML_PREFIX + "1_1");
+ private static final List<String> TOSCA_DEFINITION_VERSIONS = Arrays.asList(
+ TOSCA_SIMPLE_YAML_PREFIX + "1_0_0",
+ TOSCA_SIMPLE_YAML_PREFIX + "1_1_0",
+ "tosca_simple_profile_for_nfv_1_0_0",
+ TOSCA_SIMPLE_YAML_PREFIX + "1_0",
+ TOSCA_SIMPLE_YAML_PREFIX + "1_1",
+ TOSCA_SIMPLE_YAML_PREFIX + "1_2");
private static final List<String> TOSCA_YML_CSAR_VALID_SUFFIX = Arrays.asList(".yml", ".yaml", ".csar");
protected ServletUtils servletUtils;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 64afee7904..1ca087d38a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -181,18 +181,22 @@ public class ToscaExportHandler {
return Either.left(toscaRepresentation);
}
- public Either<ToscaRepresentation, ToscaError> exportComponentInterface(Component component,
- boolean isAssociatedComponent) {
+ public Either<ToscaRepresentation, ToscaError> exportComponentInterface(final Component component,
+ final boolean isAssociatedComponent) {
if (null == DEFAULT_IMPORTS) {
log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
- ToscaTemplate toscaTemplate = new ToscaTemplate(TOSCA_VERSION);
+ String toscaVersion = null;
+ if (component instanceof Resource) {
+ toscaVersion = ((Resource) component).getToscaVersion();
+ }
+ ToscaTemplate toscaTemplate = new ToscaTemplate(toscaVersion != null ? toscaVersion : TOSCA_VERSION);
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- Either<ToscaTemplate, ToscaError> toscaTemplateRes = convertInterfaceNodeType(new HashMap<>(), component,
- toscaTemplate, nodeTypes, isAssociatedComponent);
+ final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
+ final Either<ToscaTemplate, ToscaError> toscaTemplateRes =
+ convertInterfaceNodeType(new HashMap<>(), component, toscaTemplate, nodeTypes, isAssociatedComponent);
if (toscaTemplateRes.isRight()) {
return Either.right(toscaTemplateRes.right().value());
}
@@ -240,18 +244,21 @@ public class ToscaExportHandler {
return Either.left(fillImports.left().value().left);
}
- private Either<ToscaTemplate, ToscaError> convertToToscaTemplate(Component component) {
+ private Either<ToscaTemplate, ToscaError> convertToToscaTemplate(final Component component) {
if (null == DEFAULT_IMPORTS) {
log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
log.trace("start tosca export for {}", component.getUniqueId());
- ToscaTemplate toscaTemplate = new ToscaTemplate(TOSCA_VERSION);
-
+ String toscaVersion = null;
+ if (component instanceof Resource) {
+ toscaVersion = ((Resource) component).getToscaVersion();
+ }
+ final ToscaTemplate toscaTemplate = new ToscaTemplate(toscaVersion != null ? toscaVersion : TOSCA_VERSION);
toscaTemplate.setMetadata(convertMetadata(component));
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
+ final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
if (ModelConverter.isAtomicComponent(component)) {
log.trace("convert component as node type");
return convertNodeType(new HashMap<>(), component, toscaTemplate, nodeTypes);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
index a38095a3ce..e9756b6c4e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
@@ -57,9 +57,7 @@ public class Resource extends Component {
private List<PropertyDefinition> attributes;
- private Map<String, InterfaceInstanceDataDefinition> instInterfaces;
-
- private List<String> defaultCapabilities;
+ private String toscaVersion;
public Resource() {
super(new ResourceMetadataDefinition());
@@ -75,16 +73,6 @@ public class Resource extends Component {
this.getComponentMetadataDefinition().getMetadataDataDefinition().setComponentType(ComponentTypeEnum.RESOURCE);
}
- @Override
- public List<PropertyDefinition> getProperties() {
- return properties;
- }
-
- @Override
- public void setProperties(List<PropertyDefinition> properties) {
- this.properties = properties;
- }
-
public Boolean isAbstract() {
return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition()
.getMetadataDataDefinition())
@@ -115,7 +103,6 @@ public class Resource extends Component {
.setLicenseType(licenseType);
}
-
public String getToscaResourceName() {
return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
.getToscaResourceName();
@@ -136,36 +123,36 @@ public class Resource extends Component {
.setResourceType(resourceType);
}
- public void setVendorName(String vendorName) {
- ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
- .setVendorName(vendorName);
- }
-
- public void setVendorRelease(String vendorRelease) {
- ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
- .setVendorRelease(vendorRelease);
- }
-
- public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
- ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).
- setResourceVendorModelNumber(resourceVendorModelNumber);
- }
-
public String getVendorName() {
return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
.getVendorName();
}
+ public void setVendorName(String vendorName) {
+ ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
+ .setVendorName(vendorName);
+ }
+
public String getVendorRelease() {
return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
.getVendorRelease();
}
+ public void setVendorRelease(String vendorRelease) {
+ ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
+ .setVendorRelease(vendorRelease);
+ }
+
public String getResourceVendorModelNumber() {
return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition())
.getResourceVendorModelNumber();
}
+ public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
+ ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).
+ setResourceVendorModelNumber(resourceVendorModelNumber);
+ }
+
@Override
public String fetchGenericTypeToscaNameFromConfig() {
String result = super.fetchGenericTypeToscaNameFromConfig();
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java
index 28efb308b6..d6d3347000 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java
@@ -20,6 +20,12 @@
package org.openecomp.sdc.be.model.jsonjanusgraph.datamodel;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Getter;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
@@ -35,25 +41,21 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTypeOperation;
import org.openecomp.sdc.common.log.api.ILogConfiguration;
import org.slf4j.MDC;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
+@Getter
+@Setter
public abstract class ToscaElement {
protected Map<String, Object> metadata;
protected List<CategoryDefinition> categories;
protected Map<String, ArtifactDataDefinition> toscaArtifacts;
+ protected ToscaElementTypeEnum toscaType;
private Map<String, ArtifactDataDefinition> artifacts;
private Map<String, ArtifactDataDefinition> deploymentArtifacts;
private Map<String, AdditionalInfoParameterDataDefinition> additionalInformation;
private Map<String, PropertyDataDefinition> properties;
private Map<String, ListCapabilityDataDefinition> capabilities;
- private Map<String, MapPropertiesDataDefinition> capabiltiesProperties;
+ private Map<String, MapPropertiesDataDefinition> capabilitiesProperties;
private Map<String, ListRequirementDataDefinition> requirements;
-
- protected ToscaElementTypeEnum toscaType;
// User
private String creatorUserId;
private String creatorFullName;
@@ -61,101 +63,12 @@ public abstract class ToscaElement {
private String lastUpdaterFullName;
private Map<String, String> allVersions;
+ private String toscaVersion;
public ToscaElement(ToscaElementTypeEnum toscaType){
this.toscaType = toscaType;
}
- public Map<String, Object> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, Object> metadata) {
- this.metadata = metadata;
- }
-
- public List<CategoryDefinition> getCategories() {
- return categories;
- }
-
- public void setCategories(List<CategoryDefinition> categories) {
- this.categories = categories;
- }
- public Map<String, ArtifactDataDefinition> getToscaArtifacts() {
- return toscaArtifacts;
- }
-
- public void setToscaArtifacts(Map<String, ArtifactDataDefinition> toscaArtifacts) {
- this.toscaArtifacts = toscaArtifacts;
- }
-
- public ToscaElementTypeEnum getToscaType() {
- return toscaType;
- }
-
- public void setToscaType(ToscaElementTypeEnum toscaType) {
- this.toscaType = toscaType;
- }
- public Map<String, ArtifactDataDefinition> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(Map<String, ArtifactDataDefinition> artifacts) {
- this.artifacts = artifacts;
- }
-
- public Map<String, ArtifactDataDefinition> getDeploymentArtifacts() {
- return deploymentArtifacts;
- }
-
- public void setDeploymentArtifacts(Map<String, ArtifactDataDefinition> deploymentArtifacts) {
- this.deploymentArtifacts = deploymentArtifacts;
- }
- public Map<String, AdditionalInfoParameterDataDefinition> getAdditionalInformation() {
- return additionalInformation;
- }
- public void setAdditionalInformation(Map<String, AdditionalInfoParameterDataDefinition> additionalInformation) {
- this.additionalInformation = additionalInformation;
- }
- public Map<String, PropertyDataDefinition> getProperties() {
- return properties;
- }
- public void setProperties(Map<String, PropertyDataDefinition> properties) {
- this.properties = properties;
- }
-
- public Map<String, String> getAllVersions() {
- return allVersions;
- }
-
- public void setAllVersions(Map<String, String> allVersions) {
- this.allVersions = allVersions;
- }
-
- public Map<String, ListCapabilityDataDefinition> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, ListCapabilityDataDefinition> capabilities) {
- this.capabilities = capabilities;
- }
-
- public Map<String, ListRequirementDataDefinition> getRequirements() {
- return requirements;
- }
-
- public void setRequirements(Map<String, ListRequirementDataDefinition> requirements) {
- this.requirements = requirements;
- }
-
- public Map<String, MapPropertiesDataDefinition> getCapabilitiesProperties() {
- return capabiltiesProperties;
- }
-
- public void setCapabilitiesProperties(Map<String, MapPropertiesDataDefinition> capabiltiesProperties) {
- this.capabiltiesProperties = capabiltiesProperties;
- }
-
// metadata properties
// ----------------------------
public Object getMetadataValue(JsonPresentationFields name) {
@@ -294,42 +207,16 @@ public abstract class ToscaElement {
return (Long)archiveTime;
}
- public void setArchiveTime(Long archiveTime) { setMetadataValue(JsonPresentationFields.ARCHIVE_TIME, archiveTime); }
-
- public Boolean isVspArchived() { return (Boolean) getMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED); }
-
- public void setVspArchived(Boolean vspArchived) { setMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED, vspArchived); }
-
- public String getCreatorUserId() {
- return creatorUserId;
- }
-
- public void setCreatorUserId(String creatorUserId) {
- this.creatorUserId = creatorUserId;
- }
-
- public String getCreatorFullName() {
- return creatorFullName;
- }
-
- public void setCreatorFullName(String creatorFullName) {
- this.creatorFullName = creatorFullName;
- }
-
- public String getLastUpdaterUserId() {
- return lastUpdaterUserId;
- }
-
- public void setLastUpdaterUserId(String lastUpdaterUserId) {
- this.lastUpdaterUserId = lastUpdaterUserId;
+ public void setArchiveTime(Long archiveTime) {
+ setMetadataValue(JsonPresentationFields.ARCHIVE_TIME, archiveTime);
}
- public String getLastUpdaterFullName() {
- return lastUpdaterFullName;
+ public Boolean isVspArchived() {
+ return (Boolean) getMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED);
}
- public void setLastUpdaterFullName(String lastUpdaterFullName) {
- this.lastUpdaterFullName = lastUpdaterFullName;
+ public void setVspArchived(Boolean vspArchived) {
+ setMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED, vspArchived);
}
public void generateUUID() {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
index e973400963..ec1185a706 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
@@ -24,7 +24,6 @@ import java.lang.reflect.Type;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
-
import org.apache.commons.collections.CollectionUtils;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -60,6 +59,7 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -170,7 +170,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
}
if (result == null) {
createdToscaElementVertex = createNextVersionRes.left().value();
- Map<EdgePropertyEnum, Object> properties = new HashMap<>();
+ final Map<EdgePropertyEnum, Object> properties = new EnumMap<>(EdgePropertyEnum.class);
properties.put(EdgePropertyEnum.STATE, createdToscaElementVertex.getMetadataProperty(GraphPropertyEnum.STATE));
status = janusGraphDao
.createEdge(user.getVertex(), createdToscaElementVertex.getVertex(), EdgeLabelEnum.STATE, properties);
@@ -321,7 +321,10 @@ public abstract class ToscaElementOperation extends BaseOperation {
nodeTypeVertex.setUniqueId(toscaElement.getUniqueId());
nodeTypeVertex.setType(toscaElement.getComponentType());
-
+ final String toscaVersion = toscaElement.getToscaVersion();
+ if (toscaVersion != null) {
+ nodeTypeVertex.setJsonMetadataField(JsonPresentationFields.TOSCA_DEFINITIONS_VERSION, toscaVersion);
+ }
}
protected StorageOperationStatus assosiateToUsers(GraphVertex nodeTypeVertex, ToscaElement toscaElement) {
@@ -729,7 +732,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
List<T> components = new ArrayList<>();
List<T> componentsPerUser;
- HashSet<String> ids = new HashSet<String>();
+ final Set<String> ids = new HashSet<>();
Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = janusGraphDao.getChildrenVertices(userV, EdgeLabelEnum.STATE, JsonParseFlagEnum.NoParse);
if (childrenVertecies.isRight() && childrenVertecies.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
log.debug("Failed to fetch children vertices for user {} by edge {} error {}", userV.getMetadataProperty(GraphPropertyEnum.USERID), EdgeLabelEnum.STATE, childrenVertecies.right().value());
@@ -918,9 +921,15 @@ public abstract class ToscaElementOperation extends BaseOperation {
break;
}
- Map<String, Object> jsonMetada = componentV.getMetadataJson();
if (toscaElement != null) {
+ final Map<String, Object> jsonMetada = componentV.getMetadataJson();
toscaElement.setMetadata(jsonMetada);
+ if (jsonMetada != null) {
+ final Object toscaVersion = jsonMetada.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName());
+ if (toscaVersion != null) {
+ toscaElement.setToscaVersion((String) toscaVersion);
+ }
+ }
}
return (T) toscaElement;
}
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 c16c8a98e5..ae854254c2 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
@@ -246,6 +246,10 @@ public class ModelConverter {
resource.setDerivedList(nodeType.getDerivedList());
resource.setDerivedFromMapOfIdToName(nodeType.getDerivedFromMapOfIdToName());
resource.setAbstract((Boolean) nodeType.getMetadataValue(JsonPresentationFields.IS_ABSTRACT));
+ final String toscaVersion = nodeType.getToscaVersion();
+ if (toscaVersion != null) {
+ resource.setToscaVersion(toscaVersion);
+ }
convertAttributes(nodeType, resource);
convertCapabilities(nodeType, resource);
convertRequirements(nodeType, resource);
@@ -798,6 +802,10 @@ public class ModelConverter {
nodeType.setDerivedFrom(resource.getDerivedFrom());
nodeType.setDerivedList(resource.getDerivedList());
nodeType.setResourceType(resource.getResourceType());
+ final String toscaVersion = resource.getToscaVersion();
+ if (toscaVersion != null) {
+ nodeType.setToscaVersion(toscaVersion);
+ }
convertCommonToscaData(component, nodeType);
convertAdditionalInformation(component, nodeType);
convertArtifacts(resource, nodeType);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
index c53e4e00bb..bb72c53033 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,421 +28,329 @@ import org.junit.Test;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.unittests.utils.ModelConfDependentTest;
-public class ResourceTest extends ModelConfDependentTest{
-
- private Resource createTestSubject() {
- return new Resource();
- }
-
- @Test
- public void testCtor() throws Exception {
- ComponentMetadataDefinition componentMetadataDefinition = new ResourceMetadataDefinition();
- new Resource(componentMetadataDefinition);
- }
-
- @Test
- public void testGetDerivedFrom() throws Exception {
- Resource testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDerivedFrom();
- }
-
-
- @Test
- public void testSetDerivedFrom() throws Exception {
- Resource testSubject;
- List<String> derivedFrom = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDerivedFrom(derivedFrom);
- }
-
-
- @Test
- public void testGetDerivedList() throws Exception {
- Resource testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDerivedList();
- }
-
-
- @Test
- public void testSetDerivedList() throws Exception {
- Resource testSubject;
- List<String> derivedList = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDerivedList(derivedList);
- }
-
-
- @Test
- public void testGetProperties() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProperties();
- }
-
-
- @Test
- public void testSetProperties() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> properties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProperties(properties);
- }
-
-
- @Test
- public void testGetAttributes() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAttributes();
- }
-
-
- @Test
- public void testSetAttributes() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> attributes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAttributes(attributes);
- }
-
-
- @Test
- public void testGetInterfaces() throws Exception {
- Resource testSubject;
- Map<String, InterfaceDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInterfaces();
- }
-
-
- @Test
- public void testSetInterfaces() throws Exception {
- Resource testSubject;
- Map<String, InterfaceDefinition> interfaces = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInterfaces(interfaces);
- }
-
-
- @Test
- public void testIsAbstract() throws Exception {
- Resource testSubject;
- Boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isAbstract();
- }
-
-
- @Test
- public void testSetAbstract() throws Exception {
- Resource testSubject;
- Boolean isAbstract = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAbstract(isAbstract);
- }
-
-
- @Test
- public void testGetDefaultCapabilities() throws Exception {
- Resource testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDefaultCapabilities();
- }
-
-
- @Test
- public void testSetDefaultCapabilities() throws Exception {
- Resource testSubject;
- List<String> defaultCapabilities = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDefaultCapabilities(defaultCapabilities);
- }
-
-
- @Test
- public void testGetCost() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCost();
- }
-
-
- @Test
- public void testSetCost() throws Exception {
- Resource testSubject;
- String cost = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCost(cost);
- }
-
-
- @Test
- public void testGetLicenseType() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLicenseType();
- }
-
-
- @Test
- public void testSetLicenseType() throws Exception {
- Resource testSubject;
- String licenseType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLicenseType(licenseType);
- }
-
-
- @Test
- public void testHashCode() throws Exception {
- Resource testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
- }
-
-
- @Test
- public void testEquals() throws Exception {
- Resource testSubject;
- Object obj = null;
- boolean result;
-
- // test 1
- testSubject = createTestSubject();
- result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
- obj = new Object();
- result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
- result = testSubject.equals(testSubject);
- Assert.assertEquals(true, result);
-
- Resource testSubject2 = createTestSubject();
- result = testSubject.equals(testSubject2);
- Assert.assertEquals(true, result);
- }
-
-
- @Test
- public void testToString() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-
-
- @Test
- public void testGetToscaResourceName() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getToscaResourceName();
- }
-
-
- @Test
- public void testSetToscaResourceName() throws Exception {
- Resource testSubject;
- String toscaResourceName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setToscaResourceName(toscaResourceName);
- }
-
-
- @Test
- public void testGetResourceType() throws Exception {
- Resource testSubject;
- ResourceTypeEnum result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getResourceType();
- }
-
-
- @Test
- public void testSetResourceType() throws Exception {
- Resource testSubject;
- ResourceTypeEnum resourceType = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setResourceType(resourceType);
- }
-
-
- @Test
- public void testSetVendorName() throws Exception {
- Resource testSubject;
- String vendorName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setVendorName(vendorName);
- }
-
-
- @Test
- public void testSetVendorRelease() throws Exception {
- Resource testSubject;
- String vendorRelease = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setVendorRelease(vendorRelease);
- }
-
-
- @Test
- public void testSetResourceVendorModelNumber() throws Exception {
- Resource testSubject;
- String resourceVendorModelNumber = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setResourceVendorModelNumber(resourceVendorModelNumber);
- }
-
-
- @Test
- public void testGetVendorName() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getVendorName();
- }
-
-
- @Test
- public void testGetVendorRelease() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getVendorRelease();
- }
-
-
- @Test
- public void testGetResourceVendorModelNumber() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getResourceVendorModelNumber();
- }
-
- @Test
- public void testFetchGenericTypeToscaNameFromConfig() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.fetchGenericTypeToscaNameFromConfig();
- }
-
- @Test
- public void testAssetType() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.assetType();
- }
-
-
- @Test
- public void testShouldGenerateInputs() throws Exception {
- Resource testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.shouldGenerateInputs();
- }
-
-
- @Test
- public void testDeriveFromGeneric() throws Exception {
- Resource testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.deriveFromGeneric();
- }
-
- @Test
- public void testGroupRelationsByInstanceName() throws Exception {
- Resource testSubject;
- Map<String, List<RequirementCapabilityRelDef>> result;
-
- // default test
- testSubject = createTestSubject();
- Resource resource = new Resource();
- resource.setComponentInstancesRelations(new LinkedList<RequirementCapabilityRelDef>());
- result = testSubject.groupRelationsFromCsarByInstanceName(resource);
- }
+public class ResourceTest extends ModelConfDependentTest {
+
+ private Resource createTestSubject() {
+ return new Resource();
+ }
+
+ @Test
+ public void testCtor() throws Exception {
+ ComponentMetadataDefinition componentMetadataDefinition = new ResourceMetadataDefinition();
+ new Resource(componentMetadataDefinition);
+ }
+
+ @Test
+ public void testGetProperties() throws Exception {
+ Resource testSubject;
+ List<PropertyDefinition> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getProperties();
+ }
+
+ @Test
+ public void testSetProperties() throws Exception {
+ Resource testSubject;
+ List<PropertyDefinition> properties = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setProperties(properties);
+ }
+
+ @Test
+ public void testGetAttributes() throws Exception {
+ Resource testSubject;
+ List<PropertyDefinition> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAttributes();
+ }
+
+ @Test
+ public void testSetAttributes() throws Exception {
+ Resource testSubject;
+ List<PropertyDefinition> attributes = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAttributes(attributes);
+ }
+
+ @Test
+ public void testGetInterfaces() throws Exception {
+ Resource testSubject;
+ Map<String, InterfaceDefinition> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getInterfaces();
+ }
+
+ @Test
+ public void testSetInterfaces() throws Exception {
+ Resource testSubject;
+ Map<String, InterfaceDefinition> interfaces = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setInterfaces(interfaces);
+ }
+
+ @Test
+ public void testIsAbstract() throws Exception {
+ Resource testSubject;
+ Boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isAbstract();
+ }
+
+ @Test
+ public void testSetAbstract() throws Exception {
+ Resource testSubject;
+ Boolean isAbstract = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAbstract(isAbstract);
+ }
+
+ @Test
+ public void testGetCost() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCost();
+ }
+
+ @Test
+ public void testSetCost() throws Exception {
+ Resource testSubject;
+ String cost = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setCost(cost);
+ }
+
+ @Test
+ public void testGetLicenseType() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getLicenseType();
+ }
+
+ @Test
+ public void testSetLicenseType() throws Exception {
+ Resource testSubject;
+ String licenseType = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setLicenseType(licenseType);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ Resource testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ Resource testSubject;
+ Object obj = null;
+ boolean result;
+
+ // test 1
+ testSubject = createTestSubject();
+ result = testSubject.equals(obj);
+ Assert.assertEquals(false, result);
+ obj = new Object();
+ result = testSubject.equals(obj);
+ Assert.assertEquals(false, result);
+ result = testSubject.equals(testSubject);
+ Assert.assertEquals(true, result);
+
+ Resource testSubject2 = createTestSubject();
+ result = testSubject.equals(testSubject2);
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+ @Test
+ public void testGetToscaResourceName() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getToscaResourceName();
+ }
+
+ @Test
+ public void testSetToscaResourceName() throws Exception {
+ Resource testSubject;
+ String toscaResourceName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setToscaResourceName(toscaResourceName);
+ }
+
+ @Test
+ public void testGetResourceType() throws Exception {
+ Resource testSubject;
+ ResourceTypeEnum result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResourceType();
+ }
+
+ @Test
+ public void testSetResourceType() throws Exception {
+ Resource testSubject;
+ ResourceTypeEnum resourceType = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setResourceType(resourceType);
+ }
+
+ @Test
+ public void testSetVendorName() throws Exception {
+ Resource testSubject;
+ String vendorName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setVendorName(vendorName);
+ }
+
+ @Test
+ public void testSetVendorRelease() throws Exception {
+ Resource testSubject;
+ String vendorRelease = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setVendorRelease(vendorRelease);
+ }
+
+ @Test
+ public void testSetResourceVendorModelNumber() throws Exception {
+ Resource testSubject;
+ String resourceVendorModelNumber = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setResourceVendorModelNumber(resourceVendorModelNumber);
+ }
+
+ @Test
+ public void testGetVendorName() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getVendorName();
+ }
+
+ @Test
+ public void testGetVendorRelease() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getVendorRelease();
+ }
+
+ @Test
+ public void testGetResourceVendorModelNumber() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResourceVendorModelNumber();
+ }
+
+ @Test
+ public void testFetchGenericTypeToscaNameFromConfig() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ }
+
+ @Test
+ public void testAssetType() throws Exception {
+ Resource testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.assetType();
+ }
+
+ @Test
+ public void testShouldGenerateInputs() throws Exception {
+ Resource testSubject;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.shouldGenerateInputs();
+ }
+
+ @Test
+ public void testDeriveFromGeneric() throws Exception {
+ Resource testSubject;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.deriveFromGeneric();
+ }
+
+ @Test
+ public void testGroupRelationsByInstanceName() throws Exception {
+ Resource testSubject;
+ Map<String, List<RequirementCapabilityRelDef>> result;
+
+ // default test
+ testSubject = createTestSubject();
+ Resource resource = new Resource();
+ resource.setComponentInstancesRelations(new LinkedList<RequirementCapabilityRelDef>());
+ result = testSubject.groupRelationsFromCsarByInstanceName(resource);
+ }
}
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 b84baff861..027519500f 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
@@ -246,7 +246,10 @@ public enum JsonPresentationFields {
GET_PROPERTY("get_property", null),
GET_INPUT("get_input", null),
- GET_OPERATION_OUTPUT("get_operation_output", null);
+ GET_OPERATION_OUTPUT("get_operation_output", null),
+
+ TOSCA_DEFINITIONS_VERSION("tosca_definitions_version", null);
+
private String presentation;
private GraphPropertyEnum storedAs;
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java
index 18e6a49aa5..c9f5548681 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java
@@ -26,7 +26,6 @@ public class Constants {
public static final String metadataFile = "TOSCA-Metadata/TOSCA.meta";
- public static final String definitionVersion = "tosca_definitions_version";
private static final String DEFAULT_NAMESPACE = "tosca_default_namespace";
private static final String TEMPLATE_NAME = "template_name";
public static final String topologyTemplate = "topology_template";
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
index f41caff349..9b1c0126c7 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import static org.openecomp.core.converter.datatypes.Constants.*;
@@ -69,7 +70,7 @@ public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderSe
@Override
public Object getToscaVersion() {
- return this.readServiceTemplate.get(definitionVersion);
+ return this.readServiceTemplate.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName());
}
@Override
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
index 1bc547aed7..3ce9badea0 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
@@ -56,6 +56,7 @@ import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.common.zip.ZipUtils;
@@ -192,8 +193,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean isToscaYamlFile(byte[] fileContent) {
- Map fileMap = new YamlUtil().yamlToObject(new String(fileContent), Map.class);
- return fileMap.containsKey("tosca_definitions_version");
+ final Map fileMap = new YamlUtil().yamlToObject(new String(fileContent), Map.class);
+ return fileMap.containsKey(ToscaTagNamesEnum.TOSCA_VERSION.getElementName());
}
private void updateMinMaxOccurencesForNodeTypeRequirement(Map.Entry<String, RequirementAssignment> entry,
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java
index 0394073e57..9f3dd0790f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java
@@ -26,6 +26,7 @@ import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.logging.api.Logger;
@@ -55,7 +56,6 @@ public class ToscaValidationServiceImpl implements ToscaValidationService {
private static final String SDCPARSER_JTOSCA_VALIDATIONISSUE_CONFIG =
"SDCParser_jtosca-validation-issue-configuration.yaml";
private static final String SDCPARSER_ERROR_CONFIG = "SDCParser_error-configuration.yaml";
- private static final String TOSCA_DEFINITION_VERSION = "tosca_definitions_version";
static {
// Override default SDC Parser configuration
@@ -119,17 +119,17 @@ public class ToscaValidationServiceImpl implements ToscaValidationService {
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
- private boolean isToscaYaml(String filePath) {
+ private boolean isToscaYaml(final String filePath) {
boolean retValue = false;
- try (InputStream input = new BufferedInputStream(new FileInputStream(new File(filePath)));) {
- Yaml yaml = new Yaml();
- LinkedHashMap<String,Object> data = (LinkedHashMap) yaml.load(input);
- if(data.get(TOSCA_DEFINITION_VERSION) != null) {
+ try (final InputStream input = new BufferedInputStream(new FileInputStream(new File(filePath)));) {
+ final Yaml yaml = new Yaml();
+ final LinkedHashMap<String,Object> data = (LinkedHashMap) yaml.load(input);
+ if(data.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName()) != null) {
retValue = true;
}
}
- catch(Exception e){
+ catch(final Exception e){
LOGGER.info("Ignore the exception as the input file may not be a Tosca Yaml; let the " +
"default value return", e);
}