Mercurial > hg > orthanc
comparison OrthancServer/OrthancInitialization.cpp @ 435:28ba73274919
registration of user-defined metadata
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 15 May 2013 15:57:05 +0200 |
parents | f746592d8301 |
children | 081a44d5110b |
comparison
equal
deleted
inserted
replaced
434:ccf3a0a43dac | 435:28ba73274919 |
---|---|
32 | 32 |
33 #include "OrthancInitialization.h" | 33 #include "OrthancInitialization.h" |
34 | 34 |
35 #include "../Core/OrthancException.h" | 35 #include "../Core/OrthancException.h" |
36 #include "../Core/Toolbox.h" | 36 #include "../Core/Toolbox.h" |
37 #include "ServerEnumerations.h" | |
37 | 38 |
38 #include <boost/lexical_cast.hpp> | 39 #include <boost/lexical_cast.hpp> |
39 #include <boost/filesystem.hpp> | 40 #include <boost/filesystem.hpp> |
40 #include <curl/curl.h> | 41 #include <curl/curl.h> |
41 #include <boost/thread.hpp> | 42 #include <boost/thread.hpp> |
116 throw OrthancException("Unable to read the configuration file"); | 117 throw OrthancException("Unable to read the configuration file"); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 | 121 |
122 static void RegisterUserMetadata() | |
123 { | |
124 if (configuration_->isMember("UserMetadata")) | |
125 { | |
126 const Json::Value& parameter = (*configuration_) ["UserMetadata"]; | |
127 | |
128 Json::Value::Members members = parameter.getMemberNames(); | |
129 for (size_t i = 0; i < members.size(); i++) | |
130 { | |
131 std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString(); | |
132 LOG(INFO) << "Registering user-specific metadata: " << info; | |
133 | |
134 if (!parameter[members[i]].asBool()) | |
135 { | |
136 LOG(ERROR) << "Not a number in this user-specific metadata: " << info; | |
137 throw OrthancException(ErrorCode_BadParameterType); | |
138 } | |
139 | |
140 int metadata = parameter[members[i]].asInt(); | |
141 | |
142 try | |
143 { | |
144 RegisterUserMetadata(metadata, members[i]); | |
145 } | |
146 catch (OrthancException e) | |
147 { | |
148 LOG(ERROR) << "Cannot register this user-specific metadata: " << info; | |
149 throw e; | |
150 } | |
151 } | |
152 } | |
153 } | |
154 | |
155 | |
121 void OrthancInitialize(const char* configurationFile) | 156 void OrthancInitialize(const char* configurationFile) |
122 { | 157 { |
123 boost::mutex::scoped_lock lock(globalMutex_); | 158 boost::mutex::scoped_lock lock(globalMutex_); |
159 | |
160 InitializeServerEnumerations(); | |
124 defaultDirectory_ = boost::filesystem::current_path(); | 161 defaultDirectory_ = boost::filesystem::current_path(); |
125 ReadGlobalConfiguration(configurationFile); | 162 ReadGlobalConfiguration(configurationFile); |
163 | |
126 curl_global_init(CURL_GLOBAL_ALL); | 164 curl_global_init(CURL_GLOBAL_ALL); |
165 | |
166 RegisterUserMetadata(); | |
127 } | 167 } |
128 | 168 |
129 | 169 |
130 | 170 |
131 void OrthancFinalize() | 171 void OrthancFinalize() |