control: Let Manager::addObjects() take a service

When calling Manager::addObjects(), pass in the service of the object,
if known, so that addObjects() can use that service to call
getManagedObjects() with and add objects to the cache even if the
D-Bus path passed in doesn't exist.

This fixes a bug where if the path doesn't exist, that function won't
add anything at all, even though getProperties() in init.cpp was
depending on it doing that so that it only needed to call addObjects()
once per group as a performance enhancement.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I971a244d665d3aaf493c3d03e7a4fec87e7e512d
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 9825a32..c9d679f 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -531,17 +531,33 @@
 }
 
 void Manager::addObjects(const std::string& path, const std::string& intf,
-                         const std::string& prop)
+                         const std::string& prop,
+                         const std::string& serviceName)
 {
-    auto service = getService(path, intf);
+    auto service = serviceName;
     if (service.empty())
     {
-        // Log service not found for object
-        log<level::DEBUG>(
-            fmt::format("Unable to get service name for path {}, interface {}",
-                        path, intf)
-                .c_str());
-        return;
+        service = getService(path, intf);
+        if (service.empty())
+        {
+            // Log service not found for object
+            log<level::DEBUG>(
+                fmt::format(
+                    "Unable to get service name for path {}, interface {}",
+                    path, intf)
+                    .c_str());
+            return;
+        }
+    }
+    else
+    {
+        // The service is known, so the service cache can be
+        // populated even if the path itself isn't present.
+        const auto& s = findService(path, intf);
+        if (s.empty())
+        {
+            addServices(intf, 0);
+        }
     }
 
     auto objMgrPaths = getPaths(service, "org.freedesktop.DBus.ObjectManager");