aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorleventecsanyi <levente.csanyi@est.tech>2024-12-03 10:45:57 +0100
committerLevente Csanyi <levente.csanyi@est.tech>2024-12-10 13:39:02 +0000
commitd7e82deca1f8594c2421bacb0267b5f800c1f7f4 (patch)
tree644b4d5b19a23710230dc9103ba67d59373c25b7
parentffac9f27f7183d8e80aa74a7b113f68dcadb3f87 (diff)
Separated inventoryFacade to Interface and Impl
- created NetworkCmProxyInventoryFacade IF Issue-ID: CPS-2513 Change-Id: Ibda2d7899514ee22d4b04cad971e107bfccce2df Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy4
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy4
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java134
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java169
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy6
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy4
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy4
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy4
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy4
10 files changed, 206 insertions, 131 deletions
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index b998a16b2d..be7f449326 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -32,7 +32,7 @@ import groovy.json.JsonSlurper
import org.mapstruct.factory.Mappers
import org.onap.cps.TestUtils
import org.onap.cps.events.EventsPublisher
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.api.inventory.models.CompositeState
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
import org.onap.cps.ncmp.api.inventory.models.TrustLevel
@@ -91,7 +91,7 @@ class NetworkCmProxyControllerSpec extends Specification {
NetworkCmProxyFacade mockNetworkCmProxyFacade = Mock()
@SpringBean
- NetworkCmProxyInventoryFacade mockNetworkCmProxyInventoryFacade = Mock()
+ NetworkCmProxyInventoryFacadeImpl mockNetworkCmProxyInventoryFacade = Mock()
@SpringBean
AlternateIdMatcher mockAlternateIdMatcher = Mock()
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
index 59307640ef..9d79922478 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
@@ -23,7 +23,7 @@ package org.onap.cps.ncmp.rest.controller
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.TestUtils
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters
import org.onap.cps.ncmp.api.inventory.models.CmHandleRegistrationResponse
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
@@ -55,7 +55,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
MockMvc mvc
@SpringBean
- NetworkCmProxyInventoryFacade mockNetworkCmProxyInventoryFacade = Mock()
+ NetworkCmProxyInventoryFacadeImpl mockNetworkCmProxyInventoryFacade = Mock()
@SpringBean
NcmpRestInputMapper ncmpRestInputMapper = Mock()
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy
index 26060a02d2..aad04a18ae 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy
@@ -31,7 +31,7 @@ import org.onap.cps.ncmp.api.exceptions.DmiRequestException
import org.onap.cps.ncmp.api.exceptions.PayloadTooLargeException
import org.onap.cps.ncmp.api.exceptions.PolicyExecutorException
import org.onap.cps.ncmp.api.exceptions.ServerNcmpException
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.impl.data.NcmpCachedResourceRequestHandler
import org.onap.cps.ncmp.impl.data.NcmpPassthroughResourceRequestHandler
import org.onap.cps.ncmp.impl.data.NetworkCmProxyFacade
@@ -76,7 +76,7 @@ class NetworkCmProxyRestExceptionHandlerSpec extends Specification {
NetworkCmProxyFacade mockNetworkCmProxyFacade = Mock()
@SpringBean
- NetworkCmProxyInventoryFacade mockNetworkCmProxyInventoryFacade = Mock()
+ NetworkCmProxyInventoryFacadeImpl mockNetworkCmProxyInventoryFacade = Mock()
@SpringBean
InventoryPersistence mockInventoryPersistence = Mock()
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
index 64bec06fec..9bfb775d55 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
@@ -1,10 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 highstreet technologies GmbH
- * Modifications Copyright (C) 2021-2024 Nordix Foundation
- * Modifications Copyright (C) 2021 Pantheon.tech
- * Modifications Copyright (C) 2021-2022 Bell Canada
- * Modifications Copyright (C) 2023 TechMahindra Ltd.
+ * Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,47 +20,18 @@
package org.onap.cps.ncmp.api.inventory;
-import static org.onap.cps.ncmp.impl.inventory.CmHandleQueryParametersValidator.validateCmHandleQueryParameters;
-
import java.util.Collection;
-import java.util.Collections;
import java.util.Map;
-import lombok.RequiredArgsConstructor;
import org.onap.cps.api.model.ModuleDefinition;
import org.onap.cps.api.model.ModuleReference;
-import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException;
import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters;
import org.onap.cps.ncmp.api.inventory.models.CompositeState;
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration;
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistrationResponse;
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle;
-import org.onap.cps.ncmp.impl.inventory.CmHandleQueryService;
-import org.onap.cps.ncmp.impl.inventory.CmHandleRegistrationService;
-import org.onap.cps.ncmp.impl.inventory.InventoryPersistence;
-import org.onap.cps.ncmp.impl.inventory.ParameterizedCmHandleQueryService;
-import org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions;
-import org.onap.cps.ncmp.impl.inventory.models.InventoryQueryConditions;
-import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
-import org.onap.cps.ncmp.impl.inventory.trustlevel.TrustLevelManager;
-import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher;
-import org.onap.cps.ncmp.impl.utils.YangDataConverter;
-import org.onap.cps.utils.JsonObjectMapper;
-import org.springframework.stereotype.Service;
-
-@Service
-@RequiredArgsConstructor
-public class NetworkCmProxyInventoryFacade {
-
- private final CmHandleRegistrationService cmHandleRegistrationService;
- private final CmHandleQueryService cmHandleQueryService;
- private final ParameterizedCmHandleQueryService parameterizedCmHandleQueryService;
- private final InventoryPersistence inventoryPersistence;
- private final JsonObjectMapper jsonObjectMapper;
- private final TrustLevelManager trustLevelManager;
- private final AlternateIdMatcher alternateIdMatcher;
-
+public interface NetworkCmProxyInventoryFacade {
/**
* Registration of Created, Removed, Updated or Upgraded CM Handles.
@@ -72,9 +39,7 @@ public class NetworkCmProxyInventoryFacade {
* @param dmiPluginRegistration Dmi Plugin Registration details
* @return dmiPluginRegistrationResponse
*/
- public DmiPluginRegistrationResponse updateDmiRegistration(final DmiPluginRegistration dmiPluginRegistration) {
- return cmHandleRegistrationService.updateDmiRegistration(dmiPluginRegistration);
- }
+ DmiPluginRegistrationResponse updateDmiRegistration(final DmiPluginRegistration dmiPluginRegistration);
/**
* Get all cm handle references by DMI plugin identifier.
@@ -84,10 +49,8 @@ public class NetworkCmProxyInventoryFacade {
* cm handle id (false) or alternate id (true)
* @return collection of cm handle references
*/
- public Collection<String> getAllCmHandleReferencesByDmiPluginIdentifier(final String dmiPluginIdentifier,
- final boolean outputAlternateId) {
- return cmHandleQueryService.getCmHandleReferencesByDmiPluginIdentifier(dmiPluginIdentifier, outputAlternateId);
- }
+ Collection<String> getAllCmHandleReferencesByDmiPluginIdentifier(final String dmiPluginIdentifier,
+ final boolean outputAlternateId);
/**
* Get all cm handle IDs by various properties.
@@ -97,14 +60,9 @@ public class NetworkCmProxyInventoryFacade {
* cm handle id (false) or alternate id (true)
* @return collection of cm handle references
*/
- public Collection<String> executeParameterizedCmHandleIdSearch(
- final CmHandleQueryServiceParameters cmHandleQueryServiceParameters, final boolean outputAlternateId) {
- validateCmHandleQueryParameters(cmHandleQueryServiceParameters, InventoryQueryConditions.ALL_CONDITION_NAMES);
-
- return parameterizedCmHandleQueryService.queryCmHandleIdsForInventory(cmHandleQueryServiceParameters,
- outputAlternateId);
- }
-
+ Collection<String> executeParameterizedCmHandleIdSearch(final CmHandleQueryServiceParameters
+ cmHandleQueryServiceParameters,
+ final boolean outputAlternateId);
/**
* Retrieve module references for the given cm handle reference.
@@ -112,14 +70,7 @@ public class NetworkCmProxyInventoryFacade {
* @param cmHandleReference cm handle or alternate id identifier
* @return a collection of modules names and revisions
*/
- public Collection<ModuleReference> getYangResourcesModuleReferences(final String cmHandleReference) {
- try {
- final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
- return inventoryPersistence.getYangResourcesModuleReferences(cmHandleId);
- } catch (final CmHandleNotFoundException cmHandleNotFoundException) {
- return Collections.emptyList();
- }
- }
+ Collection<ModuleReference> getYangResourcesModuleReferences(final String cmHandleReference);
/**
* Retrieve module definitions for the given cm handle.
@@ -127,14 +78,7 @@ public class NetworkCmProxyInventoryFacade {
* @param cmHandleReference cm handle or alternate id identifier
* @return a collection of module definition (moduleName, revision and yang resource content)
*/
- public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleReference(final String cmHandleReference) {
- try {
- final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
- return inventoryPersistence.getModuleDefinitionsByCmHandleId(cmHandleId);
- } catch (final CmHandleNotFoundException cmHandleNotFoundException) {
- return Collections.emptyList();
- }
- }
+ Collection<ModuleDefinition> getModuleDefinitionsByCmHandleReference(final String cmHandleReference);
/**
* Get module definitions for the given parameters.
@@ -144,16 +88,9 @@ public class NetworkCmProxyInventoryFacade {
* @param moduleRevision the revision of the module
* @return list of module definitions (module name, revision, yang resource content)
*/
- public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleAndModule(final String cmHandleReference,
- final String moduleName,
- final String moduleRevision) {
- try {
- final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
- return inventoryPersistence.getModuleDefinitionsByCmHandleAndModule(cmHandleId, moduleName, moduleRevision);
- } catch (final CmHandleNotFoundException cmHandleNotFoundException) {
- return Collections.emptyList();
- }
- }
+ Collection<ModuleDefinition> getModuleDefinitionsByCmHandleAndModule(final String cmHandleReference,
+ final String moduleName,
+ final String moduleRevision);
/**
* Retrieve cm handles with details for the given query parameters.
@@ -161,16 +98,7 @@ public class NetworkCmProxyInventoryFacade {
* @param cmHandleQueryApiParameters cm handle query parameters
* @return cm handles with details
*/
- public Collection<NcmpServiceCmHandle> executeCmHandleSearch(
- final CmHandleQueryApiParameters cmHandleQueryApiParameters) {
- final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
- cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
- validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
- final Collection<NcmpServiceCmHandle> ncmpServiceCmHandles =
- parameterizedCmHandleQueryService.queryCmHandles(cmHandleQueryServiceParameters);
- trustLevelManager.applyEffectiveTrustLevels(ncmpServiceCmHandles);
- return ncmpServiceCmHandles;
- }
+ Collection<NcmpServiceCmHandle> executeCmHandleSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters);
/**
* Retrieve cm handle ids for the given query parameters.
@@ -179,14 +107,8 @@ public class NetworkCmProxyInventoryFacade {
* @param outputAlternateId boolean for cm handle reference type either cmHandleId (false) or AlternateId (true)
* @return cm handle ids
*/
- public Collection<String> executeCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters,
- final boolean outputAlternateId) {
- final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
- cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
- validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
- return parameterizedCmHandleQueryService.queryCmHandleReferenceIds(cmHandleQueryServiceParameters,
- outputAlternateId);
- }
+ Collection<String> executeCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters,
+ final boolean outputAlternateId);
/**
* Set the data sync enabled flag, along with the data sync state
@@ -195,9 +117,7 @@ public class NetworkCmProxyInventoryFacade {
* @param cmHandleId cm handle id
* @param dataSyncEnabledTargetValue data sync enabled flag
*/
- public void setDataSyncEnabled(final String cmHandleId, final Boolean dataSyncEnabledTargetValue) {
- cmHandleRegistrationService.setDataSyncEnabled(cmHandleId, dataSyncEnabledTargetValue);
- }
+ void setDataSyncEnabled(final String cmHandleId, final Boolean dataSyncEnabledTargetValue);
/**
* Retrieve cm handle details for a given cm handle reference.
@@ -205,13 +125,7 @@ public class NetworkCmProxyInventoryFacade {
* @param cmHandleReference cm handle or alternate identifier
* @return cm handle details
*/
- public NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleReference) {
- final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
- final NcmpServiceCmHandle ncmpServiceCmHandle = YangDataConverter.toNcmpServiceCmHandle(
- inventoryPersistence.getYangModelCmHandle(cmHandleId));
- trustLevelManager.applyEffectiveTrustLevel(ncmpServiceCmHandle);
- return ncmpServiceCmHandle;
- }
+ NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleReference);
/**
* Get cm handle public properties for a given cm handle or alternate id.
@@ -219,11 +133,7 @@ public class NetworkCmProxyInventoryFacade {
* @param cmHandleReference cm handle or alternate identifier
* @return cm handle public properties
*/
- public Map<String, String> getCmHandlePublicProperties(final String cmHandleReference) {
- final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
- final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
- return YangDataConverter.toPropertiesMap(yangModelCmHandle.getPublicProperties());
- }
+ Map<String, String> getCmHandlePublicProperties(final String cmHandleReference);
/**
* Get cm handle composite state for a given cm handle id.
@@ -231,9 +141,5 @@ public class NetworkCmProxyInventoryFacade {
* @param cmHandleReference cm handle or alternate identifier
* @return cm handle state
*/
- public CompositeState getCmHandleCompositeState(final String cmHandleReference) {
- final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
- return inventoryPersistence.getYangModelCmHandle(cmHandleId).getCompositeState();
- }
-
+ CompositeState getCmHandleCompositeState(final String cmHandleReference);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java
new file mode 100644
index 0000000000..118c2bba70
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/NetworkCmProxyInventoryFacadeImpl.java
@@ -0,0 +1,169 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 highstreet technologies GmbH
+ * Modifications Copyright (C) 2021-2024 Nordix Foundation
+ * Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2021-2022 Bell Canada
+ * Modifications Copyright (C) 2023 TechMahindra Ltd.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.impl;
+
+import static org.onap.cps.ncmp.impl.inventory.CmHandleQueryParametersValidator.validateCmHandleQueryParameters;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import lombok.RequiredArgsConstructor;
+import org.onap.cps.api.model.ModuleDefinition;
+import org.onap.cps.api.model.ModuleReference;
+import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException;
+import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade;
+import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryApiParameters;
+import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters;
+import org.onap.cps.ncmp.api.inventory.models.CompositeState;
+import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration;
+import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistrationResponse;
+import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle;
+import org.onap.cps.ncmp.impl.inventory.CmHandleQueryService;
+import org.onap.cps.ncmp.impl.inventory.CmHandleRegistrationService;
+import org.onap.cps.ncmp.impl.inventory.InventoryPersistence;
+import org.onap.cps.ncmp.impl.inventory.ParameterizedCmHandleQueryService;
+import org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions;
+import org.onap.cps.ncmp.impl.inventory.models.InventoryQueryConditions;
+import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
+import org.onap.cps.ncmp.impl.inventory.trustlevel.TrustLevelManager;
+import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher;
+import org.onap.cps.ncmp.impl.utils.YangDataConverter;
+import org.onap.cps.utils.JsonObjectMapper;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class NetworkCmProxyInventoryFacadeImpl implements NetworkCmProxyInventoryFacade {
+
+ private final CmHandleRegistrationService cmHandleRegistrationService;
+ private final CmHandleQueryService cmHandleQueryService;
+ private final ParameterizedCmHandleQueryService parameterizedCmHandleQueryService;
+ private final InventoryPersistence inventoryPersistence;
+ private final JsonObjectMapper jsonObjectMapper;
+ private final TrustLevelManager trustLevelManager;
+ private final AlternateIdMatcher alternateIdMatcher;
+
+ @Override
+ public DmiPluginRegistrationResponse updateDmiRegistration(final DmiPluginRegistration dmiPluginRegistration) {
+ return cmHandleRegistrationService.updateDmiRegistration(dmiPluginRegistration);
+ }
+
+ @Override
+ public Collection<String> getAllCmHandleReferencesByDmiPluginIdentifier(final String dmiPluginIdentifier,
+ final boolean outputAlternateId) {
+ return cmHandleQueryService.getCmHandleReferencesByDmiPluginIdentifier(dmiPluginIdentifier, outputAlternateId);
+ }
+
+ @Override
+ public Collection<String> executeParameterizedCmHandleIdSearch(
+ final CmHandleQueryServiceParameters cmHandleQueryServiceParameters, final boolean outputAlternateId) {
+ validateCmHandleQueryParameters(cmHandleQueryServiceParameters, InventoryQueryConditions.ALL_CONDITION_NAMES);
+
+ return parameterizedCmHandleQueryService.queryCmHandleIdsForInventory(cmHandleQueryServiceParameters,
+ outputAlternateId);
+ }
+
+ @Override
+ public Collection<ModuleReference> getYangResourcesModuleReferences(final String cmHandleReference) {
+ try {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
+ return inventoryPersistence.getYangResourcesModuleReferences(cmHandleId);
+ } catch (final CmHandleNotFoundException cmHandleNotFoundException) {
+ return Collections.emptyList();
+ }
+ }
+
+ @Override
+ public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleReference(final String cmHandleReference) {
+ try {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
+ return inventoryPersistence.getModuleDefinitionsByCmHandleId(cmHandleId);
+ } catch (final CmHandleNotFoundException cmHandleNotFoundException) {
+ return Collections.emptyList();
+ }
+ }
+
+ @Override
+ public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleAndModule(final String cmHandleReference,
+ final String moduleName,
+ final String moduleRevision) {
+ try {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
+ return inventoryPersistence.getModuleDefinitionsByCmHandleAndModule(cmHandleId, moduleName, moduleRevision);
+ } catch (final CmHandleNotFoundException cmHandleNotFoundException) {
+ return Collections.emptyList();
+ }
+ }
+
+ @Override
+ public Collection<NcmpServiceCmHandle> executeCmHandleSearch(
+ final CmHandleQueryApiParameters cmHandleQueryApiParameters) {
+ final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
+ cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
+ validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
+ final Collection<NcmpServiceCmHandle> ncmpServiceCmHandles =
+ parameterizedCmHandleQueryService.queryCmHandles(cmHandleQueryServiceParameters);
+ trustLevelManager.applyEffectiveTrustLevels(ncmpServiceCmHandles);
+ return ncmpServiceCmHandles;
+ }
+
+ @Override
+ public Collection<String> executeCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters,
+ final boolean outputAlternateId) {
+ final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
+ cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
+ validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
+ return parameterizedCmHandleQueryService.queryCmHandleReferenceIds(cmHandleQueryServiceParameters,
+ outputAlternateId);
+ }
+
+ @Override
+ public void setDataSyncEnabled(final String cmHandleId, final Boolean dataSyncEnabledTargetValue) {
+ cmHandleRegistrationService.setDataSyncEnabled(cmHandleId, dataSyncEnabledTargetValue);
+ }
+
+ @Override
+ public NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleReference) {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
+ final NcmpServiceCmHandle ncmpServiceCmHandle = YangDataConverter.toNcmpServiceCmHandle(
+ inventoryPersistence.getYangModelCmHandle(cmHandleId));
+ trustLevelManager.applyEffectiveTrustLevel(ncmpServiceCmHandle);
+ return ncmpServiceCmHandle;
+ }
+
+ @Override
+ public Map<String, String> getCmHandlePublicProperties(final String cmHandleReference) {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
+ final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
+ return YangDataConverter.toPropertiesMap(yangModelCmHandle.getPublicProperties());
+ }
+
+ @Override
+ public CompositeState getCmHandleCompositeState(final String cmHandleReference) {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
+ return inventoryPersistence.getYangModelCmHandle(cmHandleId).getCompositeState();
+ }
+
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
index ae2554762f..c62a87f5c3 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
@@ -24,7 +24,7 @@
package org.onap.cps.ncmp.impl.inventory
import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.api.model.ConditionProperties
import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryApiParameters
import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters
import org.onap.cps.ncmp.api.inventory.models.CompositeState
@@ -32,12 +32,12 @@ import org.onap.cps.ncmp.api.inventory.models.ConditionApiProperties
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
import org.onap.cps.ncmp.api.inventory.models.TrustLevel
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.impl.inventory.models.CmHandleState
import org.onap.cps.ncmp.impl.inventory.models.LockReasonCategory
import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
import org.onap.cps.ncmp.impl.inventory.trustlevel.TrustLevelManager
import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher
-import org.onap.cps.api.model.ConditionProperties
import org.onap.cps.utils.JsonObjectMapper
import spock.lang.Specification
@@ -50,7 +50,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
def mockInventoryPersistence = Mock(InventoryPersistence)
def mockTrustLevelManager = Mock(TrustLevelManager)
def mockAlternateIdMatcher = Mock(AlternateIdMatcher)
- def objectUnderTest = new NetworkCmProxyInventoryFacade(mockCmHandleRegistrationService, mockCmHandleQueryService, mockParameterizedCmHandleQueryService, mockInventoryPersistence, spiedJsonObjectMapper, mockTrustLevelManager, mockAlternateIdMatcher)
+ def objectUnderTest = new NetworkCmProxyInventoryFacadeImpl(mockCmHandleRegistrationService, mockCmHandleQueryService, mockParameterizedCmHandleQueryService, mockInventoryPersistence, spiedJsonObjectMapper, mockTrustLevelManager, mockAlternateIdMatcher)
def 'Update DMI Registration'() {
given: 'an (updated) dmi plugin registration'
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
index 0725fe82d0..9fc36331e2 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
@@ -30,7 +30,7 @@ import org.onap.cps.api.CpsModuleService
import org.onap.cps.api.CpsQueryService
import org.onap.cps.integration.DatabaseTestContainer
import org.onap.cps.integration.KafkaTestContainer
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
import org.onap.cps.ncmp.impl.data.NetworkCmProxyFacade
@@ -108,7 +108,7 @@ abstract class CpsIntegrationSpecBase extends Specification {
NetworkCmProxyFacade networkCmProxyFacade
@Autowired
- NetworkCmProxyInventoryFacade NetworkCmProxyInventoryFacade
+ NetworkCmProxyInventoryFacadeImpl NetworkCmProxyInventoryFacade
@Autowired
NetworkCmProxyQueryService networkCmProxyQueryService
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy
index ffcba025e8..e9fac48676 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy
@@ -25,7 +25,7 @@ import org.apache.kafka.common.serialization.StringDeserializer
import org.onap.cps.integration.KafkaTestContainer
import org.onap.cps.integration.base.CpsIntegrationSpecBase
import org.onap.cps.ncmp.api.NcmpResponseStatus
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.api.inventory.models.CmHandleRegistrationResponse
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
@@ -38,7 +38,7 @@ import java.time.Duration
class CmHandleCreateSpec extends CpsIntegrationSpecBase {
- NetworkCmProxyInventoryFacade objectUnderTest
+ NetworkCmProxyInventoryFacadeImpl objectUnderTest
def uniqueId = 'ch-unique-id-for-create-test'
static KafkaConsumer kafkaConsumer
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy
index 67011f811b..f2593ce587 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy
@@ -22,14 +22,14 @@ package org.onap.cps.integration.functional.ncmp
import org.onap.cps.integration.base.CpsIntegrationSpecBase
import org.onap.cps.ncmp.api.NcmpResponseStatus
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.api.inventory.models.CmHandleRegistrationResponse
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
class CmHandleUpdateSpec extends CpsIntegrationSpecBase {
- NetworkCmProxyInventoryFacade objectUnderTest
+ NetworkCmProxyInventoryFacadeImpl objectUnderTest
def setup() {
objectUnderTest = networkCmProxyInventoryFacade
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy
index a5e3daf289..5ce5658c1b 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy
@@ -21,7 +21,7 @@
package org.onap.cps.integration.functional.ncmp
import org.onap.cps.integration.base.CpsIntegrationSpecBase
-import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
+import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import org.onap.cps.ncmp.api.inventory.models.CmHandleRegistrationResponse
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.inventory.models.UpgradedCmHandles
@@ -31,7 +31,7 @@ import spock.util.concurrent.PollingConditions
class CmHandleUpgradeSpec extends CpsIntegrationSpecBase {
- NetworkCmProxyInventoryFacade objectUnderTest
+ NetworkCmProxyInventoryFacadeImpl objectUnderTest
def cmHandleId = 'ch-1'
def cmHandleIdWithExistingModuleSetTag = 'ch-2'