51 string stripPrefixes(
string urn,
bool strict) {
61 transform(lowered.begin(), lowered.end(), lowered.begin(), ::tolower);
66 if (strict && (numAts > 1 || !hasPrefix))
67 throw LSST_EXCEPT(BadNameError, (
"URN must start with \"urn:eupspkg:\" or \"@urn:eupspkg:\""));
82 void splitAndValidate(
const string& urn,
vector<string>&
a,
bool strict) {
84 string stripped = stripPrefixes(urn, strict);
88 size_t i = stripped.
find(
":");
89 if (i == string::npos) {
90 if (stripped.
length() > 0)
a.push_back(stripped);
93 a.push_back(stripped.
substr(0, i));
94 stripped = stripped.
substr(i + 1);
101 if (
a.size() < 2 ||
a.size() > 3)
102 throw LSST_EXCEPT(BadNameError,
"Wrong number of terms in policy file urn \"" + urn +
"\". " +
103 "The expected form is " +
104 "@urn:eupspkg:<product>:[<repository>:]<file> or " +
105 "@@<product>:[<repository>:]<file>. " +
106 "Is there a typo in the urn?");
117 splitAndValidate(urn, split, strictUrn);
129 splitAndValidate(urn, split, strictUrn);
141 splitAndValidate(urn, split, strictUrn);
142 if (split.
size() == 3)
158 transform(lc.begin(), lc.end(), lc.begin(), ::tolower);
159 while (lc[0] ==
'@') lc = lc.substr(1);
162 const string& stripped = stripPrefixes(s, strict);