diff OrthancServer/ServerIndex.cpp @ 1773:613df4362575

New UpdatedAttachment and UpdatedMetadata events in plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 12 Nov 2015 15:24:23 +0100
parents 98abb8d7f905
children 9ed9458aa44f
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp	Thu Nov 12 14:36:27 2015 +0100
+++ b/OrthancServer/ServerIndex.cpp	Thu Nov 12 15:24:23 2015 +0100
@@ -1525,6 +1525,7 @@
                                 const std::string& value)
   {
     boost::mutex::scoped_lock lock(mutex_);
+    Transaction t(*this);
 
     ResourceType rtype;
     int64_t id;
@@ -1534,6 +1535,13 @@
     }
 
     db_.SetMetadata(id, type, value);
+
+    if (IsUserMetadata(type))
+    {
+      LogChange(id, ChangeType_UpdatedMetadata, rtype, publicId);
+    }
+
+    t.Commit(0);
   }
 
 
@@ -1541,6 +1549,7 @@
                                    MetadataType type)
   {
     boost::mutex::scoped_lock lock(mutex_);
+    Transaction t(*this);
 
     ResourceType rtype;
     int64_t id;
@@ -1550,6 +1559,13 @@
     }
 
     db_.DeleteMetadata(id, type);
+
+    if (IsUserMetadata(type))
+    {
+      LogChange(id, ChangeType_UpdatedMetadata, rtype, publicId);
+    }
+
+    t.Commit(0);
   }
 
 
@@ -1958,6 +1974,11 @@
 
     db_.AddAttachment(resourceId, attachment);
 
+    if (IsUserContentType(attachment.GetContentType()))
+    {
+      LogChange(resourceId, ChangeType_UpdatedAttachment, resourceType, publicId);
+    }
+
     t.Commit(attachment.GetCompressedSize());
 
     return StoreStatus_Success;
@@ -1979,6 +2000,11 @@
 
     db_.DeleteAttachment(id, type);
 
+    if (IsUserContentType(type))
+    {
+      LogChange(id, ChangeType_UpdatedAttachment, rtype, publicId);
+    }
+
     t.Commit(0);
   }