2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2022 Nordix Foundation
4 * Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * 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.api.impl;
24 import io.micrometer.core.annotation.Timed;
25 import java.util.Collection;
26 import lombok.RequiredArgsConstructor;
27 import org.onap.cps.api.CpsQueryService;
28 import org.onap.cps.spi.CpsDataPersistenceService;
29 import org.onap.cps.spi.FetchDescendantsOption;
30 import org.onap.cps.spi.model.DataNode;
31 import org.onap.cps.spi.utils.CpsValidator;
32 import org.springframework.stereotype.Service;
35 @RequiredArgsConstructor
36 public class CpsQueryServiceImpl implements CpsQueryService {
38 private final CpsDataPersistenceService cpsDataPersistenceService;
39 private final CpsValidator cpsValidator;
42 @Timed(value = "cps.data.service.datanode.query",
43 description = "Time taken to query data nodes")
44 public Collection<DataNode> queryDataNodes(final String dataspaceName, final String anchorName,
45 final String cpsPath, final FetchDescendantsOption fetchDescendantsOption) {
46 cpsValidator.validateNameCharacters(dataspaceName, anchorName);
47 return cpsDataPersistenceService.queryDataNodes(dataspaceName, anchorName, cpsPath, fetchDescendantsOption);
51 public Collection<DataNode> queryDataNodesAcrossAnchors(final String dataspaceName,
52 final String cpsPath, final FetchDescendantsOption fetchDescendantsOption) {
53 cpsValidator.validateNameCharacters(dataspaceName);
54 return cpsDataPersistenceService.queryDataNodesAcrossAnchors(dataspaceName, cpsPath, fetchDescendantsOption);