diff options
author | JosephKeenan <joseph.keenan@est.tech> | 2022-03-28 12:26:07 +0100 |
---|---|---|
committer | JosephKeenan <joseph.keenan@est.tech> | 2022-04-06 15:50:08 +0100 |
commit | deac4777c1a245be1dc4c423658523b41071b110 (patch) | |
tree | 6dea5a08ae885840fbc4aff566f74f815a8444bf /cps-ncmp-service/src | |
parent | ea01d09861289ff162dff318713d1c24eba89259 (diff) |
Query based on Public CM Properties
-Updated OpenAPI for new Endpoint
-Will replace SQL with CPSPathQuery once investigation is complete
-Functionality in place to determine if public properties match -
-Added Unit and CSIT tests - small modifications may need to be made
-CSIT tests enhanced to add additional nodes and tests
Issue-ID: CPS-731
Change-Id: I403e603ce79c4a4a6994d51b459b5703510d5a83
Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
Diffstat (limited to 'cps-ncmp-service/src')
3 files changed, 67 insertions, 0 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 cbd0756c09..058c42b7b9 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 @@ -26,6 +26,8 @@ package org.onap.cps.ncmp.api; import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum; import java.util.Collection; +import java.util.Set; +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; @@ -119,4 +121,11 @@ public interface NetworkCmProxyDataService { */ NcmpServiceCmHandle getNcmpServiceCmHandle(String cmHandleId); + /** + * Query and return cm handles that match the given query parameters. + * + * @param cmHandleQueryApiParameters the cm handle query parameters + * @return collection of cm handle ids + */ + Set<String> queryCmHandles(CmHandleQueryApiParameters cmHandleQueryApiParameters); } 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 696bb0a37c..9c3d9448ef 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 @@ -31,12 +31,14 @@ import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NO_TIMES import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum; import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED; +import com.google.common.base.Strings; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -50,6 +52,7 @@ import org.onap.cps.ncmp.api.impl.operations.DmiModelOperations; import org.onap.cps.ncmp.api.impl.operations.DmiOperations; import org.onap.cps.ncmp.api.impl.operations.YangModelCmHandleRetriever; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; +import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters; import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse; import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError; import org.onap.cps.ncmp.api.models.DmiPluginRegistration; @@ -157,6 +160,20 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService return cpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNames); } + @Override + public Set<String> queryCmHandles(final CmHandleQueryApiParameters cmHandleQueryApiParameters) { + + cmHandleQueryApiParameters.getPublicProperties().forEach((key, value) -> { + if (Strings.isNullOrEmpty(key)) { + throw new DataValidationException("Invalid Query Parameter.", + "Missing property name - please supply a valid name."); + } + }); + + return cpsAdminService.queryCmHandles(jsonObjectMapper.convertToValueType(cmHandleQueryApiParameters, + org.onap.cps.spi.model.CmHandleQueryParameters.class)); + } + /** * Retrieve cm handle details for a given cm handle. * diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleQueryApiParameters.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleQueryApiParameters.java new file mode 100644 index 0000000000..3f584ed153 --- /dev/null +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleQueryApiParameters.java @@ -0,0 +1,41 @@ +/* + * ============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.models; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collections; +import java.util.Map; +import javax.validation.Valid; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +@JsonInclude(Include.NON_NULL) +public class CmHandleQueryApiParameters { + + @JsonProperty("publicCmHandleProperties") + @Valid + private Map<String, String> publicProperties = Collections.emptyMap(); + +} |