aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs')
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs902
1 files changed, 451 insertions, 451 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs b/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs
index 136fea1..874e8fb 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs
@@ -1,451 +1,451 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32using OpenMetaverse; 32using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Communications.Cache; 36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Statistics; 38using OpenSim.Framework.Statistics;
39using OpenSim.Region.Communications.Local; 39using OpenSim.Region.Communications.Local;
40 40
41namespace OpenSim.Region.Communications.Hypergrid 41namespace OpenSim.Region.Communications.Hypergrid
42{ 42{
43 public class HGInventoryService : LocalInventoryService, ISecureInventoryService 43 public class HGInventoryService : LocalInventoryService, ISecureInventoryService
44 { 44 {
45 private static readonly ILog m_log 45 private static readonly ILog m_log
46 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private string _inventoryServerUrl; 48 private string _inventoryServerUrl;
49 //private Uri m_Uri; 49 //private Uri m_Uri;
50 private UserProfileCacheService m_userProfileCache; 50 private UserProfileCacheService m_userProfileCache;
51 private bool m_gridmode = false; 51 private bool m_gridmode = false;
52 52
53 private Dictionary<UUID, InventoryReceiptCallback> m_RequestingInventory 53 private Dictionary<UUID, InventoryReceiptCallback> m_RequestingInventory
54 = new Dictionary<UUID, InventoryReceiptCallback>(); 54 = new Dictionary<UUID, InventoryReceiptCallback>();
55 55
56 public UserProfileCacheService UserProfileCache 56 public UserProfileCacheService UserProfileCache
57 { 57 {
58 set { m_userProfileCache = value; } 58 set { m_userProfileCache = value; }
59 } 59 }
60 60
61 public HGInventoryService(string inventoryServerUrl, UserProfileCacheService userProfileCacheService, bool gridmode) 61 public HGInventoryService(string inventoryServerUrl, UserProfileCacheService userProfileCacheService, bool gridmode)
62 { 62 {
63 _inventoryServerUrl = HGNetworkServersInfo.ServerURI(inventoryServerUrl); 63 _inventoryServerUrl = HGNetworkServersInfo.ServerURI(inventoryServerUrl);
64 //m_Uri = new Uri(_inventoryServerUrl); 64 //m_Uri = new Uri(_inventoryServerUrl);
65 m_userProfileCache = userProfileCacheService; 65 m_userProfileCache = userProfileCacheService;
66 m_gridmode = gridmode; 66 m_gridmode = gridmode;
67 } 67 }
68 68
69 #region ISecureInventoryService Members 69 #region ISecureInventoryService Members
70 70
71 public void RequestInventoryForUser(UUID userID, UUID session_id, InventoryReceiptCallback callback) 71 public void RequestInventoryForUser(UUID userID, UUID session_id, InventoryReceiptCallback callback)
72 { 72 {
73 if (IsLocalStandaloneUser(userID)) 73 if (IsLocalStandaloneUser(userID))
74 { 74 {
75 base.RequestInventoryForUser(userID, callback); 75 base.RequestInventoryForUser(userID, callback);
76 return; 76 return;
77 } 77 }
78 78
79 // grid/hypergrid mode 79 // grid/hypergrid mode
80 if (!m_RequestingInventory.ContainsKey(userID)) 80 if (!m_RequestingInventory.ContainsKey(userID))
81 { 81 {
82 m_RequestingInventory.Add(userID, callback); 82 m_RequestingInventory.Add(userID, callback);
83 83
84 try 84 try
85 { 85 {
86 string invServer = GetUserInventoryURI(userID); 86 string invServer = GetUserInventoryURI(userID);
87 m_log.InfoFormat( 87 m_log.InfoFormat(
88 "[HGrid INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1} ({2})", 88 "[HGrid INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1} ({2})",
89 /*_inventoryServerUrl*/ invServer, userID, userID.Guid); 89 /*_inventoryServerUrl*/ invServer, userID, userID.Guid);
90 90
91 91
92 RestSessionObjectPosterResponse<Guid, InventoryCollection> requester 92 RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
93 = new RestSessionObjectPosterResponse<Guid, InventoryCollection>(); 93 = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
94 requester.ResponseCallback = InventoryResponse; 94 requester.ResponseCallback = InventoryResponse;
95 95
96 requester.BeginPostObject(invServer + "/GetInventory/", userID.Guid, session_id.ToString(), userID.ToString()); 96 requester.BeginPostObject(invServer + "/GetInventory/", userID.Guid, session_id.ToString(), userID.ToString());
97 97
98 //Test(userID.Guid); 98 //Test(userID.Guid);
99 99
100 //RestObjectPosterResponse<InventoryCollection> requester 100 //RestObjectPosterResponse<InventoryCollection> requester
101 // = new RestObjectPosterResponse<InventoryCollection>(); 101 // = new RestObjectPosterResponse<InventoryCollection>();
102 //requester.ResponseCallback = InventoryResponse; 102 //requester.ResponseCallback = InventoryResponse;
103 103
104 //requester.BeginPostObject<Guid>(/*_inventoryServerUrl*/ invServer + "/GetInventory/", userID.Guid); 104 //requester.BeginPostObject<Guid>(/*_inventoryServerUrl*/ invServer + "/GetInventory/", userID.Guid);
105 105
106 //RestClient cli = new RestClient(invServer + "/GetInventory/" + userID.Guid); 106 //RestClient cli = new RestClient(invServer + "/GetInventory/" + userID.Guid);
107 //Stream reply = cli.Request(); 107 //Stream reply = cli.Request();
108 } 108 }
109 catch (WebException e) 109 catch (WebException e)
110 { 110 {
111 if (StatsManager.SimExtraStats != null) 111 if (StatsManager.SimExtraStats != null)
112 StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure(); 112 StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();
113 113
114 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Request inventory operation failed, {0} {1}", 114 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Request inventory operation failed, {0} {1}",
115 e.Source, e.Message); 115 e.Source, e.Message);
116 } 116 }
117 } 117 }
118 else 118 else
119 { 119 {
120 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: RequestInventoryForUser() - could not find user profile for {0}", userID); 120 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: RequestInventoryForUser() - could not find user profile for {0}", userID);
121 } 121 }
122 122
123 } 123 }
124 124
125 /// <summary> 125 /// <summary>
126 /// Add a new folder to the user's inventory 126 /// Add a new folder to the user's inventory
127 /// </summary> 127 /// </summary>
128 /// <param name="folder"></param> 128 /// <param name="folder"></param>
129 /// <returns>true if the folder was successfully added</returns> 129 /// <returns>true if the folder was successfully added</returns>
130 public bool AddFolder(InventoryFolderBase folder, UUID session_id) 130 public bool AddFolder(InventoryFolderBase folder, UUID session_id)
131 { 131 {
132 if (IsLocalStandaloneUser(folder.Owner)) 132 if (IsLocalStandaloneUser(folder.Owner))
133 { 133 {
134 return base.AddFolder(folder); 134 return base.AddFolder(folder);
135 } 135 }
136 136
137 try 137 try
138 { 138 {
139 string invServ = GetUserInventoryURI(folder.Owner); 139 string invServ = GetUserInventoryURI(folder.Owner);
140 140
141 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject( 141 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
142 "POST", invServ + "/NewFolder/", folder, session_id.ToString(), folder.Owner.ToString()); 142 "POST", invServ + "/NewFolder/", folder, session_id.ToString(), folder.Owner.ToString());
143 } 143 }
144 catch (WebException e) 144 catch (WebException e)
145 { 145 {
146 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Add new inventory folder operation failed, {0} {1}", 146 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Add new inventory folder operation failed, {0} {1}",
147 e.Source, e.Message); 147 e.Source, e.Message);
148 } 148 }
149 149
150 return false; 150 return false;
151 151
152 } 152 }
153 153
154 /// <summary> 154 /// <summary>
155 /// Update a folder in the user's inventory 155 /// Update a folder in the user's inventory
156 /// </summary> 156 /// </summary>
157 /// <param name="folder"></param> 157 /// <param name="folder"></param>
158 /// <returns>true if the folder was successfully updated</returns> 158 /// <returns>true if the folder was successfully updated</returns>
159 public bool UpdateFolder(InventoryFolderBase folder, UUID session_id) 159 public bool UpdateFolder(InventoryFolderBase folder, UUID session_id)
160 { 160 {
161 if (IsLocalStandaloneUser(folder.Owner)) 161 if (IsLocalStandaloneUser(folder.Owner))
162 { 162 {
163 return base.UpdateFolder(folder); 163 return base.UpdateFolder(folder);
164 } 164 }
165 try 165 try
166 { 166 {
167 string invServ = GetUserInventoryURI(folder.Owner); 167 string invServ = GetUserInventoryURI(folder.Owner);
168 168
169 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject( 169 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
170 "POST", invServ + "/UpdateFolder/", folder, session_id.ToString(), folder.Owner.ToString()); 170 "POST", invServ + "/UpdateFolder/", folder, session_id.ToString(), folder.Owner.ToString());
171 } 171 }
172 catch (WebException e) 172 catch (WebException e)
173 { 173 {
174 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Update inventory folder operation failed, {0} {1}", 174 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Update inventory folder operation failed, {0} {1}",
175 e.Source, e.Message); 175 e.Source, e.Message);
176 } 176 }
177 177
178 return false; 178 return false;
179 179
180 } 180 }
181 181
182 /// <summary> 182 /// <summary>
183 /// Move an inventory folder to a new location 183 /// Move an inventory folder to a new location
184 /// </summary> 184 /// </summary>
185 /// <param name="folder">A folder containing the details of the new location</param> 185 /// <param name="folder">A folder containing the details of the new location</param>
186 /// <returns>true if the folder was successfully moved</returns> 186 /// <returns>true if the folder was successfully moved</returns>
187 public bool MoveFolder(InventoryFolderBase folder, UUID session_id) 187 public bool MoveFolder(InventoryFolderBase folder, UUID session_id)
188 { 188 {
189 if (IsLocalStandaloneUser(folder.Owner)) 189 if (IsLocalStandaloneUser(folder.Owner))
190 { 190 {
191 return base.MoveFolder(folder); 191 return base.MoveFolder(folder);
192 } 192 }
193 193
194 try 194 try
195 { 195 {
196 string invServ = GetUserInventoryURI(folder.Owner); 196 string invServ = GetUserInventoryURI(folder.Owner);
197 197
198 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject( 198 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
199 "POST", invServ + "/MoveFolder/", folder, session_id.ToString(), folder.Owner.ToString()); 199 "POST", invServ + "/MoveFolder/", folder, session_id.ToString(), folder.Owner.ToString());
200 } 200 }
201 catch (WebException e) 201 catch (WebException e)
202 { 202 {
203 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}", 203 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
204 e.Source, e.Message); 204 e.Source, e.Message);
205 } 205 }
206 206
207 return false; 207 return false;
208 } 208 }
209 209
210 /// <summary> 210 /// <summary>
211 /// Purge an inventory folder of all its items and subfolders. 211 /// Purge an inventory folder of all its items and subfolders.
212 /// </summary> 212 /// </summary>
213 /// <param name="folder"></param> 213 /// <param name="folder"></param>
214 /// <returns>true if the folder was successfully purged</returns> 214 /// <returns>true if the folder was successfully purged</returns>
215 public bool PurgeFolder(InventoryFolderBase folder, UUID session_id) 215 public bool PurgeFolder(InventoryFolderBase folder, UUID session_id)
216 { 216 {
217 if (IsLocalStandaloneUser(folder.Owner)) 217 if (IsLocalStandaloneUser(folder.Owner))
218 { 218 {
219 return base.PurgeFolder(folder); 219 return base.PurgeFolder(folder);
220 } 220 }
221 221
222 try 222 try
223 { 223 {
224 string invServ = GetUserInventoryURI(folder.Owner); 224 string invServ = GetUserInventoryURI(folder.Owner);
225 225
226 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject( 226 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
227 "POST", invServ + "/PurgeFolder/", folder, session_id.ToString(), folder.Owner.ToString()); 227 "POST", invServ + "/PurgeFolder/", folder, session_id.ToString(), folder.Owner.ToString());
228 } 228 }
229 catch (WebException e) 229 catch (WebException e)
230 { 230 {
231 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}", 231 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
232 e.Source, e.Message); 232 e.Source, e.Message);
233 } 233 }
234 234
235 return false; 235 return false;
236 } 236 }
237 237
238 /// <summary> 238 /// <summary>
239 /// Add a new item to the user's inventory 239 /// Add a new item to the user's inventory
240 /// </summary> 240 /// </summary>
241 /// <param name="item"></param> 241 /// <param name="item"></param>
242 /// <returns>true if the item was successfully added</returns> 242 /// <returns>true if the item was successfully added</returns>
243 public bool AddItem(InventoryItemBase item, UUID session_id) 243 public bool AddItem(InventoryItemBase item, UUID session_id)
244 { 244 {
245 if (IsLocalStandaloneUser(item.Owner)) 245 if (IsLocalStandaloneUser(item.Owner))
246 { 246 {
247 return base.AddItem(item); 247 return base.AddItem(item);
248 } 248 }
249 249
250 try 250 try
251 { 251 {
252 string invServ = GetUserInventoryURI(item.Owner); 252 string invServ = GetUserInventoryURI(item.Owner);
253 253
254 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject( 254 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
255 "POST", invServ + "/NewItem/", item, session_id.ToString(), item.Owner.ToString()); 255 "POST", invServ + "/NewItem/", item, session_id.ToString(), item.Owner.ToString());
256 } 256 }
257 catch (WebException e) 257 catch (WebException e)
258 { 258 {
259 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Add new inventory item operation failed, {0} {1}", 259 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Add new inventory item operation failed, {0} {1}",
260 e.Source, e.Message); 260 e.Source, e.Message);
261 } 261 }
262 262
263 return false; 263 return false;
264 } 264 }
265 265
266 /// <summary> 266 /// <summary>
267 /// Update an item in the user's inventory 267 /// Update an item in the user's inventory
268 /// </summary> 268 /// </summary>
269 /// <param name="item"></param> 269 /// <param name="item"></param>
270 /// <returns>true if the item was successfully updated</returns> 270 /// <returns>true if the item was successfully updated</returns>
271 public bool UpdateItem(InventoryItemBase item, UUID session_id) 271 public bool UpdateItem(InventoryItemBase item, UUID session_id)
272 { 272 {
273 if (IsLocalStandaloneUser(item.Owner)) 273 if (IsLocalStandaloneUser(item.Owner))
274 { 274 {
275 return base.UpdateItem(item); 275 return base.UpdateItem(item);
276 } 276 }
277 277
278 try 278 try
279 { 279 {
280 string invServ = GetUserInventoryURI(item.Owner); 280 string invServ = GetUserInventoryURI(item.Owner);
281 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject( 281 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
282 "POST", invServ + "/NewItem/", item, session_id.ToString(), item.Owner.ToString()); 282 "POST", invServ + "/NewItem/", item, session_id.ToString(), item.Owner.ToString());
283 } 283 }
284 catch (WebException e) 284 catch (WebException e)
285 { 285 {
286 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Update new inventory item operation failed, {0} {1}", 286 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Update new inventory item operation failed, {0} {1}",
287 e.Source, e.Message); 287 e.Source, e.Message);
288 } 288 }
289 289
290 return false; 290 return false;
291 } 291 }
292 292
293 /// <summary> 293 /// <summary>
294 /// Delete an item from the user's inventory 294 /// Delete an item from the user's inventory
295 /// </summary> 295 /// </summary>
296 /// <param name="item"></param> 296 /// <param name="item"></param>
297 /// <returns>true if the item was successfully deleted</returns> 297 /// <returns>true if the item was successfully deleted</returns>
298 public bool DeleteItem(InventoryItemBase item, UUID session_id) 298 public bool DeleteItem(InventoryItemBase item, UUID session_id)
299 { 299 {
300 if (IsLocalStandaloneUser(item.Owner)) 300 if (IsLocalStandaloneUser(item.Owner))
301 { 301 {
302 return base.DeleteItem(item); 302 return base.DeleteItem(item);
303 } 303 }
304 304
305 try 305 try
306 { 306 {
307 string invServ = GetUserInventoryURI(item.Owner); 307 string invServ = GetUserInventoryURI(item.Owner);
308 308
309 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject( 309 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
310 "POST", invServ + "/DeleteItem/", item, session_id.ToString(), item.Owner.ToString()); 310 "POST", invServ + "/DeleteItem/", item, session_id.ToString(), item.Owner.ToString());
311 } 311 }
312 catch (WebException e) 312 catch (WebException e)
313 { 313 {
314 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Delete inventory item operation failed, {0} {1}", 314 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Delete inventory item operation failed, {0} {1}",
315 e.Source, e.Message); 315 e.Source, e.Message);
316 } 316 }
317 317
318 return false; 318 return false;
319 } 319 }
320 #endregion 320 #endregion
321 321
322 #region Methods common to ISecureInventoryService and IInventoryService 322 #region Methods common to ISecureInventoryService and IInventoryService
323 323
324 /// <summary> 324 /// <summary>
325 /// Does the given user have an inventory structure? 325 /// Does the given user have an inventory structure?
326 /// </summary> 326 /// </summary>
327 /// <param name="userID"></param> 327 /// <param name="userID"></param>
328 /// <returns></returns> 328 /// <returns></returns>
329 public override bool HasInventoryForUser(UUID userID) 329 public override bool HasInventoryForUser(UUID userID)
330 { 330 {
331 if (IsLocalStandaloneUser(userID)) 331 if (IsLocalStandaloneUser(userID))
332 { 332 {
333 return base.HasInventoryForUser(userID); 333 return base.HasInventoryForUser(userID);
334 } 334 }
335 return false; 335 return false;
336 } 336 }
337 337
338 /// <summary> 338 /// <summary>
339 /// Retrieve the root inventory folder for the given user. 339 /// Retrieve the root inventory folder for the given user.
340 /// </summary> 340 /// </summary>
341 /// <param name="userID"></param> 341 /// <param name="userID"></param>
342 /// <returns>null if no root folder was found</returns> 342 /// <returns>null if no root folder was found</returns>
343 public override InventoryFolderBase RequestRootFolder(UUID userID) 343 public override InventoryFolderBase RequestRootFolder(UUID userID)
344 { 344 {
345 if (IsLocalStandaloneUser(userID)) 345 if (IsLocalStandaloneUser(userID))
346 { 346 {
347 return base.RequestRootFolder(userID); 347 return base.RequestRootFolder(userID);
348 } 348 }
349 349
350 return null; 350 return null;
351 } 351 }
352 352
353 #endregion 353 #endregion
354 354
355 355
356 /// <summary> 356 /// <summary>
357 /// Callback used by the inventory server GetInventory request 357 /// Callback used by the inventory server GetInventory request
358 /// </summary> 358 /// </summary>
359 /// <param name="userID"></param> 359 /// <param name="userID"></param>
360 private void InventoryResponse(InventoryCollection response) 360 private void InventoryResponse(InventoryCollection response)
361 { 361 {
362 UUID userID = response.UserID; 362 UUID userID = response.UserID;
363 if (m_RequestingInventory.ContainsKey(userID)) 363 if (m_RequestingInventory.ContainsKey(userID))
364 { 364 {
365 m_log.InfoFormat("[HGrid INVENTORY SERVICE]: " + 365 m_log.InfoFormat("[HGrid INVENTORY SERVICE]: " +
366 "Received inventory response for user {0} containing {1} folders and {2} items", 366 "Received inventory response for user {0} containing {1} folders and {2} items",
367 userID, response.Folders.Count, response.Items.Count); 367 userID, response.Folders.Count, response.Items.Count);
368 368
369 InventoryFolderImpl rootFolder = null; 369 InventoryFolderImpl rootFolder = null;
370 InventoryReceiptCallback callback = m_RequestingInventory[userID]; 370 InventoryReceiptCallback callback = m_RequestingInventory[userID];
371 371
372 ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); 372 ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
373 ICollection<InventoryItemBase> items = new List<InventoryItemBase>(); 373 ICollection<InventoryItemBase> items = new List<InventoryItemBase>();
374 374
375 foreach (InventoryFolderBase folder in response.Folders) 375 foreach (InventoryFolderBase folder in response.Folders)
376 { 376 {
377 if (folder.ParentID == UUID.Zero) 377 if (folder.ParentID == UUID.Zero)
378 { 378 {
379 rootFolder = new InventoryFolderImpl(folder); 379 rootFolder = new InventoryFolderImpl(folder);
380 folders.Add(rootFolder); 380 folders.Add(rootFolder);
381 381
382 break; 382 break;
383 } 383 }
384 } 384 }
385 385
386 if (rootFolder != null) 386 if (rootFolder != null)
387 { 387 {
388 foreach (InventoryFolderBase folder in response.Folders) 388 foreach (InventoryFolderBase folder in response.Folders)
389 { 389 {
390 if (folder.ID != rootFolder.ID) 390 if (folder.ID != rootFolder.ID)
391 { 391 {
392 folders.Add(new InventoryFolderImpl(folder)); 392 folders.Add(new InventoryFolderImpl(folder));
393 } 393 }
394 } 394 }
395 395
396 foreach (InventoryItemBase item in response.Items) 396 foreach (InventoryItemBase item in response.Items)
397 { 397 {
398 items.Add(item); 398 items.Add(item);
399 } 399 }
400 } 400 }
401 else 401 else
402 { 402 {
403 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Did not get back an inventory containing a root folder for user {0}", userID); 403 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Did not get back an inventory containing a root folder for user {0}", userID);
404 } 404 }
405 405
406 callback(folders, items); 406 callback(folders, items);
407 407
408 m_RequestingInventory.Remove(userID); 408 m_RequestingInventory.Remove(userID);
409 } 409 }
410 else 410 else
411 { 411 {
412 m_log.WarnFormat( 412 m_log.WarnFormat(
413 "[HGrid INVENTORY SERVICE]: " + 413 "[HGrid INVENTORY SERVICE]: " +
414 "Received inventory response for {0} for which we do not have a record of requesting!", 414 "Received inventory response for {0} for which we do not have a record of requesting!",
415 userID); 415 userID);
416 } 416 }
417 } 417 }
418 418
419 419
420 private bool IsLocalStandaloneUser(UUID userID) 420 private bool IsLocalStandaloneUser(UUID userID)
421 { 421 {
422 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userID); 422 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userID);
423 if (uinfo == null) 423 if (uinfo == null)
424 return true; 424 return true;
425 425
426 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 426 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI);
427 427
428 if ((!m_gridmode) && ((userInventoryServerURI == _inventoryServerUrl)) || (userInventoryServerURI == "")) 428 if ((!m_gridmode) && ((userInventoryServerURI == _inventoryServerUrl)) || (userInventoryServerURI == ""))
429 { 429 {
430 return true; 430 return true;
431 } 431 }
432 return false; 432 return false;
433 } 433 }
434 434
435 private string GetUserInventoryURI(UUID userID) 435 private string GetUserInventoryURI(UUID userID)
436 { 436 {
437 string invURI = _inventoryServerUrl; 437 string invURI = _inventoryServerUrl;
438 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userID); 438 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userID);
439 if ((uinfo == null) || (uinfo.UserProfile == null)) 439 if ((uinfo == null) || (uinfo.UserProfile == null))
440 return invURI; 440 return invURI;
441 441
442 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 442 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI);
443 443
444 if ((userInventoryServerURI != null) && 444 if ((userInventoryServerURI != null) &&
445 (userInventoryServerURI != "")) 445 (userInventoryServerURI != ""))
446 invURI = userInventoryServerURI; 446 invURI = userInventoryServerURI;
447 return invURI; 447 return invURI;
448 } 448 }
449 449
450 } 450 }
451} 451}