IntelliJ Code Inspection Updates 77/141877/9
authorToineSiebelink <toine.siebelink@est.tech>
Tue, 19 Aug 2025 11:43:19 +0000 (12:43 +0100)
committerToineSiebelink <toine.siebelink@est.tech>
Thu, 21 Aug 2025 17:24:59 +0000 (18:24 +0100)
- Use Lombok where possible
- Removed unused (interface) methods
- Removed parameters where method was called with only 1 (always same) value.
    This lead to so manual refactoring, more specific method names etc.
    For data job read I logged some details to get over this as the implementation is currently on hold/blocked
- Use 'record' (instead of class) where possible
- Apply @serial annotation
- Fixed unused result from matcher.find() We used to catch exceptions instead which is very bad :-(
- Some unused constant/return values needed for consistency, used annotation to ignore thee warning
- Removed Enum private value that was identical to Enum itself
- Uncheck casting, just added annotation to prevent warning I think they are all safe because we know and control the model
- Use {} for logging instead on string concatenation
- Use <a></a> for links in Javadoc
- Added missed null-checks
- Manually updated groovy test classes that were affected by some of above
- Spelling and grammar, original about 200 errors
     using 'Id' (with uppercase) I was flagged as a grammar issue and I like the idea of consistently using 'id' lower case in descriptions
     most typos where actually fixed by adding some work to the dictionary like cmhandle, onap, etsi etc.
     about 10% were genuine errors which also 2 or 3 variables affected which I have corrected now
- Security
     flagged some (http) links with suppress as we cannot change them
     some dependency issues remaining, need to check with Ger, looks like correct early warning without need for any CIO job or other tools!
- CODE ANALYZER ON WHOLE PROJECT
      only 4 java updates! inserted 2 finals (1 reverted as it was needed for test!), removed unnecessary casting in 2 places
      incorrectly add = sing in a cert.properties file for socker which I reverted

Issue-ID: CPS-2941
Change-Id: I439237422b01d533ae1c9301cbfcedbebf922fd4
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
73 files changed:
cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java
cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/src/main/java/org/onap/cps/ncmp/rest/stub/providers/ResourceProviderImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NcmpResponseStatus.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/data/models/CmResourceAddress.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/DataJobService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/ProducerKey.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/SubJobWriteRequest.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/exceptions/DmiClientRequestException.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/exceptions/NcmpException.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/exceptions/PolicyExecutorException.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CmHandleRegistrationResponse.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/CompositeState.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/config/CpsApplicationContext.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/config/OpenTelemetryConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/config/TimedCustom.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/exceptions/NcmpStartUpException.java [deleted file]
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cache/AdminCacheConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cache/AlternateIdCacheConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cache/CpsAndNcmpLockConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cache/HazelcastCacheConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cache/CmSubscriptionConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cache/DmiCacheHandler.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiInEventMapper.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiInEventProducer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/models/CmSubscriptionStatus.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/models/DmiCmSubscriptionTuple.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpInEventConsumer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventMapper.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/utils/CmDataJobSubscriptionPersistenceService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NcmpCachedResourceRequestHandler.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NcmpPassthroughResourceRequestHandler.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacade.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/async/RecordFilterStrategies.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/policyexecutor/PolicyExecutor.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/utils/DmiDataOperationsHelper.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiServiceNameOrganizer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistence.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/NcmpPersistence.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/NcmpPersistenceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/ModelledDmiServiceLeaves.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/SynchronizationCacheConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/CmHandleStateMonitor.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsProducer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/DeviceTrustLevelMessageConsumer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelCacheConfig.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/models/DmiRequestBody.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/models/RequiredDmiService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/AlternateIdMatcher.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/RestServiceUrlTemplateBuilder.java
cps-ncmp-service/src/main/resources/models/dmi-registry@2024-02-23.yang
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/models/CmHandleRegistrationResponseSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cache/HazelcastCacheConfigSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpInEventConsumerSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/RecordFilterStrategiesSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImplSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/DeviceTrustLevelMessageConsumerSpec.groovy
cps-ri/src/main/java/org/onap/cps/ri/CpsModulePersistenceServiceImpl.java
policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java

index 4318f44..81c2b0a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada
- *  Modifications Copyright (c) 2022-2024 Nordix Foundation
+ *  Modifications Copyright (c) 2022-2025 OpenInfra Foundation Europe.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -112,7 +112,7 @@ public class NetworkCmProxyStubController implements NetworkCmProxyApi {
             return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
         }
 
-        return ResponseEntity.ok(Collections.<RestOutputCmHandle>emptyList());
+        return ResponseEntity.ok(Collections.emptyList());
     }
 
     private ResponseEntity<Map<String, Object>> populateAsyncResponse(final String topicParamInQuery) {
index c0779eb..f223b4f 100644 (file)
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Service;
 @Service
 public class ResourceProviderImpl implements ResourceProvider {
 
-    private String pathToResponseFiles;
+    private final String pathToResponseFiles;
 
     @Autowired
     public ResourceProviderImpl(@Value("${stub.path}") final String pathToResponseFiles) {
index be22752..32d44f0 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2023-2024 Nordix Foundation
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import lombok.Getter;
 @Getter
 public enum NcmpResponseStatus {
 
-    SUCCESS("0", "Successfully applied changes"),
+    @SuppressWarnings("unused") SUCCESS("0", "Successfully applied changes"),
     CM_DATA_SUBSCRIPTION_ACCEPTED("1", "ACCEPTED"),
     CM_HANDLES_NOT_FOUND("100", "cm handle reference(s) not found"),
     CM_HANDLES_NOT_READY("101", "cm handle(s) not ready"),
@@ -35,8 +35,8 @@ public enum NcmpResponseStatus {
     UNKNOWN_ERROR("108", "Unknown error"),
     CM_HANDLE_ALREADY_EXIST("109", "cm-handle already exists"),
     CM_HANDLE_INVALID_ID("110", "cm handle reference has an invalid character(s) in id"),
-    ALTERNATE_ID_ALREADY_ASSOCIATED("111", "alternate id already associated"),
-    MESSAGE_TOO_LARGE("112", "message too large");
+    @SuppressWarnings("unused") ALTERNATE_ID_ALREADY_ASSOCIATED("111", "alternate id already associated"),
+    @SuppressWarnings("unused") MESSAGE_TOO_LARGE("112", "message too large");
 
     private final String code;
     private final String message;
index 24a9b21..f641f9f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.cps.ncmp.api.data.models;
 
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
 import org.onap.cps.ncmp.config.CpsApplicationContext;
 import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher;
 
-@Getter
-@RequiredArgsConstructor
-public class CmResourceAddress {
-
-    private final String datastoreName;
-    private final String cmHandleReference;
-    private final String resourceIdentifier;
+public record CmResourceAddress(String datastoreName, String cmHandleReference, String resourceIdentifier) {
 
     public String resolveCmHandleReferenceToId() {
         final AlternateIdMatcher alternateIdMatcher = CpsApplicationContext.getCpsBean(AlternateIdMatcher.class);
index 255b384..2cba7ed 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -54,4 +54,4 @@ public interface DataJobService {
                                            String dataJobId,
                                            DataJobMetadata dataJobMetadata,
                                            DataJobWriteRequest dataJobWriteRequest);
-}
\ No newline at end of file
+}
index ac6b7f8..7b4f181 100644 (file)
@@ -33,4 +33,4 @@ public record ProducerKey(String dmiServiceName, String dataProducerIdentifier)
     public String toString() {
         return dmiServiceName + "#"  + dataProducerIdentifier;
     }
-}
\ No newline at end of file
+}
index a7a6573..c80da73 100644 (file)
@@ -32,7 +32,7 @@ import java.util.Collection;
  * @param dataContentType Define the data request content type.
  *                        e.g. "application/3gpp-json-patch+json" etc.
  * @param dataProducerId  Identifier of the data producer.
- * @param dataJobId       Identifier for the overall Datajob
+ * @param dataJobId       Identifier for the overall data job
  * @param data            A collection of outgoing write operations.
  */
 public record SubJobWriteRequest (
@@ -41,4 +41,4 @@ public record SubJobWriteRequest (
         String dataContentType,
         String dataProducerId,
         String dataJobId,
-        Collection<DmiWriteOperation> data) {}
\ No newline at end of file
+        Collection<DmiWriteOperation> data) {}
index 65ccba8..01eba4e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2022-2024 Nordix Foundation
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.cps.ncmp.api.exceptions;
 
+import java.io.Serial;
 import lombok.Getter;
 import org.onap.cps.ncmp.api.NcmpResponseStatus;
 
@@ -29,6 +30,7 @@ import org.onap.cps.ncmp.api.NcmpResponseStatus;
 @Getter
 public class DmiClientRequestException extends NcmpException {
 
+    @Serial
     private static final long serialVersionUID = 6659897770659834797L;
     final NcmpResponseStatus ncmpResponseStatus;
     final String message;
index 3c81d0f..c27e34a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation
+ *  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.cps.ncmp.api.exceptions;
 
+import java.io.Serial;
 import lombok.Getter;
 
 /**
@@ -27,6 +28,7 @@ import lombok.Getter;
  */
 public class NcmpException extends RuntimeException {
 
+    @Serial
     private static final long serialVersionUID = 1482619410918497467L;
 
     @Getter
index bb753b8..0fa808f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.cps.ncmp.api.exceptions;
 
+import java.io.Serial;
 import lombok.Getter;
 
 /**
@@ -28,6 +29,7 @@ import lombok.Getter;
 @Getter
 public class PolicyExecutorException extends NcmpException {
 
+    @Serial
     private static final long serialVersionUID = 6659897770659834798L;
 
     /**
index 7523f77..b5c096d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada
- *  Modifications Copyright (C) 2022-2024 Nordix Foundation
+ *  Modifications Copyright (C) 2022--2025 OpenInfra Foundation Europe.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -88,12 +88,13 @@ public class CmHandleRegistrationResponse {
         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);
+            final String cmHandleId = YangDataConverter.extractCmHandleIdFromXpath(xpath);
+            if (cmHandleId == null) {
+                log.warn("Unexpected xpath (no id found) {}", xpath);
+            } else {
+                final CmHandleRegistrationResponse cmHandleRegistrationResponse =
+                    CmHandleRegistrationResponse.createFailureResponse(cmHandleId, ncmpResponseStatus);
+                cmHandleRegistrationResponses.add(cmHandleRegistrationResponse);
             }
         }
         return cmHandleRegistrationResponses;
@@ -142,6 +143,6 @@ public class CmHandleRegistrationResponse {
     }
 
     public enum Status {
-        SUCCESS, FAILURE;
+        SUCCESS, FAILURE
     }
 }
index d873f66..e02be31 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -114,18 +114,6 @@ public class CompositeState {
         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.
      *
index fbc31ad..32e0305 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
+ * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ package org.onap.cps.ncmp.config;
 
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.lang.NonNull;
 import org.springframework.stereotype.Component;
 
 @Component
@@ -36,12 +37,12 @@ public class CpsApplicationContext implements ApplicationContextAware {
      * @param cpsBeanClass cps class type
      * @return requested bean instance
      */
-    public static <T extends Object> T getCpsBean(final Class<T> cpsBeanClass) {
+    public static <T> T getCpsBean(final Class<T> cpsBeanClass) {
         return applicationContext.getBean(cpsBeanClass);
     }
 
     @Override
-    public void setApplicationContext(final ApplicationContext cpsApplicationContext) {
+    public void setApplicationContext(@NonNull final ApplicationContext cpsApplicationContext) {
         setCpsApplicationContext(cpsApplicationContext);
     }
 
index a6a82b7..d8094ee 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,9 +52,11 @@ public class OpenTelemetryConfig {
     @Value("${spring.application.name:cps-application}")
     private String serviceId;
 
+    @SuppressWarnings("HttpUrlsUsage")
     @Value("${cps.tracing.exporter.endpoint:http://onap-otel-collector:4317}")
     private String tracingExporterEndpointUrl;
 
+    @SuppressWarnings("HttpUrlsUsage")
     @Value("${cps.tracing.sampler.jaeger_remote.endpoint:http://onap-otel-collector:14250}")
     private String jaegerRemoteSamplerUrl;
 
index 7219147..d39bddf 100644 (file)
@@ -28,6 +28,7 @@ import java.lang.annotation.Target;
 /**
  * Custom annotation to enable metric scraping.
  */
+@SuppressWarnings("UnusedReturnValue")
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
 public @interface TimedCustom {
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/exceptions/NcmpStartUpException.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/exceptions/NcmpStartUpException.java
deleted file mode 100644 (file)
index 7ffbe2e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *  ============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.exceptions;
-
-import org.onap.cps.ncmp.api.exceptions.NcmpException;
-
-/**
- * NCMP start up exception.
- */
-public class NcmpStartUpException extends NcmpException {
-
-    /**
-     * Constructor.
-     *
-     * @param message the error message
-     * @param details the error details
-     */
-    public NcmpStartUpException(final String message, final String details) {
-        super(message, details);
-    }
-}
index fe933d7..05f96c8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2025 Nordix Foundation
+ *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class AdminCacheConfig extends HazelcastCacheConfig {
 
-    private static final MapConfig cmHandleStateCacheMapConfig = createMapConfig("cmHandleStateCacheMapConfig");
+    private static final MapConfig cmHandleStateCacheMapConfig = createGenericMapConfig("cmHandleStateCacheMapConfig");
 
     /**
      * Distributed instance admin cache map for cm handles by state for use of gauge metrics.
index 14936c8..b31bceb 100644 (file)
@@ -29,7 +29,7 @@ import org.springframework.context.annotation.Configuration;
 public class AlternateIdCacheConfig extends HazelcastCacheConfig {
 
     private static final MapConfig cmHandleIdPerAlternateIdMapConfig =
-            createMapConfig("cmHandleIdPerAlternateIdMapConfig");
+            createGenericMapConfig("cmHandleIdPerAlternateIdMapConfig");
 
     /**
      * Distributed instance used for mapping alternate id to cm handle id.
index 61cf939..294768d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START========================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ public class CpsAndNcmpLockConfig extends HazelcastCacheConfig {
     // Lock names for different use cases ( to be used as cpsAndNcmpLock keys)
     public static final String MODULE_SYNC_WORK_QUEUE_LOCK_NAME = "workQueueLock";
 
-    private static final MapConfig cpsAndNcmpLockMapConfig = createMapConfig("cpsAndNcmpLockConfig");
+    private static final MapConfig cpsAndNcmpLockMapConfig = createGenericMapConfig("cpsAndNcmpLockConfig");
 
     /**
      * Distributed instance used for locking purpose for various use cases in cps-and-ncmp.
index 1a7ef75..69e31e9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START========================================================
- *  Copyright (C) 2023-2025 Nordix Foundation
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ package org.onap.cps.ncmp.impl.cache;
 import com.hazelcast.config.Config;
 import com.hazelcast.config.MapConfig;
 import com.hazelcast.config.NamedConfig;
-import com.hazelcast.config.NearCacheConfig;
 import com.hazelcast.config.QueueConfig;
 import com.hazelcast.config.SetConfig;
 import com.hazelcast.core.Hazelcast;
@@ -78,35 +77,19 @@ public class HazelcastCacheConfig {
 
     private Config getHazelcastInstanceConfig(final String instanceConfigName) {
         final HazelcastInstance hazelcastInstance = Hazelcast.getHazelcastInstanceByName(instanceConfigName);
-        Config config = null;
-        if (hazelcastInstance != null) {
-            config = hazelcastInstance.getConfig();
-        } else {
-            config = new Config(instanceConfigName);
+        if (hazelcastInstance == null) {
+            return new Config(instanceConfigName);
         }
-        return config;
+        return hazelcastInstance.getConfig();
     }
 
-    protected static MapConfig createMapConfig(final String configName) {
+    protected static MapConfig createGenericMapConfig(final String configName) {
         final MapConfig mapConfig = new MapConfig(configName);
         mapConfig.setBackupCount(1);
         return mapConfig;
     }
 
-    protected static MapConfig createMapConfigWithTimeToLiveInSeconds(final String configName,
-                                                                      final int timeToLiveInSeconds) {
-        final MapConfig mapConfig = new MapConfig(configName);
-        mapConfig.setBackupCount(1);
-        mapConfig.setTimeToLiveSeconds(timeToLiveInSeconds);
-        return mapConfig;
-    }
 
-    protected static MapConfig createNearCacheMapConfig(final String configName) {
-        final MapConfig mapConfig = new MapConfig(configName);
-        mapConfig.setBackupCount(1);
-        mapConfig.setNearCacheConfig(new NearCacheConfig(configName));
-        return mapConfig;
-    }
 
     protected static QueueConfig createQueueConfig(final String configName) {
         final QueueConfig commonQueueConfig = new QueueConfig(configName);
index cb51020..37213c9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import org.springframework.context.annotation.Configuration;
 public class CmSubscriptionConfig extends HazelcastCacheConfig {
 
     private static final MapConfig cmNotificationSubscriptionCacheMapConfig =
-            createMapConfig("cmNotificationSubscriptionCacheMapConfig");
+            createGenericMapConfig("cmNotificationSubscriptionCacheMapConfig");
 
     /**
      * Distributed instance of cm notification subscription information
index b0b1cc5..9d87690 100644 (file)
@@ -129,7 +129,7 @@ public class DmiCacheHandler {
     /**
      *  Update status in map of subscription details per DMI.
      *
-     * @param subscriptionId    String of subscription Id
+     * @param subscriptionId    String of subscription id
      * @param dmiServiceName    String of dmiServiceName
      * @param status            String of status
      *
@@ -145,7 +145,7 @@ public class DmiCacheHandler {
     /**
      *  Persist map of subscription details per DMI.
      *
-     * @param subscriptionId    String of subscription Id
+     * @param subscriptionId    String of subscription id
      * @param dmiServiceName    String of dmiServiceName
      *
      */
index f504207..b18c7f9 100644 (file)
@@ -83,7 +83,9 @@ public class CmAvcEventConsumer {
         if (Boolean.TRUE.equals(dataSyncEnabled)) {
             final AvcEvent cmAvcEvent = toTargetEvent(cmAvcEventAsConsumerRecord.value(), AvcEvent.class);
             log.debug("Event to be processed to update the cache with cmHandleId : {}", cmHandleId);
-            cmAvcEventService.processCmAvcEvent(cmHandleId, cmAvcEvent);
+            if (cmAvcEvent != null) {
+                cmAvcEventService.processCmAvcEvent(cmHandleId, cmAvcEvent);
+            }
         }
     }
 
index 061fe56..1bfc038 100644 (file)
@@ -139,7 +139,7 @@ public class CmAvcEventService {
     }
 
     private String getCpsPath(final String cmHandleId, final String restConfStylePath) {
-        log.debug("Getting cps path from the restconfpath : {}", restConfStylePath);
+        log.debug("Getting cps path from the rest config path : {}", restConfStylePath);
         final Anchor anchor = cpsAnchorService.getAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId);
         return yangParser.getCpsPathFromRestConfStylePath(anchor, restConfStylePath);
     }
index 04fe6d1..ed5d657 100644 (file)
@@ -87,8 +87,8 @@ public class DmiInEventMapper {
             final CmHandle cmHandle = new CmHandle();
             final Map<String, String> cmHandleAdditionalProperties = new LinkedHashMap<>();
             yangModelCmHandle.getAdditionalProperties()
-                    .forEach(additionalProperty -> cmHandleAdditionalProperties.put(additionalProperty.getName(),
-                        additionalProperty.getValue()));
+                    .forEach(additionalProperty -> cmHandleAdditionalProperties.put(additionalProperty.name(),
+                        additionalProperty.value()));
             cmHandle.setCmhandleId(yangModelCmHandle.getId());
             cmHandle.setPrivateProperties(cmHandleAdditionalProperties);
             cmSubscriptionCmHandles.add(cmHandle);
index baa9926..3b1fb95 100644 (file)
@@ -45,8 +45,8 @@ public class DmiInEventProducer {
     /**
      * Send the event to the provided dmi plugin with key as subscription id and the event is in Cloud Event format.
      *
-     * @param subscriptionId Cm Subscription Id
-     * @param dmiPluginName  Dmi Plugin Name
+     * @param subscriptionId CM subscription id
+     * @param dmiPluginName  Dmi plugin Name
      * @param eventType      Type of event
      * @param dmiInEvent     Cm Notification Subscription event for Dmi
      */
index 5b7c46e..1763f24 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -22,11 +22,6 @@ package org.onap.cps.ncmp.impl.cmnotificationsubscription.models;
 
 public enum CmSubscriptionStatus {
 
-    ACCEPTED("ACCEPTED"), REJECTED("REJECTED"), PENDING("PENDING");
+    ACCEPTED(), REJECTED(), PENDING()
 
-    private final String cmNotificationSubscriptionStatusValue;
-
-    CmSubscriptionStatus(final String cmNotificationSubscriptionStatusValue) {
-        this.cmNotificationSubscriptionStatusValue = cmNotificationSubscriptionStatusValue;
-    }
 }
index cd4a15a..5be7577 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Collection;
 import java.util.Map;
 
 /**
- * Tuple to be used during for to delete usecase.
+ * Tuple to be used during for to delete use case.
  *
  * @param lastRemainingSubscriptionsPerDmi   subscriptions that are used by only one subscriber grouped per dmi
  * @param overlappingSubscriptionsPerDmi     subscriptions that are shared by multiple subscribers grouped per dmi
index d0285e1..a82b5be 100644 (file)
@@ -198,6 +198,7 @@ public class CmSubscriptionHandlerImpl implements CmSubscriptionHandler {
             final DmiCmSubscriptionKey dmiCmSubscriptionKey = extractCmSubscriptionKey(subscriptionNode.getXpath());
             final String dmiServiceName = inventoryPersistence.getYangModelCmHandle(
                     dmiCmSubscriptionKey.cmHandleId()).getDmiServiceName();
+            @SuppressWarnings("unchecked")
             final List<String> subscribers = (List<String>) subscriptionNode.getLeaves().get("subscriptionIds");
             populateDmiCmSubscriptionTuple(subscribers, overlappingSubscriptionsPerDmi,
                     lastRemainingSubscriptionsPerDmi, dmiServiceName, dmiCmSubscriptionKey);
@@ -228,4 +229,4 @@ public class CmSubscriptionHandlerImpl implements CmSubscriptionHandler {
         throw new IllegalArgumentException("DataNode xpath does not represent a subscription key");
     }
 
-}
\ No newline at end of file
+}
index 17b1de6..b3fb133 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -50,22 +50,23 @@ public class NcmpInEventConsumer {
             containerFactory = "cloudEventConcurrentKafkaListenerContainerFactory")
     public void consumeSubscriptionEvent(final ConsumerRecord<String, CloudEvent> ncmpInEventAsConsumerRecord) {
         final CloudEvent cloudEvent = ncmpInEventAsConsumerRecord.value();
-        final NcmpInEvent ncmpInEvent =
-                toTargetEvent(cloudEvent, NcmpInEvent.class);
-        log.info("Subscription with name {} to be mapped to hazelcast object...",
+        final NcmpInEvent ncmpInEvent = toTargetEvent(cloudEvent, NcmpInEvent.class);
+        if (ncmpInEvent != null) {
+            log.info("Subscription with name {} to be mapped to hazelcast object...",
                 ncmpInEvent.getData().getSubscriptionId());
 
-        final String subscriptionId = ncmpInEvent.getData().getSubscriptionId();
-        final List<Predicate> predicates = ncmpInEvent.getData().getPredicates();
-        if ("subscriptionCreateRequest".equals(cloudEvent.getType())) {
-            log.info("Subscription create request for source {} with subscription id {} ...",
+            final String subscriptionId = ncmpInEvent.getData().getSubscriptionId();
+            final List<Predicate> predicates = ncmpInEvent.getData().getPredicates();
+            if ("subscriptionCreateRequest".equals(cloudEvent.getType())) {
+                log.info("Subscription create request for source {} with subscription id {} ...",
                     cloudEvent.getSource(), subscriptionId);
-            cmSubscriptionHandler.processSubscriptionCreateRequest(subscriptionId, predicates);
-        }
-        if ("subscriptionDeleteRequest".equals(cloudEvent.getType())) {
-            log.info("Subscription delete request for source {} with subscription id {} ...",
+                cmSubscriptionHandler.processSubscriptionCreateRequest(subscriptionId, predicates);
+            }
+            if ("subscriptionDeleteRequest".equals(cloudEvent.getType())) {
+                log.info("Subscription delete request for source {} with subscription id {} ...",
                     cloudEvent.getSource(), subscriptionId);
-            cmSubscriptionHandler.processSubscriptionDeleteRequest(subscriptionId);
+                cmSubscriptionHandler.processSubscriptionDeleteRequest(subscriptionId);
+            }
         }
     }
 }
index afff9d1..9f59b1a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public class NcmpOutEventMapper {
     /**
      * Mapper to form a response for the client for the Cm Notification Subscription.
      *
-     * @param subscriptionId                          Cm Notification Subscription Id
+     * @param subscriptionId         CM notification subscription id
      * @param dmiSubscriptionsPerDmi contains CmNotificationSubscriptionDetails per dmi plugin
      * @return CmNotificationSubscriptionNcmpOutEvent to sent back to the client
      */
index 639fb65..a5b9ae6 100644 (file)
@@ -62,7 +62,7 @@ public class NcmpOutEventProducer {
      * Send the event to the client who requested the subscription with key as subscription id and event is Cloud
      * Event compliant.
      *
-     * @param subscriptionId   Cm Subscription Id
+     * @param subscriptionId   CM subscription id
      * @param eventType        Type of event
      * @param ncmpOutEvent     Cm Notification Subscription Event for the
      *                         client
index 5c53f3d..b761f84 100644 (file)
@@ -27,7 +27,6 @@ import java.io.Serializable;
 import java.time.OffsetDateTime;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -85,6 +84,7 @@ public class CmDataJobSubscriptionPersistenceService {
      * @param alternateId   the alternate id target of the data job subscription
      * @return              collection of subscription ids of ongoing cm notification subscription
      */
+    @SuppressWarnings("unchecked")
     public Collection<String> getSubscriptionIds(final String dataType, final String alternateId) {
         final String query = CPS_PATH_TEMPLATE_FOR_SUBSCRIPTION_WITH_ALTERNATE_ID_AND_DATATYPE.formatted(
                 alternateId, dataType);
@@ -94,7 +94,7 @@ public class CmDataJobSubscriptionPersistenceService {
         if (existingNodes.isEmpty()) {
             return Collections.emptyList();
         }
-        return (List<String>) existingNodes.iterator().next().getLeaves().get("dataJobId");
+        return (Collection<String>) existingNodes.iterator().next().getLeaves().get("dataJobId");
     }
 
     /**
@@ -105,8 +105,7 @@ public class CmDataJobSubscriptionPersistenceService {
      * @param subscriptionId data job subscription id to be added
      */
     public void addSubscription(final String dataType, final String alternateId, final String subscriptionId) {
-        final Collection<String> subscriptionIds =
-                getSubscriptionIds(dataType, alternateId);
+        final Collection<String> subscriptionIds = getSubscriptionIds(dataType, alternateId);
         if (subscriptionIds.isEmpty()) {
             addNewSubscriptionDetails(dataType, alternateId, subscriptionId);
         } else {
index b64d456..9b0dc9f 100644 (file)
@@ -102,7 +102,7 @@ public class DmiDataOperations {
         validateIfCmHandleStateReady(yangModelCmHandle, cmHandleState);
         final String jsonRequestBody = getDmiRequestBody(READ, requestId, null, null, yangModelCmHandle);
         final UrlTemplateParameters urlTemplateParameters = getUrlTemplateParameters(cmResourceAddress
-                .getDatastoreName(), yangModelCmHandle, cmResourceAddress.getResourceIdentifier(), options, topic);
+                .datastoreName(), yangModelCmHandle, cmResourceAddress.resourceIdentifier(), options, topic);
         return dmiRestClient.asynchronousPostOperationWithJsonData(DATA, urlTemplateParameters, jsonRequestBody, READ,
                 authorization);
     }
index 5b2fede..85456c8 100644 (file)
@@ -66,20 +66,18 @@ public class NcmpCachedResourceRequestHandler extends NcmpDatastoreRequestHandle
                                                       final String authorization) {
         final FetchDescendantsOption fetchDescendantsOption =
                 FetchDescendantsOption.getFetchDescendantsOption(includeDescendants);
-
-        final Map<String, Object> dataNodes = cpsFacade.getDataNodesByAnchorV3(resolveDatastoreName(cmResourceAddress),
-                cmResourceAddress.resolveCmHandleReferenceToId(), cmResourceAddress.getResourceIdentifier(),
+        validateDatastore(cmResourceAddress.datastoreName());
+        final Map<String, Object> dataNodes = cpsFacade.getDataNodesByAnchorV3(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
+                cmResourceAddress.resolveCmHandleReferenceToId(), cmResourceAddress.resourceIdentifier(),
                 fetchDescendantsOption);
         return Mono.justOrEmpty(dataNodes);
     }
 
-    private String resolveDatastoreName(final CmResourceAddress cmResourceAddress) {
-        final String datastoreName = cmResourceAddress.getDatastoreName();
-        if (datastoreName.equals(OPERATIONAL.getDatastoreName())) {
-            return NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME;
-        }
-        throw new IllegalArgumentException(
+    private void validateDatastore(final String datastoreName) {
+        if (!datastoreName.equals(OPERATIONAL.getDatastoreName())) {
+            throw new IllegalArgumentException(
                 "Unsupported datastore name provided to fetch the cached data: " + datastoreName);
+        }
     }
 
 }
index 8920839..276b56c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2024 Nordix Foundation
+ *  Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ public class NcmpPassthroughResourceRequestHandler extends NcmpDatastoreRequestH
      * @param topic                 the topic param in query
      * @param dataOperationRequest  data operation request details for resource data
      * @param authorization         contents of Authorization header, or null if not present
-     * @return a map with one entry of request Id for success or status and error when async feature is disabled
+     * @return a map with one entry of request id for success or status and error when async feature is disabled
      */
     public Map<String, String> executeAsynchronousRequest(final String topic,
                                                           final DataOperationRequest dataOperationRequest,
index ab20fa1..73bd1e7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2021 highstreet technologies GmbH
- *  Modifications Copyright (C) 2021-2024 Nordix Foundation
+ *  Modifications Copyright (C) 2021-2025 OpenInfra Foundation Europe.
  *  Modifications Copyright (C) 2021 Pantheon.tech
  *  Modifications Copyright (C) 2021-2022 Bell Canada
  *  Modifications Copyright (C) 2023 TechMahindra Ltd.
@@ -67,7 +67,7 @@ public class NetworkCmProxyFacade {
                                              final String authorization) {
 
         final NcmpDatastoreRequestHandler ncmpDatastoreRequestHandler
-            = getNcmpDatastoreRequestHandler(cmResourceAddress.getDatastoreName());
+            = getNcmpDatastoreRequestHandler(cmResourceAddress.datastoreName());
         return ncmpDatastoreRequestHandler.executeRequest(cmResourceAddress, optionsParamInQuery,
             topicParamInQuery, includeDescendants, authorization);
     }
@@ -78,7 +78,7 @@ public class NetworkCmProxyFacade {
      * @param topic                    the topic param in query
      * @param dataOperationRequest     data operation request details for resource data
      * @param authorization            contents of Authorization header, or null if not present
-     * @return a map with one entry of request Id for success or status and error when async feature is disabled
+     * @return a map with one entry of request id for success or status and error when async feature is disabled
      */
     public Object executeDataOperationForCmHandles(final String topic,
                                                    final DataOperationRequest dataOperationRequest,
index 2615672..cb15bca 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
+ * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,8 +47,7 @@ public class RecordFilterStrategies {
      */
     @Bean
     public RecordFilterStrategy<String, CloudEvent> includeDataOperationEventsOnly() {
-        return consumerRecord ->
-                isNotCloudEventOfType(consumerRecord.headers(), "DataOperationEvent");
+        return consumerRecord -> isNotCloudDataOperationEvent(consumerRecord.headers());
     }
 
     /**
@@ -66,12 +65,12 @@ public class RecordFilterStrategies {
         return headers.lastHeader("ce_type") != null;
     }
 
-    private boolean isNotCloudEventOfType(final Headers headers, final String requiredEventType) {
+    private boolean isNotCloudDataOperationEvent(final Headers headers) {
         final String eventTypeHeaderValue = KafkaHeaders.getParsedKafkaHeader(headers, "ce_type");
         if (eventTypeHeaderValue == null) {
             log.trace("No ce_type header found, possibly a legacy event (ignored)");
             return EXCLUDE_EVENT;
         }
-        return !(eventTypeHeaderValue.contains(requiredEventType));
+        return !(eventTypeHeaderValue.contains("DataOperationEvent"));
     }
 }
index 6e69a5c..e9d83aa 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -60,6 +60,7 @@ public class PolicyExecutor {
     @Value("${ncmp.policy-executor.defaultDecision:deny}")
     private String defaultDecision;
 
+    @SuppressWarnings("HttpUrlsUsage")
     @Value("${ncmp.policy-executor.server.address:http://policy-executor}")
     private String serverAddress;
 
index 0946eae..6fddd9e 100644 (file)
@@ -141,6 +141,7 @@ public class DmiDataOperationsHelper {
         if (!cmHandleIdsPerResponseCodesPerOperation.isEmpty()) {
             final CloudEvent dataOperationCloudEvent = DataOperationEventCreator.createDataOperationEvent(clientTopic,
                     requestId, cmHandleIdsPerResponseCodesPerOperation);
+            @SuppressWarnings("unchecked")
             final EventsProducer<CloudEvent> eventsProducer = CpsApplicationContext.getCpsBean(EventsProducer.class);
             log.warn("sending error message to client topic: {} ,requestId: {}, data operation cloud event id: {}",
                     clientTopic, requestId, dataOperationCloudEvent.getId());
index 56352c1..d4ffada 100644 (file)
@@ -48,7 +48,9 @@ public class DataJobServiceImpl implements DataJobService {
                             final String dataJobId,
                             final DataJobMetadata dataJobMetadata,
                             final DataJobReadRequest dataJobReadRequest) {
-        log.info("data job id for read operation is: {}", dataJobId);
+        logJobIdAndSize(dataJobId, dataJobReadRequest.data().size());
+        log.info("Destination: {}", dataJobMetadata.destination());
+        log.info("authorization: {}", authorization);
     }
 
     @Override
@@ -56,8 +58,7 @@ public class DataJobServiceImpl implements DataJobService {
                                                   final String dataJobId,
                                                   final DataJobMetadata dataJobMetadata,
                                                   final DataJobWriteRequest dataJobWriteRequest) {
-
-        log.info("Data Job ID: {} - Total operations received: {}", dataJobId, dataJobWriteRequest.data().size());
+        logJobIdAndSize(dataJobId, dataJobWriteRequest.data().size());
         logJsonRepresentation("Initiating WRITE operation for Data Job ID: " + dataJobId, dataJobWriteRequest);
 
         final Map<ProducerKey, List<DmiWriteOperation>> dmiWriteOperationsPerProducerKey =
@@ -71,10 +72,15 @@ public class DataJobServiceImpl implements DataJobService {
         return subJobWriteResponses;
     }
 
+    private void logJobIdAndSize(final String dataJobId, final int numberOfOperations) {
+        log.info("Data Job ID: {} - Total operations received: {}", dataJobId, numberOfOperations);
+    }
+
     private void logJsonRepresentation(final String description, final Object object) {
         if (log.isDebugEnabled()) {
             final String objectAsJsonString = jsonObjectMapper.asJsonString(object);
             log.debug("{} (JSON): {}", description, objectAsJsonString);
         }
     }
+
 }
index 5a62667..a8edbd1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2024-2025 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -79,6 +79,7 @@ public class DmiSubJobRequestHandler {
                     jsonObjectMapper.asJsonString(subJobWriteRequest),
                     OperationType.CREATE,
                     authorization);
+            @SuppressWarnings("unchecked")
             final Map<String, String> responseAsKeyValuePairs = jsonObjectMapper
                     .convertToValueType(responseEntity.getBody(), Map.class);
             final String subJobId = responseAsKeyValuePairs.get("subJobId");
index 6d35f37..868bedd 100644 (file)
@@ -61,6 +61,6 @@ public class DmiServiceNameOrganizer {
     private static Map<String, String> additionalPropertiesAsMap(
         final List<YangModelCmHandle.Property> additionalProperties) {
         return additionalProperties.stream().collect(
-                Collectors.toMap(YangModelCmHandle.Property::getName, YangModelCmHandle.Property::getValue));
+                Collectors.toMap(YangModelCmHandle.Property::name, YangModelCmHandle.Property::value));
     }
 }
index c441d4d..af9d512 100644 (file)
@@ -75,24 +75,6 @@ public interface CmHandleQueryService {
      */
     Collection<DataNode> queryCmHandleAncestorsByCpsPath(String cpsPath, FetchDescendantsOption fetchDescendantsOption);
 
-    /**
-     * Method to return data nodes representing the cm handles.
-     *
-     * @param cpsPath cps path for which the cmHandle is requested
-     * @return a list of data nodes representing the cm handles.
-     */
-    Collection<DataNode> queryNcmpRegistryByCpsPath(String cpsPath, FetchDescendantsOption fetchDescendantsOption);
-
-    /**
-     * Method to return data nodes representing the cm handles.
-     *
-     * @param cpsPath cps path for which the cmHandle is requested
-     * @param queryResultLimit the maximum number of data nodes to return; if less than 1, returns all matching nodes
-     * @return a list of data nodes representing the cm handles.
-     */
-    Collection<DataNode> queryNcmpRegistryByCpsPath(String cpsPath, FetchDescendantsOption fetchDescendantsOption,
-                                                    int queryResultLimit);
-
     /**
      * Method to check the state of a cm handle with given id.
      *
index dae2f45..b624eb8 100644 (file)
@@ -99,20 +99,6 @@ public class CmHandleQueryServiceImpl implements CmHandleQueryService {
                 .toList();
     }
 
-    @Override
-    public Collection<DataNode> queryNcmpRegistryByCpsPath(final String cpsPath,
-                                                           final FetchDescendantsOption fetchDescendantsOption) {
-        return queryNcmpRegistryByCpsPath(cpsPath, fetchDescendantsOption, NO_LIMIT);
-    }
-
-    @Override
-    public Collection<DataNode> queryNcmpRegistryByCpsPath(final String cpsPath,
-                                                           final FetchDescendantsOption fetchDescendantsOption,
-                                                           final int queryResultLimit) {
-        return cpsQueryService.queryDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath,
-                fetchDescendantsOption, queryResultLimit);
-    }
-
     @Override
     public Collection<DataNode> queryCmHandleAncestorsByCpsPath(final String cpsPath,
                                                                 final FetchDescendantsOption fetchDescendantsOption) {
@@ -267,4 +253,11 @@ public class CmHandleQueryServiceImpl implements CmHandleQueryService {
         return cpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
                 xpath, OMIT_DESCENDANTS).iterator().next();
     }
+
+    private Collection<DataNode> queryNcmpRegistryByCpsPath(final String cpsPath,
+                                                            final FetchDescendantsOption fetchDescendantsOption) {
+        return cpsQueryService.queryDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath,
+            fetchDescendantsOption, NO_LIMIT);
+    }
+
 }
index d380668..391fd6a 100644 (file)
@@ -124,8 +124,7 @@ public class CmHandleRegistrationService {
         if (CmHandleState.READY.equals(compositeState.getCmHandleState())) {
             final DataStoreSyncState dataStoreSyncState = compositeState.getDataStores()
                 .getOperationalDataStore().getDataStoreSyncState();
-            if (Boolean.FALSE.equals(dataSyncEnabledTargetValue)
-                && DataStoreSyncState.SYNCHRONIZED.equals(dataStoreSyncState)) {
+            if (!dataSyncEnabledTargetValue && DataStoreSyncState.SYNCHRONIZED.equals(dataStoreSyncState)) {
                 // TODO : This is hard-coded for onap dmi that need to be addressed
                 cpsDataService.deleteDataNode(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId,
                     "/netconf-state", OffsetDateTime.now());
index ecf27a3..7bd7c8e 100644 (file)
@@ -133,16 +133,6 @@ public interface InventoryPersistence extends NcmpPersistence {
     Collection<DataNode> getCmHandleDataNodeByCmHandleId(String cmHandleId,
                                                          FetchDescendantsOption fetchDescendantsOption);
 
-    /**
-     * Get collection of data nodes of given cm handles.
-     *
-     * @param cmHandleIds collection of cmHandle IDs
-     * @param fetchDescendantsOption fetch descendants option
-     * @return collection of data nodes
-     */
-    Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds,
-                                              FetchDescendantsOption fetchDescendantsOption);
-
     /**
      * get CM handles that has given module names.
      *
index e06a46e..d024072 100644 (file)
@@ -58,7 +58,7 @@ import org.springframework.stereotype.Component;
 @Component
 public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements InventoryPersistence {
 
-    private static final int CMHANDLE_BATCH_SIZE = 300;
+    private static final int CM_HANDLE_BATCH_SIZE = 300;
 
     private final CpsModuleService cpsModuleService;
     private final CpsValidator cpsValidator;
@@ -154,7 +154,7 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
     @Override
     public void saveCmHandleBatch(final List<YangModelCmHandle> yangModelCmHandles) {
         for (final List<YangModelCmHandle> yangModelCmHandleBatch :
-                Lists.partition(yangModelCmHandles, CMHANDLE_BATCH_SIZE)) {
+                Lists.partition(yangModelCmHandles, CM_HANDLE_BATCH_SIZE)) {
             final String cmHandlesJsonData = createCmHandlesJsonData(yangModelCmHandleBatch);
             cpsDataService.saveListElements(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
                     NCMP_DMI_REGISTRY_PARENT, cmHandlesJsonData, NO_TIMESTAMP, ContentType.JSON);
@@ -167,14 +167,6 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
         return this.getDataNode(getXPathForCmHandleById(cmHandleId), fetchDescendantsOption);
     }
 
-    @Override
-    public Collection<DataNode> getCmHandleDataNodes(final Collection<String> cmHandleIds,
-                                                     final FetchDescendantsOption fetchDescendantsOption) {
-        final Collection<String> xpaths = new ArrayList<>(cmHandleIds.size());
-        cmHandleIds.forEach(cmHandleId -> xpaths.add(getXPathForCmHandleById(cmHandleId)));
-        return this.getDataNodes(xpaths, fetchDescendantsOption);
-    }
-
     @Override
     public Collection<String> getCmHandleReferencesWithGivenModules(final Collection<String> moduleNamesForQuery,
                                                                     final boolean outputAlternateId) {
@@ -233,4 +225,11 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
         return YangDataConverter.toYangModelCmHandles(getCmHandleDataNodes(validCmHandleIds, fetchDescendantsOption));
     }
 
+    private Collection<DataNode> getCmHandleDataNodes(final Collection<String> cmHandleIds,
+                                                      final FetchDescendantsOption fetchDescendantsOption) {
+        final Collection<String> xpaths = new ArrayList<>(cmHandleIds.size());
+        cmHandleIds.forEach(cmHandleId -> xpaths.add(getXPathForCmHandleById(cmHandleId)));
+        return this.getDataNodes(xpaths, fetchDescendantsOption);
+    }
+
 }
index f327eda..f9b9dcc 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 Nordix Foundation
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,29 +57,11 @@ public interface NcmpPersistence {
      */
     Collection<DataNode> getDataNode(String xpath, FetchDescendantsOption fetchDescendantsOption);
 
-    /**
-     * Get collection of data nodes via xpaths.
-     *
-     * @param xpaths collection of xpaths
-     * @return collection of data nodes
-     */
-    Collection<DataNode> getDataNodes(Collection<String> xpaths);
-
-    /**
-     * Get collection of data nodes via xpaths.
-     *
-     * @param xpaths                 collection of xpaths
-     * @param fetchDescendantsOption fetch descendants option
-     * @return collection of data nodes
-     */
-    Collection<DataNode> getDataNodes(Collection<String> xpaths,
-                                              FetchDescendantsOption fetchDescendantsOption);
-
     /**
      * Replaces list content by removing all existing elements and inserting the given new elements as data nodes.
      *
      * @param parentNodeXpath parent node xpath
-     * @param dataNodes       datanodes representing the updated data
+     * @param dataNodes       data nodes representing the updated data
      */
     void replaceListContent(String parentNodeXpath, Collection<DataNode> dataNodes);
 
index 2232d7c..97112ba 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2023-2025 Nordix Foundation
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -61,12 +61,6 @@ public class NcmpPersistenceImpl implements NcmpPersistence {
                 fetchDescendantsOption);
     }
 
-    @Override
-    public Collection<DataNode> getDataNodes(final Collection<String> xpaths) {
-        return getDataNodes(xpaths, INCLUDE_ALL_DESCENDANTS);
-    }
-
-    @Override
     public Collection<DataNode> getDataNodes(final Collection<String> xpaths,
                                              final FetchDescendantsOption fetchDescendantsOption) {
         return cpsDataService.getDataNodesForMultipleXpaths(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, xpaths,
index 68d97fb..a34a89f 100644 (file)
@@ -225,18 +225,19 @@ public class ParameterizedCmHandleQueryServiceImpl implements ParameterizedCmHan
     }
 
     private Collection<NcmpServiceCmHandle> getNcmpServiceCmHandleBatch(final Collection<String> cmHandleIds) {
-        final Collection<YangModelCmHandle> yangModelcmHandles
+        final Collection<YangModelCmHandle> yangModelCmHandles
                 = inventoryPersistence.getYangModelCmHandles(cmHandleIds);
 
-        final Collection<NcmpServiceCmHandle> ncmpServiceCmHandles = new ArrayList<>(yangModelcmHandles.size());
+        final Collection<NcmpServiceCmHandle> ncmpServiceCmHandles = new ArrayList<>(yangModelCmHandles.size());
 
-        yangModelcmHandles.forEach(yangModelcmHandle ->
+        yangModelCmHandles.forEach(yangModelcmHandle ->
                 ncmpServiceCmHandles.add(YangDataConverter.toNcmpServiceCmHandle(yangModelcmHandle))
         );
         trustLevelManager.applyEffectiveTrustLevels(ncmpServiceCmHandles);
         return ncmpServiceCmHandles;
     }
 
+    @SafeVarargs
     private Collection<String> executeQueries(final CmHandleQueryServiceParameters cmHandleQueryServiceParameters,
                                               final boolean outputAlternateId,
                                               final BiFunction<CmHandleQueryServiceParameters, Boolean,
index e9c4957..136e473 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2023 Nordix Foundation
+ *  Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 
 package org.onap.cps.ncmp.impl.inventory.models;
 
+import lombok.Getter;
+
+@Getter
 public enum ModelledDmiServiceLeaves {
     DMI_SERVICE_NAME("dmi-service-name"),
     DMI_DATA_SERVICE_NAME("dmi-data-service-name"),
     DMI_MODEL_SERVICE_NAME("dmi-model-service-name");
 
-    private String leafName;
+    private final String leafName;
 
     ModelledDmiServiceLeaves(final String dmiPluginIdentifierKey) {
         this.leafName = dmiPluginIdentifierKey;
     }
 
-    public String getLeafName() {
-        return leafName;
-    }
-
 }
index 21ffb39..18e2ef9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2024 Nordix Foundation
+ *  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -26,8 +26,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import lombok.AllArgsConstructor;
-import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
@@ -155,15 +153,6 @@ public class YangModelCmHandle {
         return yangModelCmHandleProperties;
     }
 
-    @AllArgsConstructor
-    @Data
-    public static class Property {
-
-        @JsonProperty()
-        private final String name;
-
-        @JsonProperty()
-        private final String value;
-    }
+    public record Property(@JsonProperty() String name, @JsonProperty() String value) { }
 
 }
index 59a99ea..4843b8e 100644 (file)
@@ -49,6 +49,7 @@ import org.springframework.stereotype.Service;
 /**
  * Operations class for DMI Model.
  */
+@SuppressWarnings({"ALL", "rawtypes"})
 @RequiredArgsConstructor
 @Service
 public class DmiModelOperations {
@@ -156,7 +157,7 @@ public class DmiModelOperations {
                                                additionalProperties) {
         final JsonObject asJsonObject = new JsonObject();
         for (final YangModelCmHandle.Property additionalProperty : additionalProperties) {
-            asJsonObject.addProperty(additionalProperty.getName(), additionalProperty.getValue());
+            asJsonObject.addProperty(additionalProperty.name(), additionalProperty.value());
         }
         return asJsonObject;
     }
index c05944f..23fa917 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START========================================================
- *  Copyright (C) 2022-2025 Nordix Foundation
+ *  Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -34,13 +34,13 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class SynchronizationCacheConfig extends HazelcastCacheConfig {
 
-    public static final int MODULE_SYNC_STARTED_TTL_SECS = 600;
     public static final int DATA_SYNC_SEMAPHORE_TTL_SECS = 1800;
 
+    private static final int MODULE_SYNC_STARTED_TTL_SECS = 600;
+
     private static final QueueConfig commonQueueConfig = createQueueConfig("defaultQueueConfig");
-    private static final MapConfig moduleSyncStartedConfig =
-            createMapConfigWithTimeToLiveInSeconds("moduleSyncStartedConfig", MODULE_SYNC_STARTED_TTL_SECS);
-    private static final MapConfig dataSyncSemaphoresConfig = createMapConfig("dataSyncSemaphoresConfig");
+    private static final MapConfig moduleSyncStartedConfig =  createModuleSyncStartedMapConfig();
+    private static final MapConfig dataSyncSemaphoresConfig = createGenericMapConfig("dataSyncSemaphoresConfig");
 
     /**
      * Module Sync Distributed Queue Instance.
@@ -72,4 +72,10 @@ public class SynchronizationCacheConfig extends HazelcastCacheConfig {
         return getOrCreateHazelcastInstance(dataSyncSemaphoresConfig).getMap("dataSyncSemaphores");
     }
 
+    private static MapConfig createModuleSyncStartedMapConfig() {
+        final MapConfig mapConfig = createGenericMapConfig("moduleSyncStartedConfig");
+        mapConfig.setTimeToLiveSeconds(MODULE_SYNC_STARTED_TTL_SECS);
+        return mapConfig;
+    }
+
 }
index 3d8e8b6..5912324 100644 (file)
@@ -60,7 +60,7 @@ public class CmHandleStateMonitor {
             final String stateMetricKey = cmHandleStateAsString + METRIC_POSTFIX;
             final int cmHandleCountForState =  cmHandleQueryService.queryCmHandleIdsByState(cmHandleState).size();
             cmHandlesByState.putIfAbsent(stateMetricKey, cmHandleCountForState);
-            log.info("Cm handle state monitor has set " + stateMetricKey + " to " + cmHandleCountForState);
+            log.info("Cm handle state monitor has set {} to {}", stateMetricKey, cmHandleCountForState);
         }
     }
 
@@ -122,5 +122,4 @@ public class CmHandleStateMonitor {
         }
     }
 
-
-}
\ No newline at end of file
+}
index 521da0c..4ee6e73 100644 (file)
@@ -63,7 +63,7 @@ public class LcmEventsProducer {
      * Sends an LCM event to the dedicated topic with optional notification headers.
      * Capture and log KafkaException If an error occurs while sending the event to Kafka
      *
-     * @param cmHandleId     Cm Handle Id associated with the LCM event
+     * @param cmHandleId     CM handle id associated with the LCM event
      * @param lcmEvent       The LCM event object to be sent
      * @param lcmEventHeader Optional headers associated with the LCM event
      */
@@ -72,6 +72,7 @@ public class LcmEventsProducer {
         if (notificationsEnabled) {
             final Timer.Sample timerSample = Timer.start(meterRegistry);
             try {
+                @SuppressWarnings("unchecked")
                 final Map<String, Object> lcmEventHeadersMap =
                         jsonObjectMapper.convertToValueType(lcmEventHeader, Map.class);
                 eventsProducer.sendEvent(topicName, cmHandleId, lcmEventHeadersMap, lcmEvent);
index 44befab..9622a8f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2023 Nordix Foundation
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -53,8 +53,10 @@ public class DeviceTrustLevelMessageConsumer {
 
         final DeviceTrustLevel deviceTrustLevel =
             CloudEventMapper.toTargetEvent(consumerRecord.value(), DeviceTrustLevel.class);
-        final String trustLevelAsString = deviceTrustLevel.getData().getTrustLevel();
-        trustLevelManager.updateCmHandleTrustLevel(cmHandleId, TrustLevel.valueOf(trustLevelAsString));
+        if (deviceTrustLevel != null) {
+            final String trustLevelAsString = deviceTrustLevel.getData().getTrustLevel();
+            trustLevelManager.updateCmHandleTrustLevel(cmHandleId, TrustLevel.valueOf(trustLevelAsString));
+        }
     }
 
 }
index 779024b..3fc4b05 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START========================================================
- *  Copyright (C) 2023-2024 Nordix Foundation
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 package org.onap.cps.ncmp.impl.inventory.trustlevel;
 
 import com.hazelcast.config.MapConfig;
+import com.hazelcast.config.NearCacheConfig;
 import com.hazelcast.map.IMap;
 import org.onap.cps.ncmp.api.inventory.models.TrustLevel;
 import org.onap.cps.ncmp.impl.cache.HazelcastCacheConfig;
@@ -34,10 +35,10 @@ public class TrustLevelCacheConfig extends HazelcastCacheConfig {
 
     public static final String TRUST_LEVEL_PER_CM_HANDLE = "trustLevelPerCmHandle";
     private static final MapConfig trustLevelPerCmHandleIdNearCacheConfig =
-            createNearCacheMapConfig("trustLevelPerCmHandleCacheConfig");
+        createMapConfigsWithNearCache();
 
     private static final MapConfig trustLevelPerDmiPluginCacheConfig =
-            createMapConfig("trustLevelPerDmiPluginCacheConfig");
+        createGenericMapConfig("trustLevelPerDmiPluginCacheConfig");
 
     /**
      * Distributed instance of trust level cache containing the trust level per cm handle.
@@ -60,4 +61,10 @@ public class TrustLevelCacheConfig extends HazelcastCacheConfig {
                 trustLevelPerDmiPluginCacheConfig).getMap(TRUST_LEVEL_PER_DMI_PLUGIN);
     }
 
+    private static MapConfig createMapConfigsWithNearCache() {
+        final MapConfig mapConfig = createGenericMapConfig("trustLevelPerCmHandleCacheConfig");
+        mapConfig.setNearCacheConfig(new NearCacheConfig("trustLevelPerCmHandleCacheConfig"));
+        return mapConfig;
+    }
+
 }
index 2989b3d..0e88d42 100644 (file)
@@ -55,7 +55,7 @@ public class DmiRequestBody {
         final List<YangModelCmHandle.Property> yangModelCmHandleProperties) {
         additionalProperties = new LinkedHashMap<>();
         for (final YangModelCmHandle.Property additionalProperty : yangModelCmHandleProperties) {
-            additionalProperties.put(additionalProperty.getName(), additionalProperty.getValue());
+            additionalProperties.put(additionalProperty.name(), additionalProperty.value());
         }
     }
 
index c0c4f73..cb85205 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation
+ *  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
 package org.onap.cps.ncmp.impl.models;
 
 /**
- * Enmm to determine if the required service is for a data or model operation.
+ * Enum to determine if the required service is for a data or model operation.
  */
 public enum RequiredDmiService {
     DATA, MODEL
index e2b39e5..f9707aa 100644 (file)
@@ -117,7 +117,7 @@ public class AlternateIdMatcher {
     }
 
     /**
-     * Get cm handle Id from given cmHandleReference.
+     * Get cm handle id from given cmHandleReference.
      *
      * @param cmHandleReference cm handle or alternate identifier
      * @return cm handle id string
index 07945d9..8d7ac9f 100644 (file)
@@ -72,7 +72,7 @@ public class YangDataConverter {
     public static Map<String, String> toPropertiesMap(final List<YangModelCmHandle.Property> properties) {
         final Map<String, String> propertiesMap = new LinkedHashMap<>(properties.size());
         for (final YangModelCmHandle.Property property : properties) {
-            propertiesMap.put(property.getName(), property.getValue());
+            propertiesMap.put(property.name(), property.value());
         }
         return propertiesMap;
     }
@@ -111,12 +111,11 @@ public class YangDataConverter {
     /**
      * This method extracts cm handle id from xpath of data node.
      * @param xpath for data node of the cm handle
-     * @return cm handle Id
+     * @return cm handle id or null if no id can be found
      */
     public static String extractCmHandleIdFromXpath(final String xpath) {
         final Matcher matcher = cmHandleIdInXpathPattern.matcher(xpath);
-        matcher.find();
-        return matcher.group(1);
+        return matcher.find() ? matcher.group(1) : null;
     }
 
 
index 32d4257..659dcf5 100644 (file)
@@ -91,7 +91,7 @@ public class RestServiceUrlTemplateBuilder {
     /**
      * Constructs a URL template with variables based on the accumulated path segments and query parameters.
      *
-     * @param serviceBaseUrl the base URL of the service, e.g., "http://dmi-service.com".
+     * @param serviceBaseUrl the base URL of the service, e.g., "<a href="http://dmi-service.com">...</a>".
      * @param basePath       the base path of the service
      * @return a UrlTemplateParameters instance containing the complete URL template and URL variables
      */
@@ -120,7 +120,7 @@ public class RestServiceUrlTemplateBuilder {
     /**
      * Constructs a URL for a spring actuator health check based on the given base URL.
      *
-     * @param serviceBaseUrl the base URL of the service, e.g., "http://dmi-service.com".
+     * @param serviceBaseUrl the base URL of the service, e.g., "<a href="http://dmi-service.com">...</a>".
      * @return a {@link UrlTemplateParameters} instance containing the complete URL template and empty URL variables,
      *     suitable for DMI health check.
      */
index 8daf82f..c70e30e 100644 (file)
@@ -25,7 +25,7 @@ module dmi-registry {
 
   revision "2022-05-10" {
     description
-    "Added data-sync-enabled, sync-state with state, last-sync-time, data-store-sync-state with operational and running syncstate";
+    "Added data-sync-enabled, sync-state with state, last-sync-time, data-store-sync-state with operational and running sync-state";
   }
 
   revision "2022-02-10" {
index c49af0f..2a98592 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada
- *  Modifications Copyright (C) 2023-2025 Nordix Foundation
+ *  Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -46,10 +46,9 @@ class CmHandleRegistrationResponseSpec extends Specification {
 
     def 'Failed cm-handle Registration Response: for unexpected exception'() {
         when: 'cm-handle response is created for an unexpected exception'
-            def cmHandleRegistrationResponse =
-                CmHandleRegistrationResponse.createFailureResponse('cmHandle', new Exception('unexpected error'))
+            def result = CmHandleRegistrationResponse.createFailureResponse('cmHandle', new Exception('unexpected error'))
         then: 'the response is created with expected value'
-            with(cmHandleRegistrationResponse) {
+            with(result) {
                 assert it.ncmpResponseStatus == UNKNOWN_ERROR
                 assert it.cmHandle == 'cmHandle'
                 assert errorText == 'unexpected error'
@@ -58,44 +57,39 @@ class CmHandleRegistrationResponseSpec extends Specification {
 
     def 'Failed cm-handle Registration Response'() {
         when: 'cm-handle failure response is created'
-        def cmHandleRegistrationResponse =
-                CmHandleRegistrationResponse.createFailureResponse('cmHandle', CM_HANDLE_ALREADY_EXIST)
+        def result = CmHandleRegistrationResponse.createFailureResponse('cmHandle', CM_HANDLE_ALREADY_EXIST)
         then: 'the response is created with expected value'
-        with(cmHandleRegistrationResponse) {
-            assert it.ncmpResponseStatus == CM_HANDLE_ALREADY_EXIST
-            assert it.cmHandle == 'cmHandle'
-            assert it.status == Status.FAILURE
-            assert errorText == CM_HANDLE_ALREADY_EXIST.message
-        }
+            with(result) {
+                assert it.ncmpResponseStatus == CM_HANDLE_ALREADY_EXIST
+                assert it.cmHandle == 'cmHandle'
+                assert it.status == Status.FAILURE
+                assert errorText == CM_HANDLE_ALREADY_EXIST.message
+            }
     }
 
     def 'Failed cm-handle Registration with multiple responses.'() {
         when: 'cm-handle failure response is created for 2 xpaths'
-            def cmHandleRegistrationResponses =
-                CmHandleRegistrationResponse.createFailureResponsesFromXpaths(["somePathWithId[@id='123']", "somePathWithId[@id='456']"], CM_HANDLE_ALREADY_EXIST)
+            def result = CmHandleRegistrationResponse.createFailureResponsesFromXpaths(["somePathWithId[@id='123']", "somePathWithId[@id='456']"], CM_HANDLE_ALREADY_EXIST)
         then: 'the response has the correct cm handle ids'
-            assert cmHandleRegistrationResponses.size() == 2
-            assert cmHandleRegistrationResponses.stream().map(it -> it.cmHandle).collect(Collectors.toList())
-                .containsAll(['123','456'])
+            assert result.size() == 2
+            assert result.stream().map(it -> it.cmHandle).collect(Collectors.toList()).containsAll(['123','456'])
     }
 
     def 'Failed cm-handle Registration with multiple responses with an unexpected xpath.'() {
         when: 'cm-handle failure response is created for one valid and one unexpected xpath'
-            def cmHandleRegistrationResponses =
-                CmHandleRegistrationResponse.createFailureResponsesFromXpaths(["somePathWithId[@id='123']", "valid/xpath/without-id[@key='123']"], CM_HANDLE_ALREADY_EXIST)
+            def result =  CmHandleRegistrationResponse.createFailureResponsesFromXpaths(["somePathWithId[@id='123']", "valid/xpath/without-id[@key='123']"], CM_HANDLE_ALREADY_EXIST)
         then: 'the response has only one entry'
-            assert cmHandleRegistrationResponses.size() == 1
+            assert result.size() == 1
     }
 
     def 'Failed cm-handle registration based on cm handle id and registration error'() {
         when: 'the failure response is created with "cm-handle already exists" error code for 1 cm handle'
-            def cmHandleRegistrationResponses =
-                    CmHandleRegistrationResponse.createFailureResponses(['ch 1'], CM_HANDLE_ALREADY_EXIST)
+            def result = CmHandleRegistrationResponse.createFailureResponses(['ch 1'], CM_HANDLE_ALREADY_EXIST)
         then: 'the response with expected values'
-            assert cmHandleRegistrationResponses[0].cmHandle == 'ch 1'
-            assert cmHandleRegistrationResponses[0].status == Status.FAILURE
-            assert cmHandleRegistrationResponses[0].ncmpResponseStatus == CM_HANDLE_ALREADY_EXIST
-            assert cmHandleRegistrationResponses[0].errorText == 'cm-handle already exists'
+            assert result[0].cmHandle == 'ch 1'
+            assert result[0].status == Status.FAILURE
+            assert result[0].ncmpResponseStatus == CM_HANDLE_ALREADY_EXIST
+            assert result[0].errorText == 'cm-handle already exists'
     }
 
 }
index 0026d7c..f021930 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2023-2025 Nordix Foundation
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
 
 package org.onap.cps.ncmp.impl.cache
 
-
 import com.hazelcast.core.Hazelcast
 import spock.lang.Specification
 
@@ -54,7 +53,7 @@ class HazelcastCacheConfigSpec extends Specification {
             }
         where: 'the following configs are used'
             scenario       | config                                                    || expectMapConfig | expectQueueConfig | expectSetConfig
-            'Map Config'   | HazelcastCacheConfig.createMapConfig('my map config')     || true            | false             | false
+            'Map Config'   | HazelcastCacheConfig.createGenericMapConfig('my map config') || true | false | false
             'Queue Config' | HazelcastCacheConfig.createQueueConfig('my queue config') || false           | true              | false
             'Set Config'   | HazelcastCacheConfig.createSetConfig('my set config')     || false           | false             | true
     }
index 9c24e2b..3b8fb0f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (c) 2024 Nordix Foundation.
+ * Copyright (c) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -59,10 +59,10 @@ class NcmpInEventConsumerSpec extends MessagingBaseSpec {
     }
 
 
-    def 'Consume valid CmNotificationSubscriptionNcmpInEvent create message'() {
+    def 'Consume valid CmNotificationSubscriptionNcmpInEvent create message.'() {
         given: 'a cmNotificationSubscription event'
             def jsonData = TestUtils.getResourceFileContent('cmSubscription/cmNotificationSubscriptionNcmpInEvent.json')
-            def testEventSent = jsonObjectMapper.convertJsonString(jsonData, NcmpInEvent.class)
+            def testEventSent = jsonObjectMapper.convertJsonString(jsonData, NcmpInEvent)
             def testCloudEventSent = CloudEventBuilder.v1()
                 .withData(objectMapper.writeValueAsBytes(testEventSent))
                 .withId('subscriptionCreated')
@@ -81,10 +81,10 @@ class NcmpInEventConsumerSpec extends MessagingBaseSpec {
             1 * mockCmSubscriptionHandler.processSubscriptionCreateRequest('test-id',_)
     }
 
-    def 'Consume valid CmNotificationSubscriptionNcmpInEvent delete message'() {
+    def 'Consume valid CmNotificationSubscriptionNcmpInEvent delete message.'() {
         given: 'a cmNotificationSubscription event'
             def jsonData = TestUtils.getResourceFileContent('cmSubscription/cmNotificationSubscriptionNcmpInEvent.json')
-            def testEventSent = jsonObjectMapper.convertJsonString(jsonData, NcmpInEvent.class)
+            def testEventSent = jsonObjectMapper.convertJsonString(jsonData, NcmpInEvent)
             def testCloudEventSent = CloudEventBuilder.v1()
                 .withData(objectMapper.writeValueAsBytes(testEventSent))
                 .withId('sub-id')
@@ -103,6 +103,21 @@ class NcmpInEventConsumerSpec extends MessagingBaseSpec {
             1 * mockCmSubscriptionHandler.processSubscriptionDeleteRequest('test-id')
     }
 
+    def 'Attempt to consume unsupported Event.'() {
+        given: 'a unsupported event with a valid supported type'
+            def unsupportedEvent = Mock(CloudEvent)
+            def cloudEventWithUnsupportedEvent = CloudEventBuilder.v1()
+                .withId('some id')
+                .withType('subscriptionCreateRequest') // this is valid but does not match the event object
+                .withSource(URI.create('some-resource'))
+                .withData(objectMapper.writeValueAsBytes(unsupportedEvent)).build()
+            def consumerRecord = new ConsumerRecord<String, CloudEvent>('some topic', 0, 0, 'some key', cloudEventWithUnsupportedEvent)
+        when: 'attempt to consume the unsupported event'
+            objectUnderTest.consumeSubscriptionEvent(consumerRecord)
+        then: 'the subscription handler service is not called at all'
+            0 * mockCmSubscriptionHandler.processSubscriptionDeleteRequest(*_)
+            0 * mockCmSubscriptionHandler.processSubscriptionCreateRequest(*_)
+    }
 
     def getLoggingEvent() {
         return logger.list[1]
index 5ff2a3b..af6dabf 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * ============LICENSE_START========================================================
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved
+ *  ================================================================================
+ *  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.impl.data.async
 
 import org.apache.kafka.common.header.Header
@@ -24,18 +44,18 @@ class RecordFilterStrategiesSpec extends Specification {
             'non-cloud event' | 'other'   || false
     }
 
-    def 'Excluding cloud event of given type only with  #scenario.'() {
+    def 'Excluding cloud event with header #scenario.'() {
         given: 'headers contain a header for key: #key and value: #value'
             header.value() >> value.getBytes(Charset.defaultCharset())
             headers.lastHeader(key) >> header
         expect: 'the event would (not) be excluded: #expectedToBeExcluded'
-            assert objectUnderTest.isNotCloudEventOfType(headers,'requiredType') == expectedToBeExcluded
+            assert objectUnderTest.isNotCloudDataOperationEvent(headers) == expectedToBeExcluded
         where: 'the following headers are defined'
-            scenario                | key       | value                            || expectedToBeExcluded
-            'required type'         | 'ce_type' | 'requiredType'                   || false
-            'contains requiredType' | 'ce_type' | 'Contains requiredType and more' || false
-            'other type'            | 'ce_type' | 'other'                          || true
-            'no ce_type header'     | 'other'   | 'irrelevant'                     || true
+            scenario                      | key       | value                                  || expectedToBeExcluded
+            'DataOperationEvent'          | 'ce_type' | 'DataOperationEvent'                   || false
+            'contains DataOperationEvent' | 'ce_type' | 'Contains DataOperationEvent and more' || false
+            'other type'                  | 'ce_type' | 'other'                                || true
+            'no ce_type header'           | 'other'   | 'irrelevant'                           || true
     }
 
 }
index 9f0e134..dcad514 100644 (file)
@@ -61,7 +61,7 @@ class DataJobServiceImplSpec extends Specification {
         then: 'the data job id is correctly logged'
             def loggingEvent = logger.list[0]
             assert loggingEvent.level == Level.INFO
-            assert loggingEvent.formattedMessage.contains('data job id for read operation is: my-job-id')
+            assert loggingEvent.formattedMessage.contains('Data Job ID: my-job-id')
     }
 
     def 'Write data-job request and verify logging when info enabled.'() {
index c7d0616..ff52483 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2023 Nordix Foundation
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
index b4966e1..46ab5d1 100755 (executable)
@@ -356,8 +356,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
         DuplicatedYangResourceException duplicatedYangResourceException = null;
 
         final Throwable cause = originalException.getCause();
-        if (cause instanceof ConstraintViolationException) {
-            final ConstraintViolationException constraintException = (ConstraintViolationException) cause;
+        if (cause instanceof final ConstraintViolationException constraintException) {
             if (YANG_RESOURCE_CHECKSUM_CONSTRAINT_NAME.equals(constraintException.getConstraintName())) {
                 // Db constraint related to yang resource checksum uniqueness is not respected
                 final String checksumInError = getDuplicatedChecksumFromException(constraintException);
index aef27a6..0eb7b37 100644 (file)
@@ -44,6 +44,7 @@ public class PolicyExecutorStubController implements OperationPermissionApi {
     private final Sleeper sleeper;
     private static final Pattern ERROR_CODE_PATTERN = Pattern.compile("(\\d{3})");
     private int decisionCounter = 0;
+    // Do NOT change below to final as it needs to be set during test
     private static int slowResponseTimeInSeconds = 40;
 
     @Override