// make_atlaspool_dataset.cxx // // David Adams // June 2003 // // Create a ATLAS-POOL event dataset from a file. #include #include #include #include "dataset_util/FileStatus.h" #include "dataset_util/FileName.h" #include "dataset_util/Environment.h" #include "dataset_util/XmlElement.h" #include "dataset_util/DtdRegistry.h" #include "dataset_xml/XmlParser.h" #include "dataset_id/UniqueIdGenerator.h" #include "dataset_file/FileCatalog.h" #include "dataset_credential/GssCredentialManager.h" #include "dataset_atlaspool/AtlasPoolEventDataset.h" using std::string; using std::cout; using std::cerr; using std::endl; using dset::FileId; using dset::FileCatalog; using dset::LogicalFile; using dset::GssCredentialManager; using dset::AtlasPoolEventDataset; //********************************************************************** int main(int argc, char* argv[]) { cerr << "make_atlaspool_dataset is obselete" << endl; cerr << " Please use make_file_dataset -t AtlasPoolEventDataset" << endl; // Fetch arguments. string arg0 = argv[0]; // First argument. string ifname = ""; string fctype = ""; string id_name = ""; string content_label = ""; bool use_uid = true; string uid_name = ""; FileCatalog* pfc = 0; int stat = 0; // Print help and exit. bool help = false; // ID for dataset. DatasetId dstid; assert( ! dstid.is_valid() ); // Name for dataset XML file. string xfile = "dataset.xml"; // Flag to insert file into file catalog. bool putfile = true; for ( int iarg=1; iargput(ifname, lfn , lifetime); } else { fid = FileId(ifname); } if ( ! fid.is_valid() ) { string action = "getting"; if ( putfile ) action = "getting"; int fcerr = pfc->error(); cerr << "Error " << fcerr << " " << action << " file" << endl; cerr << " " << ifname << endl; cerr << " with catalog" << endl; cerr << " " << *pfc << endl; return 13; } LogicalFile lfile(*pfc, fid); if ( lfile.get_readonly().size() == 0 ) { cerr << "Unable to read file" << endl << lfile << endl; return 14; } // Create dataset. AtlasPoolEventDataset dst(lfile, content_label, false); if ( ! dst.is_valid() ) { cerr << "Unable to create dataset" << endl; int err = dst.error(); cerr << "AtlasPoolEventDataset reports error " << err << endl; string msg = "Unknown error"; if ( err == 15 ) { msg = "Inconsistent content"; } if ( err == 14 ) { msg = "Duplicate event ID"; } cerr << " " << msg << endl; return 15; } // Set ID. if ( use_id ) { DatasetId newid(id_name); int idstat = dst.set_id(newid); if ( idstat != 0 ) { cerr << "Error " << idstat << " setting dataset ID " << dstid << endl; return 16; } } dst.lock(); // Create XML. const XmlElement* pele = dst.xml(); if ( pele == 0 ) { cerr << "Unable to create XML" << endl; return 17; } // Write XML description. if ( xfile.size() ) { XmlParser parser; int wstat = parser.write(xfile, *pele); if ( wstat ) { cerr << "Error writing XML: " << wstat << endl; cerr << *pele << endl; } else { cerr << "Output in " << xfile << endl; } delete pele; } }