mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 22:26:09 +08:00
Adds a couple requested functions to the JsonStore script
interface. JsonPathType returns the type of node pointed to by the path and deprecates the functionality of both JsonTestPath functions. JsonArrayLength returns the length of an array node.
This commit is contained in:
@@ -265,6 +265,38 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||
return m_JsonValueStore.ContainsKey(storeID);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
public JsonStoreNodeType PathType(UUID storeID, string path)
|
||||
{
|
||||
if (! m_enabled) return JsonStoreNodeType.Undefined;
|
||||
|
||||
JsonStore map = null;
|
||||
lock (m_JsonValueStore)
|
||||
{
|
||||
if (! m_JsonValueStore.TryGetValue(storeID,out map))
|
||||
{
|
||||
m_log.InfoFormat("[JsonStore] Missing store {0}",storeID);
|
||||
return JsonStoreNodeType.Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lock (map)
|
||||
return map.PathType(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e);
|
||||
}
|
||||
|
||||
return JsonStoreNodeType.Undefined;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
@@ -370,6 +402,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
public int ArrayLength(UUID storeID, string path)
|
||||
{
|
||||
if (! m_enabled) return -1;
|
||||
|
||||
JsonStore map = null;
|
||||
lock (m_JsonValueStore)
|
||||
{
|
||||
if (! m_JsonValueStore.TryGetValue(storeID,out map))
|
||||
return -1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lock (map)
|
||||
{
|
||||
return map.ArrayLength(path);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[JsonStore]: unable to retrieve value", e);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user