Add the GetObject method to dbus_utility

There are currently many files that use the GetObject method.
Since they are a general method, they are defined in the
dbus_utility.hpp file and refactors them.

Tested: Built bmcweb successfully and Validator passes.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: If2af77294389b023b611987252ee6149906fcd25
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 61eaa6e..948bc36 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -406,8 +406,9 @@
 inline void getObjectAndEnumerate(
     const std::shared_ptr<InProgressEnumerateData>& transaction)
 {
-    crow::connections::systemBus->async_method_call(
-        [transaction](const boost::system::error_code ec,
+    dbus::utility::getDbusObject(
+        transaction->objectPath, {},
+        [transaction](const boost::system::error_code& ec,
                       const dbus::utility::MapperGetObject& objects) {
         if (ec)
         {
@@ -466,11 +467,7 @@
                     transaction->objectPath, connection.first, transaction);
             }
         }
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetObject",
-        transaction->objectPath, std::array<const char*, 0>());
+        });
 }
 
 // Structure for storing data on an in progress action
@@ -1571,9 +1568,10 @@
     transaction->path = objectPath;
     transaction->methodName = methodName;
     transaction->arguments = std::move(*data);
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::getDbusObject(
+        objectPath, {},
         [transaction](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const std::vector<std::pair<std::string, std::vector<std::string>>>&
                 interfaceNames) {
         if (ec || interfaceNames.empty())
@@ -1593,11 +1591,7 @@
         {
             findActionOnInterface(transaction, object.first);
         }
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetObject", objectPath,
-        std::array<std::string, 0>());
+        });
 }
 
 inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -1605,9 +1599,10 @@
 {
     BMCWEB_LOG_DEBUG << "handleDelete on path: " << objectPath;
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::getDbusObject(
+        objectPath, {},
         [asyncResp, objectPath](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const std::vector<std::pair<std::string, std::vector<std::string>>>&
                 interfaceNames) {
         if (ec || interfaceNames.empty())
@@ -1630,11 +1625,7 @@
         {
             findActionOnInterface(transaction, object.first);
         }
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetObject", objectPath,
-        std::array<const char*, 0>());
+        });
 }
 
 inline void handleList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -1710,9 +1701,10 @@
     std::shared_ptr<std::string> path =
         std::make_shared<std::string>(std::move(objectPath));
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::getDbusObject(
+        *path, {},
         [asyncResp, path,
-         propertyName](const boost::system::error_code ec,
+         propertyName](const boost::system::error_code& ec,
                        const dbus::utility::MapperGetObject& objectNames) {
         if (ec || objectNames.empty())
         {
@@ -1801,11 +1793,7 @@
                     });
             }
         }
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetObject", *path,
-        std::array<std::string, 0>());
+        });
 }
 
 struct AsyncPutRequest
@@ -1878,8 +1866,9 @@
     transaction->propertyName = destProperty;
     transaction->propertyValue = propertySetValue;
 
-    crow::connections::systemBus->async_method_call(
-        [transaction](const boost::system::error_code ec2,
+    dbus::utility::getDbusObject(
+        transaction->objectPath, {},
+        [transaction](const boost::system::error_code& ec2,
                       const dbus::utility::MapperGetObject& objectNames) {
         if (!ec2 && objectNames.empty())
         {
@@ -2016,11 +2005,7 @@
                 connectionName, transaction->objectPath,
                 "org.freedesktop.DBus.Introspectable", "Introspect");
         }
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetObject",
-        transaction->objectPath, std::array<std::string, 0>());
+        });
 }
 
 inline void handleDBusUrl(const crow::Request& req,