diff --git a/Framework/src/CcdbDatabase.cxx b/Framework/src/CcdbDatabase.cxx index 4e6e9b60fd..993f380f4a 100644 --- a/Framework/src/CcdbDatabase.cxx +++ b/Framework/src/CcdbDatabase.cxx @@ -33,6 +33,9 @@ #include #include +#include +#include +#include using namespace std::chrono; using namespace AliceO2::Common; @@ -184,6 +187,9 @@ std::shared_ptr CcdbDatabase::retrieveMO(std::string taskNa map metadata; TObject* obj = retrieveTObject(path, metadata, when, &headers); Version objectVersion(headers["qc_version"]); // retrieve headers to determine the version of the QC framework + // ILOG(Debug) << "Version of object is " << objectVersion << ENDM; + // ILOG(Debug) << "objectVersion == Version(\"0.0.0\") : " << (objectVersion == Version("0.0.0")) << ENDM; + // ILOG(Debug) << "objectVersion < Version(\"0.25\") : " << (objectVersion < Version("0.25")) << ENDM std::shared_ptr mo; if (objectVersion == Version("0.0.0") || objectVersion < Version("0.25")) { @@ -315,21 +321,18 @@ std::vector CcdbDatabase::getListing(std::string subpath) std::vector CcdbDatabase::getPublishedObjectNames(std::string taskName) { std::vector result; - string listing = ccdbApi.list(taskName + "/.*", true, "Application/JSON"); - // Split the string we received, by line. Also trim it and remove empty lines. Select the lines starting with "path". - std::stringstream ss(listing); - std::string line; - std::string taskNameEscaped = boost::replace_all_copy(taskName, "/", "\\/"); - while (std::getline(ss, line, '\n')) { - ltrim(line); - rtrim(line); - if (line.length() > 0 && line.find("\"path\"") == 0) { - unsigned long objNameStart = 9 + taskNameEscaped.length(); - string path = line.substr(objNameStart, line.length() - 2 /*final 2 char*/ - objNameStart); - result.push_back(path); - } + boost::property_tree::ptree pt; + stringstream ss; + ss << listing; + boost::property_tree::read_json(ss, pt); + + BOOST_FOREACH (boost::property_tree::ptree::value_type& v, pt.get_child("objects")) { + assert(v.first.empty()); // array elements have no names + string data = v.second.get_child("path").data(); + string path = data.substr(taskName.size()); + result.push_back(path); } return result; diff --git a/Framework/test/testDbFactory.cxx b/Framework/test/testDbFactory.cxx index 44f96ba3b0..9de8a2e9cd 100644 --- a/Framework/test/testDbFactory.cxx +++ b/Framework/test/testDbFactory.cxx @@ -14,12 +14,12 @@ /// #include "QualityControl/DatabaseFactory.h" +#include "QualityControl/QcInfoLogger.h" #ifdef _WITH_MYSQL - #include "QualityControl/MySqlDatabase.h" - #endif + #define BOOST_TEST_MODULE DbFactory test #define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK @@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(db_ccdb_listing) // } BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/object1") != objectNames.end()); BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/object2") != objectNames.end()); - BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/path\\/to\\/object3") != objectNames.end()); + BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/path/to/object3") != objectNames.end()); // store list of streamer infos // ccdb->storeStreamerInfosToFile("streamerinfos.root");