summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2019-01-29 15:21:13 -0500
committerJackLivio <jack@livio.io>2019-01-29 15:21:13 -0500
commitbfcae5a747ff5f72de9132c2e992e1bbaa7a23dc (patch)
tree5072eb764f340b625284c4335dba6f441574ed8c
parent38d1ad78ea7acab3e7aecc668680c1476f3bf7ec (diff)
downloadsdl_core-bfcae5a747ff5f72de9132c2e992e1bbaa7a23dc.tar.gz
Update external policies for app services parameters
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h15
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h12
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h11
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h5
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h11
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h11
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h13
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h52
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_queries.h12
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_representation.h10
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc17
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc7
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc149
-rw-r--r--src/components/policy/policy_external/src/policy_table/validation.cc8
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc36
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc83
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc164
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h5
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h5
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h5
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc2
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc4
22 files changed, 441 insertions, 196 deletions
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index 097a0ac563..65432d3741 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -446,11 +446,22 @@ class PolicyHandler : public PolicyHandlerInterface,
*/
void OnSetCloudAppProperties(
const smart_objects::SmartObject& message) OVERRIDE;
-
+
+ /**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param app_service_parameters Pointer to struct containing all app service information
+ */
void GetAppServiceParameters(const std::string& policy_app_id,
policy_table::AppServiceParameters*
app_service_parameters) const OVERRIDE;
-
+ /**
+ * @brief Check app service parameters from an app against policies
+ * @param policy_app_id Unique application id
+ * @param requested_service_name Service name published by app service provider
+ * @param requested_service_type Service type published by app service provider
+ * @param requested_handled_rpcs Vector of requested function ids an app service wants to handle from consumers
+ */
bool CheckAppServiceParameters(
const std::string& policy_app_id,
const std::string& requested_service_name,
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index 39118e9acc..bfd956c4f2 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -488,10 +488,22 @@ class PolicyHandlerInterface {
virtual void OnSetCloudAppProperties(
const smart_objects::SmartObject& message) = 0;
+ /**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param app_service_parameters Pointer to struct containing all app service information
+ */
virtual void GetAppServiceParameters(
const std::string& policy_app_id,
policy_table::AppServiceParameters* app_service_parameters) const = 0;
+ /**
+ * @brief Check app service parameters from an app against policies
+ * @param policy_app_id Unique application id
+ * @param requested_service_name Service name published by app service provider
+ * @param requested_service_type Service type published by app service provider
+ * @param requested_handled_rpcs Vector of requested function ids an app service wants to handle from consumers
+ */
virtual bool CheckAppServiceParameters(
const std::string& policy_app_id,
const std::string& requested_service_name,
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index 96b2d5d659..ec659bd1b1 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -595,16 +595,11 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
virtual void GetAppServiceParameters(
- const std::string& policy_app_id,
- std::string& service_name,
- std::string& service_type,
- std::vector<uint32_t>& handled_rpcs) const = 0;
+ const std::string& policy_app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const = 0;
/**
* @brief Gets meta information
diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index 14f10c2036..b544b9d346 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -576,10 +576,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
virtual void GetAppServiceParameters(
const std::string& policy_app_id,
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index e31e3e6c34..d7094e19e5 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -231,16 +231,11 @@ class CacheManager : public CacheManagerInterface {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
virtual void GetAppServiceParameters(
- const std::string& policy_app_id,
- std::string& service_name,
- std::string& service_type,
- std::vector<uint32_t>& handled_rpcs) const;
+ const std::string& policy_app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const;
/**
* @brief Allows to update 'vin' field in module_meta table.
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index 5b9fe5cfcb..4a904c5829 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -240,16 +240,11 @@ class CacheManagerInterface {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
virtual void GetAppServiceParameters(
- const std::string& policy_app_id,
- std::string& service_name,
- std::string& service_type,
- std::vector<uint32_t>& handled_rpcs) const = 0;
+ const std::string& policy_app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const = 0;
/**
* @brief Allows to update 'vin' field in module_meta table.
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index b5a9709ecc..fe982ff59e 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -642,16 +642,11 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
- void GetAppServiceParameters(
- const std::string& policy_app_id,
- std::string& service_name,
- std::string& service_type,
- std::vector<uint32_t>& handled_rpcs) const OVERRIDE;
+ void GetAppServiceParameters(const std::string& policy_app_id,
+ policy_table::AppServiceParameters*
+ app_service_parameters) const OVERRIDE;
/**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h
index ed845b1191..e74091b8a3 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/types.h
@@ -52,6 +52,8 @@ struct MessageLanguages;
struct MessageString;
struct RpcParameters;
struct Rpcs;
+struct AppServiceHandledRpc;
+struct AppServiceInfo;
} // namespace policy_table_interface_base
} // namespace rpc
@@ -104,7 +106,12 @@ typedef Array<Enum<RequestType>, 0, 255> RequestsTypeArray;
typedef Strings RequestSubTypes;
-typedef Array<Integer<uint64_t, 0u, UINT_MAX>, 0, 255> HandledRpcs;
+typedef String<0, 255> AppServiceType;
+typedef String<0, 255> AppServiceName;
+typedef Array<AppServiceName, 0, 255> AppServiceNames;
+typedef Array<AppServiceHandledRpc, 0, 255> AppServiceHandledRpcs;
+typedef Map<AppServiceInfo, 0, 255> AppServiceParameters;
+typedef Integer<int32_t, 0, INT32_MAX> FunctionIDInt;
typedef Map<Strings, 0, 255> RemoteRpcs;
typedef Map<RemoteRpcs, 0, 255> AccessModules;
@@ -113,6 +120,45 @@ typedef Array<Enum<ModuleType>, 0, 255> ModuleTypes;
typedef AppHMIType AppHmiType;
typedef std::vector<AppHMIType> AppHmiTypes;
+struct AppServiceHandledRpc : CompositeType {
+ public:
+ FunctionIDInt function_id;
+
+ public:
+ AppServiceHandledRpc();
+ ~AppServiceHandledRpc();
+ AppServiceHandledRpc(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+ void ReportErrors(rpc::ValidationReport* report__) const;
+
+ private:
+ bool Validate() const;
+};
+
+struct AppServiceInfo : CompositeType {
+ public:
+ Optional<AppServiceNames> service_names;
+ Optional<AppServiceHandledRpcs> handled_rpcs;
+
+ public:
+ AppServiceInfo();
+ ~AppServiceInfo();
+ AppServiceInfo(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+ void ReportErrors(rpc::ValidationReport* report__) const;
+
+ private:
+ bool Validate() const;
+};
+
struct RequestTypes : public RequestsTypeArray {
RequestTypes();
explicit RequestTypes(Json::Value* value);
@@ -188,9 +234,7 @@ struct ApplicationParams : PolicyBase {
Optional<String<0, 255> > cloud_transport_type;
// App Service Params
- Optional<String<0, 255> > service_name;
- Optional<String<0, 255> > service_type;
- Optional<HandledRpcs> handled_rpcs;
+ Optional<AppServiceParameters> app_service_parameters;
public:
ApplicationParams();
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 c66d878e5a..5382ff2d6b 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
@@ -66,7 +66,9 @@ extern const std::string kSelectNicknames;
extern const std::string kSelectAppTypes;
extern const std::string kSelectRequestTypes;
extern const std::string kSelectRequestSubTypes;
-extern const std::string kSelectHandledRpcs;
+extern const std::string kSelectAppServiceTypes;
+extern const std::string kSelectAppServiceNames;
+extern const std::string kSelectAppServiceHandledRpcs;
extern const std::string kSelectSecondsBetweenRetries;
extern const std::string kSelectIgnitionCycles;
extern const std::string kSelectKilometers;
@@ -81,7 +83,9 @@ extern const std::string kInsertNickname;
extern const std::string kInsertAppType;
extern const std::string kInsertRequestType;
extern const std::string kInsertRequestSubType;
-extern const std::string kInsertHandledRpcs;
+extern const std::string kInsertAppServiceTypes;
+extern const std::string kInsertAppServiceNames;
+extern const std::string kInsertAppServiceHandledRpcs;
extern const std::string kInsertMessageType;
extern const std::string kInsertLanguage;
extern const std::string kInsertMessageString;
@@ -103,7 +107,9 @@ extern const std::string kDeleteAppGroup;
extern const std::string kDeleteApplication;
extern const std::string kDeleteRequestType;
extern const std::string kDeleteRequestSubType;
-extern const std::string kDeleteHandledRpcs;
+extern const std::string kDeleteAppServiceTypes;
+extern const std::string kDeleteAppServiceNames;
+extern const std::string kDeleteAppServiceHandledRpcs;
extern const std::string kDeleteDevice;
extern const std::string kIncrementIgnitionCycles;
extern const std::string kResetIgnitionCycles;
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 ebc307cc8b..0d8e1c7ae9 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
@@ -134,8 +134,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool GatherRequestSubType(
const std::string& app_id,
policy_table::RequestSubTypes* request_subtypes) const;
- bool GatherHandledRpcs(const std::string& app_id,
- policy_table::HandledRpcs* handled_rpcs) const;
+ bool GatherAppServiceParameters(
+ const std::string& app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const;
bool GatherNickName(const std::string& app_id,
policy_table::Strings* nicknames) const;
@@ -174,8 +175,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool SaveRequestSubType(
const std::string& app_id,
const policy_table::RequestSubTypes& request_subtypes);
- bool SaveHandledRpcs(const std::string& app_id,
- const policy_table::HandledRpcs& handled_rpcs);
+ bool SaveAppServiceParameters(
+ const std::string& app_id,
+ const policy_table::AppServiceParameters& app_service_parameters);
public:
virtual std::string GetLockScreenIconUrl() const;
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 663ac7b395..6d400cd0b4 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1503,9 +1503,7 @@ void CacheManager::SetHybridAppPreference(
void CacheManager::GetAppServiceParameters(
const std::string& policy_app_id,
- std::string& service_name,
- std::string& service_type,
- std::vector<uint32_t>& handled_rpcs) const {
+ policy_table::AppServiceParameters* app_service_parameters) const {
LOG4CXX_AUTO_TRACE(logger_);
const policy_table::ApplicationPolicies& policies =
pt_->policy_table.app_policies_section.apps;
@@ -1513,17 +1511,8 @@ void CacheManager::GetAppServiceParameters(
policies.find(policy_app_id);
if (policies.end() != policy_iter) {
auto app_policy = (*policy_iter).second;
- service_name = app_policy.service_name.is_initialized()
- ? *app_policy.service_name
- : std::string();
- service_type = app_policy.service_type.is_initialized()
- ? *app_policy.service_type
- : std::string();
- if (!app_policy.handled_rpcs.is_initialized()) {
- return;
- }
- for (const auto& rpc : *(app_policy.handled_rpcs)) {
- handled_rpcs.push_back(rpc);
+ if (app_policy.app_service_parameters.is_initialized()) {
+ *app_service_parameters = *(app_policy.app_service_parameters);
}
}
}
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index e50a3ecedd..404c48d2e4 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -774,11 +774,8 @@ void PolicyManagerImpl::SetHybridAppPreference(
void PolicyManagerImpl::GetAppServiceParameters(
const std::string& policy_app_id,
- std::string& service_name,
- std::string& service_type,
- std::vector<uint32_t>& handled_rpcs) const {
- cache_->GetAppServiceParameters(
- policy_app_id, service_name, service_type, handled_rpcs);
+ policy_table::AppServiceParameters* app_service_parameters) const {
+ cache_->GetAppServiceParameters(policy_app_id, app_service_parameters);
}
void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc
index 8e822cb8d2..fb17391332 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -221,6 +221,112 @@ void ApplicationPoliciesSection::SetPolicyTableType(PolicyTableType pt_type) {
apps.SetPolicyTableType(pt_type);
}
+// Handled RPC Methods
+AppServiceHandledRpc::AppServiceHandledRpc() : CompositeType(kUninitialized) {}
+
+AppServiceHandledRpc::~AppServiceHandledRpc() {}
+
+AppServiceHandledRpc::AppServiceHandledRpc(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , function_id(impl::ValueMember(value__, "function_id")) {}
+
+Json::Value AppServiceHandledRpc::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("function_id", function_id, &result__);
+ return result__;
+}
+
+bool AppServiceHandledRpc::is_valid() const {
+ if (!function_id.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool AppServiceHandledRpc::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool AppServiceHandledRpc::struct_empty() const {
+ if (function_id.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void AppServiceHandledRpc::SetPolicyTableType(PolicyTableType pt_type) {
+ function_id.SetPolicyTableType(pt_type);
+}
+
+void AppServiceHandledRpc::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!function_id.is_valid()) {
+ function_id.ReportErrors(&report__->ReportSubobject("function_id"));
+ }
+}
+
+// AppServiceInfo methods
+AppServiceInfo::AppServiceInfo() : CompositeType(kUninitialized) {}
+
+AppServiceInfo::~AppServiceInfo() {}
+
+AppServiceInfo::AppServiceInfo(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , service_names(impl::ValueMember(value__, "service_names"))
+ , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {
+}
+
+Json::Value AppServiceInfo::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("service_names", service_names, &result__);
+ impl::WriteJsonField("parameters", handled_rpcs, &result__);
+ return result__;
+}
+
+bool AppServiceInfo::is_valid() const {
+ if (!service_names.is_valid()) {
+ return false;
+ }
+ if (!handled_rpcs.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool AppServiceInfo::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool AppServiceInfo::struct_empty() const {
+ if (service_names.is_initialized()) {
+ return false;
+ }
+ if (handled_rpcs.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void AppServiceInfo::SetPolicyTableType(PolicyTableType pt_type) {
+ service_names.SetPolicyTableType(pt_type);
+ handled_rpcs.SetPolicyTableType(pt_type);
+}
+
+void AppServiceInfo::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!service_names.is_valid()) {
+ service_names.ReportErrors(&report__->ReportSubobject("service_names"));
+ }
+ if (!handled_rpcs.is_valid()) {
+ handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs"));
+ }
+}
+
+
// ApplicationParams methods
ApplicationParams::ApplicationParams() : PolicyBase() {}
@@ -248,9 +354,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, enabled(impl::ValueMember(value__, "enabled"))
, auth_token(impl::ValueMember(value__, "auth_token"))
, cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type"))
- , service_name(impl::ValueMember(value__, "service_name"))
- , service_type(impl::ValueMember(value__, "service_type"))
- , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {}
+ , app_service_parameters(impl::ValueMember(value__, "app_services")) {}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -269,9 +373,7 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField("enabled", enabled, &result__);
impl::WriteJsonField("auth_token", auth_token, &result__);
impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__);
- impl::WriteJsonField("service_name", service_name, &result__);
- impl::WriteJsonField("service_type", service_type, &result__);
- impl::WriteJsonField("handled_rpcs", handled_rpcs, &result__);
+ impl::WriteJsonField("app_services", app_service_parameters, &result__);
return result__;
}
@@ -314,15 +416,9 @@ bool ApplicationParams::is_valid() const {
if (!hybrid_app_preference.is_valid()) {
return false;
}
- if (!service_name.is_valid()) {
- return false;
- }
- if (!service_type.is_valid()) {
- return false;
- }
- if (!handled_rpcs.is_valid()) {
- return false;
- }
+ if (!app_service_parameters.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -373,13 +469,7 @@ bool ApplicationParams::struct_empty() const {
if (hybrid_app_preference.is_initialized()) {
return false;
}
- if (service_name.is_initialized()) {
- return false;
- }
- if (service_type.is_initialized()) {
- return false;
- }
- if (handled_rpcs.is_initialized()) {
+ if (app_service_parameters.is_initialized()) {
return false;
}
return true;
@@ -449,14 +539,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
moduleType.ReportErrors(
&report__->ReportSubobject("hybrid_app_preference"));
}
- if (!service_name.is_valid()) {
- service_name.ReportErrors(&report__->ReportSubobject("service_name"));
- }
- if (!service_type.is_valid()) {
- service_type.ReportErrors(&report__->ReportSubobject("service_type"));
- }
- if (!handled_rpcs.is_valid()) {
- handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs"));
+ if (!app_service_parameters.is_valid()) {
+ app_service_parameters.ReportErrors(
+ &report__->ReportSubobject("app_services"));
}
}
@@ -473,9 +558,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
enabled.SetPolicyTableType(pt_type);
cloud_transport_type.SetPolicyTableType(pt_type);
hybrid_app_preference.SetPolicyTableType(pt_type);
- service_name.SetPolicyTableType(pt_type);
- service_type.SetPolicyTableType(pt_type);
- handled_rpcs.SetPolicyTableType(pt_type);
+ app_service_parameters.SetPolicyTableType(pt_type);
}
// RpcParameters methods
diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc
index 9b227615d8..77056e0d43 100644
--- a/src/components/policy/policy_external/src/policy_table/validation.cc
+++ b/src/components/policy/policy_external/src/policy_table/validation.cc
@@ -194,6 +194,14 @@ bool ApplicationParams::ValidateModuleTypes() const {
return true;
}
+bool AppServiceHandledRpc::Validate() const {
+ return true; // todo add validation
+}
+
+bool AppServiceInfo::Validate() const {
+ return true; // todo add validation
+}
+
bool ApplicationParams::Validate() const {
if (is_initialized()) {
if (preconsented_groups.is_initialized()) {
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 8f82ca0546..ce35b637a1 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
@@ -675,6 +675,22 @@ bool SQLPTExtRepresentation::SaveApplicationPoliciesSection(
return false;
}
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled rpcs.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from service names.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled service types.");
+ 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
@@ -729,6 +745,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) {
return false;
}
+ if (!SaveAppServiceParameters(app.first,
+ *app.second.app_service_parameters)) {
+ return false;
+ }
// Stop saving other params, since predefined permissions already set
return true;
}
@@ -771,12 +791,6 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
app.second.cloud_transport_type.is_initialized()
? app_query.Bind(13, *app.second.cloud_transport_type)
: app_query.Bind(13);
- app.second.service_name.is_initialized()
- ? app_query.Bind(14, *app.second.service_name)
- : app_query.Bind(14);
- app.second.service_type.is_initialized()
- ? app_query.Bind(15, *app.second.service_type)
- : app_query.Bind(15);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -811,7 +825,8 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
return false;
}
- if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) {
+ if (!SaveAppServiceParameters(app.first,
+ *app.second.app_service_parameters)) {
return false;
}
@@ -919,10 +934,6 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
*params.auth_token = query.GetString(11);
*params.cloud_transport_type = query.GetString(12);
- // AppService Parameters
- *params.service_name = query.GetString(13);
- *params.service_type = query.GetString(14);
-
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
: app_id;
@@ -955,7 +966,8 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) {
return false;
}
- if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) {
+ if (!GatherAppServiceParameters(gather_app_id,
+ &*params.app_service_parameters)) {
return false;
}
GatherPreconsentedGroup(gather_app_id, &*params.preconsented_groups);
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 1cf38e64c9..8190a6e4ca 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -156,8 +156,6 @@ const std::string kCreateSchema =
" `enabled` BOOLEAN, "
" `auth_token` VARCHAR(65535), "
" `cloud_transport_type` VARCHAR(255), "
- " `service_name` VARCHAR(255), "
- " `service_type` VARCHAR(255), "
" `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
@@ -303,14 +301,30 @@ const std::string kCreateSchema =
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
- "CREATE TABLE IF NOT EXISTS `handled_rpcs`( "
- " `handled_rpcs` INTEGER, "
+ "CREATE TABLE IF NOT EXISTS `app_service_types`( "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
+ " `service_type` VARCHAR(50), "
" `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
- " PRIMARY KEY(`handled_rpcs`,`application_id`), "
- " CONSTRAINT `fk_handled_rpcs_app_id` "
+ " CONSTRAINT `fk_service_type_app_id` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
+ "CREATE TABLE IF NOT EXISTS `app_service_names`( "
+ " `service_type_id` INTEGER NOT NULL, "
+ " `service_name` VARCHAR(45), "
+ " PRIMARY KEY(`service_name`,`service_type_id`), "
+ " CONSTRAINT `fk_service_name_service_type_id` "
+ " FOREIGN KEY(`service_type_id`) "
+ " REFERENCES `app_service_types`(`id`) "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `app_service_handled_rpcs`( "
+ " `service_type_id` INTEGER NOT NULL, "
+ " `function_id` INTEGER, "
+ " PRIMARY KEY(`function_id`,`service_type_id`), "
+ " CONSTRAINT `fk_function_id_service_type_id` "
+ " FOREIGN KEY(`service_type_id`) "
+ " REFERENCES `app_service_types`(`id`) "
+ "); "
"CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
" ON `app_type`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `consent_group`( "
@@ -519,7 +533,9 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `app_type`; "
"DROP TABLE IF EXISTS `request_type`; "
"DROP TABLE IF EXISTS `request_subtype`; "
- "DROP TABLE IF EXISTS `handled_rpcs`; "
+ "DROP TABLE IF EXISTS `app_service_types`; "
+ "DROP TABLE IF EXISTS `app_service_names`; "
+ "DROP TABLE IF EXISTS `app_service_handled_rpcs`; "
"DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; "
"DROP TABLE IF EXISTS `nickname`; "
"DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; "
@@ -660,8 +676,8 @@ const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application` (`id`, `priority_value`, "
"`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
"`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, "
- "`cloud_transport_type`, `service_name`, `service_type`) VALUES "
- "(?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "`cloud_transport_type`) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?)";
const std::string kInsertAppGroup =
"INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
@@ -682,9 +698,19 @@ const std::string kInsertRequestSubType =
"`request_subtype`) "
"VALUES (?, ?)";
-const std::string kInsertHandledRpcs =
- "INSERT INTO `handled_rpcs` (`application_id`, "
- "`handled_rpcs`) "
+const std::string kInsertAppServiceTypes =
+ "INSERT INTO `app_service_types` (`id`, "
+ "`service_type`, `application_id`) "
+ "VALUES (?, ?, ?)";
+
+const std::string kInsertAppServiceNames =
+ "INSERT INTO `app_service_names` (`service_type_id`, "
+ "`service_name`) "
+ "VALUES (?, ?)";
+
+const std::string kInsertAppServiceHandledRpcs =
+ "INSERT INTO `app_service_handled_rpcs` (`service_type_id`, "
+ "`function_id`) "
"VALUES (?, ?)";
const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?";
@@ -790,8 +816,7 @@ const std::string kSelectUserMsgsVersion =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `memory_kb`, "
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, "
- "`service_name`, `service_type` FROM "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM "
" `application`";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -819,11 +844,21 @@ const std::string kSelectRequestSubTypes =
"`application_id` "
"= ?";
-const std::string kSelectHandledRpcs =
- "SELECT DISTINCT `handled_rpcs` FROM `handled_rpcs` WHERE "
+const std::string kSelectAppServiceTypes =
+ "SELECT `id`, `service_type` FROM `app_service_types` WHERE "
"`application_id` "
"= ?";
+const std::string kSelectAppServiceNames =
+ "SELECT DISTINCT `service_name` FROM `app_service_names` WHERE "
+ "`service_type_id` "
+ "= ?";
+
+const std::string kSelectAppServiceHandledRpcs =
+ "SELECT DISTINCT `function_id` FROM `app_service_handled_rpcs` WHERE "
+ "`service_type_id` "
+ "= ?";
+
const std::string kSelectSecondsBetweenRetries =
"SELECT `value` FROM `seconds_between_retry` ORDER BY `index`";
@@ -871,7 +906,13 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`";
const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`";
-const std::string kDeleteHandledRpcs = "DELETE FROM `handled_rpcs`";
+const std::string kDeleteAppServiceTypes = "DELETE FROM `app_service_types`";
+
+const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`";
+
+const std::string kDeleteAppServiceHandledRpcs =
+ "DELETE FROM `app_service_handled_rpcs`";
+
const std::string kSelectApplicationRevoked =
"SELECT `is_revoked` FROM `application` WHERE `id` = ?";
@@ -899,16 +940,14 @@ const std::string kInsertApplicationFull =
" `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
" `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, "
" `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, "
- " `auth_token`, `cloud_transport_type`, `service_name`, "
- "`service_type`) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ " `auth_token`, `cloud_transport_type`) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
const std::string kSelectApplicationFull =
"SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, "
" `is_revoked`, `is_default`, `is_predata`, `memory_kb`,"
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, "
- "`service_name`, `service_type` "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`"
"FROM `application` "
"WHERE `id` = ?";
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 dbddd1bbd6..0897b11009 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -778,10 +778,6 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
*params.auth_token = query.GetString(8);
*params.cloud_transport_type = query.GetString(9);
- // AppService Parameters
- *params.service_name = query.GetString(10);
- *params.service_type = query.GetString(11);
-
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
: app_id;
@@ -814,7 +810,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) {
return false;
}
- if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) {
+ if (!GatherAppServiceParameters(gather_app_id, &*params.app_service_parameters)) {
return false;
}
@@ -1008,6 +1004,21 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection(
return false;
}
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled rpcs.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from service names.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled service types.");
+ return false;
+ }
+
// All predefined apps (e.g. default, pre_DataConsent) should be saved first,
// otherwise another app with the predefined permissions can get incorrect
// permissions
@@ -1077,12 +1088,6 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
app.second.cloud_transport_type.is_initialized()
? app_query.Bind(10, *app.second.cloud_transport_type)
: app_query.Bind(10);
- app.second.service_name.is_initialized()
- ? app_query.Bind(11, *app.second.service_name)
- : app_query.Bind(11);
- app.second.service_type.is_initialized()
- ? app_query.Bind(12, *app.second.service_type)
- : app_query.Bind(12);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -1119,7 +1124,8 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
if (!SaveRequestType(app.first, *app.second.RequestType)) {
return false;
}
- if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) {
+ if (!SaveAppServiceParameters(app.first,
+ *app.second.app_service_parameters)) {
return false;
}
@@ -1286,31 +1292,73 @@ bool SQLPTRepresentation::SaveRequestSubType(
return true;
}
-bool SQLPTRepresentation::SaveHandledRpcs(
- const std::string& app_id, const policy_table::HandledRpcs& handled_rpcs) {
+bool SQLPTRepresentation::SaveAppServiceParameters(
+ const std::string& app_id,
+ const policy_table::AppServiceParameters& app_service_parameters) {
+ LOG4CXX_INFO(logger_, "Save app service parameters");
utils::dbms::SQLQuery query(db());
- if (!query.Prepare(sql_pt::kInsertHandledRpcs)) {
- LOG4CXX_WARN(logger_, "Incorrect insert statement for handled rpcs.");
+
+ if (!query.Prepare(sql_pt::kInsertAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for app service types");
return false;
}
+ policy_table::AppServiceParameters::const_iterator it;
+ for (it = app_service_parameters.begin(); it != app_service_parameters.end();
+ ++it) {
+ // Create service type id from hashing app_id and service_type
+ std::string str_to_hash = std::string(app_id + it->first);
+ const long int id = abs(CacheManager::GenerateHash(str_to_hash));
+ query.Bind(0, static_cast<int64_t>(id));
+ query.Bind(1, it->first);
+ query.Bind(2, app_id);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Insert execute failed for into app service types");
+ return false;
+ }
- policy_table::HandledRpcs::const_iterator it;
- if (!handled_rpcs.empty()) {
- LOG4CXX_TRACE(logger_, "Handled Rpcs are not empty.");
- for (it = handled_rpcs.begin(); it != handled_rpcs.end(); ++it) {
- query.Bind(0, app_id);
+ // Insert app names array into db
+ utils::dbms::SQLQuery service_name_query(db());
+ if (!service_name_query.Prepare(sql_pt::kInsertAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for app service names");
+ return false;
+ }
- // TODO: Bind does not like uint64_t. Only takes ints? Not sure why this
- // is broken since seconds between retries is able to handle
- query.Bind(1, static_cast<int>(*it));
- if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger_, "Incorrect insert into handled rpcs.");
+ auto app_service_names = it->second.service_names;
+ policy_table::AppServiceNames::const_iterator names_it;
+ for (names_it = app_service_names->begin();
+ names_it != app_service_names->end();
+ ++names_it) {
+ service_name_query.Bind(0, static_cast<int64_t>(id));
+ service_name_query.Bind(1, *names_it);
+ if (!service_name_query.Exec() || !service_name_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into app service names");
+ return false;
+ }
+ }
+
+ // Insert handled rpcs array into db
+ utils::dbms::SQLQuery handled_rpcs_query(db());
+ if (!handled_rpcs_query.Prepare(sql_pt::kInsertAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect insert statement for app service handled rpcs");
+ return false;
+ }
+
+ auto handled_rpcs = it->second.handled_rpcs;
+ policy_table::AppServiceHandledRpcs::const_iterator rpc_it;
+ for (rpc_it = handled_rpcs->begin(); rpc_it != handled_rpcs->end();
+ ++rpc_it) {
+ handled_rpcs_query.Bind(0, static_cast<int64_t>(id));
+ handled_rpcs_query.Bind(1, static_cast<int32_t>(rpc_it->function_id));
+ if (!handled_rpcs_query.Exec() || !handled_rpcs_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into app service handled rpcs");
return false;
}
}
}
return true;
}
+
bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) {
// Section Module Meta is empty for SDL specific
@@ -1738,21 +1786,55 @@ bool SQLPTRepresentation::GatherRequestSubType(
return true;
}
-bool SQLPTRepresentation::GatherHandledRpcs(
- const std::string& app_id, policy_table::HandledRpcs* handled_rpcs) const {
- utils::dbms::SQLQuery query(db());
- if (!query.Prepare(sql_pt::kSelectHandledRpcs)) {
- LOG4CXX_WARN(logger_, "Incorrect select from handled rpcs.");
+bool SQLPTRepresentation::GatherAppServiceParameters(
+ const std::string& app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const {
+ LOG4CXX_INFO(logger_, "Gather app service info");
+ utils::dbms::SQLQuery service_type_query(db());
+ if (!service_type_query.Prepare(sql_pt::kSelectAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from service_types");
return false;
}
- query.Bind(0, app_id);
- while (query.Next()) {
- const uint64_t rpc_id = query.GetInteger(0);
- handled_rpcs->push_back(rpc_id);
+ utils::dbms::SQLQuery service_name_query(db());
+ if (!service_name_query.Prepare(sql_pt::kSelectAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect select all from app_service_names");
+ return false;
+ }
+
+ utils::dbms::SQLQuery handled_rpcs_query(db());
+ if (!handled_rpcs_query.Prepare(sql_pt::kSelectAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect select all from app_service_handled_rpcs");
+ return false;
}
+
+ service_type_query.Bind(2, app_id);
+ while (service_type_query.Next()) {
+ const int service_type_id = service_type_query.GetInteger(0);
+ std::string service_type = service_type_query.GetString(1);
+ (*app_service_parameters)[service_type] = policy_table::AppServiceInfo();
+
+ service_name_query.Bind(0, service_type_id);
+ while (service_name_query.Next()) {
+ (*app_service_parameters)[service_type].service_names->push_back(
+ service_name_query.GetString(0));
+ }
+
+ handled_rpcs_query.Bind(0, service_type_id);
+ while (handled_rpcs_query.Next()) {
+ policy_table::AppServiceHandledRpc handled_rpc;
+ handled_rpc.function_id = handled_rpcs_query.GetInteger(0);
+ (*app_service_parameters)[service_type].handled_rpcs->push_back(
+ handled_rpc);
+ }
+
+ service_name_query.Reset();
+ handled_rpcs_query.Reset();
+ }
+
return true;
}
+
bool SQLPTRepresentation::GatherNickName(
const std::string& app_id, policy_table::Strings* nicknames) const {
@@ -2099,9 +2181,9 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
return false;
}
- policy_table::HandledRpcs handled_rpcs;
- if (!GatherHandledRpcs(kDefaultId, &handled_rpcs) ||
- !SaveHandledRpcs(app_id, handled_rpcs)) {
+ policy_table::AppServiceParameters app_service_parameters;
+ if (!GatherAppServiceParameters(kDefaultId, &app_service_parameters) ||
+ !SaveAppServiceParameters(app_id, app_service_parameters)) {
return false;
}
@@ -2206,7 +2288,7 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
utils::dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertApplicationFull)) {
- LOG4CXX_WARN(logger_, "Incorrect insert statement into application.");
+ LOG4CXX_WARN(logger_, "Incorrect insert statement into application full.");
return false;
}
query.Bind(0, destination);
@@ -2236,10 +2318,6 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(14, source_app.GetString(13));
source_app.IsNull(14) ? query.Bind(15)
: query.Bind(15, source_app.GetString(14));
- source_app.IsNull(15) ? query.Bind(16)
- : query.Bind(16, source_app.GetString(15));
- source_app.IsNull(16) ? query.Bind(17)
- : query.Bind(17, source_app.GetString(16));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Failed inserting into application.");
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index e8d4e1782e..71e056ee22 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -219,10 +219,7 @@ class CacheManager : public CacheManagerInterface {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
virtual void GetAppServiceParameters(
const std::string& policy_app_id,
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index 4345244e76..d4ba78c43b 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -226,10 +226,7 @@ class CacheManagerInterface {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
virtual void GetAppServiceParameters(
const std::string& policy_app_id,
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index 8628b1a8a0..f3b285cbff 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -637,10 +637,7 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Get app service parameters from the policy table
* @param policy_app_id Unique application id
- * @param service_name Service name published by app service provider
- * @param service_type Service type published by app service provider
- * @param handled_rpcs Vector of allowed function ids an app service provider
- * can handle
+ * @param app_service_parameters Pointer to struct containing all app service information
*/
void GetAppServiceParameters(const std::string& policy_app_id,
policy_table::AppServiceParameters*
diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc
index 2e164d3e14..5269daccb6 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -204,7 +204,7 @@ AppServiceInfo::AppServiceInfo(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, service_names(impl::ValueMember(value__, "service_names"))
, handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {
-} // todo handled_rpcs struct
+}
Json::Value AppServiceInfo::ToJsonValue() const {
Json::Value result__(Json::objectValue);
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 dd2c38a72b..6905af659e 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -2269,10 +2269,6 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(14, source_app.GetString(13));
source_app.IsNull(14) ? query.Bind(15)
: query.Bind(15, source_app.GetString(14));
- source_app.IsNull(15) ? query.Bind(16)
- : query.Bind(16, source_app.GetString(15));
- source_app.IsNull(16) ? query.Bind(17)
- : query.Bind(17, source_app.GetString(16));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Failed inserting into application.");