Merge "Migrate CPS to Spring-boot 3.0"
[cps.git] / cps-ncmp-rest / src / main / java / org / onap / cps / ncmp / rest / controller / NetworkCmProxyInventoryController.java
index 0c428e4..87f9d83 100755 (executable)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2021-2022 Bell Canada
- *  Modifications Copyright (C) 2022 Nordix Foundation
+ *  Modifications Copyright (C) 2022-2023 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 
 package org.onap.cps.ncmp.rest.controller;
 
+import io.micrometer.core.annotation.Timed;
+import jakarta.validation.Valid;
+import java.util.Collection;
 import java.util.List;
-import java.util.Set;
 import java.util.stream.Collectors;
-import javax.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
+import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters;
 import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
 import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status;
 import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
 import org.onap.cps.ncmp.rest.api.NetworkCmProxyInventoryApi;
+import org.onap.cps.ncmp.rest.model.CmHandleQueryParameters;
 import org.onap.cps.ncmp.rest.model.CmHandlerRegistrationErrorResponse;
 import org.onap.cps.ncmp.rest.model.DmiPluginRegistrationErrorResponse;
 import org.onap.cps.ncmp.rest.model.RestDmiPluginRegistration;
@@ -47,6 +50,16 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor
     private final NetworkCmProxyDataService networkCmProxyDataService;
     private final NcmpRestInputMapper ncmpRestInputMapper;
 
+    @Override
+    public ResponseEntity<List<String>> searchCmHandleIds(final CmHandleQueryParameters cmHandleQueryParameters) {
+        final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = ncmpRestInputMapper
+                .toCmHandleQueryServiceParameters(cmHandleQueryParameters);
+
+        final Collection<String> cmHandleIds = networkCmProxyDataService
+                .executeCmHandleIdSearchForInventory(cmHandleQueryServiceParameters);
+        return ResponseEntity.ok(List.copyOf(cmHandleIds));
+    }
+
     /**
      * Get all cm-handle IDs under a registered DMI plugin.
      *
@@ -55,7 +68,7 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor
      */
     @Override
     public ResponseEntity<List<String>> getAllCmHandleIdsForRegisteredDmi(final String dmiPluginIdentifier) {
-        final Set<String> cmHandleIds =
+        final Collection<String> cmHandleIds =
                 networkCmProxyDataService.getAllCmHandleIdsByDmiPluginIdentifier(dmiPluginIdentifier);
         return ResponseEntity.ok(List.copyOf(cmHandleIds));
     }
@@ -66,6 +79,8 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor
      * @param restDmiPluginRegistration the registration data
      */
     @Override
+    @Timed(value = "cps.ncmp.inventory.controller.update",
+        description = "Time taken to handle registration request")
     public ResponseEntity updateDmiPluginRegistration(
         final @Valid RestDmiPluginRegistration restDmiPluginRegistration) {
         final DmiPluginRegistrationResponse dmiPluginRegistrationResponse =