Mercurial > hg > orthanc
changeset 413:47d63c941902
clearing /exports and /changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 May 2013 15:23:09 +0200 |
parents | f1a0c472af79 |
children | 26290b46056b |
files | NEWS OrthancServer/DatabaseWrapper.cpp OrthancServer/DatabaseWrapper.h OrthancServer/OrthancRestApi.cpp OrthancServer/ServerIndex.cpp OrthancServer/ServerIndex.h Resources/Samples/Python/HighPerformanceAutoRouting.py |
diffstat | 7 files changed, 48 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Fri May 03 13:11:16 2013 +0200 +++ b/NEWS Fri May 03 15:23:09 2013 +0200 @@ -7,6 +7,7 @@ * Store-SCU for patients and studies in Orthanc Explorer * Filtering of incoming DICOM instances (through Lua scripting) * Filtering of incoming HTTP requests (through Lua scripting) +* Clearing of "/exports" and "/changes" * Check MD5 of third party downloads
--- a/OrthancServer/DatabaseWrapper.cpp Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/DatabaseWrapper.cpp Fri May 03 15:23:09 2013 +0200 @@ -902,4 +902,10 @@ return 1; } } + + + void DatabaseWrapper::ClearTable(const std::string& tableName) + { + db_.Execute("DELETE FROM " + tableName); + } }
--- a/OrthancServer/DatabaseWrapper.h Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/DatabaseWrapper.h Fri May 03 15:23:09 2013 +0200 @@ -212,5 +212,7 @@ } uint64_t IncrementGlobalSequence(GlobalProperty property); + + void ClearTable(const std::string& tableName); }; }
--- a/OrthancServer/OrthancRestApi.cpp Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/OrthancRestApi.cpp Fri May 03 15:23:09 2013 +0200 @@ -639,6 +639,14 @@ } + static void DeleteChanges(RestApi::DeleteCall& call) + { + RETRIEVE_CONTEXT(call); + context.GetIndex().DeleteChanges(); + call.GetOutput().AnswerBuffer("", "text/plain"); + } + + static void GetExports(RestApi::GetCall& call) { RETRIEVE_CONTEXT(call); @@ -656,6 +664,14 @@ } } + + static void DeleteExports(RestApi::DeleteCall& call) + { + RETRIEVE_CONTEXT(call); + context.GetIndex().DeleteExportedResources(); + call.GetOutput().AnswerBuffer("", "text/plain"); + } + // Get information about a single patient ----------------------------------- @@ -1483,7 +1499,9 @@ Register("/system", GetSystemInformation); Register("/statistics", GetStatistics); Register("/changes", GetChanges); + Register("/changes", DeleteChanges); Register("/exports", GetExports); + Register("/exports", DeleteExports); Register("/instances", UploadDicomFile); Register("/instances", ListResources<ResourceType_Instance>);
--- a/OrthancServer/ServerIndex.cpp Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/ServerIndex.cpp Fri May 03 15:23:09 2013 +0200 @@ -1115,4 +1115,17 @@ transaction->Commit(); } + + + void ServerIndex::DeleteChanges() + { + boost::mutex::scoped_lock lock(mutex_); + db_->ClearTable("Changes"); + } + + void ServerIndex::DeleteExportedResources() + { + boost::mutex::scoped_lock lock(mutex_); + db_->ClearTable("ExportedResources"); + } }
--- a/OrthancServer/ServerIndex.h Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/ServerIndex.h Fri May 03 15:23:09 2013 +0200 @@ -161,5 +161,9 @@ void LogChange(ChangeType changeType, const std::string& publicId); + + void DeleteChanges(); + + void DeleteExportedResources(); }; }
--- a/Resources/Samples/Python/HighPerformanceAutoRouting.py Fri May 03 13:11:16 2013 +0200 +++ b/Resources/Samples/Python/HighPerformanceAutoRouting.py Fri May 03 15:23:09 2013 +0200 @@ -99,6 +99,10 @@ for instance in instances: RestToolbox.DoDelete('%s/instances/%s' % (URL, instance)) + # Clear the log of the exported instances (to prevent the + # SQLite database from growing indefinitely) + RestToolbox.DoDelete('%s/exports' % URL) + end = time.time() print 'The packet of %d instances has been sent in %d seconds' % (len(instances), end - start)