diff options
author | JackLivio <jack@livio.io> | 2019-07-17 16:51:57 -0400 |
---|---|---|
committer | JackLivio <jack@livio.io> | 2019-07-17 16:51:57 -0400 |
commit | 01f5de0fe08905bad974d5793df79e870d11ab35 (patch) | |
tree | 1086999b156a9b683525516201232fad2217e60b | |
parent | 4505a975445c1a04ec85460122abda49500cbfae (diff) | |
download | sdl_core-01f5de0fe08905bad974d5793df79e870d11ab35.tar.gz |
Fix check for duplicate name
-rw-r--r-- | src/components/application_manager/src/app_service_manager.cc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 4d4dde76a6..09bdb9ea69 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -70,19 +70,27 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::string str_to_hash = ""; std::string service_id = ""; - if (manifest.keyExists(strings::service_name) && - FindServiceByName(manifest[strings::service_name].asString())) { - LOG4CXX_WARN(logger_, "A service already exists with this name, rejecting"); - return smart_objects::SmartObject(); - } - std::string service_type = manifest[strings::service_type].asString(); AppService* found_service = FindServiceByProvider(connection_key, service_type); if (found_service) { + // Check if there is a different existing service with the same updated + // name. + if (manifest.keyExists(strings::service_name)) { + auto service_by_name = + FindServiceByName(manifest[strings::service_name].asString()); + auto service_by_name_id = + service_by_name->record[strings::service_id].asString(); + auto found_service_id = + service_by_name->record[strings::service_id].asString(); + if (service_by_name_id != found_service_id) { + LOG4CXX_WARN(logger_, + "A service already exists with this name, rejecting"); + return smart_objects::SmartObject(); + } + } LOG4CXX_WARN(logger_, "Service already exists for this provider, updating"); - published_services_lock_.Acquire(); found_service->record[strings::service_manifest] = manifest; found_service->record[strings::service_published] = true; @@ -102,6 +110,12 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( return updated_service_record; } + if (manifest.keyExists(strings::service_name) && + FindServiceByName(manifest[strings::service_name].asString())) { + LOG4CXX_WARN(logger_, "A service already exists with this name, rejecting"); + return smart_objects::SmartObject(); + } + published_services_lock_.Acquire(); do { str_to_hash = manifest[strings::service_type].asString() + |