/** * @RDE_HEADER@ * * Common class to get a file content by FTC * $Id$ * $HeadURL$ * $Author$ * Created by Iuliana Ojog, SLSE, 2017-08-22 */ #include "flm_get_content.h" namespace FileManagement { //------------------------------------------------------------------------------------ GetFileContent::GetFileContent(const std::shared_ptr &ftc, QObject *parent) : QObject(parent) , m_requestHelper(new LtsUtils::RequestHelper(this)) , m_ftc(ftc) , m_logger(getLogger("GetFileContent")) { } //------------------------------------------------------------------------------------ GetFileContent::~GetFileContent() { delete m_requestHelper; } //----------------------------------------------------------------------------------------------------------- bool GetFileContent::getContent(int fileContentId, std::vector &content) { DEBUG_LOG(m_logger) << "New Get Content"; auto handleContent = [this, &content](const Core::FunctionReply & baseReply) { const GetFileContentDataReply &reply = static_cast(baseReply); content = reply.content(); DEBUG_LOG(m_logger) << "Content size: " << content.size(); }; auto sendReq = [this, fileContentId]() { GetFileContentDataRequest req; req.fileContentId(fileContentId); return m_ftc->getFileContentDataRequest(req, this); }; if (!m_requestHelper->startSingleRequest(sendReq, handleContent)) { ERROR_LOG(m_logger) << "Cannot retrieve file content for id = " << fileContentId; return false; } DEBUG_LOG(m_logger) << "Content size: " << content.size(); return true; } } // namespace FileManagement;