3030#include < sstream>
3131
3232#include < fairlogger/Logger.h>
33+ #include < boost/algorithm/string.hpp>
3334
3435using namespace std ::chrono;
3536using namespace AliceO2 ::Common;
@@ -114,32 +115,32 @@ void CcdbDatabase::store(std::shared_ptr<o2::quality_control::core::MonitorObjec
114115 ccdbApi.storeAsTFile (mo.get (), path, metadata, from, to);
115116}
116117
117- core::MonitorObject* CcdbDatabase::retrieve (std::string taskName , std::string objectName, long timestamp)
118+ core::MonitorObject* CcdbDatabase::retrieve (std::string path , std::string objectName, long timestamp)
118119{
119- string path = taskName + " /" + objectName;
120+ string fullPath = path + " /" + objectName;
120121 map<string, string> metadata;
121122 long when = timestamp == 0 ? getCurrentTimestamp () : timestamp;
122123
123124 // we try first to load a TFile
124- TObject* object = ccdbApi.retrieveFromTFile (path , metadata, when);
125+ TObject* object = ccdbApi.retrieveFromTFile (fullPath , metadata, when);
125126 if (object == nullptr ) {
126127 // We could not open a TFile we should now try to open an object directly serialized
127- object = ccdbApi.retrieve (path , metadata, when);
128- LOG (DEBUG ) << " We could retrieve the object " << path << " as a streamed object." ;
128+ object = ccdbApi.retrieve (fullPath , metadata, when);
129+ LOG (DEBUG ) << " We could retrieve the object " << fullPath << " as a streamed object." ;
129130 if (object == nullptr ) {
130131 return nullptr ;
131132 }
132133 }
133134 auto * mo = dynamic_cast <core::MonitorObject*>(object);
134135 if (mo == nullptr ) {
135- LOG (ERROR ) << " Could not cast the object " << taskName << " / " << objectName << " to MonitorObject" ;
136+ LOG (ERROR ) << " Could not cast the object " << fullPath << " to MonitorObject" ;
136137 }
137138 return mo;
138139}
139140
140- std::string CcdbDatabase::retrieveJson (std::string taskName , std::string objectName)
141+ std::string CcdbDatabase::retrieveJson (std::string path , std::string objectName)
141142{
142- std::unique_ptr<core::MonitorObject> monitor (retrieve (taskName , objectName));
143+ std::unique_ptr<core::MonitorObject> monitor (retrieve (path , objectName));
143144 if (monitor == nullptr ) {
144145 return std::string ();
145146 }
@@ -159,9 +160,9 @@ void CcdbDatabase::prepareTaskDataContainer(std::string /*taskName*/)
159160 // NOOP for CCDB
160161}
161162
162- std::string CcdbDatabase::getListing (std::string path , std::string accept)
163+ std::string CcdbDatabase::getListingAsString (std::string subpath , std::string accept)
163164{
164- std::string tempString = ccdbApi.list (path , false , accept);
165+ std::string tempString = ccdbApi.list (subpath , false , accept);
165166
166167 return tempString;
167168}
@@ -180,12 +181,12 @@ static inline void rtrim(std::string& s)
180181 s.erase (std::find_if (s.rbegin (), s.rend (), [](int ch) { return !std::isspace (ch); }).base (), s.end ());
181182}
182183
183- std::vector<std::string> CcdbDatabase::getListOfTasksWithPublications ( )
184+ std::vector<std::string> CcdbDatabase::getListing (std::string subpath )
184185{
185186 std::vector<string> result;
186187
187- // Get the listing from CCDB
188- string listing = getListing ( );
188+ // Get the listing from CCDB (folder qc)
189+ string listing = getListingAsString (subpath );
189190
190191 // Split the string we received, by line. Also trim it and remove empty lines.
191192 std::stringstream ss (listing);
@@ -210,11 +211,12 @@ std::vector<std::string> CcdbDatabase::getPublishedObjectNames(std::string taskN
210211 // Split the string we received, by line. Also trim it and remove empty lines. Select the lines starting with "path".
211212 std::stringstream ss (listing);
212213 std::string line;
214+ std::string taskNameEscaped = boost::replace_all_copy (taskName, " /" , " \\ /" );
213215 while (std::getline (ss, line, ' \n ' )) {
214216 ltrim (line);
215217 rtrim (line);
216218 if (line.length () > 0 && line.find (" \" path\" " ) == 0 ) {
217- unsigned long objNameStart = 9 + taskName .length ();
219+ unsigned long objNameStart = 9 + taskNameEscaped .length ();
218220 string path = line.substr (objNameStart, line.length () - 2 /* final 2 char*/ - objNameStart);
219221 result.push_back (path);
220222 }
0 commit comments