summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2022-09-02 12:00:13 +0000
committerGerrit Code Review <gerrit@onap.org>2022-09-02 12:00:13 +0000
commit3c29b33cb1f9398106921e5d9510c62c34cc7694 (patch)
treebe5ff4746518584bb76e3105b2d233915bcc7115 /cps-ncmp-service
parent99ac70ab25a0c650e7f1ded19fd48296adff7f73 (diff)
parentbbaf501627a69707bd797c535750996a9dd205aa (diff)
Merge "Implement merging all ncmp datastore endpoints into one"
Diffstat (limited to 'cps-ncmp-service')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java13
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java56
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/exception/InvalidTopicException.java40
3 files changed, 46 insertions, 63 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index 45dba211a..0ea067428 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -33,6 +33,7 @@ import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
+import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.spi.model.ModuleReference;
@@ -67,6 +68,18 @@ public interface NetworkCmProxyDataService {
String requestId);
/**
+ * Get resource data for operational.
+ *
+ * @param cmHandleId cm handle identifier
+ * @param resourceIdentifier resource identifier
+ * @Link FetchDescendantsOption fetch descendants option
+ * @return {@code Object} resource data
+ */
+ Object getResourceDataOperational(String cmHandleId,
+ String resourceIdentifier,
+ FetchDescendantsOption fetchDescendantsOption);
+
+ /**
* Get resource data for data store pass-through running
* using dmi.
*
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 5b072f35e..c21c74bfb 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -23,6 +23,7 @@
package org.onap.cps.ncmp.api.impl;
+import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME;
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum;
import static org.onap.cps.utils.CmHandleQueryRestParametersValidator.validateCmHandleQueryParameters;
@@ -57,6 +58,7 @@ import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationErr
import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
+import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
@@ -116,24 +118,32 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
final String topicParamInQuery,
final String requestId) {
final ResponseEntity<?> responseEntity = dmiDataOperations.getResourceDataFromDmi(cmHandleId,
- resourceIdentifier,
- optionsParamInQuery,
- DmiOperations.DataStoreEnum.PASSTHROUGH_OPERATIONAL,
- requestId, topicParamInQuery);
+ resourceIdentifier,
+ optionsParamInQuery,
+ DmiOperations.DataStoreEnum.PASSTHROUGH_OPERATIONAL,
+ requestId, topicParamInQuery);
return responseEntity.getBody();
}
@Override
+ public Object getResourceDataOperational(final String cmHandleId,
+ final String resourceIdentifier,
+ final FetchDescendantsOption fetchDescendantsOption) {
+ return cpsDataService.getDataNode(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, resourceIdentifier,
+ fetchDescendantsOption);
+ }
+
+ @Override
public Object getResourceDataPassThroughRunningForCmHandle(final String cmHandleId,
final String resourceIdentifier,
final String optionsParamInQuery,
final String topicParamInQuery,
final String requestId) {
final ResponseEntity<?> responseEntity = dmiDataOperations.getResourceDataFromDmi(cmHandleId,
- resourceIdentifier,
- optionsParamInQuery,
- DmiOperations.DataStoreEnum.PASSTHROUGH_RUNNING,
- requestId, topicParamInQuery);
+ resourceIdentifier,
+ optionsParamInQuery,
+ DmiOperations.DataStoreEnum.PASSTHROUGH_RUNNING,
+ requestId, topicParamInQuery);
return responseEntity.getBody();
}
@@ -145,7 +155,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
final String dataType) {
CpsValidator.validateNameCharacters(cmHandleId);
return dmiDataOperations.writeResourceDataPassThroughRunningFromDmi(cmHandleId, resourceIdentifier, operation,
- requestData, dataType);
+ requestData, dataType);
}
@Override
@@ -196,29 +206,29 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
* Set the data sync enabled flag, along with the data sync state
* based on the data sync enabled boolean for the cm handle id provided.
*
- * @param cmHandleId cm handle id
+ * @param cmHandleId cm handle id
* @param dataSyncEnabled data sync enabled flag
*/
@Override
public void setDataSyncEnabled(final String cmHandleId, final boolean dataSyncEnabled) {
CpsValidator.validateNameCharacters(cmHandleId);
final CompositeState compositeState = inventoryPersistence
- .getCmHandleState(cmHandleId);
+ .getCmHandleState(cmHandleId);
if (compositeState.getDataSyncEnabled().equals(dataSyncEnabled)) {
log.info("Data-Sync Enabled flag is already: {} ", dataSyncEnabled);
} else if (compositeState.getCmHandleState() != CmHandleState.READY) {
throw new CpsException("State mismatch exception.", "Cm-Handle not in READY state. Cm handle state is: "
- + compositeState.getCmHandleState());
+ + compositeState.getCmHandleState());
} else {
final DataStoreSyncState dataStoreSyncState = compositeState.getDataStores()
- .getOperationalDataStore().getDataStoreSyncState();
+ .getOperationalDataStore().getDataStoreSyncState();
if (!dataSyncEnabled && dataStoreSyncState == DataStoreSyncState.SYNCHRONIZED) {
- cpsDataService.deleteDataNode("NFP-Operational", cmHandleId,
- "/netconf-state", OffsetDateTime.now());
+ cpsDataService.deleteDataNode(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId,
+ "/netconf-state", OffsetDateTime.now());
}
CompositeStateUtils.setDataSyncEnabledFlagWithDataSyncState(dataSyncEnabled, compositeState);
inventoryPersistence.saveCmHandleState(cmHandleId,
- compositeState);
+ compositeState);
}
}
@@ -262,7 +272,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
public Map<String, String> getCmHandlePublicProperties(final String cmHandleId) {
CpsValidator.validateNameCharacters(cmHandleId);
final YangModelCmHandle yangModelCmHandle =
- inventoryPersistence.getYangModelCmHandle(cmHandleId);
+ inventoryPersistence.getYangModelCmHandle(cmHandleId);
final List<YangModelCmHandle.Property> yangModelPublicProperties = yangModelCmHandle.getPublicProperties();
final Map<String, String> cmHandlePublicProperties = new HashMap<>();
YangDataConverter.asPropertiesMap(yangModelPublicProperties, cmHandlePublicProperties);
@@ -292,12 +302,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>();
try {
cmHandleRegistrationResponses = dmiPluginRegistration.getCreatedCmHandles().stream()
- .map(cmHandle ->
- YangModelCmHandle.toYangModelCmHandle(
- dmiPluginRegistration.getDmiPlugin(),
- dmiPluginRegistration.getDmiDataPlugin(),
- dmiPluginRegistration.getDmiModelPlugin(),
- cmHandle)).map(this::registerNewCmHandle).collect(Collectors.toList());
+ .map(cmHandle ->
+ YangModelCmHandle.toYangModelCmHandle(
+ dmiPluginRegistration.getDmiPlugin(),
+ dmiPluginRegistration.getDmiDataPlugin(),
+ dmiPluginRegistration.getDmiModelPlugin(),
+ cmHandle)).map(this::registerNewCmHandle).collect(Collectors.toList());
} catch (final DataValidationException dataValidationException) {
cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createFailureResponse(dmiPluginRegistration
.getCreatedCmHandles().stream()
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/exception/InvalidTopicException.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/exception/InvalidTopicException.java
deleted file mode 100644
index b56ca7b8c..000000000
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/exception/InvalidTopicException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation
- * ================================================================================
- * 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.api.impl.exception;
-
-import lombok.Getter;
-
-public class InvalidTopicException extends RuntimeException {
-
- @Getter
- final String details;
-
- /**
- * Constructor.
- *
- * @param message the error message
- * @param details the error details
- */
- public InvalidTopicException(final String message, final String details) {
- super(message);
- this.details = details;
- }
-}