AliDebug(2,Form("File <%s> opened",dbFile));
if(fReadOnly) AliDebug(2,Form("in read-only mode"));
}
+
+ fType="dump";
+ fBaseFolder = dbFile;
}
//_____________________________________________________________________________
// build key name from AliCDBId data (run range, version, subVersion)
if (!runRange.IsValid()) {
- AliWarning(Form("Invalid run range <%d, %d>.",
+ AliDebug(2,Form("Invalid run range <%d, %d>.",
runRange.GetFirstRun(), runRange.GetLastRun()));
return kFALSE;
}
if (version < 0) {
- AliWarning(Form("Invalid version <%d>.", version));
+ AliDebug(2,Form("Invalid version <%d>.", version));
return kFALSE;
}
if (subVersion < 0) {
- AliWarning(Form("Invalid subversion <%s>.", subVersion));
+ AliDebug(2,Form("Invalid subversion <%s>.", subVersion));
return kFALSE;
}
if (!KeyNameToId(keyName, aRunRange, aVersion,
aSubVersion)) {
- AliWarning(Form(
+ AliDebug(2,Form(
"Bad keyname <%s>!I'll skip it.", keyName));
continue;
}
if (!KeyNameToId(keyName, aRunRange, aVersion,
aSubVersion)) {
- AliWarning(Form(
+ AliDebug(2,Form(
"Bad keyname <%s>!I'll skip it.", keyName));
continue;
}
if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) &&
id.GetSubVersion() > 0 ){
- AliWarning(Form("*** WARNING! a NEW object is being stored with version v%d_s%d",
+ AliDebug(2, Form("A NEW object is being stored with version v%d_s%d",
id.GetVersion(),id.GetSubVersion()));
- AliWarning(Form("and it will hide previously stored object with v%d_s%d!",
+ AliDebug(2, Form("and it will hide previously stored object with v%d_s%d!",
id.GetVersion(),id.GetSubVersion()-1));
}
//_____________________________________________________________________________
-AliCDBId AliCDBDump::GetId(const AliCDBId& query) {
+Bool_t AliCDBDump::GetId(const AliCDBId& query, AliCDBId& result) {
// look for filename matching query (called by GetEntry)
- AliCDBId result(query.GetAliCDBPath(), -1, -1, -1, -1);
AliCDBRunRange aRunRange; // the runRange got from filename
Int_t aVersion, aSubVersion; // the version and subVersion got from filename
aRunRange.GetLastRun());
} else if (result.GetVersion() == aVersion
&& result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
result.SetRunRange(-1,-1); result.SetVersion(-1); result.SetSubVersion(-1);
- return result;
+ return kFALSE;
}
}
// aVersion is requested version!
if(result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
result.SetRunRange(-1,-1); result.SetVersion(-1); result.SetSubVersion(-1);
- return result;
+ return kFALSE;
}
if( result.GetSubVersion() < aSubVersion) {
// aVersion and aSubVersion are requested version and subVersion!
if(result.GetVersion() == aVersion && result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
result.SetRunRange(-1,-1); result.SetVersion(-1); result.SetSubVersion(-1);
- return result;
+ return kFALSE;
}
result.SetVersion(aVersion);
result.SetSubVersion(aSubVersion);
}
}
- return result;
+ return kTRUE;
}
//_____________________________________________________________________________
-AliCDBEntry* AliCDBDump::GetEntry(const AliCDBId& query) {
+AliCDBEntry* AliCDBDump::GetEntry(const AliCDBId& queryId) {
// get AliCDBEntry from the database
TDirectory::TContext context(gDirectory, fFile);
return NULL;
}
- if (!gDirectory->cd(query.GetPath())) {
+ if (!gDirectory->cd(queryId.GetPath())) {
return NULL;
}
- AliCDBId dataId;
+ AliCDBId dataId(queryId.GetAliCDBPath(), -1, -1, -1, -1);
+ Bool_t result;
// look for a filename matching query requests (path, runRange, version, subVersion)
- if (!query.HasVersion()) {
+ if (!queryId.HasVersion()) {
// if version is not specified, first check the selection criteria list
- dataId = GetId(GetSelection(query));
+ AliCDBId selectedId(queryId);
+ GetSelection(&selectedId);
+ result = GetId(selectedId, dataId);
} else {
- dataId = GetId(query);
+ result = GetId(queryId, dataId);
}
- if (!dataId.IsSpecified()) {
+ if (!result || !dataId.IsSpecified()) {
return NULL;
}
TString keyname;
if (!IdToKeyName(dataId.GetAliCDBRunRange(), dataId.GetVersion(),
dataId.GetSubVersion(), keyname)) {
- AliError("Bad ID encountered! Subnormal error!");
+ AliDebug(2,Form("Bad ID encountered! Subnormal error!"));
return NULL;
}
TObject* anObject = gDirectory->Get(keyname);
if (!anObject) {
- AliError("Bad storage data: NULL entry object!");
+ AliDebug(2,Form("Bad storage data: NULL entry object!"));
return NULL;
}
if (AliCDBEntry::Class() != anObject->IsA()) {
- AliError("Bad storage data: Invalid entry object!");
+ AliDebug(2,Form("Bad storage data: Invalid entry object!"));
return NULL;
}
// write object (key name: Run#firstRun_#lastRun_v#version_s#subVersion)
Bool_t result = gDirectory->WriteTObject(entry, keyname);
if (!result) {
- AliError(Form("Can't write entry to file: %s",
+ AliError(Form("Can't write entry to file: %s",
fFile->GetName()));
}
if(result) {
- AliInfo(Form("AliCDBEntry stored into file %s",fFile->GetName()));
+ AliInfo(Form("CDB object stored into file %s",fFile->GetName()));
AliInfo(Form("TDirectory/key name: %s/%s",id.GetPath().Data(),keyname.Data()));
}
return result;
}
+//_____________________________________________________________________________
+TList* AliCDBDump::GetIdListFromFile(const char* fileName){
+
+ TString turl(fileName);
+ if (turl[0] != '/') {
+ turl.Prepend(TString(gSystem->WorkingDirectory()) + '/');
+ }
+ TFile *file = TFile::Open(turl);
+ if (!file) {
+ AliError(Form("Can't open selection file <%s>!", turl.Data()));
+ return NULL;
+ }
+ file->cd();
+
+ TList *list = new TList();
+ list->SetOwner();
+ int i=0;
+ TString keycycle;
+
+ AliCDBId *id;
+ while(1){
+ i++;
+ keycycle = "AliCDBId;";
+ keycycle+=i;
+
+ id = (AliCDBId*) file->Get(keycycle);
+ if(!id) break;
+ list->AddFirst(id);
+ }
+ file->Close(); delete file; file=0;
+ return list;
+}
+
+//_____________________________________________________________________________
+Bool_t AliCDBDump::Contains(const char* path) const{
+// check for path in storage
+
+ TDirectory::TContext context(gDirectory, fFile);
+ if (!(fFile && fFile->IsOpen())) {
+ AliError("AliCDBDump storage is not initialized properly");
+ return kFALSE;
+ }
+
+ return gDirectory->cd(path);
+
+}
+
+//_____________________________________________________________________________
+void AliCDBDump::QueryValidFiles()
+{
+// Query the CDB for files valid for AliCDBStorage::fRun
+// fills list fValidFileIds with AliCDBId objects created from file name
+
+ AliError("Not yet (and maybe never) implemented");
+}
+
+//_____________________________________________________________________________
+Bool_t AliCDBDump::IdToFilename(const AliCDBId& /*id*/, TString& /*filename*/) const {
+// build file name from AliCDBId (path, run range, version) and fDBFolder
+
+ AliError("Not implemented");
+ return kFALSE;
+}
+
+//_____________________________________________________________________________
+Int_t AliCDBDump::GetLatestVersion(const char* path, Int_t run){
+// get last version found in the database valid for run and path
+
+ AliCDBPath aCDBPath(path);
+ if(!aCDBPath.IsValid() || aCDBPath.IsWildcard()) {
+ AliError(Form("Invalid path in request: %s", path));
+ return -1;
+ }
+
+ AliCDBId query(path, run, run, -1, -1);
+ AliCDBId dataId;
+
+ GetId(query,dataId);
+
+ return dataId.GetVersion();
+}
+
+//_____________________________________________________________________________
+Int_t AliCDBDump::GetLatestSubVersion(const char* path, Int_t run, Int_t version){
+// get last version found in the database valid for run and path
+
+ AliCDBPath aCDBPath(path);
+ if(!aCDBPath.IsValid() || aCDBPath.IsWildcard()) {
+ AliError(Form("Invalid path in request: %s", path));
+ return -1;
+ }
+
+ AliCDBId query(path, run, run, version, -1);
+ AliCDBId dataId;
+
+ GetId(query,dataId);
+
+ return dataId.GetSubVersion();
+
+}
+
/////////////////////////////////////////////////////////////////////////////////////////////////
// //
pathname.Prepend(TString(gSystem->WorkingDirectory()) + '/');
}
- AliInfo(pathname);
-
return new AliCDBDumpParam(pathname, readOnly);
}
ClassImp(AliCDBDumpParam)
//_____________________________________________________________________________
-AliCDBDumpParam::AliCDBDumpParam() {
+AliCDBDumpParam::AliCDBDumpParam():
+fDBPath(), fReadOnly(kFALSE)
+{
// default constructor
}