|
33 | 33 | #include <unordered_set> |
34 | 34 |
|
35 | 35 | #include <boost/algorithm/string.hpp> |
| 36 | +#include <boost/property_tree/json_parser.hpp> |
| 37 | +#include <boost/property_tree/ptree.hpp> |
| 38 | +#include <boost/foreach.hpp> |
36 | 39 |
|
37 | 40 | using namespace std::chrono; |
38 | 41 | using namespace AliceO2::Common; |
@@ -184,6 +187,9 @@ std::shared_ptr<core::MonitorObject> CcdbDatabase::retrieveMO(std::string taskNa |
184 | 187 | map<string, string> metadata; |
185 | 188 | TObject* obj = retrieveTObject(path, metadata, when, &headers); |
186 | 189 | Version objectVersion(headers["qc_version"]); // retrieve headers to determine the version of the QC framework |
| 190 | + // ILOG(Debug) << "Version of object is " << objectVersion << ENDM; |
| 191 | + // ILOG(Debug) << "objectVersion == Version(\"0.0.0\") : " << (objectVersion == Version("0.0.0")) << ENDM; |
| 192 | + // ILOG(Debug) << "objectVersion < Version(\"0.25\") : " << (objectVersion < Version("0.25")) << ENDM |
187 | 193 |
|
188 | 194 | std::shared_ptr<MonitorObject> mo; |
189 | 195 | if (objectVersion == Version("0.0.0") || objectVersion < Version("0.25")) { |
@@ -315,21 +321,18 @@ std::vector<std::string> CcdbDatabase::getListing(std::string subpath) |
315 | 321 | std::vector<std::string> CcdbDatabase::getPublishedObjectNames(std::string taskName) |
316 | 322 | { |
317 | 323 | std::vector<string> result; |
318 | | - |
319 | 324 | string listing = ccdbApi.list(taskName + "/.*", true, "Application/JSON"); |
320 | 325 |
|
321 | | - // Split the string we received, by line. Also trim it and remove empty lines. Select the lines starting with "path". |
322 | | - std::stringstream ss(listing); |
323 | | - std::string line; |
324 | | - std::string taskNameEscaped = boost::replace_all_copy(taskName, "/", "\\/"); |
325 | | - while (std::getline(ss, line, '\n')) { |
326 | | - ltrim(line); |
327 | | - rtrim(line); |
328 | | - if (line.length() > 0 && line.find("\"path\"") == 0) { |
329 | | - unsigned long objNameStart = 9 + taskNameEscaped.length(); |
330 | | - string path = line.substr(objNameStart, line.length() - 2 /*final 2 char*/ - objNameStart); |
331 | | - result.push_back(path); |
332 | | - } |
| 326 | + boost::property_tree::ptree pt; |
| 327 | + stringstream ss; |
| 328 | + ss << listing; |
| 329 | + boost::property_tree::read_json(ss, pt); |
| 330 | + |
| 331 | + BOOST_FOREACH (boost::property_tree::ptree::value_type& v, pt.get_child("objects")) { |
| 332 | + assert(v.first.empty()); // array elements have no names |
| 333 | + string data = v.second.get_child("path").data(); |
| 334 | + string path = data.substr(taskName.size()); |
| 335 | + result.push_back(path); |
333 | 336 | } |
334 | 337 |
|
335 | 338 | return result; |
|
0 commit comments