Refactor GetSubTreePaths method

Since the GetSubTreePaths method has been implemented in dbus_utility
and this commit is to integrate all the places where the
GetSubTreePaths method is called, and use the method in dbus_utility
uniformly.

Requires https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/60020 to
build.

Tested: Redfish Validator Passed

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ie4140d4484a7e4f4b943013f4371ffd2d44a22e9
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index c6016cb..f08a3f3 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -15,12 +15,12 @@
 */
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "health.hpp"
 #include "led.hpp"
 #include "utils/json_utils.hpp"
 
 #include <app.hpp>
-#include <dbus_utility.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
@@ -28,6 +28,9 @@
 #include <utils/collection.hpp>
 #include <utils/dbus_utils.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 
@@ -147,10 +150,11 @@
     asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
     asyncResp->res.jsonValue["Name"] = "Chassis Collection";
 
+    constexpr std::array<std::string_view, 2> interfaces{
+        "xyz.openbmc_project.Inventory.Item.Board",
+        "xyz.openbmc_project.Inventory.Item.Chassis"};
     collection_util::getCollectionMembers(
-        asyncResp, boost::urls::url("/redfish/v1/Chassis"),
-        {"xyz.openbmc_project.Inventory.Item.Board",
-         "xyz.openbmc_project.Inventory.Item.Chassis"});
+        asyncResp, boost::urls::url("/redfish/v1/Chassis"), interfaces);
 }
 
 /**
@@ -604,18 +608,14 @@
 inline void
     doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
 {
-    const char* busName = "xyz.openbmc_project.ObjectMapper";
-    const char* path = "/xyz/openbmc_project/object_mapper";
-    const char* interface = "xyz.openbmc_project.ObjectMapper";
-    const char* method = "GetSubTreePaths";
-
-    const std::array<const char*, 1> interfaces = {
+    constexpr std::array<std::string_view, 1> interfaces = {
         "xyz.openbmc_project.State.Chassis"};
 
     // Use mapper to get subtree paths.
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::getSubTreePaths(
+        "/", 0, interfaces,
         [asyncResp](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& chassisList) {
         if (ec)
         {
@@ -656,8 +656,7 @@
             processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
             interfaceName, destProperty,
             dbus::utility::DbusVariantType{propertyValue});
-        },
-        busName, path, interface, method, "/", 0, interfaces);
+        });
 }
 
 inline void handleChassisResetActionInfoPost(