@@ -270,33 +270,6 @@ void CcdbDatabase::storeQO(std::shared_ptr<const o2::quality_control::core::Qual
270270 handleStorageError (path, result);
271271}
272272
273- void CcdbDatabase::storeQCFC (std::shared_ptr<const o2::quality_control::QualityControlFlagCollection> qcfc)
274- {
275- // metadata
276- map<string, string> metadata;
277- metadata[metadata_keys::runNumber] = std::to_string (qcfc->getRunNumber ());
278- metadata[metadata_keys::periodName] = qcfc->getPeriodName ();
279- metadata[metadata_keys::passName] = qcfc->getPassName ();
280- // QC metadata (prefix qc_)
281- addFrameworkMetadata (metadata, qcfc->getDetector (), qcfc->IsA ()->GetName ());
282- metadata[metadata_keys::qcQCFCName] = qcfc->getName ();
283-
284- // other attributes
285- string path = RepoPathUtils::getQcfcPath (qcfc.get ());
286- auto from = qcfc->getStart ();
287- auto to = qcfc->getEnd ();
288- if (from > to) {
289- ILOG (Error, Support) << " QCFC '" + qcfc->getName () + " ' cannot be stored in CCDB, because it has invalid validity range (" + std::to_string (from) + " , " + std::to_string (to) + " )." << ENDM;
290- }
291- std::stringstream buffer;
292- qcfc->streamTo (buffer);
293- ILOG (Debug, Support) << " Storing QualityControlFlagCollection at " << path << " (" << qcfc->getName () << " )" << ENDM;
294- auto result = ccdbApi->storeAsBinaryFile (buffer.str ().c_str (), buffer.str ().size (), qcfc->getName (), qcfc->IsA ()->GetName (), path, metadata, from, to);
295- if (result != 0 ) {
296- ILOG (Error, Support) << " QCFC '" + qcfc->getName () + " ' could not be stored in CCDB, error: " + std::to_string (result) << ENDM;
297- }
298- }
299-
300273TObject* CcdbDatabase::retrieveTObject (std::string path, std::map<std::string, std::string> const & metadata, long timestamp, std::map<std::string, std::string>* headers)
301274{
302275 if (timestamp == Timestamp::Latest) {
@@ -396,62 +369,6 @@ std::shared_ptr<o2::quality_control::core::QualityObject> CcdbDatabase::retrieve
396369 return qo;
397370}
398371
399- std::shared_ptr<o2::quality_control::QualityControlFlagCollection> CcdbDatabase::retrieveQCFC (const std::string& qcfcName, const std::string& detector, int runNumber, const string& passName, const string& periodName, const std::string& provenance, long timestamp)
400- {
401- map<string, string> headers;
402- map<string, string> metadata;
403- if (runNumber != 0 ) {
404- metadata[metadata_keys::runNumber] = std::to_string (runNumber);
405- }
406- if (!passName.empty ()) {
407- metadata[metadata_keys::passName] = passName;
408- }
409- if (!periodName.empty ()) {
410- metadata[metadata_keys::periodName] = periodName;
411- }
412- const auto qcfcPath = RepoPathUtils::getQcfcPath (detector, qcfcName, provenance);
413- const std::string localFileDir = " /tmp" ;
414- const std::string localFileName = " qcfc_" + qcfcName + std::to_string (time_point_cast<nanoseconds>(system_clock::now ()).time_since_epoch ().count ());
415- const std::string localFilePath = localFileDir + std::filesystem::path::preferred_separator + localFileName;
416- if (localFilePath.find (" .." ) != std::string::npos || localFilePath.find (' ~' ) != std::string::npos) {
417- ILOG (Error, Support) << " The path '" << localFilePath << " ' looks hacky, will not download any files there." << ENDM;
418- return nullptr ;
419- }
420-
421- auto resultMetadata = ccdbApi->retrieveHeaders (qcfcPath, metadata, timestamp);
422- if (resultMetadata.empty ()) {
423- ILOG (Error, Support) << " Could not extract headers of QCFC at '" << qcfcPath << " ' with the metadata: " << ENDM; // TODO
424- ILOG (Error, Support) << " - RunNumber : " << metadata[metadata_keys::runNumber] << ENDM;
425- ILOG (Error, Support) << " - PassName : " << metadata[metadata_keys::passName] << ENDM;
426- ILOG (Error, Support) << " - PeriodName : " << metadata[metadata_keys::periodName] << ENDM;
427- return nullptr ;
428- }
429-
430- auto success = ccdbApi->retrieveBlob (qcfcPath, localFileDir, metadata, timestamp, false , localFileName);
431- if (!success) {
432- ILOG (Error, Support) << " Could not retrieve the QCFC at '" << qcfcPath << " ' with the metadata: " << ENDM; // TODO
433- ILOG (Error, Support) << " - RunNumber : " << metadata[metadata_keys::runNumber] << ENDM;
434- ILOG (Error, Support) << " - PassName : " << metadata[metadata_keys::passName] << ENDM;
435- ILOG (Error, Support) << " - PeriodName : " << metadata[metadata_keys::periodName] << ENDM;
436- return nullptr ;
437- }
438-
439- std::ifstream localFile (localFilePath);
440- if (!localFile.is_open ()) {
441- ILOG (Error, Support) << " Could not open a file at '" << localFilePath << " '" << ENDM;
442- std::filesystem::remove (localFilePath);
443- return nullptr ;
444- }
445-
446- QualityControlFlagCollection::RangeInterval validity{ std::stoull (resultMetadata[metadata_keys::validFrom]), std::stoull (resultMetadata[metadata_keys::validUntil]) };
447- auto qcfc = std::make_shared<QualityControlFlagCollection>(qcfcName, detector, validity, runNumber, periodName, passName, provenance);
448- qcfc->streamFrom (localFile);
449- localFile.close ();
450- std::filesystem::remove (localFilePath);
451-
452- return qcfc;
453- }
454-
455372std::string CcdbDatabase::retrieveJson (std::string path, long timestamp, const std::map<std::string, std::string>& metadata)
456373{
457374 map<string, string> headers;
0 commit comments