aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/JsonStore
diff options
context:
space:
mode:
authorMelanie2013-02-22 01:28:54 +0000
committerMelanie2013-02-22 01:28:54 +0000
commit9534d5f9296979b68550177a5201c2bdba84f14e (patch)
tree1d39dee6d1eaed10b1146a9ee59a6deaa062bae2 /OpenSim/Region/OptionalModules/Scripting/JsonStore
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-9534d5f9296979b68550177a5201c2bdba84f14e.zip
opensim-SC_OLD-9534d5f9296979b68550177a5201c2bdba84f14e.tar.gz
opensim-SC_OLD-9534d5f9296979b68550177a5201c2bdba84f14e.tar.bz2
opensim-SC_OLD-9534d5f9296979b68550177a5201c2bdba84f14e.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/JsonStore')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs28
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs32
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs38
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs22
4 files changed, 14 insertions, 106 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
index ca3989a..40adba1 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
@@ -84,11 +84,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
84 protected static Regex m_PathComponent = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])"); 84 protected static Regex m_PathComponent = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])");
85 85
86 // extract the internals of an array reference 86 // extract the internals of an array reference
87 protected static Regex m_SimpleArrayPattern = new Regex("\\[([0-9]+)\\]"); 87 protected static Regex m_SimpleArrayPattern = new Regex("^\\[([0-9]+)\\]$");
88 protected static Regex m_ArrayPattern = new Regex("\\[([0-9]+|\\+)\\]"); 88 protected static Regex m_ArrayPattern = new Regex("^\\[([0-9]+|\\+)\\]$");
89 89
90 // extract the internals of a has reference 90 // extract the internals of a has reference
91 protected static Regex m_HashPattern = new Regex("{([^}]+)}"); 91 protected static Regex m_HashPattern = new Regex("^{([^}]+)}$");
92 92
93 // ----------------------------------------------------------------- 93 // -----------------------------------------------------------------
94 /// <summary> 94 /// <summary>
@@ -173,28 +173,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
173 /// 173 ///
174 /// </summary> 174 /// </summary>
175 // ----------------------------------------------------------------- 175 // -----------------------------------------------------------------
176 public bool TestPath(string expr, bool useJson)
177 {
178 Stack<string> path;
179 if (! ParsePathExpression(expr,out path))
180 return false;
181
182 OSD result = ProcessPathExpression(ValueStore,path);
183
184 if (result == null)
185 return false;
186
187 if (useJson || OSDBaseType(result.Type))
188 return true;
189
190 return false;
191 }
192
193 // -----------------------------------------------------------------
194 /// <summary>
195 ///
196 /// </summary>
197 // -----------------------------------------------------------------
198 public int ArrayLength(string expr) 176 public int ArrayLength(string expr)
199 { 177 {
200 Stack<string> path; 178 Stack<string> path;
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
index fb35068..e78a2f4 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
@@ -302,38 +302,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
302 /// 302 ///
303 /// </summary> 303 /// </summary>
304 // ----------------------------------------------------------------- 304 // -----------------------------------------------------------------
305 public bool TestPath(UUID storeID, string path, bool useJson)
306 {
307 if (! m_enabled) return false;
308
309 JsonStore map = null;
310 lock (m_JsonValueStore)
311 {
312 if (! m_JsonValueStore.TryGetValue(storeID,out map))
313 {
314 m_log.InfoFormat("[JsonStore] Missing store {0}",storeID);
315 return false;
316 }
317 }
318
319 try
320 {
321 lock (map)
322 return map.TestPath(path,useJson);
323 }
324 catch (Exception e)
325 {
326 m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e);
327 }
328
329 return false;
330 }
331
332 // -----------------------------------------------------------------
333 /// <summary>
334 ///
335 /// </summary>
336 // -----------------------------------------------------------------
337 public bool SetValue(UUID storeID, string path, string value, bool useJson) 305 public bool SetValue(UUID storeID, string path, string value, bool useJson)
338 { 306 {
339 if (! m_enabled) return false; 307 if (! m_enabled) return false;
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index ef08c05..e13eb56 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -168,32 +168,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
168 { 168 {
169 m_comms.RegisterScriptInvocations(this); 169 m_comms.RegisterScriptInvocations(this);
170 m_comms.RegisterConstants(this); 170 m_comms.RegisterConstants(this);
171
172 // m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
173 // m_comms.RegisterScriptInvocation(this, "JsonAttachObjectStore");
174 // m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
175 // m_comms.RegisterScriptInvocation(this, "JsonTestStore");
176
177 // m_comms.RegisterScriptInvocation(this, "JsonReadNotecard");
178 // m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard");
179
180 // m_comms.RegisterScriptInvocation(this, "JsonTestPathList");
181 // m_comms.RegisterScriptInvocation(this, "JsonTestPath");
182 // m_comms.RegisterScriptInvocation(this, "JsonTestPathJson");
183
184 // m_comms.RegisterScriptInvocation(this, "JsonGetValue");
185 // m_comms.RegisterScriptInvocation(this, "JsonGetValueJson");
186
187 // m_comms.RegisterScriptInvocation(this, "JsonTakeValue");
188 // m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson");
189
190 // m_comms.RegisterScriptInvocation(this, "JsonReadValue");
191 // m_comms.RegisterScriptInvocation(this, "JsonReadValueJson");
192
193 // m_comms.RegisterScriptInvocation(this, "JsonSetValue");
194 // m_comms.RegisterScriptInvocation(this, "JsonSetValueJson");
195
196 // m_comms.RegisterScriptInvocation(this, "JsonRemoveValue");
197 } 171 }
198 catch (Exception e) 172 catch (Exception e)
199 { 173 {
@@ -341,18 +315,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
341 return (int)m_store.GetPathType(storeID,path); 315 return (int)m_store.GetPathType(storeID,path);
342 } 316 }
343 317
344 [ScriptInvocation]
345 public int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path)
346 {
347 return m_store.TestPath(storeID,path,false) ? 1 : 0;
348 }
349
350 [ScriptInvocation]
351 public int JsonTestPathJson(UUID hostID, UUID scriptID, UUID storeID, string path)
352 {
353 return m_store.TestPath(storeID,path,true) ? 1 : 0;
354 }
355
356 // ----------------------------------------------------------------- 318 // -----------------------------------------------------------------
357 /// <summary> 319 /// <summary>
358 /// 320 ///
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
index 3d9ad16..b64dbd4 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
@@ -158,8 +158,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
158 158
159 Assert.That(dsrv, Is.EqualTo(1)); 159 Assert.That(dsrv, Is.EqualTo(1));
160 160
161 int tprv = (int)InvokeOp("JsonTestPath", storeId, "Hello"); 161 int tprv = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
162 Assert.That(tprv, Is.EqualTo(0)); 162 Assert.That(tprv, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
163 } 163 }
164 164
165 [Test] 165 [Test]
@@ -277,8 +277,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
277 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); 277 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
278 Assert.That(returnValue, Is.EqualTo(1)); 278 Assert.That(returnValue, Is.EqualTo(1));
279 279
280 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); 280 int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
281 Assert.That(result, Is.EqualTo(0)); 281 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
282 282
283 string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); 283 string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello");
284 Assert.That(returnValue2, Is.EqualTo("")); 284 Assert.That(returnValue2, Is.EqualTo(""));
@@ -291,8 +291,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
291 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); 291 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
292 Assert.That(returnValue, Is.EqualTo(1)); 292 Assert.That(returnValue, Is.EqualTo(1));
293 293
294 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); 294 int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
295 Assert.That(result, Is.EqualTo(0)); 295 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
296 296
297 string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello"); 297 string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello");
298 Assert.That(returnValue2, Is.EqualTo("")); 298 Assert.That(returnValue2, Is.EqualTo(""));
@@ -306,11 +306,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
306 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]"); 306 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]");
307 Assert.That(returnValue, Is.EqualTo(1)); 307 Assert.That(returnValue, Is.EqualTo(1));
308 308
309 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello[0]"); 309 int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello[0]");
310 Assert.That(result, Is.EqualTo(1)); 310 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
311 311
312 result = (int)InvokeOp("JsonTestPath", storeId, "Hello[1]"); 312 result = (int)InvokeOp("JsonGetPathType", storeId, "Hello[1]");
313 Assert.That(result, Is.EqualTo(0)); 313 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
314 314
315 string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]"); 315 string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]");
316 Assert.That(stringReturnValue, Is.EqualTo("value2")); 316 Assert.That(stringReturnValue, Is.EqualTo("value2"));
@@ -400,7 +400,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
400// } 400// }
401 401
402 [Test] 402 [Test]
403 public void TestGetArrayLength() 403 public void TestJsonGetArrayLength()
404 { 404 {
405 TestHelpers.InMethod(); 405 TestHelpers.InMethod();
406// TestHelpers.EnableLogging(); 406// TestHelpers.EnableLogging();