summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-06-29 18:00:52 +0100
committerMichael Morris <michael.morris@est.tech>2023-07-10 09:15:51 +0000
commitb76217740231c916fce669613e20fb70c7320a2e (patch)
treec52e77ecd9d367c0439f1ab75327635f3a9a1570 /catalog-be/src/main/java
parent01eb0ed11a0e97a3ae3a5ccfc5afc0702ad9d2fa (diff)
Include version in metadata
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ia7278b7e6a751c69a4fc50c66697c14c4025f178 Issue-ID: SDC-4558
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java42
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java184
5 files changed, 40 insertions, 206 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
index f33a87b696..17d01c64b1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
@@ -20,10 +20,6 @@
package org.openecomp.sdc.be.components.lifecycle;
import fj.data.Either;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
@@ -55,6 +51,11 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
public class CertificationChangeTransition extends LifeCycleTransition {
private static final String ALLOTTED_CATEGORY = "Allotted Resource";
@@ -122,7 +123,7 @@ public class CertificationChangeTransition extends LifeCycleTransition {
if (oldState != LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT && oldState != LifecycleStateEnum.NOT_CERTIFIED_CHECKIN) {
log.debug("Valid states for certification are NOT_CERTIFIED_CHECKIN and NOT_CERTIFIED_CHECKOUT. {} is invalid state", oldState);
ResponseFormat error = componentUtils
- .getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE, componentName, componentType.name().toLowerCase(), oldState.name());
+ .getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE, componentName, componentType.name().toLowerCase(), oldState.name());
return Either.right(error);
}
return Either.left(true);
@@ -135,24 +136,26 @@ public class CertificationChangeTransition extends LifeCycleTransition {
log.info("start performing certification change for resource {}", component.getUniqueId());
Either<T, ResponseFormat> result = null;
try {
- handleValidationsAndArtifactsGenerationBeforeCertifying(componentType, component, componentBl, modifier, shouldLock, inTransaction);
+ component = handleValidationsBeforeCertifying(componentType, component, modifier, shouldLock, inTransaction);
Either<ToscaElement, StorageOperationStatus> certificationChangeResult = lifeCycleOperation
- .certifyToscaElement(component.getUniqueId(), modifier.getUserId(), owner.getUserId());
+ .certifyToscaElement(component.getUniqueId(), modifier.getUserId(), owner.getUserId());
if (certificationChangeResult.isRight()) {
ResponseFormat responseFormat = formatCertificationError(component, certificationChangeResult.right().value(), componentType);
result = Either.right(responseFormat);
return result;
}
+
ToscaElement certificationResult = certificationChangeResult.left().value();
T componentAfterCertification = ModelConverter.convertFromToscaElement(certificationResult);
if (result == null || result.isLeft()) {
- //update edges for allotted resource
+ //update edges for allotted resource
StorageOperationStatus status = handleConnectionsForAllotted(componentAfterCertification);
if (status != StorageOperationStatus.OK) {
ResponseFormat responseFormat = formatCertificationError(componentAfterCertification, status, componentType);
result = Either.right(responseFormat);
}
}
+ componentBl.populateToscaArtifacts(componentAfterCertification, modifier, true, inTransaction, shouldLock);
updateCalculatedCapabilitiesRequirements(componentAfterCertification);
updateCapReqPropertiesOwnerId(componentAfterCertification);
result = Either.left(componentAfterCertification);
@@ -183,21 +186,21 @@ public class CertificationChangeTransition extends LifeCycleTransition {
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
if (component.isVspArchived()) {
return Either.right(
- componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
+ componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
}
List<ComponentInstance> resourceInstance = component.getComponentInstances();
if (resourceInstance != null) {
//Filter components instances with archived origins
Optional<ComponentInstance> archivedRIOptional = resourceInstance.stream().filter(ComponentInstanceDataDefinition::isOriginArchived)
- .findAny();
+ .findAny();
//RIs with archived origins found, return relevant error
if (archivedRIOptional.isPresent()) {
return Either.right(
- componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
+ componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
}
//Continue with searching for non certified RIs
Optional<ComponentInstance> nonCertifiedRIOptional = resourceInstance.stream()
- .filter(p -> !ValidationUtils.validateCertifiedVersion(p.getComponentVersion())).findAny();
+ .filter(p -> !ValidationUtils.validateCertifiedVersion(p.getComponentVersion())).findAny();
// Uncertified Resource Found
if (nonCertifiedRIOptional.isPresent()) {
ComponentInstance nonCertifiedRI = nonCertifiedRIOptional.get();
@@ -232,9 +235,8 @@ public class CertificationChangeTransition extends LifeCycleTransition {
return componentUtils.getResponseFormat(actionStatus, componentType == ComponentTypeEnum.RESOURCE ? "VF" : "service", resource.getName());
}
- private void handleValidationsAndArtifactsGenerationBeforeCertifying(ComponentTypeEnum componentType, Component component,
- ComponentBusinessLogic componentBl, User modifier, boolean shouldLock,
- boolean inTransaction) {
+ private Component handleValidationsBeforeCertifying(ComponentTypeEnum componentType, Component component,
+ User modifier, boolean shouldLock, boolean inTransaction) {
if (component.isTopologyTemplate()) {
Either<Boolean, ResponseFormat> statusCert = validateAllResourceInstanceCertified(component);
if (statusCert.isRight()) {
@@ -243,18 +245,18 @@ public class CertificationChangeTransition extends LifeCycleTransition {
}
if (componentType == ComponentTypeEnum.SERVICE) {
Either<Service, ResponseFormat> generateHeatEnvResult = serviceBusinessLogic
- .generateHeatEnvArtifacts((Service) component, modifier, shouldLock, inTransaction);
+ .generateHeatEnvArtifacts((Service) component, modifier, shouldLock, inTransaction);
if (generateHeatEnvResult.isRight()) {
throw new ByResponseFormatComponentException(generateHeatEnvResult.right().value());
}
Either<Service, ResponseFormat> generateVfModuleResult = serviceBusinessLogic
- .generateVfModuleArtifacts(generateHeatEnvResult.left().value(), modifier, shouldLock, inTransaction);
+ .generateVfModuleArtifacts(generateHeatEnvResult.left().value(), modifier, shouldLock, inTransaction);
if (generateVfModuleResult.isRight()) {
throw new ByResponseFormatComponentException(generateVfModuleResult.right().value());
}
component = generateVfModuleResult.left().value();
}
- componentBl.populateToscaArtifacts(component, modifier, true, inTransaction, shouldLock);
+ return component;
}
private void updateCalculatedCapabilitiesRequirements(Component certifiedComponent) {
@@ -285,7 +287,7 @@ public class CertificationChangeTransition extends LifeCycleTransition {
componentInstancesProperties.entrySet().forEach(e -> {
List<ComponentInstanceProperty> props = e.getValue();
Optional<ComponentInstanceProperty> findProp = props.stream()
- .filter(p -> p.getName().equals(DEPENDING_SRV_NAME) || p.getName().equals(PROVIDING_SRV_NAME)).findFirst();
+ .filter(p -> p.getName().equals(DEPENDING_SRV_NAME) || p.getName().equals(PROVIDING_SRV_NAME)).findFirst();
if (findProp.isPresent()) {
log.debug("Find specific properties [{} or {}]on instance {} ", DEPENDING_SRV_NAME, PROVIDING_SRV_NAME, e.getKey());
handleAllotedInstance(component.getUniqueId(), e.getKey(), e.getValue());
@@ -298,7 +300,7 @@ public class CertificationChangeTransition extends LifeCycleTransition {
private StorageOperationStatus handleAllotedInstance(String componentId, String instanceId, List<ComponentInstanceProperty> props) {
ComponentInstanceProperty serviceUUIDProp = props.stream()
- .filter(p -> p.getName().equals(PROVIDING_SRV_UUID) || p.getName().equals(DEPENDING_SRV_UUID)).findFirst().get();
+ .filter(p -> p.getName().equals(PROVIDING_SRV_UUID) || p.getName().equals(DEPENDING_SRV_UUID)).findFirst().get();
if (serviceUUIDProp.getValue() != null && !serviceUUIDProp.getValue().contains("get_input")) {
log.debug("Handle Allotted edge on instance {} for service UUID {} ", instanceId, serviceUUIDProp.getValue());
return nodeTemplateOperation.createAllottedOfEdge(componentId, instanceId, serviceUUIDProp.getValue());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
index 90778105af..ced257fb18 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
@@ -81,7 +81,7 @@ public class CheckoutTransition extends LifeCycleTransition {
log.debug("start performing {} for resource {}", getName(), component.getUniqueId());
Either<? extends Component, ResponseFormat> result = null;
try {
- Either<ToscaElement, StorageOperationStatus> checkoutResourceResult = lifeCycleOperation
+ final Either<ToscaElement, StorageOperationStatus> checkoutResourceResult = lifeCycleOperation
.checkoutToscaElement(component.getUniqueId(), modifier.getUserId(), owner.getUserId());
if (checkoutResourceResult.isRight()) {
log.debug("checkout failed on graph");
@@ -110,7 +110,7 @@ public class CheckoutTransition extends LifeCycleTransition {
}
}
result = Either.left(clonedComponent);
- Either<Boolean, ResponseFormat> upgradeToLatestGeneric = componentBl.shouldUpgradeToLatestGeneric(clonedComponent);
+ final Either<Boolean, ResponseFormat> upgradeToLatestGeneric = componentBl.shouldUpgradeToLatestGeneric(clonedComponent);
if (upgradeToLatestGeneric.isRight()) {
result = Either.right(upgradeToLatestGeneric.right().value());
} else if (upgradeToLatestGeneric.left().value()) {
@@ -123,6 +123,10 @@ public class CheckoutTransition extends LifeCycleTransition {
}
handleCalculatedCapabilitiesRequirements(clonedComponent);
updateCapReqPropertiesOwnerId(clonedComponent);
+ final Either<Component, StorageOperationStatus> updateEither = toscaOperationFacade.updateToscaElement(clonedComponent);
+ if (updateEither.isRight()){
+ result = Either.right(componentUtils.getResponseFormat(updateEither.right().value()));
+ }
}
} finally {
if (result == null || result.isRight()) {
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 44da4f2500..540ea6ec5c 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
@@ -606,6 +606,7 @@ public class ToscaExportHandler {
}
toscaMetadata.put(JsonPresentationFields.RESOURCE_VENDOR_RELEASE.getPresentation(), resource.getVendorRelease());
toscaMetadata.put(JsonPresentationFields.RESOURCE_VENDOR_MODEL_NUMBER.getPresentation(), resource.getResourceVendorModelNumber());
+ toscaMetadata.put(resource.isTopologyTemplate() ? JsonPresentationFields.TEMPLATE_VERSION.getPresentation() : JsonPresentationFields.VERSION.getPresentation(), resource.getVersion());
break;
case SERVICE:
Service service = (Service) component;
@@ -614,6 +615,7 @@ public class ToscaExportHandler {
toscaMetadata.put(JsonPresentationFields.SERVICE_ROLE.getPresentation(), service.getServiceRole());
toscaMetadata.put(JsonPresentationFields.SERVICE_FUNCTION.getPresentation(), service.getServiceFunction());
toscaMetadata.put(JsonPresentationFields.ENVIRONMENT_CONTEXT.getPresentation(), service.getEnvironmentContext());
+ toscaMetadata.put(JsonPresentationFields.TEMPLATE_VERSION.getPresentation(), service.getVersion());
toscaMetadata.put(JsonPresentationFields.INSTANTIATION_TYPE.getPresentation(),
service.getEnvironmentContext() == null ? StringUtils.EMPTY : service.getInstantiationType());
if (!isInstance) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java
index e24316ca02..c850bec68d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java
@@ -21,13 +21,13 @@ package org.openecomp.sdc.be.tosca.model;
public interface IToscaMetadata {
- public void setName(String name);
+ void setName(String name);
- public void setInvariantUUID(String invariantUUID);
+ void setInvariantUUID(String invariantUUID);
- public void setUUID(String uUID);
+ void setUUID(String uUID);
- public void setVersion(String version);
+ void setVersion(String version);
- public void setCustomizationUUID(String customizationUUID);
+ void setCustomizationUUID(String customizationUUID);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
index 54d382ff82..62a0a50733 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
@@ -19,6 +19,11 @@
*/
package org.openecomp.sdc.be.tosca.model;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
public class ToscaMetadata implements IToscaMetadata {
private String invariantUUID;
@@ -46,121 +51,6 @@ public class ToscaMetadata implements IToscaMetadata {
private String serviceFunction;
private String model;
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- public String getInvariantUUID() {
- return invariantUUID;
- }
-
- @Override
- public void setInvariantUUID(String invariantUUID) {
- this.invariantUUID = invariantUUID;
- }
-
- public String getUUID() {
- return UUID;
- }
-
- @Override
- public void setUUID(String uUID) {
- UUID = uUID;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getSubcategory() {
- return subcategory;
- }
-
- public void setSubcategory(String subcategory) {
- this.subcategory = subcategory;
- }
-
- public String getResourceVendor() {
- return resourceVendor;
- }
-
- public void setResourceVendor(String resourceVendor) {
- this.resourceVendor = resourceVendor;
- }
-
- public String getResourceVendorRelease() {
- return resourceVendorRelease;
- }
-
- public void setResourceVendorRelease(String resourceVendorRelease) {
- this.resourceVendorRelease = resourceVendorRelease;
- }
-
- public String getResourceVendorModelNumber() {
- return resourceVendorModelNumber;
- }
-
- public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
- this.resourceVendorModelNumber = resourceVendorModelNumber;
- }
-
- public String getServiceType() {
- return serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
- public String getServiceRole() {
- return serviceRole;
- }
-
- public void setServiceRole(String serviceRole) {
- this.serviceRole = serviceRole;
- }
-
- public String getServiceFunction() {
- return serviceFunction;
- }
-
- public void setServiceFunction(String serviceFunction) {
- this.serviceFunction = serviceFunction;
- }
-
- public String getInstantiationType() {
- return instantiationType;
- }
-
- public void setInstantiationType(String instantiationType) {
- this.instantiationType = instantiationType;
- }
-
public Boolean isEcompGeneratedNaming() {
return new Boolean(ecompGeneratedNaming);
}
@@ -169,14 +59,6 @@ public class ToscaMetadata implements IToscaMetadata {
this.ecompGeneratedNaming = ecompGeneratedNaming == null ? null : ecompGeneratedNaming.toString();
}
- public String isNamingPolicy() {
- return namingPolicy;
- }
-
- public void setNamingPolicy(String namingPolicy) {
- this.namingPolicy = namingPolicy;
- }
-
public Boolean getServiceEcompNaming() {
return new Boolean(serviceEcompNaming);
}
@@ -185,60 +67,4 @@ public class ToscaMetadata implements IToscaMetadata {
this.serviceEcompNaming = serviceEcompNaming == null ? null : serviceEcompNaming.toString();
}
- public String getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getCustomizationUUID() {
- return customizationUUID;
- }
-
- public void setCustomizationUUID(String customizationUUID) {
- this.customizationUUID = customizationUUID;
- }
-
- public String getSourceModelInvariant() {
- return sourceModelInvariant;
- }
-
- public void setSourceModelInvariant(String sourceModelInvariant) {
- this.sourceModelInvariant = sourceModelInvariant;
- }
-
- public String getSourceModelName() {
- return sourceModelName;
- }
-
- public void setSourceModelName(String sourceModelName) {
- this.sourceModelName = sourceModelName;
- }
-
- public String getSourceModelUuid() {
- return sourceModelUuid;
- }
-
- public void setSourceModelUuid(String sourceModelUuid) {
- this.sourceModelUuid = sourceModelUuid;
- }
-
- public String getEnvironmentContext() {
- return environmentContext;
- }
-
- public void setEnvironmentContext(String environmentContext) {
- this.environmentContext = environmentContext;
- }
-
- public String getModel() {
- return model;
- }
-
- public void setModel(String model) {
- this.model = model;
- }
}