changeset 723:94e3a3eac0f5 sql-opti

merge
author Alain Mazy <am@orthanc.team>
date Mon, 11 Aug 2025 18:21:42 +0200
parents 845c3dcb723e (diff) 691af3fc15c5 (current diff)
children c76a214a3954
files
diffstat 3 files changed, 31 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/BaseIndexConnectionsPool.cpp	Mon Aug 11 17:50:58 2025 +0200
+++ b/Framework/Plugins/BaseIndexConnectionsPool.cpp	Mon Aug 11 18:21:42 2025 +0200
@@ -28,25 +28,6 @@
 
 namespace OrthancDatabases
 {
-//   class BaseIndexConnectionsPool::ManagerReference : public Orthanc::IDynamicObject
-//   {
-//   private:
-//     DatabaseManager*  manager_;
-
-//   public:
-//     explicit ManagerReference(DatabaseManager& manager) :
-//       manager_(&manager)
-//     {
-//     }
-
-//     DatabaseManager& GetManager()
-//     {
-//       assert(manager_ != NULL);
-//       return *manager_;
-//     }
-//   };
-
-
   void BaseIndexConnectionsPool::HousekeepingThread(BaseIndexConnectionsPool* that)
   {
 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 2)
@@ -134,7 +115,6 @@
 
 
   BaseIndexConnectionsPool::Accessor::Accessor(BaseIndexConnectionsPool& pool) :
-    // lock_(pool.connectionsMutex_),
     pool_(pool),
     manager_(NULL)
   {
@@ -155,11 +135,6 @@
   {
     assert(manager_ != NULL);
     pool_.ReleaseConnection(manager_);
-    // boost::unique_lock<boost::shared_mutex>  lock(pool_.connectionsMutex_);
-    // pool_.availableConnections_.push_front(manager_);
-    // pool_.availableConnectionsSemaphore_.Release(1);
-
-
   }
 
   
--- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Mon Aug 11 17:50:58 2025 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Mon Aug 11 18:21:42 2025 +0200
@@ -1578,6 +1578,7 @@
     uint64_t limit = 0;
     uint64_t fromTs = 0;
     uint64_t toTs = 0;
+    bool logDataInJson = false;
 
     if (getArguments.find("user-id") != getArguments.end())
     {
@@ -1614,6 +1615,11 @@
       toTs = boost::lexical_cast<uint64_t>(getArguments["to-timestamp"]);
     }
 
+    if (getArguments.find("log-data-format") != getArguments.end())
+    {
+       logDataInJson = getArguments["log-data-format"] == "json";
+    }
+
     Json::Value jsonLogs;
 
 #if ORTHANC_PLUGINS_HAS_AUDIT_LOGS == 1
@@ -1667,17 +1673,35 @@
 
         serializedAuditLog["ResourceType"] = level;
 
-        // TODO - Shouldn't the "LogData" information be Base64-encoded?
-        // Plugins are not required to write JSON (e.g., could be Protocol Buffers)
-        if (it->GetLogData().empty())
+        if (logDataInJson)
         {
-          serializedAuditLog["LogData"] = Json::nullValue;
+          if (it->GetLogData().empty())
+          {
+            serializedAuditLog["JsonLogData"] = Json::nullValue;
+          }
+          else
+          {
+            Json::Value logData;
+            if (Orthanc::Toolbox::ReadJson(logData, it->GetLogData()))
+            {
+              serializedAuditLog["JsonLogData"] = logData;
+            }
+            else // if the data is not json compatible, export it in b64 anyway
+            {
+              std::string b64logData;
+              Orthanc::Toolbox::EncodeBase64(b64logData, it->GetLogData());
+              serializedAuditLog["Base64LogData"] = b64logData;
+            }
+          }
         }
         else
         {
-          Json::Value logData;
-          Orthanc::Toolbox::ReadJson(logData, it->GetLogData());
-          serializedAuditLog["LogData"] = logData;
+          std::string b64logData;
+          if (!it->GetLogData().empty())
+          {
+            Orthanc::Toolbox::EncodeBase64(b64logData, it->GetLogData());
+          }
+          serializedAuditLog["Base64LogData"] = b64logData;
         }
 
         jsonLogs.append(serializedAuditLog);
--- a/Framework/Plugins/DynamicIndexConnectionsPool.cpp	Mon Aug 11 17:50:58 2025 +0200
+++ b/Framework/Plugins/DynamicIndexConnectionsPool.cpp	Mon Aug 11 18:21:42 2025 +0200
@@ -154,45 +154,4 @@
     availableConnectionsSemaphore_.Release(1);
   }
 
-  // DynamicIndexConnectionsPool::Accessor::Accessor(DynamicIndexConnectionsPool& pool) :
-  //   // lock_(pool.connectionsMutex_),
-  //   pool_(pool),
-  //   manager_(NULL)
-  // {
-  //   for (;;)
-  //   {
-  //     std::unique_ptr<DatabaseManager> manager(pool.GetConnection());
-  //     if (manager.get() != NULL)
-  //     {
-  //       manager_ = manager.release();
-  //       return;
-  //     }
-  //     boost::this_thread::sleep(boost::posix_time::millisec(100));
-  //   }
-  // }
-
-  
-  // DynamicIndexConnectionsPool::Accessor::~Accessor()
-  // {
-  //   assert(manager_ != NULL);
-  //   pool_.ReleaseConnection(manager_);
-  //   // boost::unique_lock<boost::shared_mutex>  lock(pool_.connectionsMutex_);
-  //   // pool_.availableConnections_.push_front(manager_);
-  //   // pool_.availableConnectionsSemaphore_.Release(1);
-
-
-  // }
-
-  
-  // IndexBackend& DynamicIndexConnectionsPool::Accessor::GetBackend() const
-  // {
-  //   return *pool_.backend_;
-  // }
-
-  
-  // DatabaseManager& DynamicIndexConnectionsPool::Accessor::GetManager() const
-  // {
-  //   assert(manager_ != NULL);
-  //   return *manager_;
-  // }
 }