aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-05-13 15:25:30 +0100
committerJulien Bertozzi <julien.bertozzi@intl.att.com>2020-08-24 12:38:49 +0000
commit597bc127b6fc91c77fe2c5c759c194a6e50b9c4e (patch)
treeff8b4f377d2f8589f9171f12277d45ddcf798d53 /catalog-be/src/main/java/org/openecomp
parentec44cb3e846e1129dc0cb245bd1edef67d8ed3e3 (diff)
Expose generic Service properties as properties
During the Service creation, the properties declared in the Generic Service Type are being parsed to inputs, but not to properties. The change parses the properties also to properties, keeping the previous input logic. Change-Id: I3ceba3adeaab56cd49fc8fbd657b02aa7c93e79b Issue-ID: SDC-3061 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java45
1 files changed, 33 insertions, 12 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index f4ccb868d9..552fbb0b16 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -845,7 +845,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (createServiceResponse.isRight()) {
return createServiceResponse;
}
- return createServiceByDao(service, AuditingActionEnum.CREATE_RESOURCE, user)
+ return createServiceByDao(service, user)
.left()
.bind(c -> updateCatalog(c, ChangeTypeEnum.LIFECYCLE)
.left()
@@ -859,42 +859,42 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
}
- private Either<Service, ResponseFormat> createServiceByDao(Service service, AuditingActionEnum actionEnum, User user) {
+ private Either<Service, ResponseFormat> createServiceByDao(final Service service, final User user) {
log.debug("send service {} to dao for create", service.getComponentMetadataDefinition().getMetadataDataDefinition().getName());
Either<Boolean, ResponseFormat> lockResult = lockComponentByName(service.getSystemName(), service, "Create Service");
if (lockResult.isRight()) {
ResponseFormat responseFormat = lockResult.right().value();
- componentsUtils.auditComponentAdmin(responseFormat, user, service, actionEnum, ComponentTypeEnum.SERVICE);
+ componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE,
+ ComponentTypeEnum.SERVICE);
return Either.right(responseFormat);
}
log.debug("System name locked is {}, status = {}", service.getSystemName(), lockResult);
try {
-
createMandatoryArtifactsData(service, user);
createServiceApiArtifactsData(service, user);
setToscaArtifactsPlaceHolders(service, user);
- generateAndAddInputsFromGenericTypeProperties(service, fetchAndSetDerivedFromGenericType(service));
+ final Resource genericType = fetchAndSetDerivedFromGenericType(service);
+ generatePropertiesFromGenericType(service, genericType);
+ generateAndAddInputsFromGenericTypeProperties(service, genericType);
beforeCreate(service);
Either<Service, StorageOperationStatus> dataModelResponse = toscaOperationFacade.createToscaComponent(service);
-
- // service created successfully!!!
if (dataModelResponse.isLeft()) {
- log.debug("Service created successfully!!!");
+ log.debug("Service '{}' created successfully", service.getName());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
- componentsUtils.auditComponentAdmin(responseFormat, user, service, actionEnum, ComponentTypeEnum.SERVICE);
+ componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE,
+ ComponentTypeEnum.SERVICE);
ASDCKpiApi.countCreatedServicesKPI();
return Either.left(dataModelResponse.left().value());
}
-
ResponseFormat responseFormat = componentsUtils.getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(dataModelResponse.right().value()), service, ComponentTypeEnum.SERVICE);
log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
- componentsUtils.auditComponentAdmin(responseFormat, user, service, actionEnum, ComponentTypeEnum.SERVICE);
+ componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE,
+ ComponentTypeEnum.SERVICE);
return Either.right(responseFormat);
-
} finally {
graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(), NodeTypeEnum.Service);
}
@@ -916,6 +916,27 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
});
}
+ private void generatePropertiesFromGenericType(final Service service, final Resource genericType) {
+ if (CollectionUtils.isEmpty(genericType.getProperties())) {
+ return;
+ }
+ final List<PropertyDefinition> genericTypePropertyList = genericType.getProperties().stream()
+ .map(PropertyDefinition::new)
+ .peek(propertyDefinition -> propertyDefinition.setUniqueId(null))
+ .collect(Collectors.toList());
+ if (service.getProperties() == null) {
+ service.setProperties(new ArrayList<>(genericTypePropertyList));
+ } else {
+ List<PropertyDefinition> servicePropertyList = service.getProperties();
+ genericTypePropertyList.stream()
+ .filter(property -> servicePropertyList.stream()
+ .noneMatch(property1 -> property1.getName().equals(property.getName())))
+ .forEach(servicePropertyList::add);
+ }
+
+ service.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(null));
+ }
+
@SuppressWarnings("unchecked")
private void createServiceApiArtifactsData(Service service, User user) {
// create mandatory artifacts