8 #include <xercesc/dom/DOM.hpp>
9 #include <xercesc/parsers/XercesDOMParser.hpp>
10 #include <xercesc/util/PlatformUtils.hpp>
11 #include <xercesc/util/XMLString.hpp>
15 using namespace xercesc;
28 inline std::string
_toString(XMLCh
const* toTranscode) {
29 std::string
tmp(XMLString::transcode(toTranscode));
33 inline unsigned int _toUInt(XMLCh
const* toTranscode) {
34 std::istringstream iss(
_toString(toTranscode));
35 unsigned int returnValue;
40 inline double _toDouble(XMLCh
const* toTranscode) {
41 std::istringstream iss(
_toString(toTranscode));
48 XMLCh* buff = XMLString::transcode(temp.c_str());
54 inline std::string _toParenString(DOMNode
const& nodeToConvert) {
55 std::ostringstream oss;
57 DOMNodeList *childList = nodeToConvert.getChildNodes();
59 unsigned int numNodes = childList->getLength();
60 for (
unsigned int i = 0;
i < numNodes; ++
i) {
61 DOMNode *childNode = childList->item(
i);
62 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
65 DOMElement *
child =
static_cast<DOMElement *
>(childNode);
67 DOMNamedNodeMap *
attributes = child->getAttributes();
68 unsigned int numAttributes = attributes->getLength();
69 for (
unsigned int j = 0;
j < numAttributes; ++
j) {
70 DOMNode *attributeNode = attributes->item(
j);
71 if (attributeNode->getNodeType() != DOMNode::ATTRIBUTE_NODE) {
74 DOMAttr *attribute =
static_cast<DOMAttr *
>(attributeNode);
76 oss <<
"(" <<
_toString(child->getTagName()) <<
87 T& iHolder,
T const*& iPointer) {
98 m_url(
"/SITECONF/local/JobConfig/site-local-config.xml"),
100 m_fallbackDataCatalog(),
102 m_rfioType(
"castor"),
105 m_cacheTempDirPtr(0),
107 m_cacheMinFreePtr(0),
112 m_ttreeCacheSize(0U),
113 m_ttreeCacheSizePtr(0),
117 m_nativeProtocolsPtr(0) {
119 char*
tmp = getenv(
"CMS_PATH");
144 return "file:PoolFileCatalog.xml";
149 <<
"Did not find catalog in event-data section in " <<
m_url;
161 return "file:PoolFileCatalog.xml";
172 <<
"Valid site-local-config not found at " <<
m_url;
177 <<
"Did not find frontier-connect in calib-data section in " <<
m_url;
188 std::string complexstr =
"";
189 while ((serverurl =
m_frontierConnect.find(
"(serverurl=", nextparen)) != std::string::npos) {
194 complexstr.append(servlet);
203 static std::string
const proto =
"frontier://";
205 if (input.substr(0,proto.length()) == proto) {
223 if (endservlet == std::string::npos) {
224 endservlet = input.rfind(
'/', input.length());
226 std::string servlet = input.substr(startservlet, endservlet - startservlet);
227 if ((servlet !=
"") && (servlet.find_first_of(
":/)[]") == std::string::npos)) {
228 if (servlet ==
"cms_conditions_data") {
273 std::vector<std::string>
const*
280 XMLPlatformUtils::Initialize();
281 std::auto_ptr<XercesDOMParser>
parser(
new XercesDOMParser);
283 parser->setValidationScheme(XercesDOMParser::Val_Auto);
284 parser->setDoNamespaces(
false);
286 parser->parse(url.c_str());
287 DOMDocument*
doc = parser->getDocument();
320 DOMNodeList *sites = doc->getElementsByTagName(
_toDOMS(
"site"));
321 unsigned int numSites = sites->getLength();
322 for (
unsigned int i = 0;
i < numSites; ++
i) {
323 DOMElement *site =
static_cast<DOMElement *
>(sites->item(
i));
327 DOMNodeList *eventDataList = site->getElementsByTagName(
_toDOMS(
"event-data"));
328 if (eventDataList->getLength() > 0) {
329 DOMElement *eventData =
static_cast<DOMElement *
>(eventDataList->item(0));
331 DOMNodeList *catalogs = eventData->getElementsByTagName(
_toDOMS(
"catalog"));
333 if (catalogs->getLength() > 0) {
334 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(0));
338 if (catalogs->getLength() > 1) {
339 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(1));
343 DOMNodeList* rfiotypes = eventData->getElementsByTagName(
_toDOMS(
"rfiotype"));
345 if (rfiotypes->getLength() > 0) {
346 DOMElement* rfiotype =
static_cast<DOMElement *
>(rfiotypes->item(0));
354 DOMNodeList *calibDataList = site->getElementsByTagName(
_toDOMS(
"calib-data"));
356 if (calibDataList->getLength() > 0) {
357 DOMElement *calibData =
static_cast<DOMElement *
>(calibDataList->item(0));
358 DOMNodeList *frontierConnectList = calibData->getElementsByTagName(
_toDOMS(
"frontier-connect"));
360 if (frontierConnectList->getLength() > 0) {
361 DOMElement *
frontierConnect =
static_cast<DOMElement *
>(frontierConnectList->item(0));
368 DOMNodeList *sourceConfigList = site->getElementsByTagName(
_toDOMS(
"source-config"));
370 if (sourceConfigList->getLength() > 0) {
371 DOMElement *sourceConfig =
static_cast<DOMElement *
>(sourceConfigList->item(0));
372 DOMNodeList *cacheTempDirList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-temp-dir"));
374 if (cacheTempDirList->getLength() > 0) {
375 DOMElement *cacheTempDir =
static_cast<DOMElement *
>(cacheTempDirList->item(0));
380 DOMNodeList *cacheMinFreeList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-min-free"));
382 if (cacheMinFreeList->getLength() > 0) {
383 DOMElement *cacheMinFree =
static_cast<DOMElement *
>(cacheMinFreeList->item(0));
388 DOMNodeList *cacheHintList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-hint"));
390 if (cacheHintList->getLength() > 0) {
391 DOMElement *cacheHint =
static_cast<DOMElement *
>(cacheHintList->item(0));
396 DOMNodeList *readHintList = sourceConfig->getElementsByTagName(
_toDOMS(
"read-hint"));
398 if (readHintList->getLength() > 0) {
399 DOMElement *readHint =
static_cast<DOMElement *
>(readHintList->item(0));
404 DOMNodeList *ttreeCacheSizeList = sourceConfig->getElementsByTagName(
_toDOMS(
"ttree-cache-size"));
406 if (ttreeCacheSizeList->getLength() > 0) {
407 DOMElement *ttreeCacheSize =
static_cast<DOMElement *
>(ttreeCacheSizeList->item(0));
412 DOMNodeList *timeoutList = sourceConfig->getElementsByTagName(
_toDOMS(
"timeout-in-seconds"));
414 if (timeoutList->getLength() > 0) {
415 DOMElement *timeout =
static_cast<DOMElement *
>(timeoutList->item(0));
420 DOMNodeList *nativeProtocolsList = sourceConfig->getElementsByTagName(
_toDOMS(
"native-protocols"));
422 if (nativeProtocolsList->getLength() > 0) {
423 DOMElement *nativeProtocol =
static_cast<DOMElement *
>(nativeProtocolsList->item(0));
424 DOMNodeList *childList = nativeProtocol->getChildNodes();
426 XMLCh* prefixXMLCh =
_toDOMS(
"prefix");
427 unsigned int numNodes = childList->getLength();
428 for (
unsigned int i = 0;
i < numNodes; ++
i) {
429 DOMNode *childNode = childList->item(
i);
430 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
433 DOMElement *child =
static_cast<DOMElement *
>(childNode);
443 catch (xercesc::DOMException
const& e) {
450 desc.
setComment(
"Service to translate logical file names to physical file names.");
460 descriptions.
add(
"SiteLocalConfigService", desc);
unsigned int const * m_timeoutPtr
std::string const fallbackDataCatalog(void) const
T getUntrackedParameter(std::string const &, T const &) const
std::string const * m_cacheTempDirPtr
std::string m_frontierConnect
void parse(std::string const &url)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
std::string m_fallbackDataCatalog
std::string const rfioType(void) const
double const * m_cacheMinFreePtr
double const * sourceCacheMinFree() const
std::string _toString(const XMLCh *toTranscode)
std::string const dataCatalog(void) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string m_cacheTempDir
unsigned int m_ttreeCacheSize
std::vector< std::string > const * m_nativeProtocolsPtr
std::string const lookupCalibConnect(std::string const &input) const
void setComment(std::string const &value)
std::string const * sourceCacheHint() const
std::string const * sourceReadHint() const
std::vector< std::string > m_nativeProtocols
std::string const * m_cacheHintPtr
std::string const * m_readHintPtr
unsigned int const * m_ttreeCacheSizePtr
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const * sourceCacheTempDir() const
std::vector< std::vector< double > > tmp
XMLCh * _toDOMS(std::string temp)
unsigned int const * sourceTimeout() const
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
std::string const frontierConnect(std::string const &servlet) const
std::vector< std::string > const * sourceNativeProtocols() const
unsigned int const * sourceTTreeCacheSize() const
std::string m_dataCatalog