Migrates flm handlers and objects to plain member access
This commit is contained in:
1 parent
e156fbb5e4
commit
3c058facd7
9 files changed
+217
-217
No files matched your search
+29
-29
@@ -70,7 +70,7 @@ bool HandlerFileContent::init()
|
||||
void HandlerFileContent::onFileContentModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const FileManagement::FileContentModifyRequest &request)
|
||||
{
|
||||
auto ret = request.id() > 0 ? fileContentModifyRequest(request) : fileContentCreateRequest(request);
|
||||
auto ret = request.id > 0 ? fileContentModifyRequest(request) : fileContentCreateRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
fts()->fileContentModifyReply(cookie, ret);
|
||||
@@ -91,9 +91,9 @@ Core::FunctionReplyObject HandlerFileContent::fileContentCreateRequest(const Fil
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject HandlerFileContent::fileContentModifyRequest(const FileManagement::FileContentModifyRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
return ifs->updateObject(request);
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ Core::FunctionReplyObject HandlerFileContent::fileContentModifyRequest(const Fil
|
||||
void HandlerFileContent::onFileContentChangeStatusRequest(const rti::core::SampleIdentity &cookie,
|
||||
const FileManagement::FileContentChangeStatusRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
fts()->fileContentChangeStatusReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
@@ -127,13 +127,13 @@ void HandlerFileContent::onFileContentRemoveRequest(const rti::core::SampleIdent
|
||||
|
||||
Core::FunctionReplyObject HandlerFileContent::fileContentRemoveRequest(const Core::RemoveElementRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
|
||||
if (ifs == nullptr)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
|
||||
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent '%1' is used by another user!")).arg(ifs->getName());
|
||||
return Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent '%1' is used by another user!")).arg(ifs->getName());
|
||||
|
||||
auto ret = ifs->removeObject();
|
||||
|
||||
@@ -141,7 +141,7 @@ Core::FunctionReplyObject HandlerFileContent::fileContentRemoveRequest(const Cor
|
||||
{
|
||||
// delete ObjectFileContent
|
||||
delete ifs;
|
||||
m_objectFileContentMap.remove(request.id());
|
||||
m_objectFileContentMap.remove(request.id);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -152,28 +152,28 @@ void HandlerFileContent::onFileContentExportRequest(const rti::core::SampleIdent
|
||||
const FileManagement::FileContentExportRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
fts()->fileContentExportReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
// get content on demand from DB
|
||||
Database::FlmFileContent flmContent;
|
||||
if (!db()->selectFlmFileContent(request.id(), flmContent))
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found in database")).arg(request.id());
|
||||
if (!db()->selectFlmFileContent(request.id, flmContent))
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found in database")).arg(request.id);
|
||||
|
||||
QByteArray content = flmContent.content;
|
||||
DEBUG_LOG(m_logger) << "Content size: " << content.size();
|
||||
|
||||
// creating an unique file name: temp path + folderId + file name + file extension (NN_FileName.FileExt)
|
||||
QString fileName = QDir::tempPath() + QLatin1Char('/') + QString::number(ifs->getFolderId()) + QLatin1Char('-');
|
||||
fileName += QString::fromStdString(ifs->getData().name()).simplified().replace(QLatin1Char(' '), QLatin1Char('_'));
|
||||
fileName += QString::fromStdString(ifs->getData().name).simplified().replace(QLatin1Char(' '), QLatin1Char('_'));
|
||||
|
||||
// add extension
|
||||
FileType fileType = ifs->getData().fileType().underlying();
|
||||
FileType fileType = ifs->getData().fileType;
|
||||
QString fileExt = m_mainHandler->getHandlerFileTypeInfo()->getFileExtension(fileType);
|
||||
if (!fileExt.isEmpty())
|
||||
fileName += QLatin1Char('.') + fileExt;
|
||||
@@ -184,7 +184,7 @@ void HandlerFileContent::onFileContentExportRequest(const rti::core::SampleIdent
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Failed to write to %1")).arg(fileName);
|
||||
ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "Failed to write to %1")).arg(fileName);
|
||||
fts()->fileContentExportReply(cookie, ret);
|
||||
delete ifs;
|
||||
return;
|
||||
@@ -213,16 +213,16 @@ void HandlerFileContent::onGetFileContentDataRequest(const rti::core::SampleIden
|
||||
Core::FunctionReplyObject fro;
|
||||
GetFileContentDataReply reply;
|
||||
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.fileContentId());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.fileContentId);
|
||||
|
||||
if (ifs)
|
||||
{
|
||||
reply.id(ifs->getId());
|
||||
reply.id = ifs->getId();
|
||||
|
||||
// get content on demand from DB
|
||||
Database::FlmFileContent flmContent;
|
||||
if (!db()->selectFlmFileContent(request.fileContentId(), flmContent))
|
||||
fro = Core::FunctionReplyObject(request.fileContentId(), tr_lts("dds", "File content with id %1 not found in database")).arg(request.fileContentId());
|
||||
if (!db()->selectFlmFileContent(request.fileContentId, flmContent))
|
||||
fro = Core::FunctionReplyObject(request.fileContentId, tr_lts("dds", "File content with id %1 not found in database")).arg(request.fileContentId);
|
||||
/* no need to set content of object
|
||||
else
|
||||
ifs->setContent(LtsUtils::convert<std::vector<uint8_t>>(flmContent.content));
|
||||
@@ -233,21 +233,21 @@ void HandlerFileContent::onGetFileContentDataRequest(const rti::core::SampleIden
|
||||
reply.content(ifs->getContent());
|
||||
*/
|
||||
if (flmContent.content.size() <= 0)
|
||||
fro = Core::FunctionReplyObject(request.fileContentId(), tr_lts("dds", "No content available"));
|
||||
fro = Core::FunctionReplyObject(request.fileContentId, tr_lts("dds", "No content available"));
|
||||
else
|
||||
reply.content(LtsUtils::convert<std::vector<uint8_t>>(flmContent.content));
|
||||
reply.content = LtsUtils::convert<std::vector<uint8_t>>(flmContent.content);
|
||||
}
|
||||
else
|
||||
fro = Core::FunctionReplyObject(request.fileContentId(), tr_lts("dds", "No valid id = %1 for retrieving file content")).arg(request.fileContentId());
|
||||
fro = Core::FunctionReplyObject(request.fileContentId, tr_lts("dds", "No valid id = %1 for retrieving file content")).arg(request.fileContentId);
|
||||
|
||||
if (fro.error())
|
||||
{
|
||||
reply.id(fro.id());
|
||||
reply.errorString(fro.str());
|
||||
reply.errorParams(fro.args());
|
||||
reply.id = fro.id();
|
||||
reply.errorString = fro.str();
|
||||
reply.errorParams = fro.args();
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Got content size: " << reply.content().size();
|
||||
DEBUG_LOG(m_logger) << "Got content size: " << reply.content.size();
|
||||
|
||||
fts()->getFileContentDataReply(cookie, reply);
|
||||
}
|
||||
@@ -307,10 +307,10 @@ bool HandlerFileContent::initByDbId(int dbId)
|
||||
void HandlerFileContent::onFileContentSetUsedRequest(const rti::core::SampleIdentity &cookie,
|
||||
const FileManagement::FileContentSetUsedRequest &request)
|
||||
{
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id());
|
||||
ObjectFileContent *ifs = m_objectFileContentMap.value(request.id);
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "FileContent with id %1 not found")).arg(request.id());
|
||||
Core::FunctionReplyObject ret = Core::FunctionReplyObject(request.id, tr_lts("dds", "FileContent with id %1 not found")).arg(request.id);
|
||||
fts()->fileContentSetUsedReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user