From d275929c3548d4f858a321ff151c27af5bb3da0e Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Tue, 2 Sep 2025 16:55:15 +0100 Subject: [PATCH] Code Inspection WHOLE project - applied most of the simple/safe stuff - Many @suppress unchecked-warnings - Many @Serial annotations - A lot of copyrights updates! Issue-ID: CPS-2941 Change-Id: Id926ba1e9d7c6e0941355f89e5c736907e7af165 Signed-off-by: ToineSiebelink --- .../src/main/java/org/onap/cps/Application.java | 2 +- .../cps/startup/InstanceStartupDelayManager.java | 2 +- .../onap/cps/ncmp/events/NcmpEventDataSchema.java | 6 ++--- .../NetworkCmProxyInventoryController.java | 1 + .../rest/util/CountCmHandleSearchExecution.java | 1 + .../cps/cpspath/parser/PathParsingException.java | 4 ++- .../cps/rest/controller/AdminRestController.java | 27 ++++++++++---------- .../org/onap/cps/rest/utils/MultipartFileUtil.java | 6 ++--- .../onap/cps/rest/utils/ZipFileSizeValidator.java | 11 ++++---- .../cps/rest/utils/MultipartFileUtilSpec.groovy | 4 +-- .../cps/rest/utils/ZipFileSizeValidatorSpec.groovy | 8 +++--- .../onap/cps/ri/CpsDataPersistenceServiceImpl.java | 5 +++- .../java/org/onap/cps/ri/models/AnchorEntity.java | 4 ++- .../org/onap/cps/ri/models/DataspaceEntity.java | 4 ++- .../org/onap/cps/ri/models/FragmentEntity.java | 4 ++- .../org/onap/cps/ri/models/SchemaSetEntity.java | 3 +++ .../org/onap/cps/ri/models/YangResourceEntity.java | 4 ++- .../cps/ri/repository/FragmentQueryBuilder.java | 2 ++ .../repository/FragmentRepositoryCpsPathQuery.java | 2 +- .../FragmentRepositoryCpsPathQueryImpl.java | 8 ++++-- .../repository/ModuleReferenceRepositoryImpl.java | 3 ++- .../java/org/onap/cps/ri/utils/SessionManager.java | 9 ++++--- .../api/exceptions/AlreadyDefinedException.java | 10 +++++--- .../api/exceptions/AnchorNotFoundException.java | 5 +++- .../onap/cps/api/exceptions/CpsAdminException.java | 27 ++++++++++++-------- .../org/onap/cps/api/exceptions/CpsException.java | 26 +++++++++++-------- .../onap/cps/api/exceptions/CpsPathException.java | 27 +++++++++++--------- .../cps/api/exceptions/DataInUseException.java | 29 +++++++++++++--------- .../api/exceptions/DataNodeNotFoundException.java | 5 +++- .../api/exceptions/DataValidationException.java | 5 +++- .../api/exceptions/DataspaceInUseException.java | 5 +++- .../api/exceptions/DataspaceNotFoundException.java | 27 ++++++++++++-------- .../DuplicatedYangResourceException.java | 7 +++++- .../api/exceptions/ModelValidationException.java | 27 ++++++++++++-------- .../exceptions/ModuleNamesNotFoundException.java | 4 ++- .../exceptions/NotFoundInDataspaceException.java | 27 ++++++++++++-------- .../api/exceptions/SchemaSetInUseException.java | 29 +++++++++++++--------- .../api/exceptions/SchemaSetNotFoundException.java | 29 +++++++++++++--------- .../api/exceptions/SessionManagerException.java | 5 +++- .../api/exceptions/SessionTimeoutException.java | 5 +++- .../main/java/org/onap/cps/api/model/Anchor.java | 4 ++- .../main/java/org/onap/cps/api/model/DataNode.java | 4 ++- .../java/org/onap/cps/api/model/Dataspace.java | 3 +++ .../org/onap/cps/api/model/ModuleDefinition.java | 6 +++-- .../org/onap/cps/api/model/ModuleReference.java | 4 ++- .../java/org/onap/cps/api/model/SchemaSet.java | 4 ++- .../java/org/onap/cps/events/EventsProducer.java | 4 +-- .../java/org/onap/cps/impl/DataNodeBuilder.java | 10 +++----- .../cps/impl/YangTextSchemaSourceSetCache.java | 4 ++- .../main/java/org/onap/cps/utils/XmlFileUtils.java | 9 ++++--- .../java/org/onap/cps/utils/YangParserHelper.java | 4 ++- .../cps/yang/YangTextSchemaSourceSetBuilder.java | 4 +-- .../org/onap/cps/impl/DataNodeBuilderSpec.groovy | 8 ++---- .../controller/PolicyExecutorStubController.java | 8 +++--- 54 files changed, 303 insertions(+), 192 deletions(-) diff --git a/cps-application/src/main/java/org/onap/cps/Application.java b/cps-application/src/main/java/org/onap/cps/Application.java index 3c7750d528..7e06907b73 100644 --- a/cps-application/src/main/java/org/onap/cps/Application.java +++ b/cps-application/src/main/java/org/onap/cps/Application.java @@ -29,7 +29,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @Slf4j public class Application { - static InstanceStartupDelayManager instanceStartupDelayManager = new InstanceStartupDelayManager(); + static final InstanceStartupDelayManager instanceStartupDelayManager = new InstanceStartupDelayManager(); /** * The main method which serves as the entry point to the Spring Boot application. diff --git a/cps-application/src/main/java/org/onap/cps/startup/InstanceStartupDelayManager.java b/cps-application/src/main/java/org/onap/cps/startup/InstanceStartupDelayManager.java index 4ce94225e7..213fb341c5 100644 --- a/cps-application/src/main/java/org/onap/cps/startup/InstanceStartupDelayManager.java +++ b/cps-application/src/main/java/org/onap/cps/startup/InstanceStartupDelayManager.java @@ -47,7 +47,7 @@ public class InstanceStartupDelayManager { final Matcher matcher = HOST_NAME_WITH_SEQUENCE_PATTERN.matcher(hostName); final long startupDelayInMillis; if (matcher.matches()) { - startupDelayInMillis = Integer.valueOf(matcher.group(1)) * 2_000L; + startupDelayInMillis = Integer.parseInt(matcher.group(1)) * 2_000L; log.info("Sequenced host name detected, calculated delay = {} ms", startupDelayInMillis); } else { startupDelayInMillis = Math.abs(hostName.hashCode() % 10_000L); diff --git a/cps-ncmp-events/src/main/java/org/onap/cps/ncmp/events/NcmpEventDataSchema.java b/cps-ncmp-events/src/main/java/org/onap/cps/ncmp/events/NcmpEventDataSchema.java index 9cdb6d76ee..2a311796c5 100644 --- a/cps-ncmp-events/src/main/java/org/onap/cps/ncmp/events/NcmpEventDataSchema.java +++ b/cps-ncmp-events/src/main/java/org/onap/cps/ncmp/events/NcmpEventDataSchema.java @@ -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. @@ -27,9 +27,7 @@ public enum NcmpEventDataSchema { BATCH_RESPONSE_V1("urn:cps:org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent:1.0.0"), SUBSCRIPTIONS_V1("urn:cps:org.onap.ncmp.events.subscription:1.0.0"), - MOI_CHANGES_V1("urn:cps:org.onap.cps.ncmp.events.moi-changes:1.0.0"), - INVENTORY_EVENTS_V1("urn:cps:org.onap.cps.ncmp.events:inventory-event:1.0.0"), - CM_HANDLE_TRUST_LEVEL_V1("urn:cps:org.onap.cps.ncmp.dmi.events:cm-handle-trust-level:1.0.0"); + INVENTORY_EVENTS_V1("urn:cps:org.onap.cps.ncmp.events:inventory-event:1.0.0"); private final String dataSchema; diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java index c0744e91eb..3fbf0516e4 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java @@ -125,6 +125,7 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor * * @param restDmiPluginRegistration the registration data */ + @SuppressWarnings({"unchecked", "rawtypes"}) @Override @Timed(value = "cps.ncmp.inventory.controller.update", description = "Time taken to handle registration request") diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/CountCmHandleSearchExecution.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/CountCmHandleSearchExecution.java index d04a2ea515..e876068f76 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/CountCmHandleSearchExecution.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/CountCmHandleSearchExecution.java @@ -48,5 +48,6 @@ public @interface CountCmHandleSearchExecution { * * @return the description of the metric. */ + @SuppressWarnings("UnusedReturnValue") String description(); } diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/PathParsingException.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/PathParsingException.java index 4a67167c96..ef3f8d2c1d 100755 --- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/PathParsingException.java +++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/PathParsingException.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation + * 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. @@ -20,6 +20,7 @@ package org.onap.cps.cpspath.parser; +import java.io.Serial; import lombok.Getter; /** @@ -27,6 +28,7 @@ import lombok.Getter; */ public class PathParsingException extends RuntimeException { + @Serial private static final long serialVersionUID = 7072864354925271894L; @Getter diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java index 01a9746af0..f1215ba305 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2025 Nordix Foundation + * Copyright (C) 2020-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2020-2021 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022-2025 TechMahindra Ltd. @@ -68,7 +68,7 @@ public class AdminRestController implements CpsAdminApi { * Create a dataspace. * * @param dataspaceName dataspace name - * @return a {@Link ResponseEntity} of created dataspace name & {@link HttpStatus} CREATED + * @return a { {@code @Link} ResponseEntity } of created dataspace name & {@link HttpStatus} CREATED */ @Override public ResponseEntity createDataspace(@NotNull @Valid final String dataspaceName) { @@ -80,7 +80,7 @@ public class AdminRestController implements CpsAdminApi { * Create a dataspace without returning any response body. * * @param dataspaceName dataspace name - * @return a {@Link ResponseEntity} of created dataspace name & {@link HttpStatus} CREATED + * @return a { {@code @Link} ResponseEntity } of created dataspace name & {@link HttpStatus} CREATED */ @Override public ResponseEntity createDataspaceV2(@NotNull @Valid final String dataspaceName) { @@ -92,7 +92,7 @@ public class AdminRestController implements CpsAdminApi { * Delete a dataspace. * * @param dataspaceName name of dataspace to be deleted - * @return a {@Link ResponseEntity} of {@link HttpStatus} NO_CONTENT + * @return a { {@code @Link} ResponseEntity } of {@link HttpStatus} NO_CONTENT */ @Override public ResponseEntity deleteDataspace(final String apiVersion, final String dataspaceName) { @@ -106,7 +106,7 @@ public class AdminRestController implements CpsAdminApi { * @param dataspaceName dataspace name * @param schemaSetName schemaset name * @param multipartFile multipart file - * @return a {@Link ResponseEntity} of created schemaset name & {@link HttpStatus} CREATED + * @return a { {@code @Link} ResponseEntity } of created schemaset name & {@link HttpStatus} CREATED */ @Override public ResponseEntity createSchemaSet(final String dataspaceName, @@ -122,7 +122,8 @@ public class AdminRestController implements CpsAdminApi { * @param dataspaceName dataspace name * @param schemaSetName schemaset name * @param multipartFile multipart file - * @return a {@Link ResponseEntity} of created schema set without any response body & {@link HttpStatus} CREATED + * @return a { {@code @Link} ResponseEntity } of created schema set + * without any response body & {@link HttpStatus} CREATED */ @Override @Timed(value = "cps.rest.admin.controller.schemaset.create", @@ -140,7 +141,7 @@ public class AdminRestController implements CpsAdminApi { * @param apiVersion api version * @param dataspaceName dataspace name * @param schemaSetName schemaset name - * @return a {@Link ResponseEntity} of {@Link SchemaSetDetails} & {@link HttpStatus} OK + * @return a { {@code @Link} ResponseEntity } of { {@code @Link} SchemaSetDetails } & {@link HttpStatus} OK */ @Override public ResponseEntity getSchemaSet(final String apiVersion, @@ -155,7 +156,7 @@ public class AdminRestController implements CpsAdminApi { * * @param apiVersion api version * @param dataspaceName dataspace name - * @return a {@Link ResponseEntity} of schema sets & {@link HttpStatus} OK + * @return a { {@code @Link} ResponseEntity } of schema sets & {@link HttpStatus} OK */ @Override public ResponseEntity> getSchemaSets(final String apiVersion, final String dataspaceName) { @@ -171,7 +172,7 @@ public class AdminRestController implements CpsAdminApi { * @param apiVersion api version * @param dataspaceName dataspace name * @param schemaSetName schemaset name - * @return a {@Link ResponseEntity} of {@link HttpStatus} NO_CONTENT + * @return a { {@code @Link} ResponseEntity } of {@link HttpStatus} NO_CONTENT */ @Override public ResponseEntity deleteSchemaSet(final String apiVersion, @@ -186,7 +187,7 @@ public class AdminRestController implements CpsAdminApi { * @param apiVersion api version * @param dataspaceName dataspace name * - * @return a {@Link ResponseEntity} of {@link HttpStatus} NO_CONTENT + * @return a { {@code @Link} ResponseEntity } of {@link HttpStatus} NO_CONTENT */ @Override public ResponseEntity cleanDataspace(final String apiVersion, final String dataspaceName) { @@ -230,7 +231,7 @@ public class AdminRestController implements CpsAdminApi { * @param apiVersion api version * @param dataspaceName dataspace name * @param anchorName anchor name - * @return a {@Link ResponseEntity} of {@link HttpStatus} NO_CONTENT + * @return a { {@code @Link} ResponseEntity } of {@link HttpStatus} NO_CONTENT */ @Override public ResponseEntity deleteAnchor(final String apiVersion, @@ -245,7 +246,7 @@ public class AdminRestController implements CpsAdminApi { * @param apiVersion api version * @param dataspaceName dataspace name * @param anchorName anchor name - * @return a {@Link ResponseEntity} of an {@Link AnchorDetails} & {@link HttpStatus} OK + * @return a { {@code @Link} ResponseEntity } of an { {@code @Link} AnchorDetails } & {@link HttpStatus} OK */ @Override public ResponseEntity getAnchor(final String apiVersion, @@ -260,7 +261,7 @@ public class AdminRestController implements CpsAdminApi { * * @param apiVersion api version * @param dataspaceName dataspace name - * @return a {@Link ResponseEntity} of all {@Link AnchorDetails} & {@link HttpStatus} OK + * @return a { {@code @Link} ResponseEntity } of all { {@code @Link} AnchorDetails } & {@link HttpStatus} OK */ @Override public ResponseEntity> getAnchors(final String apiVersion, diff --git a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java index b41d78b21f..3c1cc5d499 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech * Modifications Copyright (C) 2021 Bell Canada. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. * Modifications Copyright (C) 2025 TechMahindra Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -77,7 +77,7 @@ public class MultipartFileUtil { * * @param multipartFile the json file uploaded * @return the string representation of the JSON content - * @throws IOException if the file is null or empty + * @throws DataValidationException if the file is null or empty */ public static String extractJsonContent(final MultipartFile multipartFile, final JsonObjectMapper @@ -165,7 +165,7 @@ public class MultipartFileUtil { byteArrayOutputStream.write(buffer, 0, numberOfBytesRead); totalSizeEntry += numberOfBytesRead; zipFileSizeValidator.updateTotalUncompressedSizeOfYangFilesInArchive(numberOfBytesRead); - zipFileSizeValidator.validateCompresssionRatio(totalSizeEntry); + zipFileSizeValidator.validateCompressionRatio(totalSizeEntry); } return byteArrayOutputStream.toString(StandardCharsets.UTF_8); } diff --git a/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java b/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java index 0308a10bfd..316b4d4764 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/utils/ZipFileSizeValidator.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Bell Canada. - * Modifications Copyright (C) 2023 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. @@ -29,7 +29,8 @@ import org.onap.cps.api.exceptions.ModelValidationException; public class ZipFileSizeValidator { private static final int THRESHOLD_ENTRIES = 10000; - private static int thresholdSize = 100000000; + @SuppressWarnings("FieldCanBeLocal") + private static int THRESHOLD_SIZE = 100000000; private static final double THRESHOLD_RATIO = 40; private static final String INVALID_ZIP = "Invalid ZIP archive content."; @@ -58,7 +59,7 @@ public class ZipFileSizeValidator { * * @param totalEntrySize the size of the unzipped entry. */ - public void validateCompresssionRatio(final int totalEntrySize) { + public void validateCompressionRatio(final int totalEntrySize) { final double compressionRatio = (double) totalEntrySize / compressedSize; if (compressionRatio > THRESHOLD_RATIO) { throw new ModelValidationException(INVALID_ZIP, @@ -71,10 +72,10 @@ public class ZipFileSizeValidator { * Validate the total Size and number of entries in the zip. */ public void validateSizeAndEntries() { - if (totalUncompressedSizeOfYangFilesInArchive > thresholdSize) { + if (totalUncompressedSizeOfYangFilesInArchive > THRESHOLD_SIZE) { throw new ModelValidationException(INVALID_ZIP, String.format("The total size of uncompressed yang files exceeds the CPS limit of %s bytes.", - thresholdSize)); + THRESHOLD_SIZE)); } if (totalYangFileEntriesInArchive > THRESHOLD_ENTRIES) { throw new ModelValidationException(INVALID_ZIP, diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy index 73819f8cdf..97c0ff1e31 100644 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/MultipartFileUtilSpec.groovy @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * Modifications Copyright (C) 2023 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. @@ -52,7 +52,7 @@ class MultipartFileUtilSpec extends Specification { def 'Yang file limits in zip archive: #scenario for the bug reported in CPS-1477'() { given: 'a yang file size (uncompressed) limit of #threshold bytes' - ZipFileSizeValidator.thresholdSize = threshold + ZipFileSizeValidator.THRESHOLD_SIZE = threshold and: 'an archive with a yang file of 1083 bytes' def multipartFile = multipartZipFileFromResource('/yang-files-set-total-1083-bytes.zip') when: 'attempt to extract yang files' diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy index e5aecb9e5d..cdb206aa07 100644 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/utils/ZipFileSizeValidatorSpec.groovy @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Bell Canada. - * Modifications Copyright (C) 2023 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. @@ -25,7 +25,7 @@ import spock.lang.Specification class ZipFileSizeValidatorSpec extends Specification { - def static thresholdSize = ZipFileSizeValidator.thresholdSize + def static thresholdSize = ZipFileSizeValidator.THRESHOLD_SIZE def static thresholdEntries = ZipFileSizeValidator.THRESHOLD_ENTRIES def static thresholdRatio = ZipFileSizeValidator.THRESHOLD_RATIO @@ -58,7 +58,7 @@ class ZipFileSizeValidatorSpec extends Specification { given: 'the totalEntrySize of the archive so that compression ratio is within the threshold' int totalEntrySize = compressedFileSize * thresholdRatio - 1 when: 'the validation is performed against the threshold compression ratio' - objectUnderTest.validateCompresssionRatio(totalEntrySize) + objectUnderTest.validateCompressionRatio(totalEntrySize) then: 'validation passes and no exception is thrown' noExceptionThrown() } @@ -67,7 +67,7 @@ class ZipFileSizeValidatorSpec extends Specification { given: 'the totalEntrySize of the archive so that compression ratio is higher than the threshold' int totalEntrySize = compressedFileSize * thresholdRatio + 1 when: 'the validation is performed against the threshold compression ratio' - objectUnderTest.validateCompresssionRatio(totalEntrySize) + objectUnderTest.validateCompressionRatio(totalEntrySize) then: 'validation fails and exception is thrown' thrown ModelValidationException } diff --git a/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java index 472da34833..ddf7d6efe2 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java @@ -249,7 +249,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService } final AnchorEntity anchorEntity = getAnchorEntity(dataspaceName, anchorName); return fragmentRepository.findAttributeValuesByAnchorAndCpsPath(anchorEntity, cpsPathQuery, - cpsPathQuery.getAttributeAxisAttributeName(), queryResultLimit, targetClass); + queryResultLimit, targetClass); } @Override @@ -511,6 +511,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService return Collections.unmodifiableList(dataNodes); } + @SuppressWarnings("unchecked") private DataNode toDataNode(final FragmentEntity fragmentEntity, final FetchDescendantsOption fetchDescendantsOption) { final List childDataNodes = getChildDataNodes(fragmentEntity, fetchDescendantsOption); @@ -596,6 +597,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService return existingListElementEntity; } + @SuppressWarnings("unchecked") private String mergeLeaves(final Map updateLeaves, final String currentLeavesAsString) { Map currentLeavesAsMap = new HashMap<>(); if (currentLeavesAsString != null) { @@ -628,6 +630,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService if (currentLeavesAsString == null) { return "{}"; } + @SuppressWarnings("unchecked") final Map sortedLeaves = jsonObjectMapper.convertJsonString(currentLeavesAsString, TreeMap.class); return jsonObjectMapper.asJsonString(sortedLeaves); diff --git a/cps-ri/src/main/java/org/onap/cps/ri/models/AnchorEntity.java b/cps-ri/src/main/java/org/onap/cps/ri/models/AnchorEntity.java index bf9e25daf1..6c670062a3 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/models/AnchorEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/models/AnchorEntity.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2023 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. @@ -31,6 +31,7 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; +import java.io.Serial; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; @@ -52,6 +53,7 @@ import lombok.Setter; @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class AnchorEntity implements Serializable { + @Serial private static final long serialVersionUID = -8049987915308262518L; @Id diff --git a/cps-ri/src/main/java/org/onap/cps/ri/models/DataspaceEntity.java b/cps-ri/src/main/java/org/onap/cps/ri/models/DataspaceEntity.java index 689ae2c000..fe790fccb3 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/models/DataspaceEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/models/DataspaceEntity.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2023 Nordix Foundation. + * Copyright (C) 2020-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2020-2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +28,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; +import java.io.Serial; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -48,6 +49,7 @@ import lombok.Setter; @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class DataspaceEntity implements Serializable { + @Serial private static final long serialVersionUID = 8395254649813051882L; @Id diff --git a/cps-ri/src/main/java/org/onap/cps/ri/models/FragmentEntity.java b/cps-ri/src/main/java/org/onap/cps/ri/models/FragmentEntity.java index 2c851b60a5..e4cdc7f669 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/models/FragmentEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/models/FragmentEntity.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2024 Nordix Foundation. + * Copyright (C) 2020-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ import jakarta.persistence.OneToMany; import jakarta.persistence.SequenceGenerator; import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; +import java.io.Serial; import java.io.Serializable; import java.util.Set; import lombok.AllArgsConstructor; @@ -61,6 +62,7 @@ import org.hibernate.type.SqlTypes; @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class FragmentEntity implements Serializable { + @Serial private static final long serialVersionUID = 7737669789097119667L; @Id diff --git a/cps-ri/src/main/java/org/onap/cps/ri/models/SchemaSetEntity.java b/cps-ri/src/main/java/org/onap/cps/ri/models/SchemaSetEntity.java index e99f79e330..e223f6c129 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/models/SchemaSetEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/models/SchemaSetEntity.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech + * Modifications Copyright (C) 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. @@ -31,6 +32,7 @@ import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; +import java.io.Serial; import java.io.Serializable; import java.util.Set; import lombok.Getter; @@ -47,6 +49,7 @@ import lombok.Setter; @Table(name = "schema_set") public class SchemaSetEntity implements Serializable { + @Serial private static final long serialVersionUID = 6665056955069047269L; @Id diff --git a/cps-ri/src/main/java/org/onap/cps/ri/models/YangResourceEntity.java b/cps-ri/src/main/java/org/onap/cps/ri/models/YangResourceEntity.java index 2b2d7924db..51650f7746 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/models/YangResourceEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/models/YangResourceEntity.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * Modifications Copyright (C) 2021-2023 Nordix Foundation + * Modifications Copyright (C) 2021-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. @@ -28,6 +28,7 @@ import jakarta.persistence.Id; import jakarta.persistence.ManyToMany; import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; +import java.io.Serial; import java.io.Serializable; import java.util.Set; import lombok.Getter; @@ -44,6 +45,7 @@ import lombok.Setter; @Table(name = "yang_resource") public class YangResourceEntity implements Serializable { + @Serial private static final long serialVersionUID = -4496883162142106774L; @Id diff --git a/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentQueryBuilder.java b/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentQueryBuilder.java index 3b88748545..82b167f996 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentQueryBuilder.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentQueryBuilder.java @@ -42,6 +42,7 @@ import org.onap.cps.ri.models.FragmentEntity; import org.onap.cps.ri.utils.EscapeUtils; import org.springframework.stereotype.Component; +@SuppressWarnings("unused") @RequiredArgsConstructor @Component public class FragmentQueryBuilder { @@ -362,6 +363,7 @@ public class FragmentQueryBuilder { } } + @SuppressWarnings("SameParameterValue") private static String substitute(final String template, final Map valueMap) { final StringSubstitutor stringSubstitutor = new StringSubstitutor(valueMap); return stringSubstitutor.replace(template); diff --git a/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQuery.java b/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQuery.java index a24b280bf8..fe29a7362b 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQuery.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQuery.java @@ -35,7 +35,7 @@ public interface FragmentRepositoryCpsPathQuery { int queryResultLimit); Set findAttributeValuesByAnchorAndCpsPath(AnchorEntity anchorEntity, CpsPathQuery cpsPathQuery, - String attributeName, int queryResultLimit, Class targetClass); + int queryResultLimit, Class targetClass); List findByDataspaceAndCpsPath(DataspaceEntity dataspaceEntity, CpsPathQuery cpsPathQuery, List anchorIds); diff --git a/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQueryImpl.java b/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQueryImpl.java index cc8055d3c1..ac9939cee2 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQueryImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/repository/FragmentRepositoryCpsPathQueryImpl.java @@ -35,6 +35,7 @@ import org.onap.cps.ri.models.DataspaceEntity; import org.onap.cps.ri.models.FragmentEntity; import org.onap.cps.utils.JsonObjectMapper; +@SuppressWarnings("unused") @RequiredArgsConstructor @Slf4j public class FragmentRepositoryCpsPathQueryImpl implements FragmentRepositoryCpsPathQuery { @@ -49,6 +50,7 @@ public class FragmentRepositoryCpsPathQueryImpl implements FragmentRepositoryCps final int queryResultLimit) { final Query query = fragmentQueryBuilder.getQueryForAnchorAndCpsPath(anchorEntity, cpsPathQuery, queryResultLimit); + @SuppressWarnings("unchecked") final List fragmentEntities = query.getResultList(); log.debug("Fetched {} fragment entities by anchor and cps path.", fragmentEntities.size()); if (queryResultLimit > 0) { @@ -61,11 +63,11 @@ public class FragmentRepositoryCpsPathQueryImpl implements FragmentRepositoryCps @Transactional public Set findAttributeValuesByAnchorAndCpsPath(final AnchorEntity anchorEntity, final CpsPathQuery cpsPathQuery, - final String attributeName, final int queryResultLimit, final Class targetClass) { final Query query = fragmentQueryBuilder.getQueryForAnchorAndCpsPath(anchorEntity, cpsPathQuery, queryResultLimit); + @SuppressWarnings("unchecked") final List jsonResultList = query.getResultList(); return jsonResultList.stream() .map(jsonValue -> jsonObjectMapper.convertJsonString(jsonValue, targetClass)) @@ -75,9 +77,11 @@ public class FragmentRepositoryCpsPathQueryImpl implements FragmentRepositoryCps @Override @Transactional public List findByDataspaceAndCpsPath(final DataspaceEntity dataspaceEntity, - final CpsPathQuery cpsPathQuery, final List anchorIds) { + final CpsPathQuery cpsPathQuery, + final List anchorIds) { final Query query = fragmentQueryBuilder.getQueryForDataspaceAndCpsPath( dataspaceEntity, cpsPathQuery, anchorIds); + @SuppressWarnings("unchecked") final List fragmentEntities = query.getResultList(); log.debug("Fetched {} fragment entities by cps path across all anchors.", fragmentEntities.size()); return fragmentEntities; diff --git a/cps-ri/src/main/java/org/onap/cps/ri/repository/ModuleReferenceRepositoryImpl.java b/cps-ri/src/main/java/org/onap/cps/ri/repository/ModuleReferenceRepositoryImpl.java index 7611dcd8a5..dbc3eeb7bb 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/repository/ModuleReferenceRepositoryImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/repository/ModuleReferenceRepositoryImpl.java @@ -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. @@ -32,6 +32,7 @@ import lombok.SneakyThrows; import org.onap.cps.api.model.ModuleReference; import org.springframework.transaction.annotation.Transactional; +@SuppressWarnings("unused") @Transactional @RequiredArgsConstructor public class ModuleReferenceRepositoryImpl implements ModuleReferenceQuery { diff --git a/cps-ri/src/main/java/org/onap/cps/ri/utils/SessionManager.java b/cps-ri/src/main/java/org/onap/cps/ri/utils/SessionManager.java index 06ac12594d..c672673cfb 100644 --- a/cps-ri/src/main/java/org/onap/cps/ri/utils/SessionManager.java +++ b/cps-ri/src/main/java/org/onap/cps/ri/utils/SessionManager.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 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. @@ -100,8 +100,9 @@ public class SessionManager { * @param commit indicator whether session will commit or rollback */ public void closeSession(final String sessionId, final boolean commit) { + Session session = null; try { - final Session session = getSession(sessionId); + session = getSession(sessionId); if (commit) { session.getTransaction().commit(); } else { @@ -112,7 +113,9 @@ public class SessionManager { throw new SessionManagerException("Cannot close session", String.format("Unable to close session with session ID '%s'", sessionId), e); } finally { - sessionMap.remove(sessionId); + if (session != null) { + sessionMap.remove(sessionId); + } } } diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/AlreadyDefinedException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/AlreadyDefinedException.java index 0b2204221d..2da2ceb983 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/AlreadyDefinedException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/AlreadyDefinedException.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation + * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,6 +21,7 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; import java.util.Collection; import java.util.Collections; import lombok.Getter; @@ -32,6 +33,7 @@ import lombok.Getter; @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class AlreadyDefinedException extends CpsAdminException { + @Serial private static final long serialVersionUID = 501929839139881112L; public static final String ALREADY_DEFINED_EXCEPTION_MESSAGE = "Already defined exception"; @@ -45,10 +47,10 @@ public class AlreadyDefinedException extends CpsAdminException { alreadyDefinedObjectNames = Collections.singletonList(objectName); } - private AlreadyDefinedException(final String objectType, final Collection objectNames, + private AlreadyDefinedException(final Collection objectNames, final String contextName) { super(ALREADY_DEFINED_EXCEPTION_MESSAGE, - String.format("%d %s already exist for %s.", objectNames.size(), objectType, contextName)); + String.format("%d data node(s) already exist for %s.", objectNames.size(), contextName)); alreadyDefinedObjectNames = objectNames; } @@ -72,6 +74,6 @@ public class AlreadyDefinedException extends CpsAdminException { } public static AlreadyDefinedException forDataNodes(final Collection xpaths, final String contextName) { - return new AlreadyDefinedException("data node(s)", xpaths, contextName); + return new AlreadyDefinedException(xpaths, contextName); } } diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/AnchorNotFoundException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/AnchorNotFoundException.java index 27ba296bb3..a63db14774 100755 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/AnchorNotFoundException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/AnchorNotFoundException.java @@ -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,9 +20,12 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; + @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class AnchorNotFoundException extends CpsAdminException { + @Serial private static final long serialVersionUID = -1821064664642194882L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsAdminException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsAdminException.java index de5181572a..d229a852db 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsAdminException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsAdminException.java @@ -1,29 +1,34 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Bell Canada. 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; + /** * CPS Admin exception. */ public class CpsAdminException extends CpsException { + @Serial private static final long serialVersionUID = 5573438585188332404L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsException.java index e2b2b7b286..abd89dcb2c 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsException.java @@ -1,24 +1,27 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * ================================================================================ - * 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; import lombok.Getter; /** @@ -26,6 +29,7 @@ import lombok.Getter; */ public class CpsException extends RuntimeException { + @Serial private static final long serialVersionUID = 1592619410918497467L; @Getter diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsPathException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsPathException.java index 00664de373..aa4a55f535 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsPathException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/CpsPathException.java @@ -1,27 +1,30 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Copyright (C) 2021-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. + * 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. + * 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========================================================= + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ package org.onap.cps.api.exceptions; +import java.io.Serial; + public class CpsPathException extends CpsException { + @Serial private static final long serialVersionUID = 1006899957127327791L; private static final String ERROR_MESSAGE = "Error while parsing cpsPath expression"; diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataInUseException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataInUseException.java index 6127608b90..fc995a03bb 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataInUseException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataInUseException.java @@ -1,29 +1,34 @@ /* - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech - * ================================================================================ - * 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; + /** * Runtime exception. Thrown when data record rejected to be deleted because it's being referenced by other data. */ public class DataInUseException extends CpsException { + @Serial private static final long serialVersionUID = 5011830482789788314L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataNodeNotFoundException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataNodeNotFoundException.java index 521b786095..e890f9fa6c 100755 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataNodeNotFoundException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataNodeNotFoundException.java @@ -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,12 +20,15 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; + /** * DataNode Not Found Exception. Indicates the requested data being absent. */ @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class DataNodeNotFoundException extends DataValidationException { + @Serial private static final long serialVersionUID = 7786740001662205407L; private static final String DATANODE_NOT_FOUND = "DataNode not found"; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataValidationException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataValidationException.java index 5306819485..15483159cf 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataValidationException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataValidationException.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * Modifications Copyright (C) 2020-2021 Nordix Foundation + * Modifications Copyright (C) 2020-2025 OpenInfra Foundation Europe. * Modifications Copyright (C) 2020 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,8 +22,11 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; + public class DataValidationException extends CpsException { + @Serial private static final long serialVersionUID = 7747941311132087621L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceInUseException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceInUseException.java index 8ceaf1aba2..0508c85b0d 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceInUseException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceInUseException.java @@ -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. @@ -19,6 +19,8 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; + /** * Runtime exception. * Thrown when given dataspace name is rejected to be deleted because it has anchor or schemasets associated. @@ -26,6 +28,7 @@ package org.onap.cps.api.exceptions; @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class DataspaceInUseException extends DataInUseException { + @Serial private static final long serialVersionUID = 4531370947720760347L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceNotFoundException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceNotFoundException.java index 0be2fec70c..77e6bcc651 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceNotFoundException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/DataspaceNotFoundException.java @@ -1,24 +1,28 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Bell Canada. 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; + /** * Dataspace Not Found Exception. Indicates the requested data being absent. */ @@ -26,6 +30,7 @@ package org.onap.cps.api.exceptions; @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class DataspaceNotFoundException extends CpsAdminException { + @Serial private static final long serialVersionUID = -1852996415384288431L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/DuplicatedYangResourceException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/DuplicatedYangResourceException.java index 0dec574212..f8527e46d5 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/DuplicatedYangResourceException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/DuplicatedYangResourceException.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= - * Copyright (c) 2021 Bell Canada. + * Copyright (c) 2021 Bell Canada. + * Modifications Copyright (C) 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. @@ -13,11 +14,14 @@ * 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.api.exceptions; +import java.io.Serial; import lombok.Getter; /** @@ -26,6 +30,7 @@ import lombok.Getter; @Getter public class DuplicatedYangResourceException extends CpsException { + @Serial private static final long serialVersionUID = 9085557087319212380L; private final String name; diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/ModelValidationException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/ModelValidationException.java index d38fe8d048..85d1c3cab3 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/ModelValidationException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/ModelValidationException.java @@ -1,29 +1,34 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Bell Canada. 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; + /** * Yang Model Validation exception. */ public class ModelValidationException extends CpsException { + @Serial private static final long serialVersionUID = 650368325928748496L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/ModuleNamesNotFoundException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/ModuleNamesNotFoundException.java index 977ecec74e..3df2114a1f 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/ModuleNamesNotFoundException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/ModuleNamesNotFoundException.java @@ -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,11 +20,13 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; import java.util.Collection; @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class ModuleNamesNotFoundException extends CpsAdminException { + @Serial private static final long serialVersionUID = 3105694256583924137L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/NotFoundInDataspaceException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/NotFoundInDataspaceException.java index 71322b7dee..150ed029f4 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/NotFoundInDataspaceException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/NotFoundInDataspaceException.java @@ -1,29 +1,34 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * ================================================================================ - * 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; + /** * Not found in dataspace exception. Indicates the requested data being absent in a given dataspace */ public class NotFoundInDataspaceException extends CpsException { + @Serial private static final long serialVersionUID = 3838769447129047713L; public NotFoundInDataspaceException(final String dataspaceName, final String descriptionOfObject) { diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetInUseException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetInUseException.java index 4d481be0aa..e19a5221ed 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetInUseException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetInUseException.java @@ -1,30 +1,35 @@ /* - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech - * ================================================================================ - * 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; + /** * Runtime exception. Thrown when schema set record rejected to be deleted because it has anchor records associated. */ @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class SchemaSetInUseException extends DataInUseException { + @Serial private static final long serialVersionUID = -3729328573253023683L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetNotFoundException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetNotFoundException.java index e95d907f91..33b8d4e6bd 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetNotFoundException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/SchemaSetNotFoundException.java @@ -1,24 +1,28 @@ /* - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * ================================================================================ - * 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 + * Modifications Copyright (C) 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. + * 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========================================================= + * 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.api.exceptions; +import java.io.Serial; + /** * Schema set not found exception. Indicates the schema set is not found in a given dataspace */ @@ -26,6 +30,7 @@ package org.onap.cps.api.exceptions; @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class SchemaSetNotFoundException extends CpsAdminException { + @Serial private static final long serialVersionUID = 7422782395935450035L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionManagerException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionManagerException.java index d1f32c0744..e87cc69841 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionManagerException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionManagerException.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 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. @@ -21,8 +21,11 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; + public class SessionManagerException extends CpsException { + @Serial private static final long serialVersionUID = 7957090904519019500L; /** diff --git a/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionTimeoutException.java b/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionTimeoutException.java index 6b45e1b891..dd634cefd1 100644 --- a/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionTimeoutException.java +++ b/cps-service/src/main/java/org/onap/cps/api/exceptions/SessionTimeoutException.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 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,9 +20,12 @@ package org.onap.cps.api.exceptions; +import java.io.Serial; + @SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions public class SessionTimeoutException extends SessionManagerException { + @Serial private static final long serialVersionUID = -8809577494038691360L; public SessionTimeoutException(final String message, final String details, final Throwable cause) { diff --git a/cps-service/src/main/java/org/onap/cps/api/model/Anchor.java b/cps-service/src/main/java/org/onap/cps/api/model/Anchor.java index 68f7920046..a5a5b45a67 100644 --- a/cps-service/src/main/java/org/onap/cps/api/model/Anchor.java +++ b/cps-service/src/main/java/org/onap/cps/api/model/Anchor.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020-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.api.model; +import java.io.Serial; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; @@ -32,6 +33,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class Anchor implements Serializable { + @Serial private static final long serialVersionUID = 1464791260718603291L; private String name; diff --git a/cps-service/src/main/java/org/onap/cps/api/model/DataNode.java b/cps-service/src/main/java/org/onap/cps/api/model/DataNode.java index 6597aa3908..3d24159446 100644 --- a/cps-service/src/main/java/org/onap/cps/api/model/DataNode.java +++ b/cps-service/src/main/java/org/onap/cps/api/model/DataNode.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2022 Nordix Foundation. + * Copyright (C) 2020-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2021 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ @@ -22,6 +22,7 @@ package org.onap.cps.api.model; +import java.io.Serial; import java.io.Serializable; import java.util.Collection; import java.util.Collections; @@ -37,6 +38,7 @@ import lombok.Setter; @NoArgsConstructor public class DataNode implements Serializable { + @Serial private static final long serialVersionUID = 1482619410918597467L; private String dataspace; diff --git a/cps-service/src/main/java/org/onap/cps/api/model/Dataspace.java b/cps-service/src/main/java/org/onap/cps/api/model/Dataspace.java index 238b8611f0..8f1fad5321 100644 --- a/cps-service/src/main/java/org/onap/cps/api/model/Dataspace.java +++ b/cps-service/src/main/java/org/onap/cps/api/model/Dataspace.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2022 TechMahindra Ltd. + * Modifications (C) 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. @@ -20,6 +21,7 @@ package org.onap.cps.api.model; +import java.io.Serial; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; @@ -36,6 +38,7 @@ import lombok.Setter; @EqualsAndHashCode public class Dataspace implements Serializable { + @Serial private static final long serialVersionUID = 1464791062718603291L; private String name; diff --git a/cps-service/src/main/java/org/onap/cps/api/model/ModuleDefinition.java b/cps-service/src/main/java/org/onap/cps/api/model/ModuleDefinition.java index c2f23d6a2d..03a2fb89ac 100644 --- a/cps-service/src/main/java/org/onap/cps/api/model/ModuleDefinition.java +++ b/cps-service/src/main/java/org/onap/cps/api/model/ModuleDefinition.java @@ -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.api.model; +import java.io.Serial; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -31,6 +32,7 @@ import lombok.ToString; @ToString public class ModuleDefinition extends ModuleReference { + @Serial private static final long serialVersionUID = -6591435720836327732L; private final String content; @@ -38,4 +40,4 @@ public class ModuleDefinition extends ModuleReference { super(moduleName, revision); this.content = content; } -} \ No newline at end of file +} diff --git a/cps-service/src/main/java/org/onap/cps/api/model/ModuleReference.java b/cps-service/src/main/java/org/onap/cps/api/model/ModuleReference.java index a93a510780..adc618abfa 100644 --- a/cps-service/src/main/java/org/onap/cps/api/model/ModuleReference.java +++ b/cps-service/src/main/java/org/onap/cps/api/model/ModuleReference.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 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.api.model; +import java.io.Serial; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; @@ -32,6 +33,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class ModuleReference implements Serializable { + @Serial private static final long serialVersionUID = -1761408847591042599L; private String moduleName; private String revision; diff --git a/cps-service/src/main/java/org/onap/cps/api/model/SchemaSet.java b/cps-service/src/main/java/org/onap/cps/api/model/SchemaSet.java index be57d2d3ae..d7a62a6176 100644 --- a/cps-service/src/main/java/org/onap/cps/api/model/SchemaSet.java +++ b/cps-service/src/main/java/org/onap/cps/api/model/SchemaSet.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * Modifications Copyright (C) 2022 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. @@ -21,6 +21,7 @@ package org.onap.cps.api.model; +import java.io.Serial; import java.io.Serializable; import java.util.List; import lombok.AllArgsConstructor; @@ -34,6 +35,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class SchemaSet implements Serializable { + @Serial private static final long serialVersionUID = 1464791260718603291L; private String name; private String dataspaceName; diff --git a/cps-service/src/main/java/org/onap/cps/events/EventsProducer.java b/cps-service/src/main/java/org/onap/cps/events/EventsProducer.java index 01e1ad183a..ee65e3acd2 100644 --- a/cps-service/src/main/java/org/onap/cps/events/EventsProducer.java +++ b/cps-service/src/main/java/org/onap/cps/events/EventsProducer.java @@ -44,7 +44,7 @@ public class EventsProducer { /** * KafkaTemplate for legacy (non-cloud) events. - * Note: Cloud events should be used. This will be addressed as part of https://lf-onap.atlassian.net/browse/CPS-1717. + * Note: Cloud events should be used. This will be addressed as part of .... */ private final KafkaTemplate legacyKafkaEventTemplate; @@ -73,7 +73,7 @@ public class EventsProducer { /** * Generic Event sender. - * Note: Cloud events should be used. This will be addressed as part of https://lf-onap.atlassian.net/browse/CPS-1717. + * Note: Cloud events should be used. This will be addressed as part of .... * * @param topicName valid topic name * @param eventKey message key diff --git a/cps-service/src/main/java/org/onap/cps/impl/DataNodeBuilder.java b/cps-service/src/main/java/org/onap/cps/impl/DataNodeBuilder.java index a78f3d9826..e9c11a7676 100644 --- a/cps-service/src/main/java/org/onap/cps/impl/DataNodeBuilder.java +++ b/cps-service/src/main/java/org/onap/cps/impl/DataNodeBuilder.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2021 Bell Canada. All rights reserved. * Modifications Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2022-2024 Nordix Foundation. + * Modifications Copyright (C) 2022-2025 OpenInfra Foundation Europe. * Modifications Copyright (C) 2022-2023 TechMahindra Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -193,11 +193,9 @@ public class DataNodeBuilder { } private Collection buildCollectionFromContainerNode() { - final var parentDataNode = new DataNodeBuilder().withXpath(parentNodeXpath).build(); - if (containerNode.body() != null) { - for (final NormalizedNode normalizedNode: containerNode.body()) { - addDataNodeFromNormalizedNode(parentDataNode, normalizedNode); - } + final DataNode parentDataNode = new DataNodeBuilder().withXpath(parentNodeXpath).build(); + for (final NormalizedNode normalizedNode : containerNode.body()) { + addDataNodeFromNormalizedNode(parentDataNode, normalizedNode); } return parentDataNode.getChildDataNodes(); } diff --git a/cps-service/src/main/java/org/onap/cps/impl/YangTextSchemaSourceSetCache.java b/cps-service/src/main/java/org/onap/cps/impl/YangTextSchemaSourceSetCache.java index e7e7b1c5ce..0a35813771 100644 --- a/cps-service/src/main/java/org/onap/cps/impl/YangTextSchemaSourceSetCache.java +++ b/cps-service/src/main/java/org/onap/cps/impl/YangTextSchemaSourceSetCache.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022 Bell Canada - * Modifications Copyright (C) 2022-2025 Nordix Foundation + * Modifications 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. @@ -74,6 +74,7 @@ public class YangTextSchemaSourceSetCache { * @param yangTextSchemaSourceSet yangTextSchemaSourceSet * @return YangTextSchemaSourceSet */ + @SuppressWarnings("unused") @CachePut(key = "#p0.concat('-').concat(#p1)") @CanIgnoreReturnValue public YangTextSchemaSourceSet updateCache(final String dataspaceName, final String schemaSetName, @@ -89,6 +90,7 @@ public class YangTextSchemaSourceSetCache { * @param dataspaceName dataspace name * @param schemaSetName schema set name */ + @SuppressWarnings("unused") @CacheEvict(key = "#p0.concat('-').concat(#p1)") public void removeFromCache(final String dataspaceName, final String schemaSetName) { cpsValidator.validateNameCharacters(dataspaceName); diff --git a/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java b/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java index 01093d7d74..dfe3a38710 100644 --- a/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java +++ b/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2022 Deutsche Telekom AG - * Modifications Copyright (C) 2023-2024 Nordix Foundation. + * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. * Modifications Copyright (C) 2024-2025 TechMahindra Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -170,6 +170,7 @@ public class XmlFileUtils { * @param dataMaps List of data maps to convert * @return XML string representation of the data maps */ + @SuppressWarnings("unchecked") @SuppressFBWarnings(value = "DCN_NULLPOINTER_EXCEPTION") public static String convertDataMapsToXml(final Object dataMaps) { try { @@ -206,6 +207,7 @@ public class XmlFileUtils { } } + @SuppressWarnings("unchecked") private static void appendList(final Document document, final Node parentNode, final Map.Entry dataNodeMapEntry) { final List dataNodeMaps = (List) dataNodeMapEntry.getValue(); @@ -227,6 +229,7 @@ public class XmlFileUtils { } } + @SuppressWarnings("unchecked") private static void appendMap(final Document document, final Node parentNode, final Map.Entry dataNodeMapEntry) { final Element childElement = document.createElement(dataNodeMapEntry.getKey()); @@ -253,8 +256,8 @@ public class XmlFileUtils { return writer.toString(); } + @SuppressWarnings("SameReturnValue") private static DocumentBuilderFactory getDocumentBuilderFactory() { - if (isNewDocumentBuilderFactoryInstance) { documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); @@ -264,8 +267,8 @@ public class XmlFileUtils { return documentBuilderFactory; } + @SuppressWarnings("SameReturnValue") private static TransformerFactory getTransformerFactory() { - if (isNewTransformerFactoryInstance) { transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); diff --git a/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java b/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java index 83f7ce220f..be2c657e63 100644 --- a/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java +++ b/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java @@ -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. @@ -193,6 +193,7 @@ public class YangParserHelper { return Builders.containerBuilder().withChild(dataContainerChild).withNodeIdentifier(nodeIdentifier).build(); } + @SuppressWarnings("unchecked") private static Collection getDataSchemaNodeIdentifiers(final SchemaContext schemaContext, final String parentNodeXpath) { return (Collection) getDataSchemaNodeAndIdentifiersByXpath(parentNodeXpath, schemaContext) @@ -250,6 +251,7 @@ public class YangParserHelper { private static NormalizedNode getFirstChildXmlRoot(final NormalizedNode parent) { final String rootNodeType = parent.getIdentifier().getNodeType().getLocalName(); + @SuppressWarnings("unchecked") final Collection children = (Collection) parent.body(); final Iterator iterator = children.iterator(); NormalizedNode child = null; diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java index efbe488f60..b33d7a8cfe 100644 --- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java +++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java @@ -29,13 +29,13 @@ import io.micrometer.core.annotation.Timed; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import lombok.NoArgsConstructor; import org.onap.cps.api.exceptions.ModelValidationException; import org.onap.cps.api.model.ModuleReference; @@ -142,7 +142,7 @@ public final class YangTextSchemaSourceSetBuilder { try { return yangParser.buildEffectiveModel(); } catch (final YangParserException yangParserException) { - final List resourceNames = yangResourceNameToContent.keySet().stream().collect(Collectors.toList()); + final List resourceNames = new ArrayList<>(yangResourceNameToContent.keySet()); Collections.sort(resourceNames); throw new ModelValidationException("Invalid schema set.", String.format("Effective schema context build failed for resources %s.", resourceNames), diff --git a/cps-service/src/test/groovy/org/onap/cps/impl/DataNodeBuilderSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/impl/DataNodeBuilderSpec.groovy index 28ba0a946c..5b9a961627 100644 --- a/cps-service/src/test/groovy/org/onap/cps/impl/DataNodeBuilderSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/impl/DataNodeBuilderSpec.groovy @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2021-2024 Nordix Foundation. + * Modifications Copyright (C) 2021-2025 OpenInfra Foundation Europe. * Modifications Copyright (C) 2022 TechMahindra Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -179,11 +179,7 @@ class DataNodeBuilderSpec extends Specification { def 'Converting ContainerNode to a Collection with #scenario.'() { expect: 'converting null to a collection returns an empty collection' - assert objectUnderTest.withContainerNode(containerNode).buildCollection().isEmpty() - where: 'the following container node is used' - scenario | containerNode - 'null object' | null - 'object without body' | Mock(ContainerNode) + assert objectUnderTest.withContainerNode(null).buildCollection().isEmpty() } def 'Converting ContainerNode to a DataNode with unsupported Normalized Node.'() { diff --git a/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java b/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java index 0eb7b37800..6f3fb9546a 100644 --- a/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java +++ b/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java @@ -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. @@ -44,7 +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 + @SuppressWarnings("CanBeFinal") // Do NOT change below to final as it needs to be set during test private static int slowResponseTimeInSeconds = 40; @Override @@ -59,7 +59,7 @@ public class PolicyExecutorStubController implements OperationPermissionApi { final Operation firstOperation = permissionRequest.getOperations().iterator().next(); log.info("1st Operation: {}", firstOperation.getOperation()); if (!"delete".equals(firstOperation.getOperation()) && firstOperation.getChangeRequest() == null) { - log.warn("Change Request is required for " + firstOperation.getOperation() + " operations"); + log.warn("Change Request is required for {} operations", firstOperation.getOperation()); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } return handleOperation(firstOperation); @@ -71,7 +71,7 @@ public class PolicyExecutorStubController implements OperationPermissionApi { final Matcher matcher = ERROR_CODE_PATTERN.matcher(targetIdentifier); if (matcher.find()) { final int errorCode = Integer.parseInt(matcher.group(1)); - log.warn("Stub is mocking an error response, code: " + errorCode); + log.warn("Stub is mocking an error response, code: {}", errorCode); return new ResponseEntity<>(HttpStatusCode.valueOf(errorCode)); } -- 2.16.6