Adds immediate migration results in progress

This commit is contained in:
torsten committed 2026-08-19 11:18:24 +02:00
1 parent 8453e104c5
commit 3bb6e89496
2102 files changed
+17482 -15071

No files matched your search

@@ -65,7 +65,7 @@ FlmTests::~FlmTests()
// ------------------------------------------------------------------------------
bool FlmTests::init(int domainId, int testId, int folderId, int fileContentId, int operatorId)
{
INFO_LOG() << "init begin";
INFO_LOG(m_logger) << "init begin";
m_testId = testId;
m_folderId = folderId;
@@ -79,33 +79,33 @@ bool FlmTests::init(int domainId, int testId, int folderId, int fileContentId, i
return false;
m_ddsConnector->initPublisherSubscriber();
TRACE_LOG() << "create dtc";
TRACE_LOG(m_logger) << "create dtc";
m_dtc = FileManagement::Interface::Dtc::create(m_ddsConnector);
TRACE_LOG() << "init dtc";
TRACE_LOG(m_logger) << "init dtc";
bool bRet = m_dtc->enableAll();
TRACE_LOG() << "init dtc end - bRet = " << bRet;
TRACE_LOG(m_logger) << "init dtc end - bRet = " << bRet;
TRACE_LOG() << "create ftc";
TRACE_LOG(m_logger) << "create ftc";
m_ftc = FileManagement::Interface::Ftc::create(m_ddsConnector);
TRACE_LOG() << "init ftc";
TRACE_LOG(m_logger) << "init ftc";
bRet &= m_ftc->enableAll();
TRACE_LOG() << "init ftc end - bRet = " << bRet;
TRACE_LOG(m_logger) << "init ftc end - bRet = " << bRet;
// initialize database
m_dbHandler = std::make_shared<DbHandler>();
if(!m_dbHandler->init(0, Settings::settings()))
{
ERROR_LOG() << "Initialisation dbHandler failed.";
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
return false;
}
DEBUG_LOG() << "Initialisation dbHandler succesful.";
DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful.";
m_db = m_dbHandler->db();
DEBUG_LOG() << "########### Domain Id = " << domainId;
DEBUG_LOG() << "########### Test Id = " << testId;
DEBUG_LOG() << "########### Folder Id = " << folderId;
DEBUG_LOG() << "########### File Content Id = " << fileContentId;
DEBUG_LOG() << "########### Operator Id = " << operatorId;
DEBUG_LOG(m_logger) << "########### Domain Id = " << domainId;
DEBUG_LOG(m_logger) << "########### Test Id = " << testId;
DEBUG_LOG(m_logger) << "########### Folder Id = " << folderId;
DEBUG_LOG(m_logger) << "########### File Content Id = " << fileContentId;
DEBUG_LOG(m_logger) << "########### Operator Id = " << operatorId;
return bRet;
}
@@ -113,7 +113,7 @@ bool FlmTests::init(int domainId, int testId, int folderId, int fileContentId, i
// ------------------------------------------------------------------------------
void FlmTests::startTest()
{
INFO_LOG() << "********* startTest **************";
INFO_LOG(m_logger) << "********* startTest **************";
switch (m_testId)
{
// folder
@@ -168,11 +168,11 @@ void FlmTests::startTest()
tryCreateSymbol();
break;
default:
ERROR_LOG() << "Unknown test case !";
ERROR_LOG(m_logger) << "Unknown test case !";
failExit();
break;
}
INFO_LOG() << "********* endTest **************";
INFO_LOG(m_logger) << "********* endTest **************";
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
@@ -181,13 +181,13 @@ void FlmTests::startTest()
// ------------------------------------------------------------------------------
void FlmTests::tryCreateFolder()
{
INFO_LOG() << "trying to send FolderCreateRequest";
INFO_LOG(m_logger) << "trying to send FolderCreateRequest";
int parentFolderId = m_folderId;
if (parentFolderId == 0)
parentFolderId = 1;
DEBUG_LOG() << "Creating Folder under folder id = " << parentFolderId;
DEBUG_LOG(m_logger) << "Creating Folder under folder id = " << parentFolderId;
// Creating hidden folder
m_folderId = createFolder(parentFolderId, QStringLiteral("Test Folder"), true);
@@ -197,7 +197,7 @@ void FlmTests::tryCreateFolder()
parentFolderId = m_folderId;
m_folderId = 0;
DEBUG_LOG() << "Creating Subfolder for folder id = " << parentFolderId;
DEBUG_LOG(m_logger) << "Creating Subfolder for folder id = " << parentFolderId;
m_folderId = createFolder(parentFolderId, QStringLiteral("Test Sub Folder"));
@@ -209,19 +209,19 @@ void FlmTests::tryCreateFolder()
// ------------------------------------------------------------------------------
void FlmTests::tryModifyFolder()
{
INFO_LOG() << "trying to send folder modify request ";
INFO_LOG(m_logger) << "trying to send folder modify request ";
DEBUG_LOG() << "m_folderId = " << m_folderId;
DEBUG_LOG(m_logger) << "m_folderId = " << m_folderId;
m_dtc->waitForHistoricalDataFolder();
const FileManagement::Folder &fld = m_dtc->folder(m_folderId);
FileManagement::FolderModifyRequest data;
DEBUG_LOG() << "fld.id() = " << fld.id();
DEBUG_LOG(m_logger) << "fld.id() = " << fld.id();
if (fld.id() == 0)
{
ERROR_LOG() << "Cannot find Folder Id = " << m_folderId;
ERROR_LOG(m_logger) << "Cannot find Folder Id = " << m_folderId;
failExit();
}
else
@@ -240,7 +240,7 @@ void FlmTests::tryModifyFolder()
if (!m_ftc->folderModifyRequest(FolderModifyRequest(data), this))
{
ERROR_LOG() << "Error requesting modify data";
ERROR_LOG(m_logger) << "Error requesting modify data";
failExit();
}
QTRY_VERIFY(m_folderId > 0);
@@ -252,11 +252,11 @@ void FlmTests::tryModifyFolder()
// ------------------------------------------------------------------------------
void FlmTests::tryRemoveFolder()
{
INFO_LOG() << "trying to send FolderRemoveRequest ";
INFO_LOG(m_logger) << "trying to send FolderRemoveRequest ";
m_dtc->waitForHistoricalDataFolder();
if (!m_ftc->folderRemoveRequest(FolderRemoveRequest(m_folderId), this))
{
ERROR_LOG() << "Error requesting delete data";
ERROR_LOG(m_logger) << "Error requesting delete data";
failExit();
}
QTest::qWait(1000);
@@ -278,7 +278,7 @@ int FlmTests::createFolder(int parentFolderId, const QString &folderName, bool i
if (!m_ftc->folderModifyRequest(req, this))
{
ERROR_LOG() << "Error creating folder with parent = " << parentFolderId << " and name = " << folderName ;
ERROR_LOG(m_logger) << "Error creating folder with parent = " << parentFolderId << " and name = " << folderName ;
failExit();
}
@@ -290,7 +290,7 @@ int FlmTests::createFolder(int parentFolderId, const QString &folderName, bool i
// ------------------------------------------------------------------------------
void FlmTests::tryCreateFileContent()
{
INFO_LOG() << "trying to send file content create request ";
INFO_LOG(m_logger) << "trying to send file content create request ";
m_dtc->waitForHistoricalDataFileContent();
FileContentModifyRequest data;
@@ -313,7 +313,7 @@ void FlmTests::tryCreateFileContent()
m_fileContentId = 0;
if (!m_ftc->fileContentModifyRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTRY_VERIFY(m_fileContentId > 0);
@@ -333,7 +333,7 @@ void FlmTests::tryCreateFileContent()
m_fileContentId = 0;
if (!m_ftc->fileContentModifyRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTRY_VERIFY(m_fileContentId > 0);
@@ -352,11 +352,11 @@ void FlmTests::tryCreateFileContent()
file.setFileName(QCoreApplication::applicationDirPath()+fileName);
if (!file.open(QFile::ReadOnly))
{
ERROR_LOG() << "Error opening file " << fileName;
ERROR_LOG(m_logger) << "Error opening file " << fileName;
failExit();
}
QByteArray rawImage = file.readAll();
DEBUG_LOG() << "Read file " << fileName;
DEBUG_LOG(m_logger) << "Read file " << fileName;
file.close();
data.content(LtsUtils::convert<std::vector<uint8_t>>(rawImage));
@@ -364,7 +364,7 @@ void FlmTests::tryCreateFileContent()
m_fileContentId = 0;
if (!m_ftc->fileContentModifyRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTRY_VERIFY(m_fileContentId > 0);
@@ -382,11 +382,11 @@ void FlmTests::tryCreateFileContent()
file.setFileName(QCoreApplication::applicationDirPath()+fileName);
if (!file.open(QFile::ReadOnly))
{
ERROR_LOG() << "Error opening file " << fileName;
ERROR_LOG(m_logger) << "Error opening file " << fileName;
failExit();
}
rawImage = file.readAll();
DEBUG_LOG() << "Read file " << fileName;
DEBUG_LOG(m_logger) << "Read file " << fileName;
file.close();
data.content(LtsUtils::convert<std::vector<uint8_t>>(rawImage));
@@ -394,7 +394,7 @@ void FlmTests::tryCreateFileContent()
m_fileContentId = 0;
if (!m_ftc->fileContentModifyRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTRY_VERIFY(m_fileContentId > 0);
@@ -403,30 +403,30 @@ void FlmTests::tryCreateFileContent()
// ------------------------------------------------------------------------------
void FlmTests::tryModifyFileContent()
{
INFO_LOG() << "trying to send file content modify request ";
INFO_LOG(m_logger) << "trying to send file content modify request ";
DEBUG_LOG() << "m_fileContentId = " << m_fileContentId;
DEBUG_LOG(m_logger) << "m_fileContentId = " << m_fileContentId;
m_dtc->waitForHistoricalDataFileContent();
const FileManagement::FileContent &flc = m_dtc->fileContent(m_fileContentId);
FileManagement::FileContentModifyRequest data;
DEBUG_LOG() << "flc.id() = " << flc.id();
DEBUG_LOG(m_logger) << "flc.id() = " << flc.id();
if (flc.id() == 0)
{
ERROR_LOG() << "Cannot find File Content Id = " << m_fileContentId;
ERROR_LOG(m_logger) << "Cannot find File Content Id = " << m_fileContentId;
failExit();
}
else
{
if (!checkContentSize(m_fileContentId))
{
ERROR_LOG() << "Content size 0";
ERROR_LOG(m_logger) << "Content size 0";
failExit();
}
DEBUG_LOG() << "Content size = " << m_content.size();
DEBUG_LOG(m_logger) << "Content size = " << m_content.size();
data.id(flc.id());
data.name(flc.name());
@@ -454,7 +454,7 @@ void FlmTests::tryModifyFileContent()
if (!m_ftc->fileContentModifyRequest(FileContentModifyRequest(data), this))
{
ERROR_LOG() << "Error requesting modify data";
ERROR_LOG(m_logger) << "Error requesting modify data";
failExit();
}
@@ -471,7 +471,7 @@ bool FlmTests::checkContentSize(int fileId)
m_content.clear();
if (!m_ftc->getFileContentDataRequest(request, this))
{
ERROR_LOG() << "Cannot retrieve file content for id = " << fileId;
ERROR_LOG(m_logger) << "Cannot retrieve file content for id = " << fileId;
return false;
}
@@ -483,25 +483,25 @@ bool FlmTests::checkContentSize(int fileId)
// ------------------------------------------------------------------------------
void FlmTests::tryUpdateStatus()
{
INFO_LOG() << "trying update status file content";
INFO_LOG(m_logger) << "trying update status file content";
DEBUG_LOG() << "m_fileContentId = " << m_fileContentId;
DEBUG_LOG(m_logger) << "m_fileContentId = " << m_fileContentId;
m_dtc->waitForHistoricalDataFileContent();
const FileManagement::FileContent &flc = m_dtc->fileContent(m_fileContentId);
DEBUG_LOG() << "flc.id() = " << flc.id();
DEBUG_LOG(m_logger) << "flc.id() = " << flc.id();
if (flc.id() == 0)
{
ERROR_LOG() << "Cannot find File Content Id = " << m_fileContentId;
ERROR_LOG(m_logger) << "Cannot find File Content Id = " << m_fileContentId;
failExit();
}
else
{
if (!m_db->updateStatus(m_fileContentId, FileManagement::FileStatus::Deleted, m_operatorId))
{
ERROR_LOG() << "Cannot update status for File Content Id = " << m_fileContentId;
ERROR_LOG(m_logger) << "Cannot update status for File Content Id = " << m_fileContentId;
failExit();
}
@@ -509,7 +509,7 @@ void FlmTests::tryUpdateStatus()
if (!checkContentSize(m_fileContentId))
{
ERROR_LOG() << "Content size 0";
ERROR_LOG(m_logger) << "Content size 0";
failExit();
}
@@ -520,11 +520,11 @@ void FlmTests::tryUpdateStatus()
// ------------------------------------------------------------------------------
void FlmTests::tryRemoveFileContent()
{
INFO_LOG() << "trying to send FileContentRemoveRequest ";
INFO_LOG(m_logger) << "trying to send FileContentRemoveRequest ";
m_dtc->waitForHistoricalDataFileContent();
if (!m_ftc->fileContentRemoveRequest(FileContentRemoveRequest(m_fileContentId), this))
{
ERROR_LOG() << "Error requesting delete data";
ERROR_LOG(m_logger) << "Error requesting delete data";
failExit();
}
QTest::qWait(1000);
@@ -533,11 +533,11 @@ void FlmTests::tryRemoveFileContent()
// ------------------------------------------------------------------------------
void FlmTests::tryExportFileContent()
{
INFO_LOG() << "trying to send FileContentExportRequest ";
INFO_LOG(m_logger) << "trying to send FileContentExportRequest ";
m_dtc->waitForHistoricalDataFileContent();
if (!m_ftc->fileContentExportRequest(FileContentExportRequest(m_fileContentId), this))
{
ERROR_LOG() << "Error requesting export data";
ERROR_LOG(m_logger) << "Error requesting export data";
failExit();
}
@@ -545,7 +545,7 @@ void FlmTests::tryExportFileContent()
if (!checkContentSize(m_fileContentId))
{
ERROR_LOG() << "Content size 0";
ERROR_LOG(m_logger) << "Content size 0";
failExit();
}
@@ -555,7 +555,7 @@ void FlmTests::tryExportFileContent()
// ------------------------------------------------------------------------------
void FlmTests::tryCreatePlan()
{
INFO_LOG() << "trying to send file content create request ";
INFO_LOG(m_logger) << "trying to send file content create request ";
FileContentModifyRequest data;
@@ -575,7 +575,7 @@ void FlmTests::tryCreatePlan()
m_fileContentId = 0;
if (!m_ftc->fileContentModifyRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTRY_VERIFY(m_fileContentId > 0);
@@ -584,7 +584,7 @@ void FlmTests::tryCreatePlan()
// ------------------------------------------------------------------------------
void FlmTests::tryCreateFav()
{
INFO_LOG() << "trying to send file content create request ";
INFO_LOG(m_logger) << "trying to send file content create request ";
FileContentModifyRequest data;
@@ -604,7 +604,7 @@ void FlmTests::tryCreateFav()
m_fileContentId = 0;
if (!m_ftc->fileContentModifyRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTRY_VERIFY(m_fileContentId > 0);
@@ -613,7 +613,7 @@ void FlmTests::tryCreateFav()
// ------------------------------------------------------------------------------
void FlmTests::tryCreateSymbol()
{
INFO_LOG() << "trying to send file content create request ";
INFO_LOG(m_logger) << "trying to send file content create request ";
FileContentModifyRequest data;
@@ -633,7 +633,7 @@ void FlmTests::tryCreateSymbol()
m_fileContentId = 0;
if (!m_ftc->fileContentModifyRequest(data, this))
{
ERROR_LOG() << "Error requesting create data";
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTRY_VERIFY(m_fileContentId > 0);
@@ -645,15 +645,15 @@ void FlmTests::tryGetContent()
GetFileContentDataRequest request;
request.fileContentId(m_fileContentId);
INFO_LOG() << "trying to send content request for file Id = " << m_fileContentId;
INFO_LOG(m_logger) << "trying to send content request for file Id = " << m_fileContentId;
if (!m_ftc->getFileContentDataRequest(request, this))
{
ERROR_LOG() << "Error requesting content for id : " << m_fileContentId;
ERROR_LOG(m_logger) << "Error requesting content for id : " << m_fileContentId;
failExit();
}
QTRY_VERIFY(m_content.size() > 0);
DEBUG_LOG() << "Got content size: " << m_content.size();
DEBUG_LOG(m_logger) << "Got content size: " << m_content.size();
}
// ------------------------------------------------------------------------------
@@ -661,16 +661,16 @@ void FlmTests::onGetFileContentDataReply(const GetFileContentDataReply &replyObj
{
if (replyObject.errorString().size() > 0)
{
ERROR_LOG() << "Got onGetFileContentDataReply error: " << replyObject.errorString();
ERROR_LOG(m_logger) << "Got onGetFileContentDataReply error: " << replyObject.errorString();
failExit();
}
INFO_LOG() << "Got reply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got reply with id " << replyObject.id()
<< " and errorString " << replyObject.errorString();
m_content = replyObject.content();
DEBUG_LOG() << "Content size: " << m_content.size();
DEBUG_LOG(m_logger) << "Content size: " << m_content.size();
// QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
@@ -679,19 +679,19 @@ void FlmTests::onGetFileContentDataReply(const GetFileContentDataReply &replyObj
// ------------------------------------------------------------------------------
void FlmTests::tryGetAllTemplates()
{
INFO_LOG() << "tryGetAllTemplates";
INFO_LOG(m_logger) << "tryGetAllTemplates";
QList<FileContent> allTemplates;
m_dtc->waitForHistoricalDataFileContent();
if (!m_dtc->getAllTemplates(allTemplates))
{
ERROR_LOG() << "Error requesting dtc data";
ERROR_LOG(m_logger) << "Error requesting dtc data";
failExit();
}
DEBUG_LOG() << "Found " << allTemplates.size() << " templates";
DEBUG_LOG(m_logger) << "Found " << allTemplates.size() << " templates";
for (const FileContent &fc : std::as_const(allTemplates))
DEBUG_LOG() << "Found template (id, name) = (" << fc.id() << ", " << fc.name() << ")";
DEBUG_LOG(m_logger) << "Found template (id, name) = (" << fc.id() << ", " << fc.name() << ")";
QTest::qWait(1000);
}
@@ -699,19 +699,19 @@ void FlmTests::tryGetAllTemplates()
// ------------------------------------------------------------------------------
void FlmTests::tryGetAllPlans()
{
INFO_LOG() << "tryGetAllPlans";
INFO_LOG(m_logger) << "tryGetAllPlans";
QStringList allPlans;
m_dtc->waitForHistoricalDataFileContent();
if (!m_dtc->getAllFiles(FileManagement::FileType::TacticalPlan, m_folderId, allPlans))
{
ERROR_LOG() << "Error requesting dtc data";
ERROR_LOG(m_logger) << "Error requesting dtc data";
failExit();
}
DEBUG_LOG() << "Found " << allPlans.size() << " plans";
DEBUG_LOG(m_logger) << "Found " << allPlans.size() << " plans";
for (const QString &plan : std::as_const(allPlans))
DEBUG_LOG() << "Found plan = " << plan;
DEBUG_LOG(m_logger) << "Found plan = " << plan;
QTest::qWait(1000);
}
@@ -719,19 +719,19 @@ void FlmTests::tryGetAllPlans()
// ------------------------------------------------------------------------------
void FlmTests::tryGetAllFavs()
{
INFO_LOG() << "tryGetAllFavs";
INFO_LOG(m_logger) << "tryGetAllFavs";
QStringList allFavs;
m_dtc->waitForHistoricalDataFileContent();
if (!m_dtc->getAllFiles(FileManagement::FileType::OperatorFavourite, m_folderId, allFavs))
{
ERROR_LOG() << "Error requesting dtc data";
ERROR_LOG(m_logger) << "Error requesting dtc data";
failExit();
}
DEBUG_LOG() << "Found " << allFavs.size() << " favs";
DEBUG_LOG(m_logger) << "Found " << allFavs.size() << " favs";
for (const QString &fav : std::as_const(allFavs))
DEBUG_LOG() << "Found fav = " << fav;
DEBUG_LOG(m_logger) << "Found fav = " << fav;
QTest::qWait(1000);
}
@@ -739,19 +739,19 @@ void FlmTests::tryGetAllFavs()
// ------------------------------------------------------------------------------
void FlmTests::tryGetAllSymbols()
{
INFO_LOG() << "tryGetAllSymbols";
INFO_LOG(m_logger) << "tryGetAllSymbols";
QStringList allSymbols;
m_dtc->waitForHistoricalDataFileContent();
if (!m_dtc->getAllFiles(FileManagement::FileType::OperatorDefinedSymbol, m_folderId, allSymbols))
{
ERROR_LOG() << "Error requesting dtc data";
ERROR_LOG(m_logger) << "Error requesting dtc data";
failExit();
}
DEBUG_LOG() << "Found " << allSymbols.size() << " symbols";
DEBUG_LOG(m_logger) << "Found " << allSymbols.size() << " symbols";
for (const QString &symbol : std::as_const(allSymbols))
DEBUG_LOG() << "Found symbol = " << symbol;
DEBUG_LOG(m_logger) << "Found symbol = " << symbol;
QTest::qWait(1000);
}
@@ -760,7 +760,7 @@ void FlmTests::tryGetAllSymbols()
// ------------------------------------------------------------------------------
void FlmTests::onError(const QString &reason)
{
ERROR_LOG() << "Got Reply error: " << reason;
ERROR_LOG(m_logger) << "Got Reply error: " << reason;
failExit();
}
@@ -772,7 +772,7 @@ void FlmTests::onReply(const Core::FunctionReplyObject &replyObject)
onError(replyObject.translated());
return;
}
INFO_LOG() << "Got Reply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got Reply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
// QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
@@ -780,7 +780,7 @@ void FlmTests::onReply(const Core::FunctionReplyObject &replyObject)
// ------------------------------------------------------------------------------
void FlmTests::failExit()
{
ERROR_LOG() << "FAIL EXIT !";
ERROR_LOG(m_logger) << "FAIL EXIT !";
m_bTestsSuccessful = false;
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
@@ -790,11 +790,11 @@ void FlmTests::onFolderModifyReply(const Core::FunctionReplyObject &replyObject)
{
if (replyObject.error())
{
ERROR_LOG() << "Got onFolderModifyReply error: " << replyObject();
ERROR_LOG(m_logger) << "Got onFolderModifyReply error: " << replyObject();
failExit();
return;
}
INFO_LOG() << "Got modifyFolderReply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got modifyFolderReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
m_folderId = replyObject.id();
}
@@ -804,11 +804,11 @@ void FlmTests::onFileContentModifyReply(const Core::FunctionReplyObject &replyOb
{
if (replyObject.error())
{
ERROR_LOG() << "Got onFileContentModifyReply error: " << replyObject();
ERROR_LOG(m_logger) << "Got onFileContentModifyReply error: " << replyObject();
failExit();
return;
}
INFO_LOG() << "Got modifyFileReply with id " << replyObject.id()
INFO_LOG(m_logger) << "Got modifyFileReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
m_fileContentId = replyObject.id();
}
@@ -53,9 +53,8 @@ ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandle
// ####### ClientMessage end #######
// ####### BaseDlRequest begin #######
BaseDlRequest::BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
: ClientMessage(dataManager, client, type, typeId, uuid, data)
{}
BaseDlRequest::BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data) : ClientMessage(dataManager, client, type, typeId, uuid, data),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
void BaseDlRequest::process()
{
@@ -36,7 +36,7 @@ bool WebSocketInterfaceHandler::init()
{
cleanup();
DEBUG_LOG() << "... ok";
DEBUG_LOG(m_logger) << "... ok";
m_dataManager = new DataManager(m_mainHandler);
@@ -44,16 +44,16 @@ bool WebSocketInterfaceHandler::init()
m_webSocketServer = new LtsWebSocket::LtsWebSocketServer(m_messageFactory, this);
DEBUG_LOG() << "Initialising LtsWebSocketServer";
DEBUG_LOG(m_logger) << "Initialising LtsWebSocketServer";
if (!m_webSocketServer->init(QStringLiteral("FLM"), Settings::getWebSocketServerPortRange(1)))
{
ERROR_LOG() << "Failed to initialise LtsWebSocketServer";
ERROR_LOG(m_logger) << "Failed to initialise LtsWebSocketServer";
return false;
}
DEBUG_LOG() << "... ok";
DEBUG_LOG(m_logger) << "... ok";
DEBUG_LOG() << "Connection signals and slots";
DEBUG_LOG() << "... ok";
DEBUG_LOG(m_logger) << "Connection signals and slots";
DEBUG_LOG(m_logger) << "... ok";
return true;
}
@@ -22,6 +22,7 @@ class Base : public QObject
{
Q_OBJECT
protected:
NGL::INGLLogger &m_logger;
explicit Base(MainHandler *mainHandler, NGL::INGLLogger &logger, QObject *parent = nullptr);
virtual ~Base();
@@ -17,14 +17,14 @@ namespace FileManagement
DdsHandler::DdsHandler(int domainId)
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Any))
{
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
}
bool DdsHandler::init(const QStringList &qosFileList)
{
if (!m_ddsConnector->init(qosFileList))
{
ERROR_LOG() << "Error initializing dds connections - aborting";
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
return false;
}
@@ -40,13 +40,13 @@ bool DdsHandler::init(const QStringList &qosFileList)
m_ddsFts = FileManagement::Interface::Fts::create(m_ddsConnector);
bool bRet = m_ddsDts->enableAll();
INFO_LOG() << "Dts initialised";
INFO_LOG(m_logger) << "Dts initialised";
bRet &= m_ddsDtc->enableAll();
INFO_LOG() << "Dtc initialised";
INFO_LOG(m_logger) << "Dtc initialised";
bRet &= m_ddsFts->enableAll();
INFO_LOG() << "Fts initialised";
INFO_LOG(m_logger) << "Fts initialised";
return bRet;
}
@@ -40,6 +40,7 @@ public:
std::shared_ptr<FileManagement::Interface::Fts> fts() const { return m_ddsFts; }
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<Core::Pacemaker> m_pacemaker;
std::shared_ptr<Core::TopicLockMaster> m_topicLockMaster;
@@ -16,9 +16,8 @@
//------------------------------------------------------------------------------------------------------
namespace FileManagement
{
HandlerFileTypeInfo::HandlerFileTypeInfo(MainHandler *mainHandler)
: Base(mainHandler, getLogger("HandlerFileTypeInfo"))
{}
HandlerFileTypeInfo::HandlerFileTypeInfo(MainHandler *mainHandler) : Base(mainHandler, getLogger("HandlerFileTypeInfo")),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
//------------------------------------------------------------------------------------------------------
HandlerFileTypeInfo::~HandlerFileTypeInfo()
@@ -29,6 +29,8 @@ public:
QString getFileExtension(const FileManagement::FileType &fileType) const;
private:
NGL::INGLLogger &m_logger;
QMap<int, ObjectFileTypeInfo *> m_objectFileTypeInfoMap;
};
}
@@ -21,15 +21,14 @@
namespace FileManagement
{
MainHandler::MainHandler(QObject *parent)
: QObject(parent)
MainHandler::MainHandler(QObject *parent) : QObject(parent)
, m_ddsHandler(nullptr)
, m_dbHandler(nullptr)
, m_handlerFileTypeInfo(nullptr)
, m_handlerFolder(nullptr)
, m_handlerFileContent(nullptr)
, m_handlerWebSocket(nullptr)
{}
, m_handlerWebSocket(nullptr),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
MainHandler::~MainHandler()
{
@@ -48,29 +47,29 @@ bool MainHandler::init(int domainId)
m_dbHandler = std::make_shared<DbHandler>();
if (!m_dbHandler->init(0, Settings::settings()))
{
ERROR_LOG() << "Initialisation dbHandler failed.";
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
return false;
}
DEBUG_LOG() << "Initialisation dbHandler succesful.";
DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful.";
// initialize DDS
m_ddsHandler.reset(new DdsHandler(domainId));
if (!m_ddsHandler->init())
{
ERROR_LOG() << "Initialisation ddsHandler failed.";
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
return false;
}
DEBUG_LOG() << "Initialisation ddsHandler succesful.";
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
// read project specific data from database
// publish project specific data
// initialize all handlers
if (!initFlmHandler())
{
ERROR_LOG() << "Initialisation FlmHandler failed.";
ERROR_LOG(m_logger) << "Initialisation FlmHandler failed.";
return false;
}
DEBUG_LOG() << "Initialisation FlmHandler succesful.";
DEBUG_LOG(m_logger) << "Initialisation FlmHandler succesful.";
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
@@ -86,52 +85,52 @@ int MainHandler::exerciseId() const
bool MainHandler::initFlmHandler()
{
DEBUG_LOG() << "Start Initialisation FlmHandler";
DEBUG_LOG(m_logger) << "Start Initialisation FlmHandler";
// FileTypeInfo
m_handlerFileTypeInfo.reset(new HandlerFileTypeInfo(this));
DEBUG_LOG() << "Reset HandlerFileTypeInfo successful.";
DEBUG_LOG(m_logger) << "Reset HandlerFileTypeInfo successful.";
if (!m_handlerFileTypeInfo->init())
{
ERROR_LOG() << "Initialisation of HandlerFileTypeInfo failed.";
ERROR_LOG(m_logger) << "Initialisation of HandlerFileTypeInfo failed.";
return false;
}
DEBUG_LOG() << "Initialisation HandlerFileTypeInfo succesful.";
DEBUG_LOG(m_logger) << "Initialisation HandlerFileTypeInfo succesful.";
// Folder
m_handlerFolder.reset(new HandlerFolder(this));
DEBUG_LOG() << "Reset HandlerFolder successful.";
DEBUG_LOG(m_logger) << "Reset HandlerFolder successful.";
if (!m_handlerFolder->init())
{
ERROR_LOG() << "Initialisation of HandlerFolder failed.";
ERROR_LOG(m_logger) << "Initialisation of HandlerFolder failed.";
return false;
}
DEBUG_LOG() << "Initialisation HandlerFolder successful.";
DEBUG_LOG(m_logger) << "Initialisation HandlerFolder successful.";
// FileContent
m_handlerFileContent.reset(new HandlerFileContent(this));
DEBUG_LOG() << "Reset HandlerFileContent successful.";
DEBUG_LOG(m_logger) << "Reset HandlerFileContent successful.";
if (!m_handlerFileContent->init())
{
ERROR_LOG() << "Initialisation of HandlerFileContent failed.";
ERROR_LOG(m_logger) << "Initialisation of HandlerFileContent failed.";
return false;
}
DEBUG_LOG() << "Initialisation HandlerFileContent successful.";
DEBUG_LOG(m_logger) << "Initialisation HandlerFileContent successful.";
// WebSocketServer
m_handlerWebSocket = std::make_shared<WebSocketInterface::WebSocketInterfaceHandler>(this);
DEBUG_LOG() << "Reset WebSocketInterfaceHandler successful.";
DEBUG_LOG(m_logger) << "Reset WebSocketInterfaceHandler successful.";
if (!m_handlerWebSocket->init())
{
ERROR_LOG() << "Initialisation WebSocketInterfaceHandler failed.";
ERROR_LOG(m_logger) << "Initialisation WebSocketInterfaceHandler failed.";
return false;
}
m_ddsHandler->pacemaker()->addPort(m_handlerWebSocket->serverWebSocketPort(), Core::PortType::WebSocketServer);
DEBUG_LOG() << "Initialisation WebSocketInterfaceHandler successful.";
DEBUG_LOG(m_logger) << "Initialisation WebSocketInterfaceHandler successful.";
@@ -139,7 +138,7 @@ bool MainHandler::initFlmHandler()
m_thpScriptServer.reset(new ThpScriptServer(this));
DEBUG_LOG() << "Initialisation ThpTcpScriptServer successful.";
DEBUG_LOG(m_logger) << "Initialisation ThpTcpScriptServer successful.";
@@ -149,10 +148,10 @@ bool MainHandler::initFlmHandler()
m_pdfServer.reset(new PdfServer(this, this));
if (!m_pdfServer->init())
{
ERROR_LOG() << "Initialisation PdfServer failed.";
ERROR_LOG(m_logger) << "Initialisation PdfServer failed.";
return false;
}
DEBUG_LOG() << "Initialisation PdfServer successful.";
DEBUG_LOG(m_logger) << "Initialisation PdfServer successful.";
return true;
}
@@ -45,9 +45,11 @@ public:
int exerciseId() const;
private:
NGL::INGLLogger &m_logger;
bool initFlmHandler();
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DdsHandler> m_ddsHandler;
std::shared_ptr<DbHandler> m_dbHandler;
std::shared_ptr<HandlerFileTypeInfo> m_handlerFileTypeInfo;
@@ -16,22 +16,21 @@
namespace FileManagement
{
CBI_PdfDownload::CBI_PdfDownload(unsigned short port)
: CommandInterface(port, "PDF_DOWNLOAD")
{}
CBI_PdfDownload::CBI_PdfDownload(unsigned short port) : CommandInterface(port, "PDF_DOWNLOAD"),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
void CBI_PdfDownload::handleCommandInternal(const QVector<QByteArray> &args)
{
setAutoWriteEOL(false);
DEBUG_LOG() << "Got command for PDF download";
DEBUG_LOG(m_logger) << "Got command for PDF download";
if (args.count() != 1)
{
ERROR_LOG() << "Invalid arg count";
ERROR_LOG(m_logger) << "Invalid arg count";
return;
}
DEBUG_LOG() << "Argument count ok";
DEBUG_LOG(m_logger) << "Argument count ok";
bool bOk;
int documentId = args.at(0).toInt(&bOk);
@@ -40,10 +39,10 @@ void CBI_PdfDownload::handleCommandInternal(const QVector<QByteArray> &args)
{
const QString err(QStringLiteral("Invalid file id: '%1'").arg(QString::fromUtf8(args.at(0))));
writeError(err);
ERROR_LOG() << err;
ERROR_LOG(m_logger) << err;
return;
}
DEBUG_LOG() << "Argument ok";
DEBUG_LOG(m_logger) << "Argument ok";
MainHandler *mainHandler = static_cast<MainHandler *>(TcpServer::instance(port())->userData());
@@ -54,22 +53,22 @@ void CBI_PdfDownload::handleCommandInternal(const QVector<QByteArray> &args)
{
const QString err(QStringLiteral("File with ID '%1' does not exist").arg(QString::fromUtf8(args.at(0))));
writeError(err);
ERROR_LOG() << err;
ERROR_LOG(m_logger) << err;
return;
}
DEBUG_LOG() << "File ID valid";
DEBUG_LOG(m_logger) << "File ID valid";
if (fileContent.fileTypeId != FileManagement::FileType::Pdf)
{
const QString err(QStringLiteral("File with ID '%1' is not of type Pdf").arg(QString::fromUtf8(args.at(0))));
writeError(err);
ERROR_LOG() << err;
ERROR_LOG(m_logger) << err;
return;
}
DEBUG_LOG() << "FileType valid";
DEBUG_LOG(m_logger) << "FileType valid";
// success
DEBUG_LOG() << "File ok, sending file \"" << fileContent.name << "\" with ID " << fileContent.id;
DEBUG_LOG(m_logger) << "File ok, sending file \"" << fileContent.name << "\" with ID " << fileContent.id;
writeData(fileContent.content);
}
@@ -26,6 +26,8 @@ public:
QString help() const override;
protected:
NGL::INGLLogger &m_logger;
void handleCommandInternal(const QVector<QByteArray> &args) override;
private:
@@ -16,10 +16,9 @@
namespace FileManagement
{
PdfServer::PdfServer(MainHandler *mainHandler, QObject *parent)
: QObject(parent)
, m_tcpServer(TcpServer::instance(NGL::Connections::port(NGL::Connections::eConnection::FLM_PDF_SERVER)))
{
PdfServer::PdfServer(MainHandler *mainHandler, QObject *parent) : QObject(parent)
, m_tcpServer(TcpServer::instance(NGL::Connections::port(NGL::Connections::eConnection::FLM_PDF_SERVER))),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
m_tcpServer->setUserData(mainHandler);
m_tcpServer->setUseWorkerThreads(false);
}
@@ -27,6 +27,7 @@ public:
bool init();
private:
NGL::INGLLogger &m_logger;
TcpServer *m_tcpServer;
};
} // namespace FileManagement
@@ -63,19 +63,19 @@ Logger::Logger(LoggerFactory *loggerFactory, QObject *parent)
void Logger::debug(const QString &message)
{
/*DEBUG_LOG*/ERROR_LOG() << message;
/*DEBUG_LOG*/ERROR_LOG(m_logger) << message;
}
void Logger::warning(const QString &message)
{
WARNING_LOG() << message;
WARNING_LOG(m_logger) << message;
}
void Logger::error(const QString &message)
{
ERROR_LOG() << message;
ERROR_LOG(m_logger) << message;
}
@@ -86,7 +86,7 @@ ThpScriptServer::ThpScriptServer(QObject *parent)
{
if (!listen(NGL::Connections::port(NGL::Connections::eConnection::FLM_THP_SERVER)))
{
ERROR_LOG() << "cannot listen on port " << NGL::Connections::port(NGL::Connections::eConnection::FLM_THP_SERVER);
ERROR_LOG(m_logger) << "cannot listen on port " << NGL::Connections::port(NGL::Connections::eConnection::FLM_THP_SERVER);
Q_ASSERT(false);
}
@@ -148,7 +148,7 @@ ThpScriptServer::ThpScriptServer(QObject *parent)
default:
{
ERROR_LOG() << "ws unknown path: " << cli->requestUrl().path();
ERROR_LOG(m_logger) << "ws unknown path: " << cli->requestUrl().path();
failed = true;
break;
}
@@ -192,7 +192,7 @@ const QString ThpScriptServer::readContentFile() const
f->deleteLater();
if (!f->open(QIODevice::ReadOnly))
{
WARNING_LOG() << "Error opening " << f->fileName() << " for reading: " << f->errorString();
WARNING_LOG(m_logger) << "Error opening " << f->fileName() << " for reading: " << f->errorString();
return QStringLiteral("[]");
}
@@ -224,7 +224,7 @@ bool ThpScriptServer::newHttpConnection(httq::HttpRequest *request)
}
catch(const DataStreamError &err)
{
DEBUG_LOG() << "handler threw DataStreamError: " << err.what();
DEBUG_LOG(m_logger) << "handler threw DataStreamError: " << err.what();
// do not delete request as a failed datastream deletes it itself
return false;
}
@@ -304,7 +304,7 @@ ThpServerInformation ThpScriptServer::fromJson(const QJsonValue &val)
void ThpScriptServer::errorHandler(httq::HttpRequest *request, const HttpException &e) const
{
DEBUG_LOG() << "handler threw error: " << e.error << " (http status = " << e.status << ")";
DEBUG_LOG(m_logger) << "handler threw error: " << e.error << " (http status = " << e.status << ")";
QJsonObject root;
@@ -325,7 +325,7 @@ void ThpScriptServer::changeList(const ThpServerInformation &tsi, httq::HttpRequ
QFile contentFile(thpDirectory() + QStringLiteral("content.json"), this);
if (!contentFile.open(QIODevice::ReadWrite))
{
ERROR_LOG() << "Error opening file '" << contentFile.fileName() << "' for read/write: " << contentFile.errorString();
ERROR_LOG(m_logger) << "Error opening file '" << contentFile.fileName() << "' for read/write: " << contentFile.errorString();
throw(HttpException(QStringLiteral("cannot open content file '%1': %2").arg(contentFile.fileName(), contentFile.errorString())));
}
@@ -340,7 +340,7 @@ void ThpScriptServer::changeList(const ThpServerInformation &tsi, httq::HttpRequ
if (err.error != QJsonParseError::NoError)
{
ERROR_LOG() << "content file's json invalid at" << err.offset << ":" << err.errorString();
ERROR_LOG(m_logger) << "content file's json invalid at" << err.offset << ":" << err.errorString();
throw(HttpException(QStringLiteral("content file's json invalid at %1: %2").arg(err.offset).arg(err.errorString())));
}
@@ -368,7 +368,7 @@ void ThpScriptServer::changeList(const ThpServerInformation &tsi, httq::HttpRequ
if (!contentFile.resize(0) || !contentFile.write(QJsonDocument(arr).toJson()))
{
ERROR_LOG() << "Error writing content.json: " << contentFile.errorString();
ERROR_LOG(m_logger) << "Error writing content.json: " << contentFile.errorString();
throw(HttpException(QStringLiteral("error writing content file: %1").arg(contentFile.errorString())));
}
@@ -534,7 +534,7 @@ bool ThpScriptServer::handleRequestSync(httq::HttpRequest &request) noexcept(fal
default:
{
WARNING_LOG() << "unsupported method for /thp2";
WARNING_LOG(m_logger) << "unsupported method for /thp2";
throw HttpException(L("unsupported method for /thp2: %1").arg((int)request.method()), 405);
}
}
@@ -624,7 +624,7 @@ bool ThpScriptServer::handleRequest(httq::HttpRequest *request) noexcept(false)
if (!QFile::remove(destFile))
{
const QString err(QStringLiteral("Cannot remove old THP upload file %1 - removing THP not possible").arg(destFile));
ERROR_LOG() << err;
ERROR_LOG(m_logger) << err;
throw(HttpException(err));
}
@@ -663,7 +663,7 @@ bool ThpScriptServer::handleRequest(httq::HttpRequest *request) noexcept(false)
if (!QDir().mkpath(destDir))
{
const QString err(QStringLiteral("Cannot create directory %1 - THP upload not possible").arg(destDir));
ERROR_LOG() << err;
ERROR_LOG(m_logger) << err;
throw(HttpException(err));
}
@@ -672,7 +672,7 @@ bool ThpScriptServer::handleRequest(httq::HttpRequest *request) noexcept(false)
if (fi.exists() && !QFile::remove(destFile))
{
const QString err(QStringLiteral("Cannot remove old THP upload file %1 - THP upload not possible").arg(destDir));
ERROR_LOG() << err;
ERROR_LOG(m_logger) << err;
throw(HttpException(err));
}
@@ -701,7 +701,7 @@ bool ThpScriptServer::handleRequest(httq::HttpRequest *request) noexcept(false)
if (!d.exists() && !d.mkpath(destDir))
{
const QString errstr(QStringLiteral("Can create directory '%1' - THP upload not possible").arg(destDir));
ERROR_LOG() << errstr;
ERROR_LOG(m_logger) << errstr;
throw(HttpException(errstr));
}
@@ -710,7 +710,7 @@ bool ThpScriptServer::handleRequest(httq::HttpRequest *request) noexcept(false)
if (fi.exists() && !QFile::remove(destFile))
{
const QString errstr(QStringLiteral("Can not remove old file '%1'").arg(destDir));
ERROR_LOG() << errstr;
ERROR_LOG(m_logger) << errstr;
throw(HttpException(errstr));
}
@@ -719,7 +719,7 @@ bool ThpScriptServer::handleRequest(httq::HttpRequest *request) noexcept(false)
if (!f->rename(destFile))
{
const QString errstr(QStringLiteral("Can not rename %1 to %2: %3").arg(tmpFilename, destFile, f->errorString()));
ERROR_LOG() << errstr;
ERROR_LOG(m_logger) << errstr;
throw(HttpException(errstr));
}
@@ -743,7 +743,7 @@ bool ThpScriptServer::handleRequest(httq::HttpRequest *request) noexcept(false)
default:
{
WARNING_LOG() << "unsupported method";
WARNING_LOG(m_logger) << "unsupported method";
throw(HttpException(QStringLiteral("unsupported method"), 405));
}
}
@@ -52,6 +52,8 @@ public:
void error(const QString &message) override;
private:
NGL::INGLLogger &m_logger;
};