aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorMelanie2013-06-30 18:27:30 +0100
committerMelanie2013-06-30 18:27:30 +0100
commitffcee82b1d62150b772464841023a29acc334c84 (patch)
tree957d562be1f9e567daabb9bfdd25e779ec2c11a4 /OpenSim/Framework
parentMerge branch 'master' into careminster (diff)
parentGroups V2: charge for group creation only after the group has been successful... (diff)
downloadopensim-SC_OLD-ffcee82b1d62150b772464841023a29acc334c84.zip
opensim-SC_OLD-ffcee82b1d62150b772464841023a29acc334c84.tar.gz
opensim-SC_OLD-ffcee82b1d62150b772464841023a29acc334c84.tar.bz2
opensim-SC_OLD-ffcee82b1d62150b772464841023a29acc334c84.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Data/MySQL/MySQLSimulationData.cs OpenSim/Region/Framework/Scenes/EventManager.cs OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/DAMap.cs299
-rw-r--r--OpenSim/Framework/DOMap.cs8
-rw-r--r--OpenSim/Framework/WebUtil.cs10
3 files changed, 192 insertions, 125 deletions
diff --git a/OpenSim/Framework/DAMap.cs b/OpenSim/Framework/DAMap.cs
index df4a6bc..5c729e8 100644
--- a/OpenSim/Framework/DAMap.cs
+++ b/OpenSim/Framework/DAMap.cs
@@ -29,10 +29,12 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection;
32using System.Text; 33using System.Text;
33using System.Xml; 34using System.Xml;
34using System.Xml.Schema; 35using System.Xml.Schema;
35using System.Xml.Serialization; 36using System.Xml.Serialization;
37using log4net;
36using OpenMetaverse; 38using OpenMetaverse;
37using OpenMetaverse.StructuredData; 39using OpenMetaverse.StructuredData;
38 40
@@ -48,13 +50,20 @@ namespace OpenSim.Framework
48 /// within their data store. However, avoid storing large amounts of data because that 50 /// within their data store. However, avoid storing large amounts of data because that
49 /// would slow down database access. 51 /// would slow down database access.
50 /// </remarks> 52 /// </remarks>
51 public class DAMap : IDictionary<string, OSDMap>, IXmlSerializable 53 public class DAMap : IXmlSerializable
52 { 54 {
53 private static readonly int MIN_STORE_NAME_LENGTH = 4; 55// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 56
55 protected OSDMap m_map; 57 private static readonly int MIN_NAMESPACE_LENGTH = 4;
56 58
57 public DAMap() { m_map = new OSDMap(); } 59 private OSDMap m_map = new OSDMap();
60
61 // WARNING: this is temporary for experimentation only, it will be removed!!!!
62 public OSDMap TopLevelMap
63 {
64 get { return m_map; }
65 set { m_map = value; }
66 }
58 67
59 public XmlSchema GetSchema() { return null; } 68 public XmlSchema GetSchema() { return null; }
60 69
@@ -64,39 +73,34 @@ namespace OpenSim.Framework
64 map.ReadXml(rawXml); 73 map.ReadXml(rawXml);
65 return map; 74 return map;
66 } 75 }
67 76
77 public void ReadXml(XmlReader reader)
78 {
79 ReadXml(reader.ReadInnerXml());
80 }
81
68 public void ReadXml(string rawXml) 82 public void ReadXml(string rawXml)
69 { 83 {
70 // System.Console.WriteLine("Trying to deserialize [{0}]", rawXml); 84 // System.Console.WriteLine("Trying to deserialize [{0}]", rawXml);
71 85
72 lock (this) 86 lock (this)
87 {
73 m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); 88 m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
89 SanitiseMap(this);
90 }
74 } 91 }
75 92
76 // WARNING: this is temporary for experimentation only, it will be removed!!!! 93 public void WriteXml(XmlWriter writer)
77 public OSDMap TopLevelMap
78 { 94 {
79 get { return m_map; } 95 writer.WriteRaw(ToXml());
80 set { m_map = value; }
81 } 96 }
82
83 97
84 public void ReadXml(XmlReader reader)
85 {
86 ReadXml(reader.ReadInnerXml());
87 }
88
89 public string ToXml() 98 public string ToXml()
90 { 99 {
91 lock (this) 100 lock (this)
92 return OSDParser.SerializeLLSDXmlString(m_map); 101 return OSDParser.SerializeLLSDXmlString(m_map);
93 } 102 }
94 103
95 public void WriteXml(XmlWriter writer)
96 {
97 writer.WriteRaw(ToXml());
98 }
99
100 public void CopyFrom(DAMap other) 104 public void CopyFrom(DAMap other)
101 { 105 {
102 // Deep copy 106 // Deep copy
@@ -104,7 +108,7 @@ namespace OpenSim.Framework
104 string data = null; 108 string data = null;
105 lock (other) 109 lock (other)
106 { 110 {
107 if (other.Count > 0) 111 if (other.CountNamespaces > 0)
108 { 112 {
109 data = OSDParser.SerializeLLSDXmlString(other.m_map); 113 data = OSDParser.SerializeLLSDXmlString(other.m_map);
110 } 114 }
@@ -120,59 +124,136 @@ namespace OpenSim.Framework
120 } 124 }
121 125
122 /// <summary> 126 /// <summary>
123 /// Returns the number of data stores. 127 /// Sanitise the map to remove any namespaces or stores that are not OSDMap.
124 /// </summary> 128 /// </summary>
125 public int Count { get { lock (this) { return m_map.Count; } } } 129 /// <param name='map'>
126 130 /// </param>
127 public bool IsReadOnly { get { return false; } } 131 public static void SanitiseMap(DAMap daMap)
128 132 {
133 List<string> keysToRemove = null;
134
135 // Hard-coded special case that needs to be removed in the future. Normally, modules themselves should
136 // handle reading data from old locations
137 bool osMaterialsMigrationRequired = false;
138
139 OSDMap namespacesMap = daMap.m_map;
140
141 foreach (string key in namespacesMap.Keys)
142 {
143// Console.WriteLine("Processing ns {0}", key);
144 if (!(namespacesMap[key] is OSDMap))
145 {
146 if (keysToRemove == null)
147 keysToRemove = new List<string>();
148
149 keysToRemove.Add(key);
150 }
151 }
152
153 if (keysToRemove != null)
154 {
155 foreach (string key in keysToRemove)
156 {
157// Console.WriteLine ("Removing bad ns {0}", key);
158 namespacesMap.Remove(key);
159 }
160 }
161
162 foreach (OSD nsOsd in namespacesMap.Values)
163 {
164 OSDMap nsOsdMap = (OSDMap)nsOsd;
165 keysToRemove = null;
166
167 foreach (string key in nsOsdMap.Keys)
168 {
169 if (!(nsOsdMap[key] is OSDMap))
170 {
171 if (keysToRemove == null)
172 keysToRemove = new List<string>();
173
174 keysToRemove.Add(key);
175 }
176 }
177
178 if (keysToRemove != null)
179 foreach (string key in keysToRemove)
180 nsOsdMap.Remove(key);
181 }
182 }
183
129 /// <summary> 184 /// <summary>
130 /// Returns the names of the data stores. 185 /// Get the number of namespaces
131 /// </summary> 186 /// </summary>
132 public ICollection<string> Keys { get { lock (this) { return m_map.Keys; } } } 187 public int CountNamespaces { get { lock (this) { return m_map.Count; } } }
133 188
134 /// <summary> 189 /// <summary>
135 /// Returns all the data stores. 190 /// Get the number of stores.
136 /// </summary> 191 /// </summary>
137 public ICollection<OSDMap> Values 192 public int CountStores
138 { 193 {
139 get 194 get
140 { 195 {
196 int count = 0;
197
141 lock (this) 198 lock (this)
142 { 199 {
143 List<OSDMap> stores = new List<OSDMap>(m_map.Count); 200 foreach (OSD osdNamespace in m_map)
144 foreach (OSD llsd in m_map.Values) 201 {
145 stores.Add((OSDMap)llsd); 202 count += ((OSDMap)osdNamespace).Count;
146 return stores; 203 }
147 } 204 }
205
206 return count;
148 } 207 }
149 } 208 }
150 209
151 /// <summary> 210 /// <summary>
152 /// Gets or sets one data store. 211 /// Retrieve a Dynamic Attribute store
153 /// </summary> 212 /// </summary>
154 /// <param name="key">Store name</param> 213 /// <param name="ns">namespace for the store - use "OpenSim" for in-core modules</param>
155 /// <returns></returns> 214 /// <param name="storeName">name of the store within the namespace</param>
156 public OSDMap this[string key] 215 /// <returns>an OSDMap representing the stored data, or null if not found</returns>
157 { 216 public OSDMap GetStore(string ns, string storeName)
158 get 217 {
159 { 218 OSD namespaceOsd;
160 OSD llsd; 219
161 220 lock (this)
162 lock (this) 221 {
222 if (m_map.TryGetValue(ns, out namespaceOsd))
163 { 223 {
164 if (m_map.TryGetValue(key, out llsd)) 224 OSD store;
165 return (OSDMap)llsd; 225
166 else 226 if (((OSDMap)namespaceOsd).TryGetValue(storeName, out store))
167 return null; 227 return (OSDMap)store;
168 } 228 }
169 } 229 }
170 230
171 set 231 return null;
232 }
233
234 /// <summary>
235 /// Saves a Dynamic attribute store
236 /// </summary>
237 /// <param name="ns">namespace for the store - use "OpenSim" for in-core modules</param>
238 /// <param name="storeName">name of the store within the namespace</param>
239 /// <param name="store">an OSDMap representing the data to store</param>
240 public void SetStore(string ns, string storeName, OSDMap store)
241 {
242 ValidateNamespace(ns);
243 OSDMap nsMap;
244
245 lock (this)
172 { 246 {
173 ValidateKey(key); 247 if (!m_map.ContainsKey(ns))
174 lock (this) 248 {
175 m_map[key] = value; 249 nsMap = new OSDMap();
250 m_map[ns] = nsMap;
251 }
252
253 nsMap = (OSDMap)m_map[ns];
254
255// m_log.DebugFormat("[DA MAP]: Setting store to {0}:{1}", ns, storeName);
256 nsMap[storeName] = store;
176 } 257 }
177 } 258 }
178 259
@@ -180,54 +261,46 @@ namespace OpenSim.Framework
180 /// Validate the key used for storing separate data stores. 261 /// Validate the key used for storing separate data stores.
181 /// </summary> 262 /// </summary>
182 /// <param name='key'></param> 263 /// <param name='key'></param>
183 public static void ValidateKey(string key) 264 public static void ValidateNamespace(string ns)
184 { 265 {
185 if (key.Length < MIN_STORE_NAME_LENGTH) 266 if (ns.Length < MIN_NAMESPACE_LENGTH)
186 throw new Exception("Minimum store name length is " + MIN_STORE_NAME_LENGTH); 267 throw new Exception("Minimum namespace length is " + MIN_NAMESPACE_LENGTH);
187 } 268 }
188 269
189 public bool ContainsKey(string key) 270 public bool ContainsStore(string ns, string storeName)
190 { 271 {
191 lock (this) 272 OSD namespaceOsd;
192 return m_map.ContainsKey(key);
193 }
194 273
195 public void Add(string key, OSDMap store)
196 {
197 ValidateKey(key);
198 lock (this)
199 m_map.Add(key, store);
200 }
201
202 public void Add(KeyValuePair<string, OSDMap> kvp)
203 {
204 ValidateKey(kvp.Key);
205 lock (this) 274 lock (this)
206 m_map.Add(kvp.Key, kvp.Value); 275 {
207 } 276 if (m_map.TryGetValue(ns, out namespaceOsd))
277 {
278 return ((OSDMap)namespaceOsd).ContainsKey(storeName);
279 }
280 }
208 281
209 public bool Remove(string key) 282 return false;
210 { 283 }
211 lock (this)
212 return m_map.Remove(key);
213 }
214 284
215 public bool TryGetValue(string key, out OSDMap store) 285 public bool TryGetStore(string ns, string storeName, out OSDMap store)
216 { 286 {
287 OSD namespaceOsd;
288
217 lock (this) 289 lock (this)
218 { 290 {
219 OSD llsd; 291 if (m_map.TryGetValue(ns, out namespaceOsd))
220 if (m_map.TryGetValue(key, out llsd))
221 {
222 store = (OSDMap)llsd;
223 return true;
224 }
225 else
226 { 292 {
227 store = null; 293 OSD storeOsd;
228 return false; 294
295 bool result = ((OSDMap)namespaceOsd).TryGetValue(storeName, out storeOsd);
296 store = (OSDMap)storeOsd;
297
298 return result;
229 } 299 }
230 } 300 }
301
302 store = null;
303 return false;
231 } 304 }
232 305
233 public void Clear() 306 public void Clear()
@@ -235,39 +308,25 @@ namespace OpenSim.Framework
235 lock (this) 308 lock (this)
236 m_map.Clear(); 309 m_map.Clear();
237 } 310 }
238
239 public bool Contains(KeyValuePair<string, OSDMap> kvp)
240 {
241 lock (this)
242 return m_map.ContainsKey(kvp.Key);
243 }
244
245 public void CopyTo(KeyValuePair<string, OSDMap>[] array, int index)
246 {
247 throw new NotImplementedException();
248 }
249 311
250 public bool Remove(KeyValuePair<string, OSDMap> kvp) 312 public bool RemoveStore(string ns, string storeName)
251 { 313 {
252 lock (this) 314 OSD namespaceOsd;
253 return m_map.Remove(kvp.Key);
254 }
255 315
256 public System.Collections.IDictionaryEnumerator GetEnumerator()
257 {
258 lock (this) 316 lock (this)
259 return m_map.GetEnumerator(); 317 {
260 } 318 if (m_map.TryGetValue(ns, out namespaceOsd))
319 {
320 OSDMap namespaceOsdMap = (OSDMap)namespaceOsd;
321 namespaceOsdMap.Remove(storeName);
261 322
262 IEnumerator<KeyValuePair<string, OSDMap>> IEnumerable<KeyValuePair<string, OSDMap>>.GetEnumerator() 323 // Don't keep empty namespaces around
263 { 324 if (namespaceOsdMap.Count <= 0)
264 return null; 325 m_map.Remove(ns);
265 } 326 }
327 }
266 328
267 IEnumerator IEnumerable.GetEnumerator() 329 return false;
268 { 330 }
269 lock (this)
270 return m_map.GetEnumerator();
271 }
272 } 331 }
273} \ No newline at end of file 332} \ No newline at end of file
diff --git a/OpenSim/Framework/DOMap.cs b/OpenSim/Framework/DOMap.cs
index 755e129..f5b650b 100644
--- a/OpenSim/Framework/DOMap.cs
+++ b/OpenSim/Framework/DOMap.cs
@@ -42,22 +42,22 @@ namespace OpenSim.Framework
42 /// This class stores and retrieves dynamic objects. 42 /// This class stores and retrieves dynamic objects.
43 /// </summary> 43 /// </summary>
44 /// <remarks> 44 /// <remarks>
45 /// Experimental - DO NOT USE. 45 /// Experimental - DO NOT USE. Does not yet have namespace support.
46 /// </remarks> 46 /// </remarks>
47 public class DOMap 47 public class DOMap
48 { 48 {
49 private IDictionary<string, object> m_map; 49 private IDictionary<string, object> m_map;
50 50
51 public void Add(string key, object dynObj) 51 public void Add(string ns, string objName, object dynObj)
52 { 52 {
53 DAMap.ValidateKey(key); 53 DAMap.ValidateNamespace(ns);
54 54
55 lock (this) 55 lock (this)
56 { 56 {
57 if (m_map == null) 57 if (m_map == null)
58 m_map = new Dictionary<string, object>(); 58 m_map = new Dictionary<string, object>();
59 59
60 m_map.Add(key, dynObj); 60 m_map.Add(objName, dynObj);
61 } 61 }
62 } 62 }
63 63
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 312e9a9..dfa37ca 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -972,11 +972,12 @@ namespace OpenSim.Framework
972 /// <param name="verb"></param> 972 /// <param name="verb"></param>
973 /// <param name="requestUrl"></param> 973 /// <param name="requestUrl"></param>
974 /// <param name="obj"> </param> 974 /// <param name="obj"> </param>
975 /// <param name="timeoutsecs"> </param>
975 /// <returns></returns> 976 /// <returns></returns>
976 /// 977 ///
977 /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting 978 /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting
978 /// the request. You'll want to make sure you deal with this as they're not uncommon</exception> 979 /// the request. You'll want to make sure you deal with this as they're not uncommon</exception>
979 public static string MakeRequest(string verb, string requestUrl, string obj) 980 public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs)
980 { 981 {
981 int reqnum = WebUtil.RequestNumber++; 982 int reqnum = WebUtil.RequestNumber++;
982 983
@@ -990,6 +991,8 @@ namespace OpenSim.Framework
990 991
991 WebRequest request = WebRequest.Create(requestUrl); 992 WebRequest request = WebRequest.Create(requestUrl);
992 request.Method = verb; 993 request.Method = verb;
994 if (timeoutsecs > 0)
995 request.Timeout = timeoutsecs * 1000;
993 string respstring = String.Empty; 996 string respstring = String.Empty;
994 997
995 int tickset = Util.EnvironmentTickCountSubtract(tickstart); 998 int tickset = Util.EnvironmentTickCountSubtract(tickstart);
@@ -1086,6 +1089,11 @@ namespace OpenSim.Framework
1086 1089
1087 return respstring; 1090 return respstring;
1088 } 1091 }
1092
1093 public static string MakeRequest(string verb, string requestUrl, string obj)
1094 {
1095 return MakeRequest(verb, requestUrl, obj, -1);
1096 }
1089 } 1097 }
1090 1098
1091 public class SynchronousRestObjectRequester 1099 public class SynchronousRestObjectRequester