comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5244:72dfa0ac84eb db-protobuf

lookup for labels in orthanc explorer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Apr 2023 16:55:55 +0200
parents 367e8af46cfd
children a7d95f951f8a
comparison
equal deleted inserted replaced
5243:f00811d14348 5244:72dfa0ac84eb
1916 operations.Apply(*this, found, target, publicId, parentType); 1916 operations.Apply(*this, found, target, publicId, parentType);
1917 return found; 1917 return found;
1918 } 1918 }
1919 1919
1920 1920
1921 static void CheckValidLabels(const std::set<std::string>& labels)
1922 {
1923 for (std::set<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it)
1924 {
1925 ServerToolbox::CheckValidLabel(*it);
1926 }
1927 }
1928
1929
1921 void StatelessDatabaseOperations::ApplyLookupResources(std::vector<std::string>& resourcesId, 1930 void StatelessDatabaseOperations::ApplyLookupResources(std::vector<std::string>& resourcesId,
1922 std::vector<std::string>* instancesId, 1931 std::vector<std::string>* instancesId,
1923 const DatabaseLookup& lookup, 1932 const DatabaseLookup& lookup,
1924 ResourceType queryLevel, 1933 ResourceType queryLevel,
1925 const std::set<std::string>& withLabels, 1934 const std::set<std::string>& withLabels,
1964 if ((!withLabels.empty() || !withoutLabels.empty()) && 1973 if ((!withLabels.empty() || !withoutLabels.empty()) &&
1965 !db_.HasLabelsSupport()) 1974 !db_.HasLabelsSupport())
1966 { 1975 {
1967 throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support labels"); 1976 throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support labels");
1968 } 1977 }
1978
1979 CheckValidLabels(withLabels);
1980 CheckValidLabels(withoutLabels);
1969 1981
1970 std::vector<DatabaseConstraint> normalized; 1982 std::vector<DatabaseConstraint> normalized;
1971 NormalizeLookup(normalized, lookup, queryLevel); 1983 NormalizeLookup(normalized, lookup, queryLevel);
1972 1984
1973 Operations operations; 1985 Operations operations;
3625 } 3637 }
3626 } 3638 }
3627 } 3639 }
3628 }; 3640 };
3629 3641
3630 if (!Toolbox::IsAsciiString(label)) 3642 ServerToolbox::CheckValidLabel(label);
3631 {
3632 throw OrthancException(ErrorCode_ParameterOutOfRange, "A label must only contain ASCII characters");
3633 }
3634 3643
3635 Operations operations(publicId, level, label, operation); 3644 Operations operations(publicId, level, label, operation);
3636 Apply(operations); 3645 Apply(operations);
3637 } 3646 }
3638 3647