# HG changeset patch # User Sebastien Jodogne # Date 1680681739 -7200 # Node ID 367e8af46cfd53b9e4f99bb9edf9152759611a5a # Parent cd2258ca7894582c8ea73aa3d9a63cb9be5b3c5b added "HasLabels" in /system diff -r cd2258ca7894 -r 367e8af46cfd NEWS --- a/NEWS Wed Apr 05 09:07:47 2023 +0200 +++ b/NEWS Wed Apr 05 10:02:19 2023 +0200 @@ -12,9 +12,9 @@ * API version upgraded to 20 * New URIs "/.../{id}/labels/{label}" to test/set/remove labels * "/tools/find" accepts the "WithLabels" and "WithoutLabels" arguments -* The "/patients/{id}", "/studies/{id}", "/series/{id}" and "/instances/{id}" +* "/patients/{id}", "/studies/{id}", "/series/{id}" and "/instances/{id}" contain the "Labels" field -* "/system": added "UserMetadata" +* "/system": added "UserMetadata" and "HasLabels" Plugins ------- diff -r cd2258ca7894 -r 367e8af46cfd OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Wed Apr 05 09:07:47 2023 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Wed Apr 05 10:02:19 2023 +0200 @@ -1961,6 +1961,11 @@ } }; + if ((!withLabels.empty() || !withoutLabels.empty()) && + !db_.HasLabelsSupport()) + { + throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support labels"); + } std::vector normalized; NormalizeLookup(normalized, lookup, queryLevel); @@ -3630,4 +3635,11 @@ Operations operations(publicId, level, label, operation); Apply(operations); } + + + bool StatelessDatabaseOperations::HasLabelsSupport() + { + boost::shared_lock lock(mutex_); + return db_.HasLabelsSupport(); + } } diff -r cd2258ca7894 -r 367e8af46cfd OrthancServer/Sources/Database/StatelessDatabaseOperations.h --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Wed Apr 05 09:07:47 2023 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Wed Apr 05 10:02:19 2023 +0200 @@ -765,5 +765,7 @@ ResourceType level, const std::string& label, LabelOperation operation); + + bool HasLabelsSupport(); }; } diff -r cd2258ca7894 -r 367e8af46cfd OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Wed Apr 05 09:07:47 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Wed Apr 05 10:02:19 2023 +0200 @@ -89,6 +89,7 @@ static const char* const MAXIMUM_STORAGE_SIZE = "MaximumStorageSize"; static const char* const MAXIMUM_STORAGE_MODE = "MaximumStorageMode"; static const char* const USER_METADATA = "UserMetadata"; + static const char* const HAS_LABELS = "HasLabels"; if (call.IsDocumentation()) { @@ -131,6 +132,8 @@ "The configured MaximumStorageMode (new in Orthanc 1.11.3)") .SetAnswerField(USER_METADATA, RestApiCallDocumentation::Type_JsonObject, "The configured UserMetadata (new in Orthanc 1.12.0)") + .SetAnswerField(HAS_LABELS, RestApiCallDocumentation::Type_Boolean, + "Whether the database back-end supports labels (new in Orthanc 1.12.0)") .SetHttpGetSample("https://demo.orthanc-server.com/system", true); return; } @@ -187,6 +190,8 @@ result[USER_METADATA] = Json::objectValue; GetUserMetadataConfiguration(result[USER_METADATA]); + result[HAS_LABELS] = OrthancRestApi::GetIndex(call).HasLabelsSupport(); + call.GetOutput().AnswerJson(result); }