2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 highstreet technologies GmbH
4 * Modifications Copyright (C) 2021 Nordix Foundation
5 * Modifications Copyright (C) 2021 Pantheon.tech
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.cps.ncmp.api.impl;
25 import java.util.Collection;
26 import org.onap.cps.api.CpsDataService;
27 import org.onap.cps.api.CpsQueryService;
28 import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
29 import org.onap.cps.spi.FetchDescendantsOption;
30 import org.onap.cps.spi.model.DataNode;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Service;
33 import org.springframework.util.StringUtils;
36 public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService {
38 private static final String NF_PROXY_DATASPACE_NAME = "NFP-Operational";
41 private CpsDataService cpsDataService;
44 private CpsQueryService cpsQueryService;
46 private String getDataspaceName() {
47 return NF_PROXY_DATASPACE_NAME;
51 public DataNode getDataNode(final String cmHandle, final String xpath,
52 final FetchDescendantsOption fetchDescendantsOption) {
53 return cpsDataService.getDataNode(getDataspaceName(), cmHandle, xpath, fetchDescendantsOption);
57 public Collection<DataNode> queryDataNodes(final String cmHandle, final String cpsPath,
58 final FetchDescendantsOption fetchDescendantsOption) {
59 return cpsQueryService.queryDataNodes(getDataspaceName(), cmHandle, cpsPath, fetchDescendantsOption);
63 public void createDataNode(final String cmHandle, final String parentNodeXpath, final String jsonData) {
64 if (!StringUtils.hasText(parentNodeXpath) || "/".equals(parentNodeXpath)) {
65 cpsDataService.saveData(getDataspaceName(), cmHandle, jsonData);
67 cpsDataService.saveData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
72 public void addListNodeElements(final String cmHandle, final String parentNodeXpath, final String jsonData) {
73 cpsDataService.saveListNodeData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
77 public void updateNodeLeaves(final String cmHandle, final String parentNodeXpath, final String jsonData) {
78 cpsDataService.updateNodeLeaves(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
82 public void replaceNodeTree(final String cmHandle, final String parentNodeXpath, final String jsonData) {
83 cpsDataService.replaceNodeTree(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);