CMS 3D CMS Logo

DbConnectionString.cc
Go to the documentation of this file.
3 #include "DbConnectionString.h"
4 //
8 
9 namespace cond {
10 
11  namespace persistency {
12 
13  unsigned int countslash(const std::string& input) {
14  unsigned int count = 0;
15  std::string::size_type slashpos(0);
16  while (slashpos != std::string::npos) {
17  slashpos = input.find('/', slashpos);
18  if (slashpos != std::string::npos) {
19  ++count;
20  // start next search after this word
21  slashpos += 1;
22  }
23  }
24  return count;
25  }
26 
28  std::string connect("sqlite_file:");
29  std::string::size_type pos = fipConnect.find(':');
30  std::string fipLocation = fipConnect.substr(pos + 1);
31  edm::FileInPath fip(fipLocation);
32  connect.append(fip.fullPath());
33  return connect;
34  }
35 
36  //FIXME: sdg this function does not support frontier connections strings like
37  //frontier://cmsfrontier.cern.ch:8000/FrontierPrep/CMS_CONDITIONS
38  //as http://cmsfrontier.cern.ch:8000/FrontierPrep(freshkey=foo) is an invalid URI.
39  std::pair<std::string, std::string> getConnectionParams(const std::string& connectionString,
40  const std::string& transactionId,
41  const std::string& signature) {
42  if (connectionString.empty())
43  cond::throwException("The connection string is empty.", "getConnectionParams");
45  std::string finalConn = connectionString;
46  std::string refreshConn("");
47  if (protocol == "frontier") {
48  std::string protocol("frontier://");
49  std::string::size_type fpos = connectionString.find(protocol);
50  unsigned int nslash = countslash(connectionString.substr(protocol.size(), connectionString.size() - fpos));
51  if (nslash == 1) {
52  edm::Service<edm::SiteLocalConfig> localconfservice;
53  if (!localconfservice.isAvailable()) {
54  cond::throwException("edm::SiteLocalConfigService is not available", "getConnectionParams");
55  }
56  finalConn = localconfservice->lookupCalibConnect(connectionString);
57  }
58  if (!transactionId.empty()) {
59  size_t l = finalConn.rfind('/');
60  finalConn.insert(l, "(freshkey=" + transactionId + ')');
61  }
62 
63  //When the signature parameter is set to sig, FroNTier requests that the server sends digital signatures on every response.
64  //We test here that the signature string, if defined, is actually set to sig, otherwise we throw an exception
65  std::string signatureParameter("sig");
66  if (!signature.empty()) {
67  if (signature == signatureParameter) {
68  std::string::size_type s = finalConn.rfind('/');
69  finalConn.insert(s, "(security=" + signature + ')');
70  } else {
71  cond::throwException("The FroNTier security option is invalid.", "getConnectionParams");
72  }
73  }
74 
75  std::string::size_type startRefresh = finalConn.find("://");
76  if (startRefresh != std::string::npos) {
77  startRefresh += 3;
78  }
79  std::string::size_type endRefresh = finalConn.rfind('/', std::string::npos);
80  if (endRefresh == std::string::npos) {
81  refreshConn = finalConn;
82  } else {
83  refreshConn = finalConn.substr(startRefresh, endRefresh - startRefresh);
84  if (refreshConn.substr(0, 1) != "(") {
85  //if the connect string is not a complicated parenthesized string,
86  // an http:// needs to be at the beginning of it
87  refreshConn.insert(0, "http://");
88  }
89  }
90  } else if (protocol == "sqlite_fip") {
92  }
93  return std::make_pair(finalConn, refreshConn);
94  }
95 
96  } // namespace persistency
97 } // namespace cond
input
static const std::string input
Definition: EdmProvDump.cc:48
Exception.h
pos
Definition: PixelAliasList.h:18
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::FileInPath
Definition: FileInPath.h:61
GlobalPosition_Frontier_DevDB_cff.connect
connect
Definition: GlobalPosition_Frontier_DevDB_cff.py:8
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
DbConnectionString.h
Utils.h
Service.h
cond::persistency::countslash
unsigned int countslash(const std::string &input)
Definition: DbConnectionString.cc:13
cond::persistency::parseFipConnectionString
std::string parseFipConnectionString(const std::string &fipConnect)
Definition: DbConnectionString.cc:27
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
cond::persistency::getConnectionParams
std::pair< std::string, std::string > getConnectionParams(const std::string &connectionString, const std::string &transactionId, const std::string &signature)
Definition: DbConnectionString.cc:39
FileInPath.h
cond
Definition: plugin.cc:23
cond::persistency::getConnectionProtocol
std::string getConnectionProtocol(const std::string &connectionString)
Definition: Utils.h:87
signature
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined signature
Definition: Activities.doc:4
edm::Service
Definition: Service.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
edm::SiteLocalConfig::lookupCalibConnect
virtual const std::string lookupCalibConnect(std::string const &input) const =0
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
SiteLocalConfig.h
cond::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18