diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Server/Handlers/Inventory | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Server/Handlers/Inventory')
3 files changed, 119 insertions, 72 deletions
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index 1d422a7..b295446 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs | |||
@@ -86,10 +86,6 @@ namespace OpenSim.Server.Handlers.Inventory | |||
86 | protected virtual void AddHttpHandlers(IHttpServer m_httpServer) | 86 | protected virtual void AddHttpHandlers(IHttpServer m_httpServer) |
87 | { | 87 | { |
88 | m_httpServer.AddStreamHandler( | 88 | m_httpServer.AddStreamHandler( |
89 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | ||
90 | "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); | ||
91 | |||
92 | m_httpServer.AddStreamHandler( | ||
93 | new RestDeserialiseSecureHandler<Guid, List<InventoryFolderBase>>( | 89 | new RestDeserialiseSecureHandler<Guid, List<InventoryFolderBase>>( |
94 | "POST", "/SystemFolders/", GetSystemFolders, CheckAuthSession)); | 90 | "POST", "/SystemFolders/", GetSystemFolders, CheckAuthSession)); |
95 | 91 | ||
@@ -178,12 +174,6 @@ namespace OpenSim.Server.Handlers.Inventory | |||
178 | 174 | ||
179 | #region Wrappers for converting the Guid parameter | 175 | #region Wrappers for converting the Guid parameter |
180 | 176 | ||
181 | public InventoryCollection GetUserInventory(Guid guid) | ||
182 | { | ||
183 | UUID userID = new UUID(guid); | ||
184 | return m_InventoryService.GetUserInventory(userID); | ||
185 | } | ||
186 | |||
187 | public List<InventoryFolderBase> GetSystemFolders(Guid guid) | 177 | public List<InventoryFolderBase> GetSystemFolders(Guid guid) |
188 | { | 178 | { |
189 | UUID userID = new UUID(guid); | 179 | UUID userID = new UUID(guid); |
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs index 231e32f..e2c50fe 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs | |||
@@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Inventory | |||
56 | m_InventoryService = service; | 56 | m_InventoryService = service; |
57 | } | 57 | } |
58 | 58 | ||
59 | public override byte[] Handle(string path, Stream request, | 59 | protected override byte[] ProcessRequest(string path, Stream request, |
60 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 60 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
61 | { | 61 | { |
62 | XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>)); | 62 | XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>)); |
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 64127c2..5c4e7a9 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -33,6 +33,7 @@ using System.Collections.Generic; | |||
33 | using System.IO; | 33 | using System.IO; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.ServiceAuth; | ||
36 | using OpenSim.Server.Base; | 37 | using OpenSim.Server.Base; |
37 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
@@ -40,7 +41,9 @@ using OpenSim.Server.Handlers.Base; | |||
40 | using log4net; | 41 | using log4net; |
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
42 | 43 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 44 | using System.Threading; |
45 | |||
46 | namespace OpenSim.Server.Handlers.Inventory | ||
44 | { | 47 | { |
45 | public class XInventoryInConnector : ServiceConnector | 48 | public class XInventoryInConnector : ServiceConnector |
46 | { | 49 | { |
@@ -71,7 +74,9 @@ namespace OpenSim.Server.Handlers.Asset | |||
71 | m_InventoryService = | 74 | m_InventoryService = |
72 | ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args); | 75 | ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args); |
73 | 76 | ||
74 | server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService)); | 77 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
78 | |||
79 | server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService, auth)); | ||
75 | } | 80 | } |
76 | } | 81 | } |
77 | 82 | ||
@@ -81,13 +86,13 @@ namespace OpenSim.Server.Handlers.Asset | |||
81 | 86 | ||
82 | private IInventoryService m_InventoryService; | 87 | private IInventoryService m_InventoryService; |
83 | 88 | ||
84 | public XInventoryConnectorPostHandler(IInventoryService service) : | 89 | public XInventoryConnectorPostHandler(IInventoryService service, IServiceAuth auth) : |
85 | base("POST", "/xinventory") | 90 | base("POST", "/xinventory", auth) |
86 | { | 91 | { |
87 | m_InventoryService = service; | 92 | m_InventoryService = service; |
88 | } | 93 | } |
89 | 94 | ||
90 | public override byte[] Handle(string path, Stream requestData, | 95 | protected override byte[] ProcessRequest(string path, Stream requestData, |
91 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 96 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
92 | { | 97 | { |
93 | StreamReader sr = new StreamReader(requestData); | 98 | StreamReader sr = new StreamReader(requestData); |
@@ -114,14 +119,14 @@ namespace OpenSim.Server.Handlers.Asset | |||
114 | return HandleCreateUserInventory(request); | 119 | return HandleCreateUserInventory(request); |
115 | case "GETINVENTORYSKELETON": | 120 | case "GETINVENTORYSKELETON": |
116 | return HandleGetInventorySkeleton(request); | 121 | return HandleGetInventorySkeleton(request); |
117 | case "GETUSERINVENTORY": | ||
118 | return HandleGetUserInventory(request); | ||
119 | case "GETROOTFOLDER": | 122 | case "GETROOTFOLDER": |
120 | return HandleGetRootFolder(request); | 123 | return HandleGetRootFolder(request); |
121 | case "GETFOLDERFORTYPE": | 124 | case "GETFOLDERFORTYPE": |
122 | return HandleGetFolderForType(request); | 125 | return HandleGetFolderForType(request); |
123 | case "GETFOLDERCONTENT": | 126 | case "GETFOLDERCONTENT": |
124 | return HandleGetFolderContent(request); | 127 | return HandleGetFolderContent(request); |
128 | case "GETMULTIPLEFOLDERSCONTENT": | ||
129 | return HandleGetMultipleFoldersContent(request); | ||
125 | case "GETFOLDERITEMS": | 130 | case "GETFOLDERITEMS": |
126 | return HandleGetFolderItems(request); | 131 | return HandleGetFolderItems(request); |
127 | case "ADDFOLDER": | 132 | case "ADDFOLDER": |
@@ -144,6 +149,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
144 | return HandleDeleteItems(request); | 149 | return HandleDeleteItems(request); |
145 | case "GETITEM": | 150 | case "GETITEM": |
146 | return HandleGetItem(request); | 151 | return HandleGetItem(request); |
152 | case "GETMULTIPLEITEMS": | ||
153 | return HandleGetMultipleItems(request); | ||
147 | case "GETFOLDER": | 154 | case "GETFOLDER": |
148 | return HandleGetFolder(request); | 155 | return HandleGetFolder(request); |
149 | case "GETACTIVEGESTURES": | 156 | case "GETACTIVEGESTURES": |
@@ -155,7 +162,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
155 | } | 162 | } |
156 | catch (Exception e) | 163 | catch (Exception e) |
157 | { | 164 | { |
158 | m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e.StackTrace); | 165 | m_log.Error(string.Format("[XINVENTORY HANDLER]: Exception {0} ", e.Message), e); |
159 | } | 166 | } |
160 | 167 | ||
161 | return FailureResult(); | 168 | return FailureResult(); |
@@ -190,18 +197,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
190 | 197 | ||
191 | rootElement.AppendChild(result); | 198 | rootElement.AppendChild(result); |
192 | 199 | ||
193 | return DocToBytes(doc); | 200 | return Util.DocToBytes(doc); |
194 | } | ||
195 | |||
196 | private byte[] DocToBytes(XmlDocument doc) | ||
197 | { | ||
198 | MemoryStream ms = new MemoryStream(); | ||
199 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
200 | xw.Formatting = Formatting.Indented; | ||
201 | doc.WriteTo(xw); | ||
202 | xw.Flush(); | ||
203 | |||
204 | return ms.ToArray(); | ||
205 | } | 201 | } |
206 | 202 | ||
207 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) | 203 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) |
@@ -250,45 +246,6 @@ namespace OpenSim.Server.Handlers.Asset | |||
250 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 246 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
251 | } | 247 | } |
252 | 248 | ||
253 | byte[] HandleGetUserInventory(Dictionary<string, object> request) | ||
254 | { | ||
255 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
256 | UUID principal = UUID.Zero; | ||
257 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
258 | |||
259 | InventoryCollection icoll = m_InventoryService.GetUserInventory(principal); | ||
260 | if (icoll != null) | ||
261 | { | ||
262 | Dictionary<string, object> folders = new Dictionary<string, object>(); | ||
263 | int i = 0; | ||
264 | if (icoll.Folders != null) | ||
265 | { | ||
266 | foreach (InventoryFolderBase f in icoll.Folders) | ||
267 | { | ||
268 | folders["folder_" + i.ToString()] = EncodeFolder(f); | ||
269 | i++; | ||
270 | } | ||
271 | result["FOLDERS"] = folders; | ||
272 | } | ||
273 | if (icoll.Items != null) | ||
274 | { | ||
275 | i = 0; | ||
276 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
277 | foreach (InventoryItemBase it in icoll.Items) | ||
278 | { | ||
279 | items["item_" + i.ToString()] = EncodeItem(it); | ||
280 | i++; | ||
281 | } | ||
282 | result["ITEMS"] = items; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
287 | |||
288 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
289 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
290 | } | ||
291 | |||
292 | byte[] HandleGetRootFolder(Dictionary<string,object> request) | 249 | byte[] HandleGetRootFolder(Dictionary<string,object> request) |
293 | { | 250 | { |
294 | Dictionary<string,object> result = new Dictionary<string,object>(); | 251 | Dictionary<string,object> result = new Dictionary<string,object>(); |
@@ -312,7 +269,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
312 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | 269 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); |
313 | int type = 0; | 270 | int type = 0; |
314 | Int32.TryParse(request["TYPE"].ToString(), out type); | 271 | Int32.TryParse(request["TYPE"].ToString(), out type); |
315 | InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type); | 272 | InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (FolderType)type); |
316 | if (folder != null) | 273 | if (folder != null) |
317 | result["folder"] = EncodeFolder(folder); | 274 | result["folder"] = EncodeFolder(folder); |
318 | 275 | ||
@@ -333,6 +290,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
333 | InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); | 290 | InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); |
334 | if (icoll != null) | 291 | if (icoll != null) |
335 | { | 292 | { |
293 | result["FID"] = icoll.FolderID.ToString(); | ||
294 | result["VERSION"] = icoll.Version.ToString(); | ||
336 | Dictionary<string, object> folders = new Dictionary<string, object>(); | 295 | Dictionary<string, object> folders = new Dictionary<string, object>(); |
337 | int i = 0; | 296 | int i = 0; |
338 | if (icoll.Folders != null) | 297 | if (icoll.Folders != null) |
@@ -363,7 +322,71 @@ namespace OpenSim.Server.Handlers.Asset | |||
363 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 322 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
364 | } | 323 | } |
365 | 324 | ||
366 | byte[] HandleGetFolderItems(Dictionary<string,object> request) | 325 | byte[] HandleGetMultipleFoldersContent(Dictionary<string, object> request) |
326 | { | ||
327 | Dictionary<string, object> resultSet = new Dictionary<string, object>(); | ||
328 | UUID principal = UUID.Zero; | ||
329 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
330 | string folderIDstr = request["FOLDERS"].ToString(); | ||
331 | int count = 0; | ||
332 | Int32.TryParse(request["COUNT"].ToString(), out count); | ||
333 | |||
334 | UUID[] fids = new UUID[count]; | ||
335 | string[] uuids = folderIDstr.Split(','); | ||
336 | int i = 0; | ||
337 | foreach (string id in uuids) | ||
338 | { | ||
339 | UUID fid = UUID.Zero; | ||
340 | if (UUID.TryParse(id, out fid)) | ||
341 | fids[i] = fid; | ||
342 | i += 1; | ||
343 | } | ||
344 | |||
345 | count = 0; | ||
346 | InventoryCollection[] icollList = m_InventoryService.GetMultipleFoldersContent(principal, fids); | ||
347 | if (icollList != null && icollList.Length > 0) | ||
348 | { | ||
349 | foreach (InventoryCollection icoll in icollList) | ||
350 | { | ||
351 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
352 | result["FID"] = icoll.FolderID.ToString(); | ||
353 | result["VERSION"] = icoll.Version.ToString(); | ||
354 | result["OWNER"] = icoll.OwnerID.ToString(); | ||
355 | Dictionary<string, object> folders = new Dictionary<string, object>(); | ||
356 | i = 0; | ||
357 | if (icoll.Folders != null) | ||
358 | { | ||
359 | foreach (InventoryFolderBase f in icoll.Folders) | ||
360 | { | ||
361 | folders["folder_" + i.ToString()] = EncodeFolder(f); | ||
362 | i++; | ||
363 | } | ||
364 | result["FOLDERS"] = folders; | ||
365 | } | ||
366 | i = 0; | ||
367 | if (icoll.Items != null) | ||
368 | { | ||
369 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
370 | foreach (InventoryItemBase it in icoll.Items) | ||
371 | { | ||
372 | items["item_" + i.ToString()] = EncodeItem(it); | ||
373 | i++; | ||
374 | } | ||
375 | result["ITEMS"] = items; | ||
376 | } | ||
377 | |||
378 | resultSet["F_" + fids[count++]] = result; | ||
379 | //m_log.DebugFormat("[XXX]: Sending {0} {1}", fids[count-1], icoll.FolderID); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | string xmlString = ServerUtils.BuildXmlResponse(resultSet); | ||
384 | |||
385 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
386 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
387 | } | ||
388 | |||
389 | byte[] HandleGetFolderItems(Dictionary<string, object> request) | ||
367 | { | 390 | { |
368 | Dictionary<string,object> result = new Dictionary<string,object>(); | 391 | Dictionary<string,object> result = new Dictionary<string,object>(); |
369 | UUID principal = UUID.Zero; | 392 | UUID principal = UUID.Zero; |
@@ -555,6 +578,40 @@ namespace OpenSim.Server.Handlers.Asset | |||
555 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 578 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
556 | } | 579 | } |
557 | 580 | ||
581 | byte[] HandleGetMultipleItems(Dictionary<string, object> request) | ||
582 | { | ||
583 | Dictionary<string, object> resultSet = new Dictionary<string, object>(); | ||
584 | UUID principal = UUID.Zero; | ||
585 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
586 | string itemIDstr = request["ITEMS"].ToString(); | ||
587 | int count = 0; | ||
588 | Int32.TryParse(request["COUNT"].ToString(), out count); | ||
589 | |||
590 | UUID[] fids = new UUID[count]; | ||
591 | string[] uuids = itemIDstr.Split(','); | ||
592 | int i = 0; | ||
593 | foreach (string id in uuids) | ||
594 | { | ||
595 | UUID fid = UUID.Zero; | ||
596 | if (UUID.TryParse(id, out fid)) | ||
597 | fids[i] = fid; | ||
598 | i += 1; | ||
599 | } | ||
600 | |||
601 | InventoryItemBase[] itemsList = m_InventoryService.GetMultipleItems(principal, fids); | ||
602 | if (itemsList != null && itemsList.Length > 0) | ||
603 | { | ||
604 | count = 0; | ||
605 | foreach (InventoryItemBase item in itemsList) | ||
606 | resultSet["item_" + count++] = (item == null) ? (object)"NULL" : EncodeItem(item); | ||
607 | } | ||
608 | |||
609 | string xmlString = ServerUtils.BuildXmlResponse(resultSet); | ||
610 | |||
611 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
612 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
613 | } | ||
614 | |||
558 | byte[] HandleGetFolder(Dictionary<string,object> request) | 615 | byte[] HandleGetFolder(Dictionary<string,object> request) |
559 | { | 616 | { |
560 | Dictionary<string, object> result = new Dictionary<string, object>(); | 617 | Dictionary<string, object> result = new Dictionary<string, object>(); |