diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc index 75263494c2..620d901f3c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc @@ -59,6 +59,8 @@ namespace sdl_rpc_plugin { using namespace application_manager; namespace commands { +SDL_CREATE_LOG_VARIABLE("Commands") + GetFileRequest::GetFileRequest( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, @@ -85,8 +87,7 @@ bool GetFileRequest::GetFilePath(std::string& file_path, bool& forward_to_hmi) { if ((*message_)[strings::msg_params].keyExists(strings::app_service_id)) { std::string service_id = (*message_)[strings::msg_params][strings::app_service_id].asString(); - LOG4CXX_DEBUG(logger_, - "Finding storage directory for service id: " << service_id); + SDL_LOG_DEBUG("Finding storage directory for service id: " << service_id); AppService* app_service_info = application_manager_.GetAppServiceManager().FindServiceByID(service_id); @@ -101,7 +102,7 @@ bool GetFileRequest::GetFilePath(std::string& file_path, bool& forward_to_hmi) { return false; } } else { - LOG4CXX_DEBUG(logger_, "Using current storage directory"); + SDL_LOG_DEBUG("Using current storage directory"); } ApplicationSharedPtr app = application_manager_.application(connect_key); @@ -110,15 +111,15 @@ bool GetFileRequest::GetFilePath(std::string& file_path, bool& forward_to_hmi) { } void GetFileRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_INFO(logger_, "Received GetFile request"); + SDL_LOG_AUTO_TRACE(); + SDL_LOG_INFO("Received GetFile request"); ApplicationSharedPtr app = application_manager_.application(connection_key()); smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); if (!app) { - LOG4CXX_ERROR(logger_, "Application is not registered"); + SDL_LOG_ERROR("Application is not registered"); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } @@ -126,8 +127,7 @@ void GetFileRequest::Run() { file_name_ = (*message_)[strings::msg_params][strings::file_name].asString(); if (!file_system::IsFileNameValid(file_name_)) { - LOG4CXX_ERROR(logger_, - "File name " << file_name_ << " contains forbidden symbols."); + SDL_LOG_ERROR("File name " << file_name_ << " contains forbidden symbols."); SendResponse(false, mobile_apis::Result::INVALID_DATA, "File name contains forbidden symbols", @@ -136,7 +136,7 @@ void GetFileRequest::Run() { } // Initialize other params with default values. If exists overwrite the values - LOG4CXX_DEBUG(logger_, "Intialize non manadatory params with default values"); + SDL_LOG_DEBUG("Intialize non manadatory params with default values"); if ((*message_)[strings::msg_params].keyExists(strings::file_type)) { file_type_ = static_cast<mobile_apis::FileType::eType>( @@ -145,13 +145,13 @@ void GetFileRequest::Run() { // Check if file exists on system (may have to use app service id to get the // correct app folder) - LOG4CXX_DEBUG(logger_, "Check if file exists on system"); + SDL_LOG_DEBUG("Check if file exists on system"); std::string file_path; bool forward_to_hmi; if (GetFilePath(file_path, forward_to_hmi)) { if (forward_to_hmi) { - LOG4CXX_DEBUG(logger_, "Forwarding GetFile request to HMI"); + SDL_LOG_DEBUG("Forwarding GetFile request to HMI"); application_manager_.IncreaseForwardedRequestTimeout(connection_key(), correlation_id()); SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_GetFilePath, @@ -160,7 +160,7 @@ void GetFileRequest::Run() { return; } } else { - LOG4CXX_ERROR(logger_, "Could not get file path"); + SDL_LOG_ERROR("Could not get file path"); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Could not get file path", @@ -170,7 +170,7 @@ void GetFileRequest::Run() { const std::string full_path = file_path + "/" + file_name_; if (!file_system::FileExists(full_path)) { - LOG4CXX_ERROR(logger_, "File " << full_path << " does not exist"); + SDL_LOG_ERROR("File " << full_path << " does not exist"); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "File does not exist", @@ -179,7 +179,7 @@ void GetFileRequest::Run() { } // Handle offset - LOG4CXX_DEBUG(logger_, "Handle offset and length parameters"); + SDL_LOG_DEBUG("Handle offset and length parameters"); const uint64_t file_size = file_system::FileSize(full_path); if ((*message_)[strings::msg_params].keyExists(strings::offset)) { @@ -195,9 +195,8 @@ void GetFileRequest::Run() { } if (offset_ > file_size) { - LOG4CXX_ERROR( - logger_, - "Offset " << offset_ << " greater than file size " << file_size); + SDL_LOG_ERROR("Offset " << offset_ << " greater than file size " + << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Offset greater than file size", @@ -205,8 +204,7 @@ void GetFileRequest::Run() { return; } if (length_ > file_size - offset_) { - LOG4CXX_ERROR(logger_, - "Length " << length_ << " greater than file size - offset" + SDL_LOG_ERROR("Length " << length_ << " greater than file size - offset" << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, @@ -216,10 +214,10 @@ void GetFileRequest::Run() { } // Load data from file as binary data - LOG4CXX_DEBUG(logger_, "Load binary data from file"); + SDL_LOG_DEBUG("Load binary data from file"); std::vector<uint8_t> bin_data; if (!file_system::ReadBinaryFile(full_path, bin_data, offset_, length_)) { - LOG4CXX_ERROR(logger_, "Failed to read from file: " << full_path); + SDL_LOG_ERROR("Failed to read from file: " << full_path); SendResponse(false, mobile_apis::Result::GENERIC_ERROR, "Unable to read from file", @@ -248,7 +246,7 @@ void GetFileRequest::Run() { } void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); + SDL_LOG_AUTO_TRACE(); if (hmi_apis::FunctionID::BasicCommunication_GetFilePath != event.id()) { return; @@ -287,7 +285,7 @@ void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { event_message[strings::msg_params][strings::file_path].asString(); if (!file_system::FileExists(full_path)) { - LOG4CXX_ERROR(logger_, "File " << full_path << " does not exist"); + SDL_LOG_ERROR("File " << full_path << " does not exist"); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "File does not exist", @@ -309,9 +307,8 @@ void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { } if (offset_ > file_size) { - LOG4CXX_ERROR( - logger_, - "Offset " << offset_ << " greater than file size " << file_size); + SDL_LOG_ERROR("Offset " << offset_ << " greater than file size " + << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Offset greater than file size", @@ -319,8 +316,7 @@ void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { return; } if (length_ > file_size - offset_) { - LOG4CXX_ERROR(logger_, - "Length " << length_ << " greater than file size - offset" + SDL_LOG_ERROR("Length " << length_ << " greater than file size - offset" << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, @@ -329,7 +325,7 @@ void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { return; } if (!file_system::ReadBinaryFile(full_path, bin_data, offset_, length_)) { - LOG4CXX_ERROR(logger_, "Failed to read from file: " << full_path); + SDL_LOG_ERROR("Failed to read from file: " << full_path); SendResponse(false, mobile_apis::Result::GENERIC_ERROR, "Failed to read from file", @@ -341,7 +337,7 @@ void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { response_params[strings::crc32_check_sum] = crc_calculated; } else { - LOG4CXX_ERROR(logger_, "HMI did not return a file path: "); + SDL_LOG_ERROR("HMI did not return a file path: "); SendResponse(false, mobile_apis::Result::INVALID_DATA, "HMI did not return a file path", |