comparison OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp @ 4628:5fabef29c4ff db-changes

added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Apr 2021 15:59:31 +0200
parents f8c1d94363b6
children f0038043fb97 7826ac059c31
comparison
equal deleted inserted replaced
4627:f7d5372b59b3 4628:5fabef29c4ff
59 call.GetOutput().Redirect("app/images/favicon.ico"); 59 call.GetOutput().Redirect("app/images/favicon.ico");
60 } 60 }
61 61
62 static void GetSystemInformation(RestApiGetCall& call) 62 static void GetSystemInformation(RestApiGetCall& call)
63 { 63 {
64 static const char* const API_VERSION = "ApiVersion";
65 static const char* const CHECK_REVISIONS = "CheckRevisions";
66 static const char* const DATABASE_BACKEND_PLUGIN = "DatabaseBackendPlugin";
67 static const char* const DATABASE_VERSION = "DatabaseVersion";
68 static const char* const DICOM_AET = "DicomAet";
69 static const char* const DICOM_PORT = "DicomPort";
70 static const char* const HTTP_PORT = "HttpPort";
71 static const char* const IS_HTTP_SERVER_SECURE = "IsHttpServerSecure";
72 static const char* const NAME = "Name";
73 static const char* const PLUGINS_ENABLED = "PluginsEnabled";
74 static const char* const STORAGE_AREA_PLUGIN = "StorageAreaPlugin";
75 static const char* const VERSION = "Version";
76
64 if (call.IsDocumentation()) 77 if (call.IsDocumentation())
65 { 78 {
66 call.GetDocumentation() 79 call.GetDocumentation()
67 .SetTag("System") 80 .SetTag("System")
68 .SetSummary("Get system information") 81 .SetSummary("Get system information")
69 .SetDescription("Get system information about Orthanc") 82 .SetDescription("Get system information about Orthanc")
70 .SetAnswerField("ApiVersion", RestApiCallDocumentation::Type_Number, "Version of the REST API") 83 .SetAnswerField(API_VERSION, RestApiCallDocumentation::Type_Number, "Version of the REST API")
71 .SetAnswerField("Version", RestApiCallDocumentation::Type_String, "Version of Orthanc") 84 .SetAnswerField(VERSION, RestApiCallDocumentation::Type_String, "Version of Orthanc")
72 .SetAnswerField("DatabaseVersion", RestApiCallDocumentation::Type_Number, 85 .SetAnswerField(DATABASE_VERSION, RestApiCallDocumentation::Type_Number,
73 "Version of the database: https://book.orthanc-server.com/developers/db-versioning.html") 86 "Version of the database: https://book.orthanc-server.com/developers/db-versioning.html")
74 .SetAnswerField("IsHttpServerSecure", RestApiCallDocumentation::Type_Boolean, 87 .SetAnswerField(IS_HTTP_SERVER_SECURE, RestApiCallDocumentation::Type_Boolean,
75 "Whether the REST API is properly secured (assuming no reverse proxy is in use): https://book.orthanc-server.com/faq/security.html#securing-the-http-server") 88 "Whether the REST API is properly secured (assuming no reverse proxy is in use): https://book.orthanc-server.com/faq/security.html#securing-the-http-server")
76 .SetAnswerField("StorageAreaPlugin", RestApiCallDocumentation::Type_String, 89 .SetAnswerField(STORAGE_AREA_PLUGIN, RestApiCallDocumentation::Type_String,
77 "Information about the installed storage area plugin (`null` if no such plugin is installed)") 90 "Information about the installed storage area plugin (`null` if no such plugin is installed)")
78 .SetAnswerField("DatabaseBackendPlugin", RestApiCallDocumentation::Type_String, 91 .SetAnswerField(DATABASE_BACKEND_PLUGIN, RestApiCallDocumentation::Type_String,
79 "Information about the installed database index plugin (`null` if no such plugin is installed)") 92 "Information about the installed database index plugin (`null` if no such plugin is installed)")
80 .SetAnswerField("DicomAet", RestApiCallDocumentation::Type_String, "The DICOM AET of Orthanc") 93 .SetAnswerField(DICOM_AET, RestApiCallDocumentation::Type_String, "The DICOM AET of Orthanc")
81 .SetAnswerField("DicomPort", RestApiCallDocumentation::Type_Number, "The port to the DICOM server of Orthanc") 94 .SetAnswerField(DICOM_PORT, RestApiCallDocumentation::Type_Number, "The port to the DICOM server of Orthanc")
82 .SetAnswerField("HttpPort", RestApiCallDocumentation::Type_Number, "The port to the HTTP server of Orthanc") 95 .SetAnswerField(HTTP_PORT, RestApiCallDocumentation::Type_Number, "The port to the HTTP server of Orthanc")
83 .SetAnswerField("Name", RestApiCallDocumentation::Type_String, 96 .SetAnswerField(NAME, RestApiCallDocumentation::Type_String,
84 "The name of the Orthanc server, cf. the `Name` configuration option") 97 "The name of the Orthanc server, cf. the `Name` configuration option")
85 .SetAnswerField("PluginsEnabled", RestApiCallDocumentation::Type_Boolean, 98 .SetAnswerField(PLUGINS_ENABLED, RestApiCallDocumentation::Type_Boolean,
86 "Whether Orthanc was built with support for plugins") 99 "Whether Orthanc was built with support for plugins")
100 .SetAnswerField(CHECK_REVISIONS, RestApiCallDocumentation::Type_Boolean,
101 "Whether Orthanc handle revisions of metadata and attachments to deal with multiple writers (new in Orthanc 1.9.2)")
87 .SetHttpGetSample("https://demo.orthanc-server.com/system", true); 102 .SetHttpGetSample("https://demo.orthanc-server.com/system", true);
88 return; 103 return;
89 } 104 }
90 105
91 ServerContext& context = OrthancRestApi::GetContext(call); 106 ServerContext& context = OrthancRestApi::GetContext(call);
92 107
93 Json::Value result = Json::objectValue; 108 Json::Value result = Json::objectValue;
94 109
95 result["ApiVersion"] = ORTHANC_API_VERSION; 110 result[API_VERSION] = ORTHANC_API_VERSION;
96 result["Version"] = ORTHANC_VERSION; 111 result[VERSION] = ORTHANC_VERSION;
97 result["DatabaseVersion"] = OrthancRestApi::GetIndex(call).GetDatabaseVersion(); 112 result[DATABASE_VERSION] = OrthancRestApi::GetIndex(call).GetDatabaseVersion();
98 result["IsHttpServerSecure"] = context.IsHttpServerSecure(); // New in Orthanc 1.5.8 113 result[IS_HTTP_SERVER_SECURE] = context.IsHttpServerSecure(); // New in Orthanc 1.5.8
99 114
100 { 115 {
101 OrthancConfiguration::ReaderLock lock; 116 OrthancConfiguration::ReaderLock lock;
102 result["DicomAet"] = lock.GetConfiguration().GetOrthancAET(); 117 result[DICOM_AET] = lock.GetConfiguration().GetOrthancAET();
103 result["DicomPort"] = lock.GetConfiguration().GetUnsignedIntegerParameter("DicomPort", 4242); 118 result[DICOM_PORT] = lock.GetConfiguration().GetUnsignedIntegerParameter(DICOM_PORT, 4242);
104 result["HttpPort"] = lock.GetConfiguration().GetUnsignedIntegerParameter("HttpPort", 8042); 119 result[HTTP_PORT] = lock.GetConfiguration().GetUnsignedIntegerParameter(HTTP_PORT, 8042);
105 result["Name"] = lock.GetConfiguration().GetStringParameter("Name", ""); 120 result[NAME] = lock.GetConfiguration().GetStringParameter(NAME, "");
106 } 121 result[CHECK_REVISIONS] = lock.GetConfiguration().GetBooleanParameter(CHECK_REVISIONS, false); // New in Orthanc 1.9.2
107 122 }
108 result["StorageAreaPlugin"] = Json::nullValue; 123
109 result["DatabaseBackendPlugin"] = Json::nullValue; 124 result[STORAGE_AREA_PLUGIN] = Json::nullValue;
125 result[DATABASE_BACKEND_PLUGIN] = Json::nullValue;
110 126
111 #if ORTHANC_ENABLE_PLUGINS == 1 127 #if ORTHANC_ENABLE_PLUGINS == 1
112 result["PluginsEnabled"] = true; 128 result[PLUGINS_ENABLED] = true;
113 const OrthancPlugins& plugins = context.GetPlugins(); 129 const OrthancPlugins& plugins = context.GetPlugins();
114 130
115 if (plugins.HasStorageArea()) 131 if (plugins.HasStorageArea())
116 { 132 {
117 std::string p = plugins.GetStorageAreaLibrary().GetPath(); 133 std::string p = plugins.GetStorageAreaLibrary().GetPath();
118 result["StorageAreaPlugin"] = boost::filesystem::canonical(p).string(); 134 result[STORAGE_AREA_PLUGIN] = boost::filesystem::canonical(p).string();
119 } 135 }
120 136
121 if (plugins.HasDatabaseBackend()) 137 if (plugins.HasDatabaseBackend())
122 { 138 {
123 std::string p = plugins.GetDatabaseBackendLibrary().GetPath(); 139 std::string p = plugins.GetDatabaseBackendLibrary().GetPath();
124 result["DatabaseBackendPlugin"] = boost::filesystem::canonical(p).string(); 140 result[DATABASE_BACKEND_PLUGIN] = boost::filesystem::canonical(p).string();
125 } 141 }
126 #else 142 #else
127 result["PluginsEnabled"] = false; 143 result[PLUGINS_ENABLED] = false;
128 #endif 144 #endif
129 145
130 call.GetOutput().AnswerJson(result); 146 call.GetOutput().AnswerJson(result);
131 } 147 }
132 148