diff options
author | Alexander <akutsan@luxoft.com> | 2018-10-12 16:19:45 +0000 |
---|---|---|
committer | Alexander <akutsan@luxoft.com> | 2018-10-15 20:05:52 +0000 |
commit | 3f37ee5c1c1f3a97b98b6dc4bfb1a20444d3b8dd (patch) | |
tree | 8623d1c045b06f0e25f5a9f877a8392ce189f3ee | |
parent | a79f04439de495787f660019859d46eede5b07e2 (diff) | |
download | sdl_core-3f37ee5c1c1f3a97b98b6dc4bfb1a20444d3b8dd.tar.gz |
Load module types from referecced group for app_policies
If appllication have default policies, sqldb does not store module types for this application separately.
During loading db SDL should check that application have default policies
and select from module_types sql table sing "default" key but not appid key.
In function `GatherApplicationPoliciesSection` already exist check for default policies :
```
if (IsDefaultPolicy(app_id)) {
(*policies).apps[app_id].set_to_string(kDefaultId);
}
```
Its setup stringified representation of application policies : "default".
This stringified reference ("default") used for select module type.
Fixes : https://github.com/smartdevicelink/sdl_core/issues/2670
-rw-r--r-- | src/components/policy/policy_regular/src/sql_pt_representation.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 4f5dbc4c3b..bb08dd185b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -692,6 +692,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( while (query.Next()) { rpc::Nullable<policy_table::ApplicationParams> params; const std::string& app_id = query.GetString(0); + if (IsApplicationRevoked(app_id)) { params.set_to_null(); (*policies).apps[app_id] = params; @@ -720,29 +721,35 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( if (!query.IsNull(3)) { *params.certificate = query.GetString(4); } - if (!GatherAppGroup(app_id, ¶ms.groups)) { + + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) + ? (*policies).apps[app_id].get_string() + : app_id; + + if (!GatherAppGroup(gather_app_id, ¶ms.groups)) { return false; } bool denied = false; - if (!GatherRemoteControlDenied(app_id, &denied)) { + if (!GatherRemoteControlDenied(gather_app_id, &denied)) { return false; } if (!denied) { - if (!GatherModuleType(app_id, &*params.moduleType)) { + // Module types should be selected from db by referenced groups + if (!GatherModuleType(gather_app_id, &*params.moduleType)) { return false; } } - if (!GatherNickName(app_id, &*params.nicknames)) { + if (!GatherNickName(gather_app_id, &*params.nicknames)) { return false; } - if (!GatherAppType(app_id, &*params.AppHMIType)) { + if (!GatherAppType(gather_app_id, &*params.AppHMIType)) { return false; } - if (!GatherRequestType(app_id, &*params.RequestType)) { + if (!GatherRequestType(gather_app_id, &*params.RequestType)) { return false; } - if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } |