summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/application_manager/include/application_manager/rpc_handler_impl.h10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc6
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc42
-rw-r--r--src/components/formatters/include/formatters/CSmartFactory.h22
-rw-r--r--src/components/include/utils/semantic_version.h48
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc10
-rw-r--r--src/components/smart_objects/include/smart_objects/always_false_schema_item.h12
-rw-r--r--src/components/smart_objects/include/smart_objects/always_true_schema_item.h11
-rw-r--r--src/components/smart_objects/include/smart_objects/array_schema_item.h14
-rw-r--r--src/components/smart_objects/include/smart_objects/default_shema_item.h23
-rw-r--r--src/components/smart_objects/include/smart_objects/enum_schema_item.h80
-rw-r--r--src/components/smart_objects/include/smart_objects/number_schema_item.h23
-rw-r--r--src/components/smart_objects/include/smart_objects/object_schema_item.h14
-rw-r--r--src/components/smart_objects/include/smart_objects/schema_item.h19
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_object.h13
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_schema.h14
-rw-r--r--src/components/smart_objects/include/smart_objects/string_schema_item.h12
-rw-r--r--src/components/smart_objects/src/always_false_schema_item.cc6
-rw-r--r--src/components/smart_objects/src/always_true_schema_item.cc5
-rw-r--r--src/components/smart_objects/src/array_schema_item.cc42
-rw-r--r--src/components/smart_objects/src/object_schema_item.cc38
-rw-r--r--src/components/smart_objects/src/schema_item.cc5
-rw-r--r--src/components/smart_objects/src/smart_object.cc4
-rw-r--r--src/components/smart_objects/src/smart_schema.cc5
-rw-r--r--src/components/smart_objects/src/string_schema_item.cc13
25 files changed, 139 insertions, 352 deletions
diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
index 7f61c7b034..8f1d454c3b 100644
--- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
@@ -143,6 +143,16 @@ class RPCHandlerImpl : public RPCHandler,
void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE;
#endif // TELEMETRY_MONITOR
+ /**
+ * @brief Extracts and validates the syncMsgVersion included in
+ * a RegisterAppInterfaceRequest
+ *
+ * @param output - SmartObject Message received from mobile
+ * @param messageVersion - message version to be updated
+ */
+ void GetMessageVersion(NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version);
+
private:
void ProcessMessageFromMobile(const std::shared_ptr<Message> message);
void ProcessMessageFromHMI(const std::shared_ptr<Message> message);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 8d81cdc444..675ffcd31a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -631,11 +631,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
utils::SemanticVersion negotiated_version = application->msg_version();
response_params[strings::sync_msg_version][strings::major_version] =
- negotiated_version.majorVersion;
+ negotiated_version.major_version_;
response_params[strings::sync_msg_version][strings::minor_version] =
- negotiated_version.minorVersion;
+ negotiated_version.minor_version_;
response_params[strings::sync_msg_version][strings::patch_version] =
- negotiated_version.patchVersion;
+ negotiated_version.patch_version_;
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index 0bf62cf64d..bf1ff78d36 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -194,6 +194,36 @@ void RPCHandlerImpl::SetTelemetryObserver(AMTelemetryObserver* observer) {
#endif // TELEMETRY_MONITOR
+void RPCHandlerImpl::GetMessageVersion(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version) {
+ if (output.keyExists(
+ NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS) &&
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS].keyExists(
+ strings::sync_msg_version)) {
+ // SyncMsgVersion exists, check if it is valid.
+ auto sync_msg_version =
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS]
+ [strings::sync_msg_version];
+ uint16_t major = 0;
+ uint16_t minor = 0;
+ uint16_t patch = 0;
+ if (sync_msg_version.keyExists(strings::major_version)) {
+ major = sync_msg_version[strings::major_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::minor_version)) {
+ minor = sync_msg_version[strings::minor_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::patch_version)) {
+ patch = sync_msg_version[strings::patch_version].asUInt();
+ }
+ utils::SemanticVersion temp_version(major, minor, patch);
+ if (temp_version.isValid()) {
+ message_version = temp_version;
+ }
+ }
+}
+
bool RPCHandlerImpl::ConvertMessageToSO(
const Message& message,
NsSmartDeviceLink::NsSmartObjects::SmartObject& output) {
@@ -220,26 +250,20 @@ bool RPCHandlerImpl::ConvertMessageToSO(
// Attach RPC version to SmartObject if it does not exist yet.
auto app_ptr = app_manager_.application(message.connection_key());
- utils::SemanticVersion msg_version(2, 0, 0);
+ utils::SemanticVersion msg_version(0, 0, 0);
if (app_ptr &&
(output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
.keyExists(NsSmartDeviceLink::NsJSONHandler::strings::
S_RPC_MSG_VERSION) == false)) {
msg_version = app_ptr->msg_version();
- output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION] =
- msg_version.toString();
} else if (mobile_apis::FunctionID::RegisterAppInterfaceID ==
static_cast<mobile_apis::FunctionID::eType>(
output[strings::params][strings::function_id].asInt())) {
- // Assume default version 2.0.0 until properly set in RAI
- output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION] =
- msg_version.toString();
+ GetMessageVersion(output, msg_version);
}
if (!conversion_result ||
- !mobile_so_factory().attachSchema(output, true) ||
+ !mobile_so_factory().attachSchema(output, true, msg_version) ||
((output.validate(&report, msg_version) !=
smart_objects::Errors::OK))) {
LOG4CXX_WARN(logger_,
diff --git a/src/components/formatters/include/formatters/CSmartFactory.h b/src/components/formatters/include/formatters/CSmartFactory.h
index d66dc56d8b..a459f179c0 100644
--- a/src/components/formatters/include/formatters/CSmartFactory.h
+++ b/src/components/formatters/include/formatters/CSmartFactory.h
@@ -153,8 +153,10 @@ class CSmartFactory {
*
* @return True if operation was successful or false otherwise.
*/
- bool attachSchema(NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
- const bool RemoveFakeParameters);
+ bool attachSchema(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
+ const bool RemoveFakeParameters,
+ const utils::SemanticVersion& MessageVersion = utils::SemanticVersion());
/**
* @brief Attach schema to the struct SmartObject.
@@ -273,7 +275,8 @@ CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::CSmartFactory(
template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::attachSchema(
NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
- const bool RemoveFakeParameters) {
+ const bool RemoveFakeParameters,
+ const utils::SemanticVersion& MessageVersion) {
if (false == object.keyExists(strings::S_PARAMS))
return false;
if (false == object[strings::S_PARAMS].keyExists(strings::S_MESSAGE_TYPE))
@@ -300,17 +303,8 @@ bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::attachSchema(
object.setSchema(schemaIterator->second);
- // Initialize msg_version to 0.0.0, an invalid value until properly set.
- utils::SemanticVersion msg_version(0, 0, 0);
- if (object[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS].keyExists(
- NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION)) {
- msg_version =
- object[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION]
- .asString();
- }
-
- schemaIterator->second.applySchema(object, RemoveFakeParameters, msg_version);
+ schemaIterator->second.applySchema(
+ object, RemoveFakeParameters, MessageVersion);
return true;
}
diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h
index 6c54a11984..7b9ec0eb96 100644
--- a/src/components/include/utils/semantic_version.h
+++ b/src/components/include/utils/semantic_version.h
@@ -37,42 +37,42 @@ namespace utils {
struct SemanticVersion {
SemanticVersion(uint16_t major = 0, uint16_t minor = 0, uint16_t patch = 0) {
- majorVersion = major;
- minorVersion = minor;
- patchVersion = patch;
+ major_version_ = major;
+ minor_version_ = minor;
+ patch_version_ = patch;
}
SemanticVersion(const SemanticVersion& other) {
- majorVersion = other.majorVersion;
- minorVersion = other.minorVersion;
- patchVersion = other.patchVersion;
+ major_version_ = other.major_version_;
+ minor_version_ = other.minor_version_;
+ patch_version_ = other.patch_version_;
}
SemanticVersion(const std::string& versionString)
- : majorVersion(0), minorVersion(0), patchVersion(0) {
- unsigned int majorInt, minorInt, patchInt;
+ : major_version_(0), minor_version_(0), patch_version_(0) {
+ unsigned int major_int, minor_int, patch_int;
int readElements = sscanf(
- versionString.c_str(), "%u.%u.%u", &majorInt, &minorInt, &patchInt);
+ versionString.c_str(), "%u.%u.%u", &major_int, &minor_int, &patch_int);
if (readElements != 3) {
// LOG4CXX_WARN(logger_,
// "Error while parsing version string: " << versionString);
} else {
- majorVersion = static_cast<uint8_t>(majorInt);
- minorVersion = static_cast<uint8_t>(minorInt);
- patchVersion = static_cast<uint8_t>(patchInt);
+ major_version_ = static_cast<uint8_t>(major_int);
+ minor_version_ = static_cast<uint8_t>(minor_int);
+ patch_version_ = static_cast<uint8_t>(patch_int);
}
}
static inline int16_t cmp(const SemanticVersion& version1,
const SemanticVersion& version2) {
int16_t diff =
- static_cast<int16_t>(version1.majorVersion - version2.majorVersion);
+ static_cast<int16_t>(version1.major_version_ - version2.major_version_);
if (diff == 0) {
- diff =
- static_cast<int16_t>(version1.minorVersion - version2.minorVersion);
+ diff = static_cast<int16_t>(version1.minor_version_ -
+ version2.minor_version_);
if (diff == 0) {
- diff =
- static_cast<int16_t>(version1.patchVersion - version2.patchVersion);
+ diff = static_cast<int16_t>(version1.patch_version_ -
+ version2.patch_version_);
}
}
return diff;
@@ -100,21 +100,21 @@ struct SemanticVersion {
const std::string toString() const {
std::string result = "";
- result += std::to_string(majorVersion);
+ result += std::to_string(major_version_);
result += ".";
- result += std::to_string(minorVersion);
+ result += std::to_string(minor_version_);
result += ".";
- result += std::to_string(patchVersion);
+ result += std::to_string(patch_version_);
return result;
}
bool isValid() const {
- return majorVersion > 0 || minorVersion > 0 || patchVersion > 0;
+ return major_version_ > 0 || minor_version_ > 0 || patch_version_ > 0;
}
- uint16_t majorVersion = 0;
- uint16_t minorVersion = 0;
- uint16_t patchVersion = 0;
+ uint16_t major_version_ = 0;
+ uint16_t minor_version_ = 0;
+ uint16_t patch_version_ = 0;
};
}
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 4ff24f9e64..0e49e28397 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -252,7 +252,7 @@ void ProtocolHandlerImpl::SendStartSessionAck(
const bool proxy_supports_v5_protocol =
input_protocol_version >= PROTOCOL_VERSION_5 ||
(ServiceTypeFromByte(service_type) == kRpc &&
- full_version.majorVersion >= PROTOCOL_VERSION_5);
+ full_version.major_version_ >= PROTOCOL_VERSION_5);
if (kRpc != service_type) {
// In case if input protocol version os bigger then supported, SDL should
@@ -308,7 +308,7 @@ void ProtocolHandlerImpl::SendStartSessionAck(
// Minimum protocol version supported by both
utils::SemanticVersion* minVersion =
- (full_version.majorVersion < PROTOCOL_VERSION_5)
+ (full_version.major_version_ < PROTOCOL_VERSION_5)
? &defaultProtocolVersion
: utils::SemanticVersion::min(full_version,
defaultProtocolVersion);
@@ -1619,7 +1619,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
std::string(bson_object_get_string(&obj, "protocolVersion")));
bson_object_deinitialize(&obj);
// Constructed payloads added in Protocol v5
- if (fullVersion->majorVersion < PROTOCOL_VERSION_5) {
+ if (fullVersion->major_version_ < PROTOCOL_VERSION_5) {
rejectedParams.push_back(std::string("protocolVersion"));
}
} else {
@@ -1674,7 +1674,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
bson_object_get_string(&obj, "protocolVersion"));
bson_object_deinitialize(&obj);
- if (fullVersion.majorVersion >= PROTOCOL_VERSION_5) {
+ if (fullVersion.major_version_ >= PROTOCOL_VERSION_5) {
// Start service without protection
SendStartSessionAck(connection_id,
session_id,
@@ -1892,7 +1892,7 @@ void ProtocolHandlerImpl::NotifySessionStarted(
std::string version_string(version_param == NULL ? "" : version_param);
fullVersion = std::make_shared<utils::SemanticVersion>(version_string);
// Constructed payloads added in Protocol v5
- if (fullVersion->majorVersion < PROTOCOL_VERSION_5) {
+ if (fullVersion->major_version_ < PROTOCOL_VERSION_5) {
rejected_params.push_back(std::string(strings::protocol_version));
}
bson_object_deinitialize(&request_params);
diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
index 87e5d31ae9..a7b93012bb 100644
--- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
@@ -54,14 +54,7 @@ class CAlwaysFalseSchemaItem : public ISchemaItem {
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return Errors::ERROR
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
+
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -71,7 +64,8 @@ class CAlwaysFalseSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
CAlwaysFalseSchemaItem();
diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
index ca590fecca..b025723ea6 100644
--- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
@@ -54,14 +54,6 @@ class CAlwaysTrueSchemaItem : public ISchemaItem {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -72,7 +64,8 @@ class CAlwaysTrueSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
CAlwaysTrueSchemaItem();
diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h
index 69a546b558..4dc416007a 100644
--- a/src/components/smart_objects/include/smart_objects/array_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h
@@ -76,17 +76,6 @@ class CArraySchemaItem : public ISchemaItem {
/**
* @brief Validate smart object.
- *
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * message if an error occurs
- *
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
- /**
- * @brief Validate smart object.
* @param Object Object to validate.
* @param report__ object for reporting errors during validation
* @param MessageVersion to check mobile RPC version against RPC Spec History
@@ -94,7 +83,8 @@ class CArraySchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
/**
* @brief Apply schema.
diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h
index b094091336..7d5b33b1a6 100644
--- a/src/components/smart_objects/include/smart_objects/default_shema_item.h
+++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h
@@ -55,14 +55,6 @@ class CDefaultSchemaItem : public ISchemaItem {
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return Errors::ERROR
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -73,7 +65,8 @@ class CDefaultSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
/**
* @brief Set default value to an object.
@@ -124,7 +117,9 @@ Errors::eType CDefaultSchemaItem<Type>::validate(const SmartObject& Object) {
template <typename Type>
Errors::eType CDefaultSchemaItem<Type>::validate(
- const SmartObject& Object, rpc::ValidationReport* report__) {
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion) {
if (getSmartType() != Object.getType()) {
std::string validation_info = "Incorrect type, expected: " +
SmartObject::typeToString(getSmartType()) +
@@ -138,14 +133,6 @@ Errors::eType CDefaultSchemaItem<Type>::validate(
}
template <typename Type>
-Errors::eType CDefaultSchemaItem<Type>::validate(
- const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) {
- return validate(Object, report__);
-}
-
-template <typename Type>
bool CDefaultSchemaItem<Type>::setDefaultValue(SmartObject& Object) {
Type value;
if (mDefaultValue.getValue(value)) {
diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
index 2a4bd5c572..41102933f3 100644
--- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
@@ -47,12 +47,6 @@
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
-// Element Signature for enums. Fields represent "since", "until", and "removed"
-// typedef boost::optional<std::string> OptionalString;
-// typedef boost::optional<bool> OptionalBool;
-// typedef std::tuple<OptionalString, OptionalString, OptionalBool>
-// ElementSignature;
-
struct ElementSignature {
boost::optional<utils::SemanticVersion> mSince;
boost::optional<utils::SemanticVersion> mUntil;
@@ -76,9 +70,6 @@ struct ElementSignature {
}
};
-// typedef std::map<OptionalString, OptionalString, OptionalBool>
-// ElementSignature;
-
template <typename EnumType>
class EnumConversionHelper;
/**
@@ -118,14 +109,6 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -136,7 +119,8 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
/**
* @brief Return the correct history signature based on message version.
* @param signatures Vector reference of enums history items.
@@ -308,63 +292,27 @@ Errors::eType TEnumSchemaItem<EnumType>::validate(const SmartObject& Object) {
}
template <typename EnumType>
-Errors::eType TEnumSchemaItem<EnumType>::validate(
- const SmartObject& Object, rpc::ValidationReport* report__) {
- if (SmartType_Integer != Object.getType()) {
- std::string validation_info;
- if (SmartType_String == Object.getType()) {
- validation_info = "Invalid enum value: " + Object.asString();
- } else {
- validation_info = "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Integer) +
- " (enum), got: " +
- SmartObject::typeToString(Object.getType());
- }
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
- if (mAllowedElements.find(static_cast<EnumType>(Object.asInt())) ==
- mAllowedElements.end()) {
- std::stringstream stream;
- stream << "Invalid enum value: " << Object.asInt();
- std::string validation_info = stream.str();
- report__->set_validation_info(validation_info);
- return Errors::OUT_OF_RANGE;
- }
- return Errors::OK;
-}
-
-template <typename EnumType>
const ElementSignature TEnumSchemaItem<EnumType>::getSignature(
const std::vector<ElementSignature>& signatures,
const utils::SemanticVersion& MessageVersion) {
for (uint i = 0; i < signatures.size(); i++) {
ElementSignature signature = signatures[i];
// Check if signature matches message version
- if (signature.mSince != boost::none) {
- if (MessageVersion < signature.mSince.get()) {
- // Msg version predates 'since' field, check next entry
- continue;
- }
-
- if (signature.mUntil != boost::none &&
- (MessageVersion >= signature.mUntil.get())) {
- continue; // Msg version newer than `until` field
- }
-
- return signature;
+ if (signature.mSince != boost::none &&
+ MessageVersion < signature.mSince.get()) {
+ // Msg version predates 'since' field, check next entry
+ continue;
}
-
if (signature.mUntil != boost::none &&
(MessageVersion >= signature.mUntil.get())) {
continue; // Msg version newer than `until` field, check next entry
}
-
+ // Found correct signature
return signature;
}
// Could not match msg version to element siganture
- ElementSignature ret("", "", true);
+ ElementSignature ret;
return ret;
}
@@ -404,13 +352,23 @@ Errors::eType TEnumSchemaItem<EnumType>::validate(
auto signatures_it = mElementSignatures.find(value);
if (signatures_it != mElementSignatures.end()) {
if (!signatures_it->second.empty()) {
- if (getSignature(signatures_it->second, MessageVersion).mRemoved) {
+ ElementSignature signature =
+ getSignature(signatures_it->second, MessageVersion);
+ if (signature.mRemoved) {
// Element was removed for this version
std::string validation_info = "Enum value : " + Object.asString() +
" removed for SyncMsgVersion " +
MessageVersion.toString();
report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
+ } else if (signature.mSince == boost::none &&
+ signature.mUntil == boost::none) {
+ // Element does not exist for this version
+ std::string validation_info = "Enum value : " + Object.asString() +
+ " does not exist for SyncMsgVersion " +
+ MessageVersion.toString();
+ report__->set_validation_info(validation_info);
+ return Errors::INVALID_VALUE;
}
}
}
diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h
index ee82b87241..0f3246ef5f 100644
--- a/src/components/smart_objects/include/smart_objects/number_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h
@@ -72,14 +72,6 @@ class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return Errors::ERROR
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Validate smart object.
@@ -90,7 +82,8 @@ class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
/**
@@ -157,7 +150,9 @@ Errors::eType TNumberSchemaItem<NumberType>::validate(
template <typename NumberType>
Errors::eType TNumberSchemaItem<NumberType>::validate(
- const SmartObject& Object, rpc::ValidationReport* report__) {
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion) {
if (!isValidNumberType(Object.getType())) {
SmartType expectedType = (typeid(double) == typeid(Object.getType()))
? SmartType_Double
@@ -205,14 +200,6 @@ Errors::eType TNumberSchemaItem<NumberType>::validate(
}
template <typename NumberType>
-Errors::eType TNumberSchemaItem<NumberType>::validate(
- const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) {
- return validate(Object, report__);
-}
-
-template <typename NumberType>
TNumberSchemaItem<NumberType>::TNumberSchemaItem(
const TSchemaItemParameter<NumberType>& MinValue,
const TSchemaItemParameter<NumberType>& MaxValue,
diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h
index aa807e98ab..4785211694 100644
--- a/src/components/smart_objects/include/smart_objects/object_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h
@@ -110,14 +110,7 @@ class CObjectSchemaItem : public ISchemaItem {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
+
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -127,7 +120,8 @@ class CObjectSchemaItem : public ISchemaItem {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
/**
* @brief Apply schema.
* @param Object Object to apply schema.
@@ -173,7 +167,7 @@ class CObjectSchemaItem : public ISchemaItem {
const utils::SemanticVersion& MessageVersion);
/**
- * @brief Returns the correct schema item based on messge version.
+ * @brief Returns the correct schema item based on message version.
* @param member Schema member
* @param MmessageVersion Semantic Version of mobile message.
**/
diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h
index 828dac33f0..2e951f7f9f 100644
--- a/src/components/smart_objects/include/smart_objects/schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/schema_item.h
@@ -68,24 +68,13 @@ class ISchemaItem {
* @param Object Object to validate.
* @param report__ object for reporting errors during validation
* message if an error occurs
- *
- * @return NsSmartObjects::Errors::eType
- **/
- virtual Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__);
-
- /**
- * @brief Validate smart object.
- *
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * message if an error occurs
* @param MessageVersion to check mobile RPC version against RPC Spec Histor
* @return NsSmartObjects::Errors::eType
**/
- virtual Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion);
+ virtual Errors::eType validate(
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion = utils::SemanticVersion());
/**
* @brief Set default value to an object.
diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h
index f594ad9820..d81e18569f 100644
--- a/src/components/smart_objects/include/smart_objects/smart_object.h
+++ b/src/components/smart_objects/include/smart_objects/smart_object.h
@@ -682,19 +682,12 @@ class SmartObject FINAL {
* @brief Validates object according to attached schema.
*
* @param report__ object for reporting errors during validation
- * @return Result of validation.
- */
- Errors::eType validate(rpc::ValidationReport* report__);
-
- /**
- * @brief Validates object according to attached schema.
- *
- * @param report__ object for reporting errors during validation
* @param messageVersion of the mobile app to check against RPC Spec Schema
* @return Result of validation.
*/
- Errors::eType validate(rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion);
+ Errors::eType validate(
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion = utils::SemanticVersion());
/**
* @brief Sets new schema
diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h
index 5ab96e82bd..d3fcc0e28d 100644
--- a/src/components/smart_objects/include/smart_objects/smart_schema.h
+++ b/src/components/smart_objects/include/smart_objects/smart_schema.h
@@ -76,23 +76,13 @@ class CSmartSchema FINAL {
*
* @param Object Object to validate.
* @param report__ object for reporting errors during validation
- *
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) const;
-
- /**
- * @brief Validate smart object.
- *
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
* @param MessageVersion to check mobile RPC version against RPC Spec History
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& messageVersion) const;
+ const utils::SemanticVersion& messageVersion =
+ utils::SemanticVersion()) const;
/**
* @brief Set new root schema item.
diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h
index 4d5f18f711..dcaad364b2 100644
--- a/src/components/smart_objects/include/smart_objects/string_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h
@@ -66,14 +66,7 @@ class CStringSchemaItem : public CDefaultSchemaItem<std::string> {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
- /**
- * @brief Validate smart object.
- * @param Object Object to validate.
- * @param report__ object for reporting errors during validation
- * @return NsSmartObjects::Errors::eType
- **/
- Errors::eType validate(const SmartObject& Object,
- rpc::ValidationReport* report__) OVERRIDE;
+
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -83,7 +76,8 @@ class CStringSchemaItem : public CDefaultSchemaItem<std::string> {
**/
Errors::eType validate(const SmartObject& Object,
rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) OVERRIDE;
+ const utils::SemanticVersion& MessageVersion =
+ utils::SemanticVersion()) OVERRIDE;
private:
/**
diff --git a/src/components/smart_objects/src/always_false_schema_item.cc b/src/components/smart_objects/src/always_false_schema_item.cc
index acbe15485b..db16640265 100644
--- a/src/components/smart_objects/src/always_false_schema_item.cc
+++ b/src/components/smart_objects/src/always_false_schema_item.cc
@@ -47,12 +47,6 @@ Errors::eType CAlwaysFalseSchemaItem::validate(const SmartObject& object) {
}
Errors::eType CAlwaysFalseSchemaItem::validate(
- const SmartObject& object, rpc::ValidationReport* report__) {
- report__->set_validation_info("Generic error");
- return Errors::ERROR;
-}
-
-Errors::eType CAlwaysFalseSchemaItem::validate(
const SmartObject& Object,
rpc::ValidationReport* report__,
const utils::SemanticVersion& MessageVersion) {
diff --git a/src/components/smart_objects/src/always_true_schema_item.cc b/src/components/smart_objects/src/always_true_schema_item.cc
index 8a72d606a0..0a3b8be134 100644
--- a/src/components/smart_objects/src/always_true_schema_item.cc
+++ b/src/components/smart_objects/src/always_true_schema_item.cc
@@ -43,11 +43,6 @@ Errors::eType CAlwaysTrueSchemaItem::validate(const SmartObject& object) {
return Errors::OK;
}
-Errors::eType CAlwaysTrueSchemaItem::validate(const SmartObject& object,
- rpc::ValidationReport* report__) {
- return Errors::OK;
-}
-
Errors::eType CAlwaysTrueSchemaItem::validate(
const SmartObject& Object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc
index 108bccce11..60081c5222 100644
--- a/src/components/smart_objects/src/array_schema_item.cc
+++ b/src/components/smart_objects/src/array_schema_item.cc
@@ -47,48 +47,6 @@ Errors::eType CArraySchemaItem::validate(const SmartObject& Object) {
return validate(Object, &report);
}
-Errors::eType CArraySchemaItem::validate(const SmartObject& Object,
- rpc::ValidationReport* report__) {
- if (SmartType_Array != Object.getType()) {
- std::string validation_info = "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Array) +
- ", got: " +
- SmartObject::typeToString(Object.getType());
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
- size_t sizeLimit;
- const size_t array_len = Object.length();
-
- if (mMinSize.getValue(sizeLimit) && (array_len < sizeLimit)) {
- std::stringstream stream;
- stream << "Got array of size: " << array_len
- << ", minimum allowed: " << sizeLimit;
- std::string validation_info = stream.str();
- report__->set_validation_info(validation_info);
- return Errors::OUT_OF_RANGE;
- }
- if (mMaxSize.getValue(sizeLimit) && (array_len > sizeLimit)) {
- std::stringstream stream;
- stream << "Got array of size: " << array_len
- << ", maximum allowed: " << sizeLimit;
- std::string validation_info = stream.str();
- report__->set_validation_info(validation_info);
- return Errors::OUT_OF_RANGE;
- }
-
- for (size_t i = 0u; i < array_len; ++i) {
- std::stringstream strVal;
- strVal << i;
- const Errors::eType result = mElementSchemaItem->validate(
- Object.getElement(i), &report__->ReportSubobject(strVal.str()));
- if (Errors::OK != result) {
- return result;
- }
- }
- return Errors::OK;
-}
-
Errors::eType CArraySchemaItem::validate(
const SmartObject& Object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc
index 533f3b5e2c..879c280a67 100644
--- a/src/components/smart_objects/src/object_schema_item.cc
+++ b/src/components/smart_objects/src/object_schema_item.cc
@@ -109,44 +109,6 @@ Errors::eType CObjectSchemaItem::validate(const SmartObject& object) {
return validate(object, &report);
}
-Errors::eType CObjectSchemaItem::validate(const SmartObject& object,
- rpc::ValidationReport* report__) {
- if (SmartType_Map != object.getType()) {
- std::string validation_info = "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Map) +
- ", got: " +
- SmartObject::typeToString(object.getType());
- report__->set_validation_info(validation_info);
- return Errors::INVALID_VALUE;
- }
-
- std::set<std::string> object_keys = object.enumerate();
-
- for (Members::const_iterator it = mMembers.begin(); it != mMembers.end();
- ++it) {
- const std::string& key = it->first;
- const SMember& member = it->second;
-
- std::set<std::string>::const_iterator key_it = object_keys.find(key);
- if (object_keys.end() == key_it) {
- if (member.mIsMandatory) {
- std::string validation_info = "Missing mandatory parameter: " + key;
- report__->set_validation_info(validation_info);
- return Errors::MISSING_MANDATORY_PARAMETER;
- }
- continue;
- }
- const SmartObject& field = object.getElement(key);
- const Errors::eType result =
- member.mSchemaItem->validate(field, &report__->ReportSubobject(key));
- if (Errors::OK != result) {
- return result;
- }
- object_keys.erase(key_it);
- }
- return Errors::OK;
-}
-
Errors::eType CObjectSchemaItem::validate(
const SmartObject& object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/schema_item.cc b/src/components/smart_objects/src/schema_item.cc
index 001aa5fc5d..ae7f3665bb 100644
--- a/src/components/smart_objects/src/schema_item.cc
+++ b/src/components/smart_objects/src/schema_item.cc
@@ -39,11 +39,6 @@ Errors::eType ISchemaItem::validate(const SmartObject& Object) {
return Errors::ERROR;
}
-Errors::eType ISchemaItem::validate(const SmartObject& object,
- rpc::ValidationReport* report__) {
- return Errors::ERROR;
-}
-
Errors::eType ISchemaItem::validate(
const SmartObject& object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc
index 527a4308f8..691f45f63b 100644
--- a/src/components/smart_objects/src/smart_object.cc
+++ b/src/components/smart_objects/src/smart_object.cc
@@ -878,10 +878,6 @@ Errors::eType SmartObject::validate() {
return validate(&report);
}
-Errors::eType SmartObject::validate(rpc::ValidationReport* report__) {
- return m_schema.validate(*this, report__);
-}
-
Errors::eType SmartObject::validate(
rpc::ValidationReport* report__,
const utils::SemanticVersion& MessageVersion) {
diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc
index 154f9e116f..3ab94caf85 100644
--- a/src/components/smart_objects/src/smart_schema.cc
+++ b/src/components/smart_objects/src/smart_schema.cc
@@ -45,11 +45,6 @@ Errors::eType CSmartSchema::validate(const SmartObject& Object) const {
return validate(Object, &report);
}
-Errors::eType CSmartSchema::validate(const SmartObject& object,
- rpc::ValidationReport* report__) const {
- return mSchemaItem->validate(object, report__);
-}
-
Errors::eType CSmartSchema::validate(
const SmartObject& object,
rpc::ValidationReport* report__,
diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc
index cc6bf79f60..f3c39eff8f 100644
--- a/src/components/smart_objects/src/string_schema_item.cc
+++ b/src/components/smart_objects/src/string_schema_item.cc
@@ -51,8 +51,10 @@ Errors::eType CStringSchemaItem::validate(const SmartObject& Object) {
return validate(Object, &report);
}
-Errors::eType CStringSchemaItem::validate(const SmartObject& Object,
- rpc::ValidationReport* report__) {
+Errors::eType CStringSchemaItem::validate(
+ const SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion) {
if (SmartType_String != Object.getType()) {
std::string validation_info = "Incorrect type, expected: " +
SmartObject::typeToString(SmartType_String) +
@@ -84,13 +86,6 @@ Errors::eType CStringSchemaItem::validate(const SmartObject& Object,
return Errors::OK;
}
-Errors::eType CStringSchemaItem::validate(
- const SmartObject& Object,
- rpc::ValidationReport* report__,
- const utils::SemanticVersion& MessageVersion) {
- return validate(Object, report__);
-}
-
SmartType CStringSchemaItem::getSmartType() const {
return SmartType_String;
}