133 Service<SiteLocalConfig> localconfservice;
134 if (!localconfservice.isAvailable())
135 throw cms::Exception(
"TrivialFileCatalog",
"edm::SiteLocalConfigService is not available");
137 m_url = (
fallback ? localconfservice->fallbackDataCatalog() : localconfservice->dataCatalog());
142 if (m_url.find(
"file:") == std::string::npos) {
143 throw cms::Exception(
"TrivialFileCatalog",
"TrivialFileCatalog::connect: Malformed url for file catalog configuration");
146 m_url = m_url.erase(0, m_url.find(
":") + 1);
148 std::vector<std::string> tokens;
152 if (tokens.size() == 2) {
154 std::vector<std::string> optionTokens;
160 for (
size_t oi = 0, oe = optionTokens.size(); oi != oe; ++oi) {
162 std::vector<std::string> argTokens;
165 if (argTokens.size() != 2) {
166 throw cms::Exception(
"TrivialFileCatalog",
"TrivialFileCatalog::connect: Malformed url for file catalog configuration");
169 if (argTokens[0] ==
"protocol") {
171 }
else if (argTokens[0] ==
"destination") {
178 throw cms::Exception(
"TrivialFileCatalog",
"TrivialFileCatalog::connect: protocol was not supplied in the contact string");
181 std::ifstream configFile;
187 if (!configFile.good() || !configFile.is_open()) {
188 throw cms::Exception(
"TrivialFileCatalog",
"TrivialFileCatalog::connect: Unable to open trivial file catalog " +
m_filename);
193 auto parser = std::make_unique<XercesDOMParser>();
195 parser->setValidationScheme(XercesDOMParser::Val_Auto);
196 parser->setDoNamespaces(
false);
198 DOMDocument* doc =
parser->getDocument();
215 DOMNodeList*
rules = doc->getElementsByTagName(
uStr(
"lfn-to-pfn").ptr());
216 XMLSize_t
const ruleTagsNum = rules->getLength();
220 for (XMLSize_t
i = 0;
i < ruleTagsNum; ++
i) {
221 DOMNode* ruleNode = rules->item(
i);
227 DOMNodeList* rules = doc->getElementsByTagName(
uStr(
"pfn-to-lfn").ptr());
228 XMLSize_t ruleTagsNum = rules->getLength();
230 for (XMLSize_t
i = 0;
i < ruleTagsNum; ++
i) {
231 DOMNode* ruleNode = rules->item(
i);
236 catch (xercesc::DOMException
const&
e) {
237 throw cms::Exception(
"TrivialFileCatalog") <<
"Xerces XML parser threw this exception: " <<
cStr(e.getMessage()).ptr() << std::endl;
std::string m_destination
ProtocolRules m_inverseRules
ZStr< char > cStr(XMLCh const *str)
ZStr< XMLCh > uStr(char const *str)
ProtocolRules m_directRules
void parseRule(xercesc::DOMNode *ruleNode, ProtocolRules &rules)
std::vector< std::string > m_protocols