From 17b87c9b2a0cc0aa32df1fa6ba6ee13e501ea537 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 4 Apr 2014 16:35:45 +0200 Subject: [PATCH] Add CompatUtility::IsLegacyAttribute(). Refs #5855 --- lib/icinga/compatutility.cpp | 36 +++++++++++++++++++++++++----------- lib/icinga/compatutility.h | 1 + 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index f18a935e7..ffc12d0f1 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -407,6 +407,30 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka } /* vars attr */ + +bool CompatUtility::IsLegacyAttribute(const String& name) +{ + if (name == "address" || + name == "address1" || + name == "address2" || + name == "address3" || + name == "address4" || + name == "address5" || + name == "address6" || /* user, host */ + name == "email" || + name == "pager" || + name == "notes" || + name == "action_url" || + name == "notes_url" || + name == "icon_image" || + name == "icon_image_alt" || + name == "statusmap_image" || + name == "2d_coords") + return true; + + return false; +} + Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr& object) { ASSERT(object->OwnsLock()); @@ -421,17 +445,7 @@ Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr ObjectLock olock(vars); BOOST_FOREACH(const Dictionary::Pair& kv, vars) { if (!kv.first.IsEmpty()) { - if (kv.first != "address" && - kv.first != "address6" && - kv.first != "email" && - kv.first != "pager" && - kv.first != "notes" && - kv.first != "action_url" && - kv.first != "notes_url" && - kv.first != "icon_image" && - kv.first != "icon_image_alt" && - kv.first != "statusmap_image" && - kv.first != "2d_coords") + if (!IsLegacyAttribute(kv.first)) varsvars->Set(kv.first, kv.second); } } diff --git a/lib/icinga/compatutility.h b/lib/icinga/compatutility.h index 446a8e9d3..936ff58a2 100644 --- a/lib/icinga/compatutility.h +++ b/lib/icinga/compatutility.h @@ -113,6 +113,7 @@ public: static String GetCommandLine(const Command::Ptr& command); /* custom attribute */ + static bool IsLegacyAttribute(const String& name); static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name); static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);