]> granicus.if.org Git - icinga2/commitdiff
compatutility: Use User(Group) Ptr, not name.
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 1 Oct 2013 14:32:29 +0000 (16:32 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 1 Oct 2013 14:44:33 +0000 (16:44 +0200)
refs #4735

components/livestatus/hoststable.cpp
components/livestatus/servicestable.cpp
lib/icinga/compatutility.cpp

index 42df97add6e9fc9087c12c855db1e82bf0bd1d4a..cefd6892355ea6c82200d523a6a24b2a7d880781 100644 (file)
@@ -1088,7 +1088,15 @@ Value HostsTable::ContactsAccessor(const Value& row)
        if (!hc)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationUsers(hc);
+       Array::Ptr contacts = CompatUtility::GetServiceNotificationUsers(hc);
+       Array::Ptr contact_names = boost::make_shared<Array>();
+
+       ObjectLock olock(contacts);
+       BOOST_FOREACH(const User::Ptr& user, contacts) {
+               contact_names->Add(user->GetName());
+       }
+
+       return contact_names;
 }
 
 Value HostsTable::DowntimesAccessor(const Value& row)
@@ -1581,7 +1589,16 @@ Value HostsTable::ContactGroupsAccessor(const Value& row)
        if (!hc)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationUserGroups(hc);
+       Array::Ptr contactgroups = CompatUtility::GetServiceNotificationUserGroups(hc);
+
+       Array::Ptr contactgroup_names = boost::make_shared<Array>();
+
+       ObjectLock olock(contactgroups);
+       BOOST_FOREACH(const UserGroup::Ptr& usergroup, contactgroups) {
+               contactgroup_names->Add(usergroup->GetName());
+       }
+
+       return contactgroup_names;
 }
 
 Value HostsTable::ServicesAccessor(const Value& row)
index 89a0d0d15c0859616286f2e6276efc7d316ae589..396b4b1e7cb76aadfbf9382a6388bbc092e77423 100644 (file)
@@ -751,7 +751,15 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
 
 Value ServicesTable::ContactsAccessor(const Value& row)
 {
-       return CompatUtility::GetServiceNotificationUsers(static_cast<Service::Ptr>(row));
+       Array::Ptr contacts = CompatUtility::GetServiceNotificationUsers(static_cast<Service::Ptr>(row));
+       Array::Ptr contact_names = boost::make_shared<Array>();
+
+       ObjectLock olock(contacts);
+       BOOST_FOREACH(const User::Ptr& user, contacts) {
+               contact_names->Add(user->GetName());
+       }
+
+       return contact_names;
 }
 
 Value ServicesTable::DowntimesAccessor(const Value& row)
@@ -1002,7 +1010,16 @@ Value ServicesTable::GroupsAccessor(const Value& row)
 
 Value ServicesTable::ContactGroupsAccessor(const Value& row)
 {
-       return CompatUtility::GetServiceNotificationUserGroups(static_cast<Service::Ptr>(row));
+       Array::Ptr contactgroups = CompatUtility::GetServiceNotificationUserGroups(static_cast<Service::Ptr>(row));
+
+       Array::Ptr contactgroup_names = boost::make_shared<Array>();
+
+       ObjectLock olock(contactgroups);
+       BOOST_FOREACH(const UserGroup::Ptr& usergroup, contactgroups) {
+               contactgroup_names->Add(usergroup->GetName());
+       }
+
+       return contactgroup_names;
 }
 
 
index e59346e2d6ce0ca08b559da9f556a64c2a8f4d5a..9fa6b96d88e2dca081c3264504a70b4830176ac7 100644 (file)
@@ -504,7 +504,7 @@ Value CompatUtility::GetServiceNotificationUsers(const Service::Ptr& service)
         }
 
        BOOST_FOREACH(const User::Ptr& user, allUsers) {
-               contacts->Add(user->GetName());
+               contacts->Add(user);
        }
 
        return contacts;
@@ -519,7 +519,7 @@ Value CompatUtility::GetServiceNotificationUserGroups(const Service::Ptr& servic
                ObjectLock olock(notification);
 
                BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
-                       contactgroups->Add(ug->GetName());
+                       contactgroups->Add(ug);
                 }
         }