summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_external/src/sql_pt_ext_representation.cc')
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
index f58a7f0b82..a43b22a3b8 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
@@ -670,6 +670,11 @@ bool SQLPTExtRepresentation::SaveApplicationPoliciesSection(
return false;
}
+ if (!query_delete.Exec(sql_pt::kDeleteRequestSubType)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from request subtype.");
+ return false;
+ }
+
// First, all predefined apps (e.g. default, pre_DataConsent) should be saved,
// otherwise another app with the predefined permissions can get incorrect
// permissions
@@ -713,18 +718,17 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
if (!SetDefaultPolicy(app.first)) {
return false;
}
- if (!SaveRequestType(app.first, *app.second.RequestType)) {
- return false;
- }
} else if (kPreDataConsentId.compare(app.second.get_string()) == 0) {
if (!SetPredataPolicy(app.first)) {
return false;
}
- if (!SaveRequestType(app.first, *app.second.RequestType)) {
- return false;
- }
}
-
+ if (!SaveRequestType(app.first, *app.second.RequestType)) {
+ return false;
+ }
+ if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) {
+ return false;
+ }
// Stop saving other params, since predefined permissions already set
return true;
}
@@ -757,6 +761,13 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
if (!SaveAppGroup(app.first, app.second.groups)) {
return false;
}
+
+ bool denied = !app.second.moduleType->is_initialized();
+ if (!SaveRemoteControlDenied(app.first, denied) ||
+ !SaveModuleType(app.first, *app.second.moduleType)) {
+ return false;
+ }
+
if (!SaveNickname(app.first, *app.second.nicknames)) {
return false;
}
@@ -771,6 +782,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
return false;
}
+ if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) {
+ return false;
+ }
+
return true;
}
@@ -859,19 +874,39 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
*params.memory_kb = query.GetInteger(5);
*params.heart_beat_timeout_ms = query.GetUInteger(6);
- if (!GatherAppGroup(app_id, &params.groups)) {
+ const auto& gather_app_id = ((*policies).apps[app_id].is_string())
+ ? (*policies).apps[app_id].get_string()
+ : app_id;
+ // Data should be gathered from db by "default" key if application has
+ // default policies
+
+ if (!GatherAppGroup(gather_app_id, &params.groups)) {
+ return false;
+ }
+
+ bool denied = false;
+ if (!GatherRemoteControlDenied(gather_app_id, &denied)) {
+ return false;
+ }
+ if (!denied) {
+ if (!GatherModuleType(gather_app_id, &*params.moduleType)) {
+ return false;
+ }
+ }
+
+ if (!GatherNickName(gather_app_id, &*params.nicknames)) {
return false;
}
- if (!GatherNickName(app_id, &*params.nicknames)) {
+ if (!GatherAppType(gather_app_id, &*params.AppHMIType)) {
return false;
}
- if (!GatherAppType(app_id, &*params.AppHMIType)) {
+ if (!GatherRequestType(gather_app_id, &*params.RequestType)) {
return false;
}
- if (!GatherRequestType(app_id, &*params.RequestType)) {
+ if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) {
return false;
}
- GatherPreconsentedGroup(app_id, &*params.preconsented_groups);
+ GatherPreconsentedGroup(gather_app_id, &*params.preconsented_groups);
(*policies).apps[app_id] = params;
}
return true;