2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 highstreet technologies GmbH
4 * 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
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.cps.ncmp.api.impl;
24 import java.util.Collection;
25 import org.onap.cps.api.CpsDataService;
26 import org.onap.cps.api.CpsQueryService;
27 import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
28 import org.onap.cps.spi.FetchDescendantsOption;
29 import org.onap.cps.spi.model.DataNode;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Service;
32 import org.springframework.util.StringUtils;
35 public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService {
37 private static final String NF_PROXY_DATASPACE_NAME = "NFP-Operational";
40 private CpsDataService cpsDataService;
43 private CpsQueryService cpsQueryService;
45 private String getDataspaceName() {
46 return NF_PROXY_DATASPACE_NAME;
50 public DataNode getDataNode(final String cmHandle, final String xpath,
51 final FetchDescendantsOption fetchDescendantsOption) {
52 return cpsDataService.getDataNode(getDataspaceName(), cmHandle, xpath, fetchDescendantsOption);
56 public Collection<DataNode> queryDataNodes(final String cmHandle, final String cpsPath,
57 final FetchDescendantsOption fetchDescendantsOption) {
58 return cpsQueryService.queryDataNodes(getDataspaceName(), cmHandle, cpsPath, fetchDescendantsOption);
62 public void createDataNode(final String cmHandle, final String parentNodeXpath, final String jsonData) {
63 if (StringUtils.isEmpty(parentNodeXpath) || "/".equals(parentNodeXpath)) {
64 cpsDataService.saveData(getDataspaceName(), cmHandle, jsonData);
66 cpsDataService.saveData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
71 public void addListNodeElements(final String cmHandle, final String parentNodeXpath, final String jsonData) {
72 cpsDataService.saveListNodeData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
76 public void updateNodeLeaves(final String cmHandle, final String parentNodeXpath, final String jsonData) {
77 cpsDataService.updateNodeLeaves(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
81 public void replaceNodeTree(final String cmHandle, final String parentNodeXpath, final String jsonData) {
82 cpsDataService.replaceNodeTree(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);