/////////////////////////////////////////////////////////////////////////////////////////////////
#include <cstdlib>
+#include <stdexcept>
+
#include <TSystem.h>
#include <TObjString.h>
#include <TRegexp.h>
#include "AliCDBLocal.h"
#include "AliCDBEntry.h"
#include "AliLog.h"
+using namespace std;
ClassImp(AliCDBLocal)
{
// constructor
+ AliDebug(1, Form("fBaseDirectory = %s",fBaseDirectory.Data()));
+
// check baseDire: trying to cd to baseDir; if it does not exist, create it
void* dir = gSystem->OpenDirectory(baseDir);
if (dir == NULL) {
Bool_t AliCDBLocal::IdToFilename(const AliCDBId& id, TString& filename) const {
// build file name from AliCDBId data (run range, version, subVersion)
+ AliDebug(1, Form("fBaseDirectory = %s",fBaseDirectory.Data()));
+
if (!id.GetAliCDBRunRange().IsValid()) {
AliDebug(2,Form("Invalid run range <%d, %d>.",
id.GetFirstRun(), id.GetLastRun()));
AliCDBId* dataId = GetEntryId(queryId);
- if (!dataId || !dataId->IsSpecified()) return NULL;
+ TString errMessage(TString::Format("No valid CDB object found! request was: %s", queryId.ToString().Data()));
+ if (!dataId || !dataId->IsSpecified()){
+ throw std::runtime_error(errMessage.Data());
+ return NULL;
+ }
TString filename;
if (!IdToFilename(*dataId, filename)) {
AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
delete dataId;
+ throw std::runtime_error(errMessage.Data());
return NULL;
}
if (!file.IsOpen()) {
AliDebug(2,Form("Can't open file <%s>!", filename.Data()));
delete dataId;
+ throw std::runtime_error(errMessage.Data());
return NULL;
}
AliDebug(2,Form("Bad storage data: No AliCDBEntry in file!"));
file.Close();
delete dataId;
+ throw std::runtime_error(errMessage.Data());
return NULL;
}
// Check whether entry contains a TTree. In case load the tree in memory!
LoadTreeFromFile(anEntry);
- // close file, return retieved entry
+ // close file, return retrieved entry
file.Close();
delete dataId;
+
return anEntry;
}
}
//_____________________________________________________________________________
-Bool_t AliCDBLocal::PutEntry(AliCDBEntry* entry) {
+Bool_t AliCDBLocal::PutEntry(AliCDBEntry* entry, const char* mirrors) {
// put an AliCDBEntry object into the database
AliCDBId& id = entry->GetId();
return kFALSE;
}
+ TString mirrorsString(mirrors);
+ if(!mirrorsString.IsNull())
+ AliWarning("AliCDBLocal storage cannot take mirror SEs into account. They will be ignored.");
+
// open file
TFile file(filename, "CREATE");
if (!file.IsOpen()) {
Bool_t AliCDBLocalFactory::Validate(const char* dbString) {
// check if the string is valid local URI
- TRegexp dbPattern("^local://.+$");
+ TRegexp dbPatternLocal("^local://.+$");
- return TString(dbString).Contains(dbPattern);
+ return (TString(dbString).Contains(dbPatternLocal) || TString(dbString).BeginsWith("snapshot://folder="));
}
//_____________________________________________________________________________
return NULL;
}
+ TString checkSS(dbString);
+ if(checkSS.BeginsWith("snapshot://"))
+ {
+ TString snapshotPath("OCDB");
+ snapshotPath.Prepend(TString(gSystem->WorkingDirectory()) + '/');
+ checkSS.Remove(0,checkSS.First(':')+3);
+ return new AliCDBLocalParam(snapshotPath,checkSS);
+ }
+
+ // if the string argument is not a snapshot URI, than it is a plain local URI
TString pathname(dbString + sizeof("local://") - 1);
- gSystem->ExpandPathName(pathname);
+ if(gSystem->ExpandPathName(pathname))
+ return NULL;
if (pathname[0] != '/') {
pathname.Prepend(TString(gSystem->WorkingDirectory()) + '/');
}
+ //pathname.Prepend("local://");
return new AliCDBLocalParam(pathname);
}
return NULL;
}
//_____________________________________________________________________________
-void AliCDBLocal::SetRetry(Int_t nretry, Int_t initsec) {
+void AliCDBLocal::SetRetry(Int_t /* nretry */, Int_t /* initsec */) {
// Function to set the exponential retry for putting entries in the OCDB
SetURI(TString("local://") + dbPath);
}
+//_____________________________________________________________________________
+AliCDBLocalParam::AliCDBLocalParam(const char* dbPath, const char* uri):
+ AliCDBParam(),
+ fDBPath(dbPath)
+{
+// constructor
+
+ SetType("local");
+ SetURI(TString("alien://") + uri);
+}
+
//_____________________________________________________________________________
AliCDBLocalParam::~AliCDBLocalParam() {
// destructor