diff options
Diffstat (limited to 'src/components')
9 files changed, 1 insertions, 233 deletions
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h index 5d75649c62..a69df20cfc 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h @@ -117,11 +117,8 @@ extern const std::string kSelectApplicationFull; extern const std::string kUpdatePreloaded; extern const std::string kUpdateRemoteControlDenied; extern const std::string kSelectRemoteControlDenied; -extern const std::string kDeleteAppGroupPrimaryByApplicationId; extern const std::string kCollectFriendlyMsg; -extern const std::string kSelectAppGroupsPrimary; extern const std::string kSelectModuleTypes; -extern const std::string kInsertAppGroupPrimary; extern const std::string kInsertModuleType; extern const std::string kInsertAccessModule; extern const std::string kSelectAccessModules; @@ -129,7 +126,6 @@ extern const std::string kDeleteAccessModules; extern const std::string kInsertRemoteRpc; extern const std::string kSelectRemoteRpcs; extern const std::string kDeleteRemoteRpc; -extern const std::string kDeleteAppGroupPrimary; extern const std::string kDeleteModuleTypes; extern const std::string kDeleteAllDevices; extern const std::string kSelectDBVersion; diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h index fc7f71e575..90dab7fa60 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h @@ -108,8 +108,6 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherAccessModule(TypeAccess access, policy_table::AccessModules* modules) const; bool GatherRemoteRpc(int module_id, policy_table::RemoteRpcs* rpcs) const; - bool SaveAppGroupPrimary(const std::string& app_id, - const policy_table::Strings& app_groups); bool SaveModuleType(const std::string& app_id, const policy_table::ModuleTypes& types); bool SaveRemoteControlDenied(const std::string& app_id, bool deny); diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 7919202cd1..e3e1029692 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -351,25 +351,6 @@ const std::string kCreateSchema = " REFERENCES `message_type`(`name`) " "); " - "CREATE TABLE IF NOT EXISTS `app_group_primary`( " - " `application_id` VARCHAR(45) NOT NULL, " - " `functional_group_id` INTEGER NOT NULL, " - " PRIMARY KEY(`application_id`,`functional_group_id`), " - " CONSTRAINT `fk_application_has_functional_group_application1` " - " FOREIGN KEY(`application_id`) " - " REFERENCES `application`(`id`), " - " CONSTRAINT `fk_application_has_functional_group_functional_group1` " - " FOREIGN KEY(`functional_group_id`) " - " REFERENCES `functional_group`(`id`) " - "); " - "CREATE INDEX IF NOT EXISTS " - "`app_group_primary.fk_application_has_functional_group_functional_group1_" - "idx` " - " ON `app_group_primary`(`functional_group_id`); " - "CREATE INDEX IF NOT EXISTS " - "`app_group_primary.fk_application_has_functional_group_application1_idx` " - " ON `app_group_primary`(`application_id`); " - /* access_module */ "CREATE TABLE `access_module`( " " `id` INTEGER PRIMARY KEY NOT NULL, " @@ -445,25 +426,13 @@ const std::string kInsertInitData = "INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); " ""; -const std::string kDeleteAppGroupPrimary = "DELETE FROM `app_group_primary`"; - const std::string kDeleteModuleTypes = "DELETE FROM `module_type`"; const std::string kDeleteAllDevices = "DELETE FROM `device`;"; -const std::string kSelectAppGroupsPrimary = - "SELECT `f`.`name` FROM `app_group_primary` AS `a`" - " LEFT JOIN `functional_group` AS `f` " - " ON (`f`.`id` = `a`.`functional_group_id`)" - " WHERE `a`.`application_id` = ?"; - const std::string kSelectRemoteControlDenied = "SELECT `remote_control_denied` FROM `application` WHERE `id` = ? LIMIT 1"; -const std::string kInsertAppGroupPrimary = - "INSERT INTO `app_group_primary` (`application_id`, `functional_group_id`)" - " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1"; - const std::string kUpdateRemoteControlDenied = "UPDATE `application` SET `remote_control_denied` = ? WHERE `id` = ?"; @@ -475,9 +444,6 @@ const std::string kInsertAccessModule = "INSERT INTO `access_module` (`name`, `user_consent_needed`) " " VALUES(?, ?, ?)"; -const std::string kDeleteAppGroupPrimaryByApplicationId = - "DELETE FROM `app_group_primary` WHERE `application_id` = ?"; - const std::string kSelectAccessModules = "SELECT `id`, `name` FROM `access_module` " " WHERE `user_consent_needed` = ?"; @@ -536,12 +502,6 @@ const std::string kDropSchema = "`preconsented_group.fk_application_has_functional_group_functional_group2_" "idx`; " "DROP TABLE IF EXISTS `preconsented_group`; " - "DROP INDEX IF EXISTS " - "`app_group_primary.fk_application_has_functional_group_application1_idx`; " - "DROP INDEX IF EXISTS " - "`app_group_primary.fk_application_has_functional_group_functional_group1_" - "idx`; " - "DROP TABLE IF EXISTS `app_group_primary`; " "DROP TABLE IF EXISTS `access_module`; " "DROP INDEX IF EXISTS `access_module.fk_module_1_idx`; " "DROP INDEX IF EXISTS " @@ -593,7 +553,6 @@ const std::string kDeleteData = "DELETE FROM `app_group`; " "DELETE FROM `application`; " "DELETE FROM `rpc`; " - "DELETE FROM `app_group_primary`; " "DELETE FROM `access_module`; " "DELETE FROM `version`; " "DELETE FROM `message_type`; " diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index b5d04be8c2..3d5ae4960d 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -967,17 +967,6 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection( return false; } -#ifdef SDL_REMOTE_CONTROL - if (!query_delete.Exec(sql_pt::kDeleteAppGroupPrimary)) { - LOG4CXX_WARN(logger_, "Incorrect delete from app_group_primary."); - return false; - } - if (!query_delete.Exec(sql_pt::kDeleteModuleTypes)) { - LOG4CXX_WARN(logger_, "Incorrect delete from module_type."); - return false; - } -#endif // SDL_REMOTE_CONTROL - if (!query_delete.Exec(sql_pt::kDeleteApplication)) { LOG4CXX_WARN(logger_, "Incorrect delete from application."); return false; @@ -1632,20 +1621,6 @@ bool SQLPTRepresentation::GatherAppGroup( } #ifdef SDL_REMOTE_CONTROL -bool SQLPTRepresentation::GatherAppGroupPrimary( - const std::string& app_id, policy_table::Strings* app_groups) const { - dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kSelectAppGroupsPrimary)) { - LOG4CXX_WARN(logger_, "Incorrect select from app groups for primary RC"); - return false; - } - - query.Bind(0, app_id); - while (query.Next()) { - app_groups->push_back(query.GetString(0)); - } - return true; -} bool SQLPTRepresentation::GatherRemoteControlDenied(const std::string& app_id, bool* denied) const { @@ -1683,49 +1658,6 @@ bool SQLPTRepresentation::GatherModuleType( return true; } -bool SQLPTRepresentation::SaveAppGroupPrimary( - const std::string& app_id, const policy_table::Strings& app_groups) { - LOG4CXX_AUTO_TRACE(logger_); - dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertAppGroupPrimary)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for app group primary"); - return false; - } - policy_table::Strings::const_iterator it; - for (it = app_groups.begin(); it != app_groups.end(); ++it) { - std::string ssss = *it; - LOG4CXX_INFO(logger_, "Group: " << ssss); - query.Bind(0, app_id); - query.Bind(1, *it); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Incorrect insert into app group primary." - << query.LastError().text()); - return false; - } - } - - return true; -} - -bool SQLPTRepresentation::SaveRemoteControlDenied(const std::string& app_id, - bool deny) { - LOG4CXX_AUTO_TRACE(logger_); - dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kUpdateRemoteControlDenied)) { - LOG4CXX_WARN(logger_, "Incorrect update statement for remote control flag"); - return false; - } - LOG4CXX_DEBUG(logger_, "App: " << app_id << std::boolalpha << " - " << deny); - query.Bind(0, deny); - query.Bind(1, app_id); - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Incorrect update remote control flag."); - return false; - } - return true; -} - bool SQLPTRepresentation::SaveModuleType( const std::string& app_id, const policy_table::ModuleTypes& types) { dbms::SQLQuery query(db()); @@ -1948,20 +1880,6 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { return false; } -#ifdef SDL_REMOTE_CONTROL - dbms::SQLQuery query_p(db()); - if (!query_p.Prepare(sql_pt::kDeleteAppGroupPrimaryByApplicationId)) { - LOG4CXX_ERROR(logger_, - "Incorrect statement to delete from app_group_primary."); - return false; - } - query_p.Bind(0, app_id); - if (!query_p.Exec()) { - LOG4CXX_ERROR(logger_, "Failed deleting from app_group_primary."); - return false; - } -#endif // SDL_REMOTE_CONTROL - if (!CopyApplication(kDefaultId, app_id)) { return false; } diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index 97b52ecf05..2ded25e456 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -116,11 +116,8 @@ extern const std::string kSelectApplicationFull; extern const std::string kUpdatePreloaded; extern const std::string kUpdateRemoteControlDenied; extern const std::string kSelectRemoteControlDenied; -extern const std::string kDeleteAppGroupPrimaryByApplicationId; extern const std::string kCollectFriendlyMsg; -extern const std::string kSelectAppGroupsPrimary; extern const std::string kSelectModuleTypes; -extern const std::string kInsertAppGroupPrimary; extern const std::string kInsertModuleType; extern const std::string kInsertAccessModule; extern const std::string kSelectAccessModules; @@ -128,7 +125,6 @@ extern const std::string kDeleteAccessModules; extern const std::string kInsertRemoteRpc; extern const std::string kSelectRemoteRpcs; extern const std::string kDeleteRemoteRpc; -extern const std::string kDeleteAppGroupPrimary; extern const std::string kDeleteModuleTypes; extern const std::string kDeleteAllDevices; extern const std::string kSelectDBVersion; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index 8c3f0ea1c5..4b66c4101b 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -107,8 +107,6 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherAccessModule(TypeAccess access, policy_table::AccessModules* modules) const; bool GatherRemoteRpc(int module_id, policy_table::RemoteRpcs* rpcs) const; - bool SaveAppGroupPrimary(const std::string& app_id, - const policy_table::Strings& app_groups); bool SaveModuleType(const std::string& app_id, const policy_table::ModuleTypes& types); bool SaveRemoteControlDenied(const std::string& app_id, bool deny); diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index f0a3c2f160..7938eb4085 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -318,25 +318,6 @@ const std::string kCreateSchema = " REFERENCES `message_type`(`name`) " "); " - "CREATE TABLE IF NOT EXISTS `app_group_primary`( " - " `application_id` VARCHAR(45) NOT NULL, " - " `functional_group_id` INTEGER NOT NULL, " - " PRIMARY KEY(`application_id`,`functional_group_id`), " - " CONSTRAINT `fk_application_has_functional_group_application1` " - " FOREIGN KEY(`application_id`) " - " REFERENCES `application`(`id`), " - " CONSTRAINT `fk_application_has_functional_group_functional_group1` " - " FOREIGN KEY(`functional_group_id`) " - " REFERENCES `functional_group`(`id`) " - "); " - "CREATE INDEX IF NOT EXISTS " - "`app_group_primary.fk_application_has_functional_group_functional_group1_" - "idx` " - " ON `app_group_primary`(`functional_group_id`); " - "CREATE INDEX IF NOT EXISTS " - "`app_group_primary.fk_application_has_functional_group_application1_idx` " - " ON `app_group_primary`(`application_id`); " - /* access_module */ "CREATE TABLE `access_module`( " " `id` INTEGER PRIMARY KEY NOT NULL, " @@ -406,25 +387,13 @@ const std::string kInsertInitData = "INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); " ""; -const std::string kDeleteAppGroupPrimary = "DELETE FROM `app_group_primary`"; - const std::string kDeleteModuleTypes = "DELETE FROM `module_type`"; const std::string kDeleteAllDevices = "DELETE FROM `device`;"; -const std::string kSelectAppGroupsPrimary = - "SELECT `f`.`name` FROM `app_group_primary` AS `a`" - " LEFT JOIN `functional_group` AS `f` " - " ON (`f`.`id` = `a`.`functional_group_id`)" - " WHERE `a`.`application_id` = ?"; - const std::string kSelectRemoteControlDenied = "SELECT `remote_control_denied` FROM `application` WHERE `id` = ? LIMIT 1"; -const std::string kInsertAppGroupPrimary = - "INSERT INTO `app_group_primary` (`application_id`, `functional_group_id`)" - " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1"; - const std::string kUpdateRemoteControlDenied = "UPDATE `application` SET `remote_control_denied` = ? WHERE `id` = ?"; @@ -436,9 +405,6 @@ const std::string kInsertAccessModule = "INSERT INTO `access_module` (`name`, `user_consent_needed`) " " VALUES(?, ?, ?)"; -const std::string kDeleteAppGroupPrimaryByApplicationId = - "DELETE FROM `app_group_primary` WHERE `application_id` = ?"; - const std::string kSelectAccessModules = "SELECT `id`, `name` FROM `access_module` " " WHERE `user_consent_needed` = ?"; @@ -494,12 +460,6 @@ const std::string kDropSchema = "`preconsented_group.fk_application_has_functional_group_functional_group2_" "idx`; " "DROP TABLE IF EXISTS `preconsented_group`; " - "DROP INDEX IF EXISTS " - "`app_group_primary.fk_application_has_functional_group_application1_idx`; " - "DROP INDEX IF EXISTS " - "`app_group_primary.fk_application_has_functional_group_functional_group1_" - "idx`; " - "DROP TABLE IF EXISTS `app_group_primary`; " "DROP TABLE IF EXISTS `access_module`; " "DROP INDEX IF EXISTS `access_module.fk_module_1_idx`; " "DROP INDEX IF EXISTS " @@ -548,7 +508,6 @@ const std::string kDeleteData = "DELETE FROM `app_group`; " "DELETE FROM `application`; " "DELETE FROM `rpc`; " - "DELETE FROM `app_group_primary`; " "DELETE FROM `access_module`; " "DELETE FROM `version`; " "DELETE FROM `message_type`; " 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 06cbc03dfb..9f529b7d78 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -871,10 +871,6 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection( return false; } #ifdef SDL_REMOTE_CONTROL - if (!query_delete.Exec(sql_pt::kDeleteAppGroupPrimary)) { - LOG4CXX_WARN(logger_, "Incorrect delete from app_group_primary."); - return false; - } if (!query_delete.Exec(sql_pt::kDeleteModuleTypes)) { LOG4CXX_WARN(logger_, "Incorrect delete from module_type."); return false; @@ -1534,20 +1530,6 @@ bool SQLPTRepresentation::GatherAppGroup( } #ifdef SDL_REMOTE_CONTROL -bool SQLPTRepresentation::GatherAppGroupPrimary( - const std::string& app_id, policy_table::Strings* app_groups) const { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kSelectAppGroupsPrimary)) { - LOG4CXX_WARN(logger_, "Incorrect select from app groups for primary RC"); - return false; - } - - query.Bind(0, app_id); - while (query.Next()) { - app_groups->push_back(query.GetString(0)); - } - return true; -} bool SQLPTRepresentation::GatherRemoteControlDenied(const std::string& app_id, bool* denied) const { @@ -1585,31 +1567,6 @@ bool SQLPTRepresentation::GatherModuleType( return true; } -bool SQLPTRepresentation::SaveAppGroupPrimary( - const std::string& app_id, const policy_table::Strings& app_groups) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertAppGroupPrimary)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for app group primary"); - return false; - } - policy_table::Strings::const_iterator it; - for (it = app_groups.begin(); it != app_groups.end(); ++it) { - std::string ssss = *it; - LOG4CXX_INFO(logger_, "Group: " << ssss); - query.Bind(0, app_id); - query.Bind(1, *it); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Incorrect insert into app group primary." - << query.LastError().text()); - return false; - } - } - - return true; -} - bool SQLPTRepresentation::SaveRemoteControlDenied(const std::string& app_id, bool deny) { LOG4CXX_AUTO_TRACE(logger_); @@ -1849,19 +1806,6 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { LOG4CXX_ERROR(logger_, "Failed deleting from app_group."); return false; } -#ifdef SDL_REMOTE_CONTROL - utils::dbms::SQLQuery query_p(db()); - if (!query_p.Prepare(sql_pt::kDeleteAppGroupPrimaryByApplicationId)) { - LOG4CXX_ERROR(logger_, - "Incorrect statement to delete from app_group_primary."); - return false; - } - query_p.Bind(0, app_id); - if (!query_p.Exec()) { - LOG4CXX_ERROR(logger_, "Failed deleting from app_group_primary."); - return false; - } -#endif // SDL_REMOTE_CONTROL if (!CopyApplication(kDefaultId, app_id)) { return false; diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index cbde0ca00f..fd83c82b1a 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -420,7 +420,7 @@ TEST_F(SQLPTRepresentationTest, ASSERT_EQ(0, dbms->FetchOneInt(query_select)); ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - const int32_t total_tables_number = 29; + const int32_t total_tables_number = 28; ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select)); const char* query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; |