summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/app_service_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/app_service_manager.cc')
-rw-r--r--src/components/application_manager/src/app_service_manager.cc37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc
index 397c4ee2fe..bab8147d9f 100644
--- a/src/components/application_manager/src/app_service_manager.cc
+++ b/src/components/application_manager/src/app_service_manager.cc
@@ -72,22 +72,16 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
std::string service_type = manifest[strings::service_type].asString();
- AppService* existing_service =
- FindServiceByProvider(connection_key, service_type);
- if (existing_service) {
- LOG4CXX_DEBUG(logger_,
- "Service already exists for this provider, rejecting");
+ if (FindServiceByProvider(connection_key, service_type)) {
+ LOG4CXX_WARN(logger_,
+ "Service already exists for this provider, rejecting");
return smart_objects::SmartObject();
}
- if (manifest.keyExists(strings::service_name)) {
- existing_service =
- FindServiceByName(manifest[strings::service_name].asString());
- if (existing_service) {
- LOG4CXX_DEBUG(logger_,
- "A service already exists with this name, rejecting");
- return smart_objects::SmartObject();
- }
+ 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();
@@ -478,13 +472,11 @@ AppService* AppServiceManager::FindServiceByProvider(
const uint32_t connection_key, const std::string service_type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
-
- for (auto it = published_services_.begin(); it != published_services_.end();
- ++it) {
- if (it->second.connection_key == connection_key &&
- it->second.record[strings::service_manifest][strings::service_type]
+ for (auto& service : published_services_) {
+ if (service.second.connection_key == connection_key &&
+ service.second.record[strings::service_manifest][strings::service_type]
.asString() == service_type) {
- return &(it->second);
+ return &(service.second);
}
}
return NULL;
@@ -493,11 +485,10 @@ AppService* AppServiceManager::FindServiceByProvider(
AppService* AppServiceManager::FindServiceByName(std::string name) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
- for (auto it = published_services_.begin(); it != published_services_.end();
- ++it) {
- if (it->second.record[strings::service_manifest][strings::service_name]
+ for (auto& service : published_services_) {
+ if (service.second.record[strings::service_manifest][strings::service_name]
.asString() == name) {
- return &(it->second);
+ return &(service.second);
}
}
return NULL;