diff options
author | ToineSiebelink <toine.siebelink@est.tech> | 2024-03-19 10:42:07 +0000 |
---|---|---|
committer | ToineSiebelink <toine.siebelink@est.tech> | 2024-03-19 14:20:24 +0000 |
commit | 59a34f5f9e1aaea13df8903ac30ee8cb5735f205 (patch) | |
tree | 9c721c49b79b75cdfb2b309bf8cc0a28d23f584b /cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java | |
parent | bf75ff4d43dc9eb459deaf61920de22cf5c6f1ea (diff) |
Fix SonarQube warnings
targetted:
- Introduced CmResourceAddress (name agreed with Daniel and Priyank)
- Extracted out private method in AltenateIdChecker to reduce complexity
side effects:
- use 'record' java feature as suggested by ItelliJ
- had to uprade spotbugs version to avoid incorrect warning on 'record' equeals method
- convention: added missing 'asserts' in affected testware
- my preference: removed a lot of unnecessary linebreaks in affected testware
- removed redunfant (variation) of a 'delegation' test
Issue-ID: CPS-475
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Change-Id: Ie0c9d5ebc33196ae14ed6c226843095a2a040d1d
Diffstat (limited to 'cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java')
-rw-r--r-- | cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java index 65410d3a3..1ae16820a 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java @@ -25,6 +25,7 @@ import java.util.UUID; import java.util.function.Supplier; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.onap.cps.ncmp.api.models.CmResourceAddress; import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor; import org.onap.cps.ncmp.rest.util.TopicValidator; import org.springframework.beans.factory.annotation.Value; @@ -50,18 +51,14 @@ public abstract class NcmpDatastoreRequestHandler { /** * Executes synchronous/asynchronous get request for given cm handle. * - * @param datastoreName the name of the datastore - * @param cmHandleId the cm handle - * @param resourceIdentifier the resource identifier + * @param cmResourceAddress the name of the datastore, cm handle and resource identifier * @param optionsParamInQuery the options param in query * @param topicParamInQuery the topic param in query * @param includeDescendants whether include descendants * @param authorization contents of Authorization header, or null if not present * @return the response entity */ - public ResponseEntity<Object> executeRequest(final String datastoreName, - final String cmHandleId, - final String resourceIdentifier, + public ResponseEntity<Object> executeRequest(final CmResourceAddress cmResourceAddress, final String optionsParamInQuery, final String topicParamInQuery, final boolean includeDescendants, @@ -69,16 +66,16 @@ public abstract class NcmpDatastoreRequestHandler { final boolean asyncResponseRequested = topicParamInQuery != null; if (asyncResponseRequested && notificationFeatureEnabled) { - return executeAsyncTaskAndGetResponseEntity(datastoreName, cmHandleId, resourceIdentifier, - optionsParamInQuery, topicParamInQuery, includeDescendants, authorization); + return executeAsyncTaskAndGetResponseEntity(cmResourceAddress, optionsParamInQuery, topicParamInQuery, + includeDescendants, authorization); } if (asyncResponseRequested) { log.warn("Asynchronous request is unavailable as notification feature is currently disabled, " + "will use synchronous operation."); } - final Supplier<Object> taskSupplier = getTaskSupplierForGetRequest(datastoreName, cmHandleId, - resourceIdentifier, optionsParamInQuery, NO_TOPIC, NO_REQUEST_ID, includeDescendants, authorization); + final Supplier<Object> taskSupplier = getTaskSupplierForGetRequest(cmResourceAddress, optionsParamInQuery, + NO_TOPIC, NO_REQUEST_ID, includeDescendants, authorization); return executeTaskSync(taskSupplier); } @@ -96,23 +93,18 @@ public abstract class NcmpDatastoreRequestHandler { return ResponseEntity.ok(taskSupplier.get()); } - private ResponseEntity<Object> executeAsyncTaskAndGetResponseEntity(final String datastoreName, - final String cmHandleId, - final String resourceIdentifier, + private ResponseEntity<Object> executeAsyncTaskAndGetResponseEntity(final CmResourceAddress cmResourceAddress, final String optionsParamInQuery, final String topicParamInQuery, final boolean includeDescendants, final String authorization) { final String requestId = UUID.randomUUID().toString(); - final Supplier<Object> taskSupplier = getTaskSupplierForGetRequest(datastoreName, cmHandleId, - resourceIdentifier, optionsParamInQuery, topicParamInQuery, requestId, includeDescendants, - authorization); + final Supplier<Object> taskSupplier = getTaskSupplierForGetRequest(cmResourceAddress, + optionsParamInQuery, topicParamInQuery, requestId, includeDescendants, authorization); return executeTaskAsync(topicParamInQuery, requestId, taskSupplier); } - protected abstract Supplier<Object> getTaskSupplierForGetRequest(final String datastoreName, - final String cmHandleId, - final String resourceIdentifier, + protected abstract Supplier<Object> getTaskSupplierForGetRequest(final CmResourceAddress cmResourceAddress, final String optionsParamInQuery, final String topicParamInQuery, final String requestId, |