Skip to content

Commit

Permalink
Replace GetType()->GetName() calls with GetReflectionType()->GetName()
Browse files Browse the repository at this point in the history
fixes #12438
  • Loading branch information
gunnarbeutner committed Aug 15, 2016
1 parent 8299f5f commit a8165eb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/base/configobject.cpp
Expand Up @@ -384,7 +384,7 @@ void ConfigObject::Start(bool runtimeCreated)

void ConfigObject::Activate(bool runtimeCreated)
{
CONTEXT("Activating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
CONTEXT("Activating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");

{
ObjectLock olock(this);
Expand Down Expand Up @@ -413,7 +413,7 @@ void ConfigObject::Stop(bool runtimeRemoved)

void ConfigObject::Deactivate(bool runtimeRemoved)
{
CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");

{
ObjectLock olock(this);
Expand Down
11 changes: 7 additions & 4 deletions lib/db_ido/dbobject.cpp
Expand Up @@ -23,6 +23,9 @@
#include "icinga/customvarobject.hpp"
#include "icinga/service.hpp"
#include "icinga/compatutility.hpp"
#include "icinga/checkcommand.hpp"
#include "icinga/eventcommand.hpp"
#include "icinga/notificationcommand.hpp"
#include "remote/endpoint.hpp"
#include "base/configobject.hpp"
#include "base/configtype.hpp"
Expand Down Expand Up @@ -359,7 +362,7 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object)
if (dbobj)
return dbobj;

DbType::Ptr dbtype = DbType::GetByName(object->GetType()->GetName());
DbType::Ptr dbtype = DbType::GetByName(object->GetReflectionType()->GetName());

if (!dbtype)
return DbObject::Ptr();
Expand All @@ -375,9 +378,9 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object)
name1 = service->GetHost()->GetName();
name2 = service->GetShortName();
} else {
if (object->GetType() == ConfigType::GetByName("CheckCommand") ||
object->GetType() == ConfigType::GetByName("EventCommand") ||
object->GetType() == ConfigType::GetByName("NotificationCommand")) {
if (object->GetReflectionType() == CheckCommand::TypeInstance ||
object->GetReflectionType() == EventCommand::TypeInstance ||
object->GetReflectionType() == NotificationCommand::TypeInstance) {
Command::Ptr command = dynamic_pointer_cast<Command>(object);
name1 = CompatUtility::GetCommandName(command);
}
Expand Down
7 changes: 4 additions & 3 deletions lib/icinga/compatutility.cpp
Expand Up @@ -20,6 +20,7 @@
#include "icinga/compatutility.hpp"
#include "icinga/checkcommand.hpp"
#include "icinga/eventcommand.hpp"
#include "icinga/notificationcommand.hpp"
#include "icinga/pluginutility.hpp"
#include "icinga/service.hpp"
#include "base/utility.hpp"
Expand Down Expand Up @@ -62,11 +63,11 @@ String CompatUtility::GetCommandNamePrefix(const Command::Ptr command)
return Empty;

String prefix;
if (command->GetType() == ConfigType::GetByName("CheckCommand"))
if (command->GetReflectionType() == CheckCommand::TypeInstance)
prefix = "check_";
else if (command->GetType() == ConfigType::GetByName("NotificationCommand"))
else if (command->GetReflectionType() == NotificationCommand::TypeInstance)
prefix = "notification_";
else if (command->GetType() == ConfigType::GetByName("EventCommand"))
else if (command->GetReflectionType() == EventCommand::TypeInstance)
prefix = "event_";

return prefix;
Expand Down
4 changes: 2 additions & 2 deletions lib/remote/apilistener-configsync.cpp
Expand Up @@ -291,7 +291,7 @@ void ApiListener::UpdateConfigObject(const ConfigObject::Ptr& object, const Mess

Dictionary::Ptr params = new Dictionary();
params->Set("name", object->GetName());
params->Set("type", object->GetType()->GetName());
params->Set("type", object->GetReflectionType()->GetName());
params->Set("version", object->GetVersion());

if (object->GetPackage() == "_api") {
Expand Down Expand Up @@ -370,7 +370,7 @@ void ApiListener::DeleteConfigObject(const ConfigObject::Ptr& object, const Mess

Dictionary::Ptr params = new Dictionary();
params->Set("name", object->GetName());
params->Set("type", object->GetType()->GetName());
params->Set("type", object->GetReflectionType()->GetName());
params->Set("version", object->GetVersion());

message->Set("params", params);
Expand Down
2 changes: 1 addition & 1 deletion lib/remote/apilistener.cpp
Expand Up @@ -651,7 +651,7 @@ void ApiListener::PersistMessage(const Dictionary::Ptr& message, const ConfigObj

if (secobj) {
Dictionary::Ptr secname = new Dictionary();
secname->Set("type", secobj->GetType()->GetName());
secname->Set("type", secobj->GetReflectionType()->GetName());
secname->Set("name", secobj->GetName());
pmessage->Set("secobj", secname);
}
Expand Down

0 comments on commit a8165eb

Please sign in to comment.