| 919 | } |
| 920 | |
| 921 | std::optional<DataStorageBridge::Json> DataStorageBridge::GetNodeProperties( |
| 922 | const std::string& uid, |
| 923 | const PropertyQueryParams& params) const |
| 924 | { |
| 925 | std::lock_guard<std::mutex> lock(m_Mutex); |
| 926 | return this->DispatchTask<std::optional<Json>>([this, uid, params]() |
| 927 | { |
| 928 | auto dataStorage = m_DataStorage.Lock(); |
| 929 | if (dataStorage.IsNull()) |
| 930 | { |
| 931 | return std::optional<Json>(std::nullopt); |
| 932 | } |
| 933 | |
| 934 | auto node = m_UidMapper->FindNodeByUid(uid); |
| 935 | if (node == nullptr) |
| 936 | { |
| 937 | return std::optional<Json>(std::nullopt); |
| 938 | } |
| 939 | |
| 940 | const std::string contextName = params.context.has_value() ? params.context.value() : ""; |
| 941 | |
| 942 | // Get the correct set of property keys for the requested scope |
| 943 | auto keys = GetPropertyKeysForScope(node, contextName, params.scope); |
| 944 | DataNode::PropertyListKeyNames filterdKeys; |
| 945 | for (const auto& key : keys) |
| 946 | { |
| 947 | // Skip internal properties (restapi.*) |
| 948 | if (IsInternalProperty(key)) |
| 949 | { |
| 950 | continue; |
| 951 | } |
| 952 | |
| 953 | // Filter by names if specified |
| 954 | if (params.names.empty() || |
| 955 | std::find(params.names.begin(), params.names.end(), key) != params.names.end()) |
| 956 | { |
| 957 | filterdKeys.push_back(key); |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | // Check if we should return content or just names |
| 962 | if (!params.includeContent) |
| 963 | { |
| 964 | // Return just property names as array |
| 965 | Json names = Json::array(); |
| 966 | for (const auto& key : filterdKeys) |
| 967 | { |
| 968 | names.push_back(key); |
| 969 | } |
| 970 | return std::optional<Json>(names); |
| 971 | } |
| 972 | |
| 973 | Json result = Json::object(); |
| 974 | for (const auto& key : filterdKeys) |
| 975 | { |
| 976 | auto prop = GetConstProperty(node, key, params.context, params.scope); |
| 977 | if (prop != nullptr) |
| 978 | { |
no test coverage detected