diff options
Diffstat (limited to 'src/components/policy/policy_external/src/sql_pt_representation.cc')
-rw-r--r-- | src/components/policy/policy_external/src/sql_pt_representation.cc | 32 |
1 files changed, 24 insertions, 8 deletions
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 b9b0194199..10be5a4626 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1740,6 +1740,10 @@ bool SQLPTRepresentation::GatherModuleType( if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) { return false; } + if (policy_table::ModuleType::MT_EMPTY == type) { + app_types->mark_initialized(); + continue; + } app_types->push_back(type); } return true; @@ -1772,18 +1776,30 @@ bool SQLPTRepresentation::SaveModuleType( } policy_table::ModuleTypes::const_iterator it; - for (it = types.begin(); it != types.end(); ++it) { + if (!types.empty()) { + for (it = types.begin(); it != types.end(); ++it) { + query.Bind(0, app_id); + std::string module(policy_table::EnumToJsonString(*it)); + query.Bind(1, module); + LOG4CXX_DEBUG(logger_, + "Module(app: " << app_id << ", type: " << module << ")"); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into module type."); + return false; + } + } + } else if (types.is_initialized()) { query.Bind(0, app_id); - std::string module(policy_table::EnumToJsonString(*it)); - query.Bind(1, module); - LOG4CXX_DEBUG(logger_, - "Module(app: " << app_id << ", type: " << module << ")"); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::ModuleType::MT_EMPTY))); if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into module type."); + LOG4CXX_WARN(logger_, "Incorrect insert into module types."); return false; - } + } + } else { + LOG4CXX_WARN(logger_, "Module Type omitted."); } - return true; } |