aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java208
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryApiParameters.java43
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryServiceParameters.java42
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleRegistrationResponse.java147
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeState.java147
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeStateBuilder.java157
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/ConditionApiProperties.java44
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistration.java89
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistrationResponse.java36
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java65
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/UpgradedCmHandles.java36
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/YangResource.java34
12 files changed, 1048 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
new file mode 100644
index 000000000..0ff59c131
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
@@ -0,0 +1,208 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 highstreet technologies GmbH
+ * Modifications Copyright (C) 2021-2024 Nordix Foundation
+ * Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2021-2022 Bell Canada
+ * Modifications Copyright (C) 2023 TechMahindra Ltd.
+ * ================================================================================
+ * 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.inventory;
+
+import static org.onap.cps.ncmp.impl.inventory.CmHandleQueryParametersValidator.validateCmHandleQueryParameters;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryApiParameters;
+import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters;
+import org.onap.cps.ncmp.api.inventory.models.CompositeState;
+import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration;
+import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistrationResponse;
+import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle;
+import org.onap.cps.ncmp.impl.inventory.CmHandleQueryService;
+import org.onap.cps.ncmp.impl.inventory.CmHandleRegistrationService;
+import org.onap.cps.ncmp.impl.inventory.InventoryPersistence;
+import org.onap.cps.ncmp.impl.inventory.ParameterizedCmHandleQueryService;
+import org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions;
+import org.onap.cps.ncmp.impl.inventory.models.InventoryQueryConditions;
+import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
+import org.onap.cps.ncmp.impl.utils.YangDataConverter;
+import org.onap.cps.spi.model.ModuleDefinition;
+import org.onap.cps.spi.model.ModuleReference;
+import org.onap.cps.utils.JsonObjectMapper;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class NetworkCmProxyInventoryFacade {
+
+ private final CmHandleRegistrationService cmHandleRegistrationService;
+ private final CmHandleQueryService cmHandleQueryService;
+ private final ParameterizedCmHandleQueryService parameterizedCmHandleQueryService;
+ private final InventoryPersistence inventoryPersistence;
+ private final JsonObjectMapper jsonObjectMapper;
+
+ /**
+ * Registration of Created, Removed, Updated or Upgraded CM Handles.
+ *
+ * @param dmiPluginRegistration Dmi Plugin Registration details
+ * @return dmiPluginRegistrationResponse
+ */
+
+ public DmiPluginRegistrationResponse updateDmiRegistrationAndSyncModule(
+ final DmiPluginRegistration dmiPluginRegistration) {
+ return cmHandleRegistrationService.updateDmiRegistrationAndSyncModule(dmiPluginRegistration);
+ }
+
+ /**
+ * Get all cm handle IDs by DMI plugin identifier.
+ *
+ * @param dmiPluginIdentifier DMI plugin identifier
+ * @return collection of cm handle IDs
+ */
+ public Collection<String> getAllCmHandleIdsByDmiPluginIdentifier(final String dmiPluginIdentifier) {
+ return cmHandleQueryService.getCmHandleIdsByDmiPluginIdentifier(dmiPluginIdentifier);
+ }
+
+ /**
+ * Get all cm handle IDs by various properties.
+ *
+ * @param cmHandleQueryServiceParameters cm handle query parameters
+ * @return collection of cm handle IDs
+ */
+ public Collection<String> executeParameterizedCmHandleIdSearch(
+ final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) {
+ validateCmHandleQueryParameters(cmHandleQueryServiceParameters, InventoryQueryConditions.ALL_CONDITION_NAMES);
+ return parameterizedCmHandleQueryService.queryCmHandleIdsForInventory(cmHandleQueryServiceParameters);
+ }
+
+
+ /**
+ * Retrieve module references for the given cm handle.
+ *
+ * @param cmHandleId cm handle identifier
+ * @return a collection of modules names and revisions
+ */
+ public Collection<ModuleReference> getYangResourcesModuleReferences(final String cmHandleId) {
+ return inventoryPersistence.getYangResourcesModuleReferences(cmHandleId);
+ }
+
+ /**
+ * Retrieve module definitions for the given cm handle.
+ *
+ * @param cmHandleId cm handle identifier
+ * @return a collection of module definition (moduleName, revision and yang resource content)
+ */
+ public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(final String cmHandleId) {
+ return inventoryPersistence.getModuleDefinitionsByCmHandleId(cmHandleId);
+ }
+
+ /**
+ * Get module definitions for the given parameters.
+ *
+ * @param cmHandleId cm-handle identifier
+ * @param moduleName module name
+ * @param moduleRevision the revision of the module
+ * @return list of module definitions (module name, revision, yang resource content)
+ */
+ public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleAndModule(final String cmHandleId,
+ final String moduleName,
+ final String moduleRevision) {
+ return inventoryPersistence.getModuleDefinitionsByCmHandleAndModule(cmHandleId, moduleName, moduleRevision);
+ }
+
+ /**
+ * Retrieve cm handles with details for the given query parameters.
+ *
+ * @param cmHandleQueryApiParameters cm handle query parameters
+ * @return cm handles with details
+ */
+ public Collection<NcmpServiceCmHandle> executeCmHandleSearch(
+ final CmHandleQueryApiParameters cmHandleQueryApiParameters) {
+ final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
+ cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
+ validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
+ return parameterizedCmHandleQueryService.queryCmHandles(cmHandleQueryServiceParameters);
+ }
+
+ /**
+ * Retrieve cm handle ids for the given query parameters.
+ *
+ * @param cmHandleQueryApiParameters cm handle query parameters
+ * @return cm handle ids
+ */
+ public Collection<String> executeCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters) {
+ final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
+ cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
+ validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
+ return parameterizedCmHandleQueryService.queryCmHandleIds(cmHandleQueryServiceParameters);
+ }
+
+ /**
+ * 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 dataSyncEnabledTargetValue data sync enabled flag
+ */
+ public void setDataSyncEnabled(final String cmHandleId, final Boolean dataSyncEnabledTargetValue) {
+ cmHandleRegistrationService.setDataSyncEnabled(cmHandleId, dataSyncEnabledTargetValue);
+ }
+
+ /**
+ * Retrieve cm handle details for a given cm handle.
+ *
+ * @param cmHandleId cm handle identifier
+ * @return cm handle details
+ */
+ public NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleId) {
+ return YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(
+ inventoryPersistence.getYangModelCmHandle(cmHandleId));
+ }
+
+ /**
+ * Get cm handle public properties for a given cm handle id.
+ *
+ * @param cmHandleId cm handle identifier
+ * @return cm handle public properties
+ */
+ public Map<String, String> getCmHandlePublicProperties(final String cmHandleId) {
+ final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
+ final List<YangModelCmHandle.Property> yangModelPublicProperties = yangModelCmHandle.getPublicProperties();
+ final Map<String, String> cmHandlePublicProperties = new HashMap<>();
+ YangDataConverter.asPropertiesMap(yangModelPublicProperties, cmHandlePublicProperties);
+ return cmHandlePublicProperties;
+ }
+
+ /**
+ * Get cm handle composite state for a given cm handle id.
+ *
+ * @param cmHandleId cm handle identifier
+ * @return cm handle state
+ */
+ public CompositeState getCmHandleCompositeState(final String cmHandleId) {
+ return inventoryPersistence.getYangModelCmHandle(cmHandleId).getCompositeState();
+ }
+
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryApiParameters.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryApiParameters.java
new file mode 100644
index 000000000..596fb94a3
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryApiParameters.java
@@ -0,0 +1,43 @@
+/*
+ * ============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.inventory.models;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.Valid;
+import java.util.Collections;
+import java.util.List;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+@EqualsAndHashCode
+@JsonInclude(Include.NON_EMPTY)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CmHandleQueryApiParameters {
+ @JsonProperty("cmHandleQueryParameters")
+ @Valid
+ private List<ConditionApiProperties> cmHandleQueryParameters = Collections.emptyList();
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryServiceParameters.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryServiceParameters.java
new file mode 100644
index 000000000..13915918e
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleQueryServiceParameters.java
@@ -0,0 +1,42 @@
+/*
+ * ============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.inventory.models;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.Valid;
+import java.util.Collections;
+import java.util.List;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.cps.spi.model.ConditionProperties;
+
+@Setter
+@Getter
+@EqualsAndHashCode
+@JsonInclude(Include.NON_EMPTY)
+public class CmHandleQueryServiceParameters {
+ @JsonProperty("cmHandleQueryParameters")
+ @Valid
+ private List<ConditionProperties> cmHandleQueryParameters = Collections.emptyList();
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleRegistrationResponse.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleRegistrationResponse.java
new file mode 100644
index 000000000..7523f77af
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleRegistrationResponse.java
@@ -0,0 +1,147 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Bell Canada
+ * Modifications Copyright (C) 2022-2024 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.inventory.models;
+
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNKNOWN_ERROR;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+import lombok.Builder;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.cps.ncmp.api.NcmpResponseStatus;
+import org.onap.cps.ncmp.impl.utils.YangDataConverter;
+
+@Data
+@Builder
+@Slf4j
+public class CmHandleRegistrationResponse {
+
+ private final String cmHandle;
+ private final Status status;
+ private NcmpResponseStatus ncmpResponseStatus;
+ private String errorText;
+
+ /**
+ * Creates a failure response based on exception.
+ *
+ * @param cmHandleId cmHandleId
+ * @param exception exception
+ * @return CmHandleRegistrationResponse
+ */
+ public static CmHandleRegistrationResponse createFailureResponse(final String cmHandleId,
+ final Exception exception) {
+ return CmHandleRegistrationResponse.builder()
+ .cmHandle(cmHandleId)
+ .status(Status.FAILURE)
+ .ncmpResponseStatus(UNKNOWN_ERROR)
+ .errorText(exception.getMessage()).build();
+ }
+
+ /**
+ * Creates a failure response based on registration error.
+ *
+ * @param cmHandleId cmHandleId
+ * @param ncmpResponseStatus registration error code and status
+ * @return CmHandleRegistrationResponse
+ */
+ public static CmHandleRegistrationResponse createFailureResponse(final String cmHandleId,
+ final NcmpResponseStatus ncmpResponseStatus) {
+ return CmHandleRegistrationResponse.builder().cmHandle(cmHandleId)
+ .status(Status.FAILURE)
+ .ncmpResponseStatus(ncmpResponseStatus)
+ .errorText(ncmpResponseStatus.getMessage())
+ .build();
+ }
+
+ /**
+ * Create a failure response of cm handle registration based on xpath and registration error.
+ * Conditions:
+ * - the xpath should be valid according to the cps path, otherwise xpath is not included in the response.
+ *
+ * @param failedXpaths the failed xpaths
+ * @param ncmpResponseStatus type of the registration error
+ * @return collection of cm handle registration response
+ */
+ public static List<CmHandleRegistrationResponse> createFailureResponsesFromXpaths(
+ final Collection<String> failedXpaths, final NcmpResponseStatus ncmpResponseStatus) {
+ final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>(failedXpaths.size());
+ for (final String xpath : failedXpaths) {
+ try {
+ final String cmHandleId = YangDataConverter.extractCmHandleIdFromXpath(xpath);
+ cmHandleRegistrationResponses
+ .add(CmHandleRegistrationResponse.createFailureResponse(cmHandleId, ncmpResponseStatus));
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ log.warn("Unexpected xpath {}", xpath);
+ }
+ }
+ return cmHandleRegistrationResponses;
+ }
+
+ /**
+ * Create a failure response of cm handle registration based on cm handle id and registration error.
+ *
+ * @param failedCmHandleIds the failed cm handle ids
+ * @param ncmpResponseStatus type of the registration error
+ * @return collection of cm handle registration response
+ */
+ public static List<CmHandleRegistrationResponse> createFailureResponses(
+ final Collection<String> failedCmHandleIds, final NcmpResponseStatus ncmpResponseStatus) {
+ final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses =
+ new ArrayList<>(failedCmHandleIds.size());
+ for (final String failedCmHandleId : failedCmHandleIds) {
+ cmHandleRegistrationResponses.add(
+ CmHandleRegistrationResponse.createFailureResponse(failedCmHandleId, ncmpResponseStatus));
+ }
+ return cmHandleRegistrationResponses;
+ }
+
+ /**
+ * Creates a failure response based on other exception.
+ *
+ * @param cmHandleIds list of failed cmHandleIds
+ * @param exception exception caught during the registration
+ * @return CmHandleRegistrationResponse
+ */
+ public static List<CmHandleRegistrationResponse> createFailureResponses(final Collection<String> cmHandleIds,
+ final Exception exception) {
+ return cmHandleIds.stream()
+ .map(cmHandleId -> CmHandleRegistrationResponse.createFailureResponse(cmHandleId, exception))
+ .toList();
+ }
+
+ public static CmHandleRegistrationResponse createSuccessResponse(final String cmHandle) {
+ return CmHandleRegistrationResponse.builder().cmHandle(cmHandle)
+ .status(Status.SUCCESS).build();
+ }
+
+ public static List<CmHandleRegistrationResponse> createSuccessResponses(final Collection<String> cmHandleIds) {
+ return cmHandleIds.stream().map(CmHandleRegistrationResponse::createSuccessResponse)
+ .collect(Collectors.toList());
+ }
+
+ public enum Status {
+ SUCCESS, FAILURE;
+ }
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeState.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeState.java
new file mode 100644
index 000000000..ca4fde2b6
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeState.java
@@ -0,0 +1,147 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022-2023 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.inventory.models;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+import lombok.Builder;
+import lombok.Data;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.cps.ncmp.impl.inventory.DataStoreSyncState;
+import org.onap.cps.ncmp.impl.inventory.models.CmHandleState;
+import org.onap.cps.ncmp.impl.inventory.models.LockReasonCategory;
+
+/**
+ * State Model to store state corresponding to the Yang resource dmi-registry model.
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CompositeState {
+
+ @JsonProperty("cm-handle-state")
+ private CmHandleState cmHandleState;
+
+ @JsonProperty("lock-reason")
+ private LockReason lockReason;
+
+ @JsonProperty("last-update-time")
+ private String lastUpdateTime;
+
+ @JsonProperty("data-sync-enabled")
+ private Boolean dataSyncEnabled;
+
+ @JsonProperty("datastores")
+ private DataStores dataStores;
+
+ /**
+ * Date and Time in the format of yyyy-MM-dd'T'HH:mm:ss.SSSZ
+ */
+ private static final DateTimeFormatter dateTimeFormatter =
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+
+ /**
+ * Composite State copy constructor.
+ *
+ * @param compositeState Composite State
+ */
+ public CompositeState(final CompositeState compositeState) {
+ this.cmHandleState = compositeState.getCmHandleState();
+ this.lockReason = compositeState.getLockReason();
+ this.lastUpdateTime = compositeState.getLastUpdateTime();
+ this.dataSyncEnabled = compositeState.getDataSyncEnabled();
+ this.dataStores = compositeState.getDataStores();
+ }
+
+
+ /**
+ * This will specify the latest lock reason for a specific cm handle. If a cm handle is in a state other than LOCKED
+ * it specifies the last lock reason.
+ * This can be used to track retry attempts as part of the lock details.
+ */
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class LockReason {
+
+ @JsonProperty("reason")
+ private LockReasonCategory lockReasonCategory;
+
+ @JsonProperty("details")
+ private String details;
+
+ }
+
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class DataStores {
+
+ @JsonProperty("operational")
+ private Operational operationalDataStore;
+ }
+
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class Operational {
+
+ @JsonProperty("sync-state")
+ private DataStoreSyncState dataStoreSyncState;
+
+ @JsonProperty("last-sync-time")
+ private String lastSyncTime;
+ }
+
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class Running {
+
+ @JsonProperty("sync-state")
+ private String syncState;
+
+ @JsonProperty("last-sync-time")
+ private String lastSyncTime;
+ }
+
+ /**
+ * The date and time format used for the cm handle sync state.
+ *
+ * @return the date and time in the format of yyyy-MM-dd'T'HH:mm:ss.SSSZ
+ */
+ public static String nowInSyncTimeFormat() {
+ return dateTimeFormatter.format(OffsetDateTime.now());
+ }
+
+ /**
+ * Sets the last updated date and time for the cm handle sync state.
+ */
+ public void setLastUpdateTimeNow() {
+ lastUpdateTime = CompositeState.nowInSyncTimeFormat();
+ }
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeStateBuilder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeStateBuilder.java
new file mode 100644
index 000000000..59d7aa2b4
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeStateBuilder.java
@@ -0,0 +1,157 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Bell Canada
+ * Modifications Copyright (C) 2022-2023 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.inventory.models;
+
+import org.onap.cps.ncmp.api.inventory.models.CompositeState.DataStores;
+import org.onap.cps.ncmp.api.inventory.models.CompositeState.LockReason;
+import org.onap.cps.ncmp.api.inventory.models.CompositeState.Operational;
+import org.onap.cps.ncmp.impl.inventory.DataStoreSyncState;
+import org.onap.cps.ncmp.impl.inventory.models.CmHandleState;
+import org.onap.cps.ncmp.impl.inventory.models.LockReasonCategory;
+import org.onap.cps.spi.model.DataNode;
+
+public class CompositeStateBuilder {
+
+ private CmHandleState cmHandleState;
+ private LockReason lockReason;
+ private DataStores datastores;
+ private String lastUpdatedTime;
+ private Boolean dataSyncEnabled;
+
+ /**
+ * To create the {@link CompositeState}.
+ *
+ * @return {@link DataNode}
+ */
+ public CompositeState build() {
+ final CompositeState compositeState = new CompositeState();
+ compositeState.setCmHandleState(cmHandleState);
+ compositeState.setLockReason(lockReason);
+ compositeState.setDataStores(datastores);
+ compositeState.setLastUpdateTime(lastUpdatedTime);
+ compositeState.setDataSyncEnabled(dataSyncEnabled);
+ return compositeState;
+ }
+
+ /**
+ * To use attributes for creating {@link CompositeState}.
+ *
+ * @param cmHandleState for the data node
+ * @return CompositeStateBuilder
+ */
+ public CompositeStateBuilder withCmHandleState(final CmHandleState cmHandleState) {
+ this.cmHandleState = cmHandleState;
+ return this;
+ }
+
+ /**
+ * To use attributes for creating {@link CompositeState}.
+ *
+ * @param reason for the locked state
+ * @param details for the locked state
+ * @return CompositeStateBuilder
+ */
+ public CompositeStateBuilder withLockReason(final LockReasonCategory reason, final String details) {
+ this.lockReason = LockReason.builder().lockReasonCategory(reason).details(details).build();
+ return this;
+ }
+
+ /**
+ * To use attributes for creating {@link CompositeState}.
+ *
+ * @param time for the state change
+ * @return CompositeStateBuilder
+ */
+ public CompositeStateBuilder withLastUpdatedTime(final String time) {
+ this.lastUpdatedTime = time;
+ return this;
+ }
+
+ /**
+ * To use attributes for creating {@link CompositeState}.
+ *
+ * @return composite state builder
+ */
+ public CompositeStateBuilder withLastUpdatedTimeNow() {
+ this.lastUpdatedTime = CompositeState.nowInSyncTimeFormat();
+ return this;
+ }
+
+ /**
+ * To use attributes for creating {@link CompositeState}.
+ *
+ * @param dataStoreSyncState for the locked state
+ * @param lastSyncTime for the locked state
+ * @return CompositeStateBuilder
+ */
+ public CompositeStateBuilder withOperationalDataStores(final DataStoreSyncState dataStoreSyncState,
+ final String lastSyncTime) {
+ this.datastores = DataStores.builder().operationalDataStore(
+ Operational.builder().dataStoreSyncState(dataStoreSyncState).lastSyncTime(lastSyncTime).build()).build();
+ return this;
+ }
+
+ /**
+ * To use dataNode for creating {@link CompositeState}.
+ *
+ * @param dataNode for the dataNode
+ * @return CompositeState
+ */
+ public CompositeStateBuilder fromDataNode(final DataNode dataNode) {
+ this.cmHandleState = CmHandleState.valueOf((String) dataNode.getLeaves()
+ .get("cm-handle-state"));
+ this.lastUpdatedTime = (String) dataNode.getLeaves().get("last-update-time");
+ if (this.cmHandleState == CmHandleState.READY) {
+ this.dataSyncEnabled = (Boolean) dataNode.getLeaves().get("data-sync-enabled");
+ }
+ for (final DataNode stateChildNode : dataNode.getChildDataNodes()) {
+ if (stateChildNode.getXpath().endsWith("/lock-reason")) {
+ this.lockReason = getLockReason(stateChildNode);
+ }
+ if (stateChildNode.getXpath().endsWith("/datastores")) {
+ for (final DataNode dataStoreNodes : stateChildNode.getChildDataNodes()) {
+ Operational operationalDataStore = null;
+ if (dataStoreNodes.getXpath().contains("/operational")) {
+ operationalDataStore = getOperationalDataStore(dataStoreNodes);
+ }
+ this.datastores = DataStores.builder().operationalDataStore(operationalDataStore).build();
+ }
+ }
+ }
+ return this;
+ }
+
+ private Operational getOperationalDataStore(final DataNode dataStoreNodes) {
+ return Operational.builder()
+ .dataStoreSyncState(DataStoreSyncState.valueOf((String) dataStoreNodes.getLeaves().get("sync-state")))
+ .lastSyncTime((String) dataStoreNodes.getLeaves().get("last-sync-time"))
+ .build();
+ }
+
+ private LockReason getLockReason(final DataNode stateChildNode) {
+ final boolean isLockReasonExists = stateChildNode.getLeaves().containsKey("reason");
+ return new LockReason(isLockReasonExists
+ ? LockReasonCategory.valueOf((String) stateChildNode.getLeaves().get("reason"))
+ : null, (String) stateChildNode.getLeaves().get("details"));
+ }
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/ConditionApiProperties.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/ConditionApiProperties.java
new file mode 100644
index 000000000..61d9f4a25
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/ConditionApiProperties.java
@@ -0,0 +1,44 @@
+/*
+ * ============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.inventory.models;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.Valid;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+@EqualsAndHashCode
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class ConditionApiProperties {
+ @JsonProperty("conditionName")
+ private String conditionName = "";
+
+ @JsonProperty("conditionParameters")
+ @Valid
+ private List<Map<String, String>> conditionParameters = Collections.emptyList();
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistration.java
new file mode 100644
index 000000000..a5002e790
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistration.java
@@ -0,0 +1,89 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021-2024 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.inventory.models;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.google.common.base.Strings;
+import java.util.Collections;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.cps.ncmp.api.impl.exception.DmiRequestException;
+import org.onap.cps.ncmp.api.impl.exception.NcmpException;
+
+/**
+ * Dmi Registry request object.
+ */
+@Getter
+@Setter
+@JsonInclude(Include.NON_NULL)
+public class DmiPluginRegistration {
+
+ private String dmiPlugin;
+
+ private String dmiDataPlugin;
+
+ private String dmiModelPlugin;
+
+ private List<NcmpServiceCmHandle> createdCmHandles = Collections.emptyList();
+
+ private List<NcmpServiceCmHandle> updatedCmHandles = Collections.emptyList();
+
+ private List<String> removedCmHandles = Collections.emptyList();
+
+ private UpgradedCmHandles upgradedCmHandles = new UpgradedCmHandles();
+
+ /**
+ * Validates plugin service names.
+ * @throws NcmpException if validation fails.
+ */
+ public void validateDmiPluginRegistration() throws NcmpException {
+ final String combinedServiceName = dmiPlugin;
+ final String dataServiceName = dmiDataPlugin;
+ final String modelsServiceName = dmiModelPlugin;
+
+ String errorMessage = null;
+
+ if (isNullEmptyOrBlank(combinedServiceName)) {
+ if ((isNullEmptyOrBlank(dataServiceName) && isNullEmptyOrBlank(modelsServiceName))) {
+ errorMessage = "No DMI plugin service names";
+ } else {
+ if (isNullEmptyOrBlank(dataServiceName) || isNullEmptyOrBlank(modelsServiceName)) {
+ errorMessage = "Cannot register just a Data or Model plugin service name";
+ }
+ }
+ } else {
+ if (!isNullEmptyOrBlank(dataServiceName) || !isNullEmptyOrBlank(modelsServiceName)) {
+ errorMessage = "Cannot register combined plugin service name and other service names";
+ }
+ }
+
+ if (errorMessage != null) {
+ throw new DmiRequestException(errorMessage, "Please supply correct plugin information.");
+ }
+ }
+
+ public static boolean isNullEmptyOrBlank(final String serviceName) {
+ return Strings.isNullOrEmpty(serviceName) || serviceName.isBlank();
+ }
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistrationResponse.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistrationResponse.java
new file mode 100644
index 000000000..736ca620d
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/DmiPluginRegistrationResponse.java
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Bell Canada
+ * Modifications Copyright (C) 2023 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.inventory.models;
+
+import java.util.Collections;
+import java.util.List;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class DmiPluginRegistrationResponse {
+ private List<CmHandleRegistrationResponse> createdCmHandles = Collections.emptyList();
+ private List<CmHandleRegistrationResponse> updatedCmHandles = Collections.emptyList();
+ private List<CmHandleRegistrationResponse> removedCmHandles = Collections.emptyList();
+ private List<CmHandleRegistrationResponse> upgradedCmHandles = Collections.emptyList();
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java
new file mode 100644
index 000000000..69b33a16f
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java
@@ -0,0 +1,65 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021-2024 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.inventory.models;
+
+import com.fasterxml.jackson.annotation.JsonSetter;
+import com.fasterxml.jackson.annotation.Nulls;
+import java.util.Collections;
+import java.util.Map;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * The NCMP Service model used for the java service API.
+ * NCMP Service CmHandle.
+ */
+@Validated
+@Getter
+@Setter
+@NoArgsConstructor
+public class NcmpServiceCmHandle {
+
+ private String cmHandleId;
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private Map<String, String> dmiProperties = Collections.emptyMap();
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private Map<String, String> publicProperties = Collections.emptyMap();
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private CompositeState compositeState;
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private String moduleSetTag;
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private TrustLevel registrationTrustLevel;
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private String alternateId;
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private String dataProducerIdentifier;
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/UpgradedCmHandles.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/UpgradedCmHandles.java
new file mode 100644
index 000000000..9f48ae968
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/UpgradedCmHandles.java
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.inventory.models;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import java.util.Collections;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class UpgradedCmHandles {
+ private List<String> cmHandles = Collections.emptyList();
+ private String moduleSetTag;
+}
+
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/YangResource.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/YangResource.java
new file mode 100644
index 000000000..1c0ca5d8c
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/YangResource.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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.inventory.models;
+
+import lombok.Data;
+
+@Data
+public class YangResource {
+
+ private String moduleName;
+
+ private String revision;
+
+ private String yangSource;
+
+}