diff options
30 files changed, 622 insertions, 299 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java index ff0f8dc432..cd3b2a377b 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.catalogdb; import org.onap.logging.filter.spring.LoggingInterceptor; +import org.onap.logging.filter.spring.StatusLoggingInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -34,11 +35,18 @@ import org.springframework.web.servlet.handler.MappedInterceptor; public class WebMvcConfig extends WebMvcConfigurerAdapter { @Autowired - LoggingInterceptor loggingInterceptor; + private LoggingInterceptor loggingInterceptor; + + @Autowired + private StatusLoggingInterceptor statusLoggingInterceptor; @Bean public MappedInterceptor mappedLoggingInterceptor() { return new MappedInterceptor(new String[] {"/**"}, loggingInterceptor); } + @Bean + public MappedInterceptor mappedStatusLoggingInterceptor() { + return new MappedInterceptor(new String[] {"/**"}, statusLoggingInterceptor); + } } diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java index e1dc4cab66..3a14b2ff84 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java @@ -41,7 +41,6 @@ import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder; * @since Version 1.0 * */ - @SpringBootApplication(scanBasePackages = {"org.onap.so", "org.onap.logging.filter"}) @EnableScheduling @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java index c0dfbe08ef..9135d31ac3 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.requestsdb.application; import org.onap.logging.filter.spring.LoggingInterceptor; +import org.onap.logging.filter.spring.StatusLoggingInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -34,11 +35,18 @@ import org.springframework.web.servlet.handler.MappedInterceptor; public class WebMvcConfig extends WebMvcConfigurerAdapter { @Autowired - LoggingInterceptor loggingInterceptor; + private LoggingInterceptor loggingInterceptor; + + @Autowired + private StatusLoggingInterceptor statusLoggingInterceptor; @Bean public MappedInterceptor mappedLoggingInterceptor() { return new MappedInterceptor(new String[] {"/**"}, loggingInterceptor); } + @Bean + public MappedInterceptor mappedStatusLoggingInterceptor() { + return new MappedInterceptor(new String[] {"/**"}, statusLoggingInterceptor); + } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java index b621759b59..ae9316cfdf 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -42,6 +42,7 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.aai.domain.yang.EsrVnfm; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; @@ -173,7 +174,8 @@ public class VnfmServiceProviderConfiguration { private void removeSpringClientFilter(final RestTemplate restTemplate) { ListIterator<ClientHttpRequestInterceptor> interceptorIterator = restTemplate.getInterceptors().listIterator(); while (interceptorIterator.hasNext()) { - if (interceptorIterator.next() instanceof SOSpringClientFilter) { + ClientHttpRequestInterceptor interceptor = interceptorIterator.next(); + if (interceptor instanceof SOSpringClientFilter || interceptor instanceof SpringClientPayloadFilter) { interceptorIterator.remove(); } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java index 7f1c1968c1..d60c377730 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java @@ -65,7 +65,7 @@ public class DeployActivitySpecs { logger.warn("The hostname for SDC activities deployment is not configured in SO"); return; } - if (!checkHttpOk(hostname)) { + if (!checkHttpServerUp(hostname)) { logger.warn("The sdc end point is not alive"); return; } @@ -144,21 +144,22 @@ public class DeployActivitySpecs { return; } - public boolean checkHttpOk(String host) { + public boolean checkHttpServerUp(String host) { URL url = null; - boolean isOk = false; + boolean isUp = false; int responseCode = 0; try { url = new URL(host); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setConnectTimeout(5000); responseCode = connection.getResponseCode(); } catch (Exception e) { logger.warn("Exception on connecting to SDC WFD endpoint: " + e.getMessage()); } - if (responseCode == HttpStatus.SC_OK) { - isOk = true; + if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_NOT_FOUND) { + isUp = true; } - return isOk; + return isUp; } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index ac78dfaefc..b2dbcb4639 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -2792,7 +2792,7 @@ public class ToscaResourceInstaller { + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); } - protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, + public List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, EntityQueryBuilder entityType, TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) { EntityQuery entityQuery = entityType.build(); @@ -2804,7 +2804,7 @@ public class ToscaResourceInstaller { } - protected String getLeafPropertyValue(IEntityDetails entityDetails, String propName) { + public String getLeafPropertyValue(IEntityDetails entityDetails, String propName) { Property leafProperty = entityDetails.getProperties().get(propName); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index 4b069e6ac7..07eca567d5 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -26,15 +26,16 @@ import java.util.Map; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; +import org.onap.sdc.tosca.parser.api.IEntityDetails; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.tosca.parser.elements.queries.EntityQuery; +import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery; import org.onap.sdc.tosca.parser.enums.SdcTypes; import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; -import org.onap.sdc.toscaparser.api.Group; -import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.so.asdc.installer.IVfModuleData; import org.onap.so.asdc.installer.ToscaResourceStructure; -import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.asdc.installer.heat.ToscaResourceInstaller; public class ASDCNotificationLogging { @@ -63,7 +64,7 @@ public class ASDCNotificationLogging { return "NULL"; } - + ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); StringBuilder buffer = new StringBuilder("CSAR Notification:"); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -103,33 +104,33 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); - List<NodeTemplate> serviceProxyResourceList = - toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY); + List<IEntityDetails> serviceProxyResourceList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), + true); + if (serviceProxyResourceList != null) { - for (NodeTemplate serviceProxyNodeTemplate : serviceProxyResourceList) { + for (IEntityDetails serviceProxyEntity : serviceProxyResourceList) { buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("Service Proxy Properties:"); buffer.append(System.lineSeparator()); buffer.append("Model Name:"); - buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + buffer.append(serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); buffer.append(System.lineSeparator()); buffer.append("Model UUID:"); - buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + buffer.append(serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append( - serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + buffer.append(serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); buffer.append(System.lineSeparator()); buffer.append("Version:"); - buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + buffer.append(serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); - buffer.append( - serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + buffer.append(serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -138,31 +139,31 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Model Customization UUID:"); - buffer.append(serviceProxyNodeTemplate.getMetaData() - .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + buffer.append( + serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); buffer.append(System.lineSeparator()); buffer.append("Model Instance Name:"); - buffer.append(serviceProxyNodeTemplate.getName()); + buffer.append(serviceProxyEntity.getName()); buffer.append(System.lineSeparator()); buffer.append("Tosca Node Type:"); - buffer.append(serviceProxyNodeTemplate.getType()); + buffer.append(serviceProxyEntity.getToscaType()); buffer.append(System.lineSeparator()); buffer.append("Version:"); - buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + buffer.append(serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); - buffer.append( - serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + buffer.append(serviceProxyEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); buffer.append(System.lineSeparator()); } } - List<NodeTemplate> configurationNodeTemplatesList = - toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION); + List<IEntityDetails> configurationList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), + true); - if (configurationNodeTemplatesList != null) { - for (NodeTemplate configNodeTemplate : configurationNodeTemplatesList) { + if (configurationList != null) { + for (IEntityDetails configEntity : configurationList) { buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -170,22 +171,22 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Model Name:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); buffer.append(System.lineSeparator()); buffer.append("Model UUID:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); buffer.append(System.lineSeparator()); buffer.append("Version:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); buffer.append(System.lineSeparator()); buffer.append("Tosca Node Type:"); - buffer.append(configNodeTemplate.getType()); + buffer.append(configEntity.getToscaType()); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -193,62 +194,63 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Model Customization UUID:"); - buffer.append( - configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); buffer.append(System.lineSeparator()); buffer.append("Model Instance Name:"); - buffer.append(configNodeTemplate.getName()); + buffer.append(configEntity.getName()); buffer.append(System.lineSeparator()); buffer.append("NFFunction:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( - configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(configEntity, + SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); buffer.append(System.lineSeparator()); buffer.append("NFRole:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(configEntity, + SdcPropertyNames.PROPERTY_NAME_NFROLE)); buffer.append(System.lineSeparator()); buffer.append("NFType:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(configEntity, + SdcPropertyNames.PROPERTY_NAME_NFTYPE)); buffer.append(System.lineSeparator()); } } - List<NodeTemplate> vfNodeTemplatesList = toscaResourceStructure.getSdcCsarHelper().getServiceVfList(); - for (NodeTemplate vfNodeTemplate : vfNodeTemplatesList) { + List<IEntityDetails> vfEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); + + + for (IEntityDetails vfEntity : vfEntityList) { buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("VNF Properties:"); buffer.append(System.lineSeparator()); buffer.append("Model Name:"); - buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); buffer.append("Model UUID:"); - buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); buffer.append("Version:"); - buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); buffer.append(System.lineSeparator()); buffer.append("Type:"); - buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))); buffer.append(System.lineSeparator()); buffer.append("Category:"); - buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY))); buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); - buffer.append( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); buffer.append(System.lineSeparator()); buffer.append("Max Instances:"); - buffer.append(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)); + buffer.append(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)); buffer.append(System.lineSeparator()); buffer.append("Min Instances:"); - buffer.append(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)); + buffer.append(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -256,37 +258,35 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Customization UUID:"); - buffer.append( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + buffer.append(testNull(vfEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); buffer.append(System.lineSeparator()); buffer.append("NFFunction:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, - SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + buffer.append( + toscaResourceInstaller.getLeafPropertyValue(vfEntity, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); buffer.append(System.lineSeparator()); buffer.append("NFCode:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, - "nf_naming_code")); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vfEntity, "nf_naming_code")); buffer.append(System.lineSeparator()); buffer.append("NFRole:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, - SdcPropertyNames.PROPERTY_NAME_NFROLE)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vfEntity, SdcPropertyNames.PROPERTY_NAME_NFROLE)); buffer.append(System.lineSeparator()); buffer.append("NFType:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, - SdcPropertyNames.PROPERTY_NAME_NFTYPE)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vfEntity, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); buffer.append(System.lineSeparator()); buffer.append("MultiStageDesign:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, - "multi_stage_design")); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vfEntity, "multi_stage_design")); buffer.append(System.lineSeparator()); - List<Group> groupList = - toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType( - vfNodeTemplate, "org.openecomp.groups.VfcInstanceGroup"); - if (groupList != null) { - for (Group group : groupList) { - Metadata instanceMetadata = group.getMetadata(); + List<IEntityDetails> vfcInstanceEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), + TopologyTemplateQuery.newBuilder(SdcTypes.VF) + .customizationUUID(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID), + false); + + if (vfcInstanceEntityList != null) { + for (IEntityDetails vfcEntity : vfcInstanceEntityList) { + Metadata instanceMetadata = vfcEntity.getMetadata(); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -300,7 +300,7 @@ public class ASDCNotificationLogging { buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); buffer.append(System.lineSeparator()); buffer.append("Type:"); - buffer.append(vfNodeTemplate.getType()); + buffer.append(vfcEntity.getToscaType()); buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); @@ -309,43 +309,43 @@ public class ASDCNotificationLogging { } + List<IEntityDetails> vfModuleEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder("org.openecomp.groups.VfModule"), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE) + .customizationUUID(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID), + false); - List<Group> vfGroups = toscaResourceStructure.getSdcCsarHelper().getVfModulesByVf( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); - for (Group group : vfGroups) { + for (IEntityDetails vfModuleEntity : vfModuleEntityList) { - Metadata vfMetadata = group.getMetadata(); + Metadata vfMetadata = vfModuleEntity.getMetadata(); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("VF Module Properties:"); buffer.append(System.lineSeparator()); buffer.append("ModelInvariantUuid:"); - buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID))); + buffer.append(testNull(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID))); buffer.append(System.lineSeparator()); buffer.append("ModelName:"); - buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME))); + buffer.append(testNull(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME))); buffer.append(System.lineSeparator()); buffer.append("ModelUuid:"); - buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))); + buffer.append(testNull(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))); buffer.append(System.lineSeparator()); buffer.append("ModelVersion:"); - buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION))); + buffer.append(testNull(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION))); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + buffer.append(testNull(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); - List<NodeTemplate> groupMembers = - toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfNodeTemplate, group); + List<IEntityDetails> groupMembers = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder("org.openecomp.groups.VfModule") + .uUID(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID), + TopologyTemplateQuery.newBuilder(SdcTypes.VF), false); - for (NodeTemplate node : groupMembers) { + for (IEntityDetails node : groupMembers) { buffer.append("Member Name:"); buffer.append(testNull(node.getName())); buffer.append(System.lineSeparator()); @@ -355,17 +355,18 @@ public class ASDCNotificationLogging { buffer.append("VF Module Customization Properties:"); buffer.append(System.lineSeparator()); buffer.append("Model Customization UUID:"); - buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, + buffer.append(testNull(toscaResourceInstaller.getLeafPropertyValue(vfModuleEntity, SdcPropertyNames.PROPERTY_NAME_VFMODULECUSTOMIZATIONUUID))); buffer.append(System.lineSeparator()); } - List<NodeTemplate> vfConfigList = toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CONFIGURATION); + List<IEntityDetails> fabricEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.VF), + false); - if (vfConfigList != null) { - for (NodeTemplate configNodeTemplate : vfConfigList) { + if (fabricEntityList != null) { + for (IEntityDetails configEntity : fabricEntityList) { buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -373,24 +374,22 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Model Name:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); buffer.append(System.lineSeparator()); buffer.append("Model UUID:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append( - configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); buffer.append(System.lineSeparator()); buffer.append("Version:"); - buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); - buffer.append( - configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + buffer.append(configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); buffer.append(System.lineSeparator()); buffer.append("Tosca Node Type:"); - buffer.append(configNodeTemplate.getType()); + buffer.append(configEntity.getToscaType()); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -398,95 +397,96 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Model Customization UUID:"); - buffer.append(configNodeTemplate.getMetaData() - .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + buffer.append( + configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); buffer.append(System.lineSeparator()); buffer.append("Model Instance Name:"); - buffer.append(configNodeTemplate.getName()); + buffer.append(configEntity.getName()); buffer.append(System.lineSeparator()); buffer.append("NFFunction:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( - configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(configEntity, + SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); buffer.append(System.lineSeparator()); buffer.append("NFRole:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( - configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(configEntity, + SdcPropertyNames.PROPERTY_NAME_NFROLE)); buffer.append(System.lineSeparator()); buffer.append("NFType:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( - configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(configEntity, + SdcPropertyNames.PROPERTY_NAME_NFTYPE)); buffer.append(System.lineSeparator()); } } - List<NodeTemplate> cvfcList = - toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CVFC); + List<IEntityDetails> cvnfcEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.CVFC), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false); - for (NodeTemplate cvfcTemplate : cvfcList) { + for (IEntityDetails cvnfcEntity : cvnfcEntityList) { buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("CVNFC Properties:"); buffer.append(System.lineSeparator()); buffer.append("ModelCustomizationUuid:"); - buffer.append(testNull( - cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + buffer.append( + testNull(cvnfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); buffer.append(System.lineSeparator()); buffer.append("ModelInvariantUuid:"); buffer.append( - testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + testNull(cvnfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); buffer.append(System.lineSeparator()); buffer.append("ModelName:"); - buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(testNull(cvnfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); buffer.append("ModelUuid:"); - buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(testNull(cvnfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); buffer.append(System.lineSeparator()); buffer.append("ModelVersion:"); - buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + buffer.append(testNull(cvnfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append( - testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + buffer.append(testNull(cvnfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); buffer.append("Template Name:"); - buffer.append(testNull(cvfcTemplate.getName())); + buffer.append(testNull(cvnfcEntity.getName())); buffer.append(System.lineSeparator()); + List<IEntityDetails> vfcEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.VFC), + TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID( + cvnfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), + false); - List<NodeTemplate> vfcList = - toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC); - - for (NodeTemplate vfcTemplate : vfcList) { + for (IEntityDetails vfcEntity : vfcEntityList) { buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("VNFC Properties:"); buffer.append(System.lineSeparator()); buffer.append("ModelCustomizationUuid:"); buffer.append(testNull( - vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); buffer.append(System.lineSeparator()); buffer.append("ModelInvariantUuid:"); buffer.append( - testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); buffer.append(System.lineSeparator()); buffer.append("ModelName:"); - buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); buffer.append("ModelUuid:"); - buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); buffer.append(System.lineSeparator()); buffer.append("ModelVersion:"); - buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + buffer.append(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); buffer.append(System.lineSeparator()); buffer.append("Description:"); buffer.append( - testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); buffer.append("Sub Category:"); buffer.append( - testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY))); + testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY))); buffer.append(System.lineSeparator()); } @@ -495,41 +495,40 @@ public class ASDCNotificationLogging { } + List<IEntityDetails> vlEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.VL), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); + if (vlEntityList != null) { - List<NodeTemplate> nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList(); - - if (nodeTemplatesVLList != null) { - - for (NodeTemplate vlNode : nodeTemplatesVLList) { + for (IEntityDetails vlEntity : vlEntityList) { buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("NETWORK Level Properties:"); buffer.append(System.lineSeparator()); buffer.append("Model Name:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); buffer.append("Model InvariantUuid:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); buffer.append(System.lineSeparator()); buffer.append("Model UUID:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); buffer.append(System.lineSeparator()); buffer.append("Model Version:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); buffer.append(System.lineSeparator()); buffer.append("AIC Max Version:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); buffer.append(System.lineSeparator()); buffer.append("AIC Min Version:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); buffer.append(System.lineSeparator()); buffer.append("Tosca Node Type:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + buffer.append(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); @@ -537,22 +536,22 @@ public class ASDCNotificationLogging { buffer.append("NETWORK Customization Properties:"); buffer.append(System.lineSeparator()); buffer.append("CustomizationUUID:"); - buffer.append(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + buffer.append(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); buffer.append(System.lineSeparator()); buffer.append("Network Technology:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vlEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)); buffer.append(System.lineSeparator()); buffer.append("Network Type:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vlEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)); buffer.append(System.lineSeparator()); buffer.append("Network Role:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vlEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)); buffer.append(System.lineSeparator()); buffer.append("Network Scope:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(vlEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)); buffer.append(System.lineSeparator()); @@ -560,52 +559,55 @@ public class ASDCNotificationLogging { } + List<IEntityDetails> crEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.CR), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); - List<NodeTemplate> networkCollectionList = - toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR); - - if (networkCollectionList != null) { - for (NodeTemplate crNode : networkCollectionList) { + if (crEntityList != null) { + for (IEntityDetails crEntity : crEntityList) { buffer.append(System.lineSeparator()); buffer.append("Network Collection Properties:"); buffer.append(System.lineSeparator()); buffer.append("Model Name:"); - buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + buffer.append(crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); buffer.append(System.lineSeparator()); buffer.append("Model UUID:"); - buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + buffer.append(crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + buffer.append(System.lineSeparator()); + buffer.append("Customization UUID:"); + buffer.append(crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); - buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + buffer.append(crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); buffer.append(System.lineSeparator()); buffer.append("Description:"); - buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + buffer.append(crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); buffer.append(System.lineSeparator()); buffer.append("Version:"); - buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + buffer.append(crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); buffer.append(System.lineSeparator()); buffer.append("Tosca Node Type:"); - buffer.append(crNode.getType()); + buffer.append(crEntity.getToscaType()); buffer.append(System.lineSeparator()); buffer.append("CR Function:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, - "cr_function")); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(crEntity, "cr_function")); buffer.append(System.lineSeparator()); buffer.append("CR Role:"); - buffer.append( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, "cr_role")); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(crEntity, "cr_role")); buffer.append(System.lineSeparator()); buffer.append("CR Type:"); - buffer.append( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, "cr_type")); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(crEntity, "cr_type")); buffer.append(System.lineSeparator()); - List<NodeTemplate> vlNodeList = - toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(crNode, SdcTypes.VL); + List<IEntityDetails> networkEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.VL), + TopologyTemplateQuery.newBuilder(SdcTypes.CR).customizationUUID( + crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), + false); + - for (NodeTemplate vlNodeTemplate : vlNodeList) { + for (IEntityDetails vlEntity : networkEntityList) { - Metadata vlMetadata = vlNodeTemplate.getMetaData(); + Metadata vlMetadata = vlEntity.getMetadata(); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -631,19 +633,20 @@ public class ASDCNotificationLogging { buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); buffer.append(System.lineSeparator()); buffer.append("Tosca Node Type:"); - buffer.append(vlNodeTemplate.getType()); + buffer.append(vlEntity.getToscaType()); buffer.append(System.lineSeparator()); } + List<IEntityDetails> ncEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder("org.openecomp.groups.NetworkCollection"), + TopologyTemplateQuery.newBuilder(SdcTypes.CR).customizationUUID( + crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), + false); - List<Group> groupList = - toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType( - crNode, "org.openecomp.groups.NetworkCollection"); - - if (groupList != null) { - for (Group group : groupList) { - Metadata instanceMetadata = group.getMetadata(); + if (ncEntityList != null) { + for (IEntityDetails ncEntity : ncEntityList) { + Metadata instanceMetadata = ncEntity.getMetadata(); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("Network Instance Group Properties:"); @@ -670,96 +673,172 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Model Customization UUID:"); - buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + buffer.append(crEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); buffer.append(System.lineSeparator()); buffer.append("Model Instance Name:"); - buffer.append(crNode.getName()); + buffer.append(crEntity.getName()); buffer.append(System.lineSeparator()); buffer.append("Network Scope:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(crEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)); buffer.append(System.lineSeparator()); buffer.append("Network Role:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(crEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)); buffer.append(System.lineSeparator()); buffer.append("Network Type:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(crEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)); buffer.append(System.lineSeparator()); buffer.append("Network Technology:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, + buffer.append(toscaResourceInstaller.getLeafPropertyValue(crEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)); buffer.append(System.lineSeparator()); } } - List<NodeTemplate> allottedResourceList = toscaResourceStructure.getSdcCsarHelper().getAllottedResources(); + List<IEntityDetails> arEntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); - if (allottedResourceList != null) { + if (arEntityList != null) { buffer.append(System.lineSeparator()); - buffer.append("Allotted Resource Properties:"); + buffer.append("VF Allotted Resource Properties:"); buffer.append(System.lineSeparator()); - for (NodeTemplate allottedNode : allottedResourceList) { + for (IEntityDetails arEntity : arEntityList) { - buffer.append("Model Name:"); - buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - buffer.append(System.lineSeparator()); - buffer.append("Model Name:"); - buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - buffer.append(System.lineSeparator()); - buffer.append("Model InvariantUuid:"); - buffer.append( - testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); - buffer.append(System.lineSeparator()); - buffer.append("Model Version:"); - buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); - buffer.append(System.lineSeparator()); - buffer.append("Model UUID:"); - buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); - buffer.append(System.lineSeparator()); - buffer.append("Model Subcategory:"); - buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); - buffer.append(System.lineSeparator()); - buffer.append("Model Category:"); - buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); - buffer.append(System.lineSeparator()); - buffer.append("Model Description:"); - buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - buffer.append(System.lineSeparator()); + Metadata metadata = arEntity.getMetadata(); + String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); + if ("Allotted Resource".equalsIgnoreCase(category)) { - buffer.append("Allotted Resource Customization Properties:"); - buffer.append(System.lineSeparator()); + buffer.append("Model Name:"); + buffer.append(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(System.lineSeparator()); + buffer.append("Model Name:"); + buffer.append(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(System.lineSeparator()); + buffer.append("Model InvariantUuid:"); + buffer.append( + testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + buffer.append(System.lineSeparator()); + buffer.append("Model Version:"); + buffer.append(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + buffer.append(System.lineSeparator()); + buffer.append("Model UUID:"); + buffer.append(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(System.lineSeparator()); + buffer.append("Model Subcategory:"); + buffer.append(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); + buffer.append(System.lineSeparator()); + buffer.append("Model Category:"); + buffer.append(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); + buffer.append(System.lineSeparator()); + buffer.append("Model Description:"); + buffer.append(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + buffer.append(System.lineSeparator()); - buffer.append("Model Cutomization UUID:"); - buffer.append(testNull( - allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); - buffer.append(System.lineSeparator()); - buffer.append("NFFunction:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, - SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); - buffer.append(System.lineSeparator()); - buffer.append("NFCode:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, - "nf_naming_code")); - buffer.append(System.lineSeparator()); - buffer.append("NFRole:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, - SdcPropertyNames.PROPERTY_NAME_NFROLE)); - buffer.append(System.lineSeparator()); - buffer.append("NFType:"); - buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, - SdcPropertyNames.PROPERTY_NAME_NFTYPE)); - buffer.append(System.lineSeparator()); + buffer.append("Allotted Resource Customization Properties:"); + buffer.append(System.lineSeparator()); + + buffer.append("Model Cutomization UUID:"); + buffer.append(testNull( + arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + buffer.append(System.lineSeparator()); + buffer.append("NFFunction:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(arEntity, + SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + buffer.append(System.lineSeparator()); + buffer.append("NFCode:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(arEntity, "nf_naming_code")); + buffer.append(System.lineSeparator()); + buffer.append("NFRole:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(arEntity, + SdcPropertyNames.PROPERTY_NAME_NFROLE)); + buffer.append(System.lineSeparator()); + buffer.append("NFType:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(arEntity, + SdcPropertyNames.PROPERTY_NAME_NFTYPE)); + buffer.append(System.lineSeparator()); + } } } + List<IEntityDetails> pnfAREntityList = toscaResourceInstaller.getEntityDetails(toscaResourceStructure, + EntityQuery.newBuilder(SdcTypes.PNF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); + + if (pnfAREntityList != null) { + + buffer.append(System.lineSeparator()); + buffer.append("PNF Allotted Resource Properties:"); + buffer.append(System.lineSeparator()); + + for (IEntityDetails pnfAREntity : pnfAREntityList) { + + Metadata metadata = pnfAREntity.getMetadata(); + String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); + + if ("Allotted Resource".equalsIgnoreCase(category)) { + + buffer.append("Model Name:"); + buffer.append(testNull(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(System.lineSeparator()); + buffer.append("Model Name:"); + buffer.append(testNull(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(System.lineSeparator()); + buffer.append("Model InvariantUuid:"); + buffer.append( + testNull(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + buffer.append(System.lineSeparator()); + buffer.append("Model Version:"); + buffer.append(testNull(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + buffer.append(System.lineSeparator()); + buffer.append("Model UUID:"); + buffer.append(testNull(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(System.lineSeparator()); + buffer.append("Model Subcategory:"); + buffer.append(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); + buffer.append(System.lineSeparator()); + buffer.append("Model Category:"); + buffer.append(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); + buffer.append(System.lineSeparator()); + buffer.append("Model Description:"); + buffer.append(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + buffer.append(System.lineSeparator()); + + + buffer.append("Allotted Resource Customization Properties:"); + buffer.append(System.lineSeparator()); + + buffer.append("Model Cutomization UUID:"); + buffer.append(testNull( + pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + buffer.append(System.lineSeparator()); + buffer.append("NFFunction:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(pnfAREntity, + SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + buffer.append(System.lineSeparator()); + buffer.append("NFCode:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(pnfAREntity, "nf_naming_code")); + buffer.append(System.lineSeparator()); + buffer.append("NFRole:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(pnfAREntity, + SdcPropertyNames.PROPERTY_NAME_NFROLE)); + buffer.append(System.lineSeparator()); + buffer.append("NFType:"); + buffer.append(toscaResourceInstaller.getLeafPropertyValue(pnfAREntity, + SdcPropertyNames.PROPERTY_NAME_NFTYPE)); + buffer.append(System.lineSeparator()); + } + + } + } + + return buffer.toString(); } diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java index b41fbaf658..75ab089719 100644 --- a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java +++ b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java @@ -29,7 +29,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; import org.junit.Test; +import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Spy; import org.onap.so.asdc.BaseTest; import org.onap.so.asdc.activity.DeployActivitySpecs; import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse; @@ -50,6 +52,10 @@ public class DeployActivitySpecsITTest extends BaseTest { @Autowired private DeployActivitySpecs deployActivitySpecs; + @InjectMocks + @Spy + DeployActivitySpecs deployActivitySpecsM; + @Test public void deployActivitySpecsIT_Test() throws Exception { ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse(); @@ -100,7 +106,9 @@ public class DeployActivitySpecsITTest extends BaseTest { put(urlPathMatching(urlPath)).willReturn(aResponse().withHeader("Content-Type", "application/json") .withStatus(org.springframework.http.HttpStatus.OK.value()))); - deployActivitySpecs.deployActivities(); + String host = "http://localhost:8090"; + when(deployActivitySpecsM.checkHttpServerUp(host)).thenReturn(false); + deployActivitySpecsM.deployActivities(); verify(0, putRequestedFor(urlEqualTo(urlPath))); } diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java index 7a876a67a2..6d88ab6630 100644 --- a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java +++ b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java @@ -71,7 +71,7 @@ public class DeployActivitySpecsTest { new ArrayList<org.onap.so.db.catalog.beans.ActivitySpec>(); catalogActivitySpecList.add(catalogActivitySpec); when(env.getProperty("mso.asdc.config.activity.endpoint")).thenReturn("http://testEndpoint"); - doReturn(true).when(deployActivitySpecs).checkHttpOk("http://testEndpoint"); + doReturn(true).when(deployActivitySpecs).checkHttpServerUp("http://testEndpoint"); when(activitySpecRepository.findAll()).thenReturn(catalogActivitySpecList); doReturn("testActivityId").when(activitySpecsActions).createActivitySpec(Mockito.any(), Mockito.any()); doReturn(true).when(activitySpecsActions).certifyActivitySpec(Mockito.any(), Mockito.any()); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index 5f70ab5924..3a1e126fef 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -82,7 +82,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple String correlationValue = messageId; callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "queryVnfNotification") @@ -117,7 +117,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setOutputs(outputs); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "createVnfNotification") @@ -150,7 +150,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setRollback(rollback); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "updateVnfNotification") @@ -181,7 +181,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setRollback(rollback); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "deleteVnfNotification") @@ -208,6 +208,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setErrorMessage(errorMessage); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java new file mode 100644 index 0000000000..d15d71a9e9 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java @@ -0,0 +1,118 @@ +package org.onap.so.bpmn.common.workflow.service; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.DeleteVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.MsoExceptionCategory; +import org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.RollbackVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification; +import org.onap.so.bpmn.common.adapter.vnf.VnfRollback; +import org.onap.so.bpmn.common.adapter.vnf.VnfStatus; +import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult; + +@RunWith(MockitoJUnitRunner.class) +public class VnfAdapterNotifyServiceImplTest { + + + @InjectMocks + @Spy + private VnfAdapterNotifyServiceImpl vnfAdapterNotifyServiceImpl; + + @Mock + private CallbackHandlerService callbackHandlerService; + + @Mock + private CallbackResult callbackResult; + + protected CreateVnfNotification.Outputs outputs = new CreateVnfNotification.Outputs(); + protected QueryVnfNotification.Outputs queryOutputs = new QueryVnfNotification.Outputs(); + protected UpdateVnfNotification.Outputs updateOutputs = new UpdateVnfNotification.Outputs(); + + protected VnfRollback vnfRollback = new VnfRollback(); + + @Test + public void rollbackVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("rollbackVnfNotification"), + any(RollbackVnfNotification.class), eq("rollbackVnfNotificationCallback"), + eq("rollbackVnfNotificationCallback"), eq("VNFRB_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + + vnfAdapterNotifyServiceImpl.rollbackVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, + "Error creating stack"); + + verify(callbackHandlerService, times(1)).handleCallback(eq("rollbackVnfNotification"), + any(RollbackVnfNotification.class), eq("rollbackVnfNotificationCallback"), + eq("rollbackVnfNotificationCallback"), eq("VNFRB_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + } + + @Test + public void queryVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("queryVnfNotification"), + any(QueryVnfNotification.class), eq("queryVnfNotificationCallback"), eq("queryVnfNotificationCallback"), + eq("VNFQ_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + + vnfAdapterNotifyServiceImpl.queryVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "", + Boolean.TRUE, "vnfid", VnfStatus.ACTIVE, queryOutputs); + + verify(callbackHandlerService, times(1)).handleCallback(eq("queryVnfNotification"), + any(QueryVnfNotification.class), eq("queryVnfNotificationCallback"), eq("queryVnfNotificationCallback"), + eq("VNFQ_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + } + + @Test + public void createVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("createVnfNotification"), + any(CreateVnfNotification.class), eq("createVnfNotificationCallback"), + eq("createVnfNotificationCallback"), eq("VNFC_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + + vnfAdapterNotifyServiceImpl.createVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "", + "vnfId", outputs, vnfRollback); + + verify(callbackHandlerService, times(1)).handleCallback(eq("createVnfNotification"), + any(CreateVnfNotification.class), eq("createVnfNotificationCallback"), + eq("createVnfNotificationCallback"), eq("VNFC_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + } + + @Test + public void updateVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("updateVnfNotification"), + any(UpdateVnfNotification.class), eq("updateVnfNotificationCallback"), + eq("updateVnfNotificationCallback"), eq("VNFU_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + + vnfAdapterNotifyServiceImpl.updateVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "", + updateOutputs, vnfRollback); + + verify(callbackHandlerService, times(1)).handleCallback(eq("updateVnfNotification"), + any(UpdateVnfNotification.class), eq("updateVnfNotificationCallback"), + eq("updateVnfNotificationCallback"), eq("VNFU_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), + eq(null)); + } + + @Test + public void deleteVnfNotificationTest() { + doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("deleteVnfNotification"), + any(DeleteVnfNotification.class), eq("deleteVnfACallback"), eq("deleteVnfACallback"), eq("VNFDEL_uuid"), + eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + + vnfAdapterNotifyServiceImpl.deleteVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, ""); + + verify(callbackHandlerService, times(1)).handleCallback(eq("deleteVnfNotification"), + any(DeleteVnfNotification.class), eq("deleteVnfACallback"), eq("deleteVnfACallback"), eq("VNFDEL_uuid"), + eq("messageId"), eq("[VNF-NOTIFY]"), eq(null)); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 9c72d229b2..79ccd9216f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -24,6 +24,7 @@ package org.onap.so.bpmn.infrastructure.appc.tasks; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import org.onap.so.logger.LoggingAnchor; import org.json.JSONArray; @@ -31,6 +32,7 @@ import org.json.JSONObject; import org.onap.aai.domain.yang.Vserver; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -166,6 +168,10 @@ public class AppcRunTasks { String pay = requestParameters.getPayload(); if (pay != null) { payload = Optional.of(pay); + } else { + String payloadFromUserParams = + buildPayloadFromUserParams(gBBInput.getRequestContext().getUserParams()); + payload = Optional.of(payloadFromUserParams); } } logger.debug("Running APP-C action: {}", action.toString()); @@ -221,6 +227,21 @@ public class AppcRunTasks { return payloadInfo; } + protected String buildPayloadFromUserParams(Map<String, Object> userParams) { + if (userParams == null || userParams.size() == 0) { + return null; + } + + String payload = "{}"; + for (Map.Entry<String, Object> entry : userParams.entrySet()) { + payload = JsonUtils.addJsonValue(payload, entry.getKey(), (String) entry.getValue()); + } + + payload = payload.replaceAll("\"", "\\\\\""); + payload = payload.replaceAll("\n", ""); + return payload; + } + protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception { AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/UnassignNetworkException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/UnassignNetworkException.java new file mode 100644 index 0000000000..566cdccd50 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/exceptions/UnassignNetworkException.java @@ -0,0 +1,14 @@ +package org.onap.so.bpmn.infrastructure.flowspecific.exceptions; + +public class UnassignNetworkException extends Exception { + + private static final long serialVersionUID = 2864418350216433736L; + + public UnassignNetworkException() { + super(); + } + + public UnassignNetworkException(String message) { + super(message); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java index c9a937b824..f95e7afed9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java @@ -24,19 +24,22 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.flowspecific.exceptions.UnassignNetworkException; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAINetworkResources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class UnassignNetworkBB { - + private static final Logger logger = LoggerFactory.getLogger(UnassignNetworkBB.class); private static String messageCannotPerformUnassign = "Cannot perform Unassign Network. Network is still related to "; private static String messageErrorRollback = " Rollback is not possible. Please restore data manually."; @@ -71,7 +74,8 @@ public class UnassignNetworkBB { if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) { String msg = messageCannotPerformUnassign + relatedToValue; execution.setVariable("ErrorUnassignNetworkBB", msg); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + logger.error("ErrorUnassignNetworkBB: {}", msg); + throw new UnassignNetworkException(msg); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index d5798150d1..f5bbcf5bc0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -38,6 +38,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.Configuration; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -398,7 +399,7 @@ public class WorkflowActionBBTasks { if (fabricConfig != null && fabricConfig.getConfigurationResource() != null && fabricConfig.getConfigurationResource().getToscaNodeType() != null && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) { - String configurationId = UUID.randomUUID().toString(); + String configurationId = getConfigurationId(vnfc); ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId); configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID); @@ -429,6 +430,17 @@ public class WorkflowActionBBTasks { } } + protected String getConfigurationId(Vnfc vnfc) { + List<Configuration> configurations = + workflowAction.getRelatedResourcesInVnfc(vnfc, Configuration.class, AAIObjectType.CONFIGURATION); + if (!configurations.isEmpty()) { + Configuration configuration = configurations.get(0); + return configuration.getConfigurationId(); + } else { + return UUID.randomUUID().toString(); + } + } + protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb, String configurationId, ConfigurationResourceKeys configurationResourceKeys) { ExecuteBuildingBlock configBB = new ExecuteBuildingBlock(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java index cc25689358..f0c333007e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java @@ -33,6 +33,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import org.junit.Test; import org.mockito.InjectMocks; @@ -168,6 +170,21 @@ public class AppcRunTasksTest extends BaseTaskTest { assertEquals(vmIdList, expectedVmIdList); } + @Test + public void testUserParams() throws Exception { + Map<String, Object> userParams = new HashMap<String, Object>(); + userParams.put("existing_software_version", "3.1"); + userParams.put("new_software_version", "3.2"); + userParams.put("operations_timeout", "150000"); + + String actualPayload = appcRunTasks.buildPayloadFromUserParams(userParams); + System.out.println(actualPayload); + String expectedPayload = + "{\\\"operations_timeout\\\":\\\"150000\\\",\\\"existing_software_version\\\":\\\"3.1\\\",\\\"new_software_version\\\":\\\"3.2\\\"}"; + assertEquals(expectedPayload, actualPayload.replaceAll(" ", "")); + + } + private void mockReferenceResponse() { ControllerSelectionReference reference = new ControllerSelectionReference(); reference.setControllerName("TEST-CONTROLLER-NAME"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java index bacc57758b..ed55c56231 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java @@ -40,9 +40,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; -import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.springframework.beans.factory.annotation.Autowired; public class UnassignNetworkBBTest extends BaseTaskTest { @@ -84,6 +82,15 @@ public class UnassignNetworkBBTest extends BaseTaskTest { } @Test + public void checkRelationshipRelatedToUnassignNetworkExceptionTest() throws Exception { + String msg = "Cannot perform Unassign Network. Network is still related to vf-module"; + expectedException.expect(BpmnError.class); + doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module")); + unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module"); + assertEquals(execution.getVariable("ErrorUnassignNetworkBB"), msg); + } + + @Test public void getCloudSdncRegion25Test() throws Exception { CloudRegion cloudRegion = setCloudRegion(); cloudRegion.setCloudRegionVersion("2.5"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index aac09b4475..1df4ad797f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -417,4 +417,22 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { workflowActionBBTasks.updateInstanceId(execution); Mockito.verify(reqMock, Mockito.times(1)).setServiceInstanceId(instanceId); } + + @Test + public void getConfigurationId() { + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("modelInvariantId"); + vnfc.setVnfcName("testVnfcName"); + List<org.onap.aai.domain.yang.Configuration> configurations = + new ArrayList<org.onap.aai.domain.yang.Configuration>(); + org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setModelCustomizationId("modelCustimizationId"); + configuration.setConfigurationName("testConfigurationName"); + configurations.add(configuration); + doReturn(configurations.get(0).getConfigurationId()).when(workflowActionBBTasks).getConfigurationId(vnfc); + assertEquals(workflowActionBBTasks.getConfigurationId(vnfc), "configurationId"); + } + + } diff --git a/common/pom.xml b/common/pom.xml index 9e4382621a..1f7f044fc8 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -186,7 +186,7 @@ <artifactId>javatuples</artifactId> <version>1.2</version> </dependency> - <dependency> + <dependency> <groupId>org.camunda.bpm</groupId> <artifactId>camunda-external-task-client</artifactId> <version>1.1.1</version> diff --git a/common/src/main/java/org/onap/so/client/BaseClient.java b/common/src/main/java/org/onap/so/client/BaseClient.java index d1523a1f96..24c83cbcab 100644 --- a/common/src/main/java/org/onap/so/client/BaseClient.java +++ b/common/src/main/java/org/onap/so/client/BaseClient.java @@ -22,6 +22,7 @@ package org.onap.so.client; import java.util.ArrayList; import java.util.List; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; @@ -81,6 +82,7 @@ public class BaseClient<I, O> { restTemplate .setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); restTemplate.getInterceptors().add(new SOSpringClientFilter()); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); ResponseEntity<O> responseEntity = restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, uriVariables); return responseEntity.getBody(); diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index c8d7dc9f5c..077ba24c2b 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -50,7 +50,6 @@ import org.onap.logging.filter.base.PayloadLoggingClientFilter; import org.onap.so.client.policy.CommonObjectMapperProvider; import org.onap.so.logging.jaxrs.filter.SOMetricLogClientFilter; import org.onap.so.utils.CryptoUtils; -import org.onap.logging.filter.base.ONAPComponents; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; diff --git a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java index 5fbc9126cf..f8587ff776 100644 --- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java +++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java @@ -20,6 +20,7 @@ package org.onap.so.client; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.configuration.rest.HttpComponentsClientConfiguration; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.springframework.beans.factory.annotation.Autowired; @@ -46,6 +47,7 @@ public class RestTemplateConfig { restTemplate .setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); restTemplate.getInterceptors().add(new SOSpringClientFilter()); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); return restTemplate; } @@ -57,6 +59,7 @@ public class RestTemplateConfig { final RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory)); restTemplate.getInterceptors().add(new SOSpringClientFilter()); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); return restTemplate; } } diff --git a/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java b/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java index 8d30ad35ff..9f71e61e1f 100644 --- a/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java +++ b/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java @@ -16,10 +16,10 @@ import org.springframework.stereotype.Component; @Component public class AuditMDCSetup { - private MDCSetup mdcSetup = new MDCSetup(); - private static final Logger logger = LoggerFactory.getLogger(AuditMDCSetup.class); + private MDCSetup mdcSetup = new MDCSetup(); + public void setupMDC(ExternalTask externalTask) { MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java index 248e2f00bf..22a8d0405a 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java @@ -2,7 +2,6 @@ package org.onap.so.logging.jaxrs.filter; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; -import org.onap.logging.filter.base.MDCSetup; import org.onap.logging.filter.base.MetricLogClientFilter; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.logger.MdcConstants; @@ -15,21 +14,19 @@ import org.slf4j.MarkerFactory; public class SOMetricLogClientFilter extends MetricLogClientFilter { - protected static Logger logger = LoggerFactory.getLogger(MDCSetup.class); + protected static Logger logger = LoggerFactory.getLogger(SOMetricLogClientFilter.class); private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN"); - private MDCSetup mdcSetup = new MDCSetup(); - @Override public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) { try { - mdcSetup.setLogTimestamp(); - mdcSetup.setElapsedTimeInvokeTimestamp(); - mdcSetup.setResponseStatusCode(responseContext.getStatus()); - mdcSetup.setResponseDescription(responseContext.getStatus()); + setLogTimestamp(); + setElapsedTimeInvokeTimestamp(); + setResponseStatusCode(responseContext.getStatus()); + setResponseDescription(responseContext.getStatus()); MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus())); logger.info(INVOKE_RETURN, "InvokeReturn"); - mdcSetup.clearClientMDCs(); + clearClientMDCs(); setOpenStackResponseCode(); } catch (Exception e) { logger.warn("Error in JAX-RS request,response client filter", e); diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java index c2b8df37c2..23df408ca5 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java @@ -2,7 +2,6 @@ package org.onap.so.logging.jaxrs.filter; import java.io.IOException; import java.nio.charset.Charset; -import org.onap.logging.filter.base.MDCSetup; import org.onap.logging.filter.spring.SpringClientFilter; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.logger.MdcConstants; @@ -11,6 +10,7 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.slf4j.Marker; import org.slf4j.MarkerFactory; +import org.springframework.http.HttpRequest; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpResponse; import org.springframework.stereotype.Component; @@ -20,27 +20,24 @@ import org.springframework.util.StreamUtils; public class SOSpringClientFilter extends SpringClientFilter implements ClientHttpRequestInterceptor { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private MDCSetup mdcSetup = new MDCSetup(); private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN"); - - protected void processResponse(ClientHttpResponse response) throws IOException { - if (logger.isDebugEnabled()) { - logger.debug("============================response begin=========================================="); - logger.debug("Status code : {}", response.getStatusCode()); - logger.debug("Status text : {}", response.getStatusText()); - logger.debug("Headers : {}", response.getHeaders()); - logger.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset())); - logger.debug("=======================response end================================================="); + @Override + protected void post(HttpRequest request, ClientHttpResponse response) { + setLogTimestamp(); + setElapsedTimeInvokeTimestamp(); + try { + setResponseStatusCode(response.getRawStatusCode()); + int statusCode = response.getRawStatusCode(); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(statusCode)); + setResponseDescription(statusCode); + } catch (IOException e) { + logger.error("Unable to get statusCode from response"); } - mdcSetup.setLogTimestamp(); - mdcSetup.setElapsedTimeInvokeTimestamp(); - mdcSetup.setResponseStatusCode(response.getRawStatusCode()); - int statusCode = response.getRawStatusCode(); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(statusCode)); - mdcSetup.setResponseDescription(statusCode); + + logger.info(INVOKE_RETURN, "InvokeReturn"); - mdcSetup.clearClientMDCs(); + clearClientMDCs(); setOpenStackResponseCode(); } diff --git a/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java b/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java index 5e2a51a56f..c4609f0336 100644 --- a/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java +++ b/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java @@ -12,6 +12,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.logging.filter.base.MDCSetup; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.logger.MdcConstants; import org.slf4j.MDC; @@ -22,6 +23,9 @@ public class AuditMDCSetupTest { @Mock private ExternalTask externalTask; + @Mock + private MDCSetup mdcSet; + @Spy @InjectMocks private AuditMDCSetup mdcSetup; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java index e157d926f3..1011454906 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,8 +101,7 @@ public class VnfRestHandler extends AbstractRestHandler { checkDuplicateRequest(instanceIdMap, ModelType.vnf, instanceName, requestId); } - public Recipe findVnfModuleRecipe(String modelCustomizationId, String modelType, String action) - throws NoRecipeException { + public Recipe findVnfModuleRecipe(String modelCustomizationId, String modelType, String action) { VnfRecipe recipe = new VnfRecipe(); recipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); return recipe; diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 5ea0d3c54a..99c1d1ea72 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -32,6 +32,7 @@ import javax.annotation.PostConstruct; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpStatus; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; @@ -158,6 +159,7 @@ public class RequestsDbClient { return Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory) .setRestTemplateConfigurer(restTemplate -> { restTemplate.getInterceptors().add((new SOSpringClientFilter())); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); restTemplate.getInterceptors().add((request, body, execution) -> { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index fcafe90405..0486494c53 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpStatus; import org.onap.logging.filter.base.Constants; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; @@ -368,6 +369,7 @@ public class CatalogDbClient { ClientFactory clientFactory = Configuration.builder().setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> { restTemplate.getInterceptors().add((new SOSpringClientFilter())); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); restTemplate.getInterceptors().add((request, body, execution) -> { @@ -417,6 +419,7 @@ public class CatalogDbClient { ClientFactory clientFactory = Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory) .setRestTemplateConfigurer(restTemplate -> { restTemplate.getInterceptors().add((new SOSpringClientFilter())); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); restTemplate.getInterceptors().add((request, body, execution) -> { @@ -635,11 +635,11 @@ <!-- *********************************************************************************************************** --> <!-- Dependencies --> <dependencies> - <dependency> - <groupId>org.onap.logging-analytics</groupId> - <artifactId>logging-slf4j</artifactId> - <version>1.5.0-SNAPSHOT</version> - </dependency> + <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-slf4j</artifactId> + <version>1.5.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-base</artifactId> |