diff options
author | Mike Mazur | 2009-03-05 08:30:00 +0000 |
---|---|---|
committer | Mike Mazur | 2009-03-05 08:30:00 +0000 |
commit | 293e70a66612a84a59d84f5764b609c4e613422b (patch) | |
tree | 5a9798130c000dce6179b05b7b5d37b1c9488142 /OpenSim/Grid | |
parent | Use Inventory{Item,Folder}Base in AssetInventoryServer. (diff) | |
download | opensim-SC-293e70a66612a84a59d84f5764b609c4e613422b.zip opensim-SC-293e70a66612a84a59d84f5764b609c4e613422b.tar.gz opensim-SC-293e70a66612a84a59d84f5764b609c4e613422b.tar.bz2 opensim-SC-293e70a66612a84a59d84f5764b609c4e613422b.tar.xz |
Implementing more inventory storage methods.
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs | 23 | ||||
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs | 425 |
2 files changed, 134 insertions, 314 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs index d742d25..ca995b3 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs | |||
@@ -36,11 +36,30 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
36 | { | 36 | { |
37 | public override void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback) {} | 37 | public override void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback) {} |
38 | 38 | ||
39 | public InventoryFolderBase GetInventoryFolder(UUID folderID) | 39 | public InventoryFolderWithChildren GetInventoryFolder(UUID folderID) |
40 | { | ||
41 | InventoryFolderBase baseFolder = null; | ||
42 | InventoryFolderWithChildren folder = null; | ||
43 | |||
44 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
45 | { | ||
46 | baseFolder = plugin.getInventoryFolder(folderID); | ||
47 | } | ||
48 | |||
49 | if (null != baseFolder) | ||
50 | { | ||
51 | folder = (InventoryFolderWithChildren) baseFolder; | ||
52 | folder.Children = null; // This call only returns data for the folder itself, no children data | ||
53 | } | ||
54 | |||
55 | return folder; | ||
56 | } | ||
57 | |||
58 | public InventoryItemBase GetInventoryItem(UUID itemID) | ||
40 | { | 59 | { |
41 | foreach (IInventoryDataPlugin plugin in m_plugins) | 60 | foreach (IInventoryDataPlugin plugin in m_plugins) |
42 | { | 61 | { |
43 | return plugin.getInventoryFolder(folderID); | 62 | return plugin.getInventoryItem(itemID); |
44 | } | 63 | } |
45 | 64 | ||
46 | return null; | 65 | return null; |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs index 851cc4a..e53462e 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs | |||
@@ -120,50 +120,14 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
120 | 120 | ||
121 | public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder) | 121 | public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder) |
122 | { | 122 | { |
123 | folder = null; | 123 | BackendResponse ret; |
124 | //BackendResponse ret; | ||
125 | |||
126 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
127 | //{ | ||
128 | // IDataReader reader; | ||
129 | |||
130 | // try | ||
131 | // { | ||
132 | // dbConnection.Open(); | ||
133 | |||
134 | // IDbCommand command = dbConnection.CreateCommand(); | ||
135 | // command.CommandText = String.Format("SELECT folderName,type,version,agentID,parentFolderID FROM inventoryfolders WHERE folderID='{0}'", | ||
136 | // folderID.ToString()); | ||
137 | // reader = command.ExecuteReader(); | ||
138 | |||
139 | // if (reader.Read()) | ||
140 | // { | ||
141 | // folder = new InventoryFolderWithChildren(); | ||
142 | // folder.Children = null; // This call only returns data for the folder itself, no children data | ||
143 | // folder.ID = folderID; | ||
144 | // folder.Name = reader.GetString(0); | ||
145 | // folder.Type = reader.GetInt16(1); | ||
146 | // folder.Version = (ushort)reader.GetInt16(2); | ||
147 | // folder.Owner = UUID.Parse(reader.GetString(3)); | ||
148 | // folder.ParentID = UUID.Parse(reader.GetString(4)); | ||
149 | 124 | ||
150 | // ret = BackendResponse.Success; | 125 | // TODO: implement some logic for "folder not found" |
151 | // } | 126 | folder = m_inventoryService.GetInventoryFolder(folderID); |
152 | // else | 127 | ret = BackendResponse.Success; |
153 | // { | ||
154 | // ret = BackendResponse.NotFound; | ||
155 | // } | ||
156 | // } | ||
157 | // catch (MySqlException ex) | ||
158 | // { | ||
159 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
160 | // ret = BackendResponse.Failure; | ||
161 | // } | ||
162 | //} | ||
163 | 128 | ||
164 | //m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); | 129 | m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); |
165 | //return ret; | 130 | return ret; |
166 | return BackendResponse.Success; | ||
167 | } | 131 | } |
168 | 132 | ||
169 | public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents) | 133 | public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents) |
@@ -268,211 +232,91 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
268 | public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders) | 232 | public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders) |
269 | { | 233 | { |
270 | folders = null; | 234 | folders = null; |
271 | //BackendResponse ret; | 235 | BackendResponse ret; |
272 | //UUID ownerID; | 236 | UUID ownerID; |
273 | |||
274 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
275 | //{ | ||
276 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
277 | // { | ||
278 | // IDataReader reader; | ||
279 | |||
280 | // try | ||
281 | // { | ||
282 | // dbConnection.Open(); | ||
283 | // folders = new List<InventoryFolderWithChildren>(); | ||
284 | |||
285 | // IDbCommand command = dbConnection.CreateCommand(); | ||
286 | // command.CommandText = String.Format("SELECT folderName,type,version,folderID,parentFolderID FROM inventoryfolders WHERE agentID='{0}'", | ||
287 | // ownerID.ToString()); | ||
288 | // reader = command.ExecuteReader(); | ||
289 | 237 | ||
290 | // while (reader.Read()) | 238 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
291 | // { | 239 | { |
292 | // InventoryFolderWithChildren folder = new InventoryFolderWithChildren(); | 240 | foreach (InventoryFolderWithChildren baseFolder in m_inventoryService.GetInventorySkeleton(ownerID)) |
293 | // folder.Owner = ownerID; | 241 | { |
294 | // folder.Children = null; // This call does not create a folder hierarchy | 242 | InventoryFolderWithChildren folder = (InventoryFolderWithChildren) baseFolder; |
295 | // folder.Name = reader.GetString(0); | 243 | folder.Children = null; // This call does not create a folder hierarchy |
296 | // folder.Type = reader.GetInt16(1); | 244 | folders.Add(folder); |
297 | // folder.Version = (ushort)reader.GetInt16(2); | 245 | } |
298 | // folder.ID = UUID.Parse(reader.GetString(3)); | ||
299 | // folder.ParentID = UUID.Parse(reader.GetString(4)); | ||
300 | |||
301 | // folders.Add(folder); | ||
302 | // } | ||
303 | 246 | ||
304 | // ret = BackendResponse.Success; | 247 | ret = BackendResponse.Success; |
305 | // } | 248 | } |
306 | // catch (MySqlException ex) | 249 | else |
307 | // { | 250 | { |
308 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | 251 | ret = BackendResponse.NotFound; |
309 | // ret = BackendResponse.Failure; | 252 | } |
310 | // } | ||
311 | // } | ||
312 | //} | ||
313 | //else | ||
314 | //{ | ||
315 | // ret = BackendResponse.NotFound; | ||
316 | //} | ||
317 | 253 | ||
318 | //m_server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now); | 254 | m_server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now); |
319 | //return ret; | 255 | return ret; |
320 | return BackendResponse.Success; | ||
321 | } | 256 | } |
322 | 257 | ||
323 | public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory) | 258 | public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory) |
324 | { | 259 | { |
325 | inventory = null; | 260 | inventory = null; |
326 | //BackendResponse ret; | 261 | BackendResponse ret; |
327 | //List<InventoryFolderWithChildren> folders; | 262 | List<InventoryFolderWithChildren> folders; |
328 | //UUID ownerID; | ||
329 | 263 | ||
330 | //ret = TryFetchFolderList(owner, out folders); | 264 | ret = TryFetchFolderList(owner, out folders); |
331 | 265 | ||
332 | //if (ret == BackendResponse.Success) | 266 | if (ret == BackendResponse.Success) |
333 | //{ | 267 | { |
334 | // // Add the retrieved folders to the inventory collection | 268 | // Add the retrieved folders to the inventory collection |
335 | // inventory = new InventoryCollection(); | 269 | inventory = new InventoryCollection(); |
336 | // inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(folders.Count); | 270 | inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(folders.Count); |
337 | // foreach (InventoryFolderWithChildren folder in folders) | 271 | foreach (InventoryFolderWithChildren folder in folders) |
338 | // inventory.Folders[folder.ID] = folder; | 272 | inventory.Folders[folder.ID] = folder; |
339 | 273 | ||
340 | // // Fetch inventory items | 274 | // Fetch inventory items |
341 | // if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | 275 | UUID ownerID; |
342 | // { | 276 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
343 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 277 | { |
344 | // { | 278 | inventory.UserID = ownerID; |
345 | // IDataReader reader; | 279 | inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(); |
346 | 280 | ||
347 | // try | 281 | foreach (InventoryFolderWithChildren folder in folders) |
348 | // { | 282 | { |
349 | // dbConnection.Open(); | 283 | foreach (InventoryItemBase item in m_inventoryService.RequestFolderItems(folder.ID)) |
350 | 284 | { | |
351 | // IDbCommand command = dbConnection.CreateCommand(); | 285 | inventory.Items.Add(item.ID, item); |
352 | // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + | 286 | } |
353 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | 287 | } |
354 | // "creationDate,groupID,groupOwned,flags,inventoryID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE " + | ||
355 | // "avatarID='{0}'", ownerID.ToString()); | ||
356 | // reader = command.ExecuteReader(); | ||
357 | |||
358 | // inventory.UserID = ownerID; | ||
359 | // inventory.Items = new Dictionary<UUID, InventoryItemBase>(); | ||
360 | |||
361 | // while (reader.Read()) | ||
362 | // { | ||
363 | // InventoryItemBase item = new InventoryItemBase(); | ||
364 | // item.Owner = ownerID; | ||
365 | // item.AssetID = UUID.Parse(reader.GetString(0)); | ||
366 | // item.AssetType = reader.GetInt32(1); | ||
367 | // item.Name = reader.GetString(2); | ||
368 | // item.Description = reader.GetString(3); | ||
369 | // item.NextPermissions = (uint)reader.GetInt32(4); | ||
370 | // item.CurrentPermissions = (uint)reader.GetInt32(5); | ||
371 | // item.InvType = reader.GetInt32(6); | ||
372 | // item.Creator = UUID.Parse(reader.GetString(7)); | ||
373 | // item.BasePermissions = (uint)reader.GetInt32(8); | ||
374 | // item.EveryOnePermissions = (uint)reader.GetInt32(9); | ||
375 | // item.SalePrice = reader.GetInt32(10); | ||
376 | // item.SaleType = reader.GetByte(11); | ||
377 | // item.CreationDate = reader.GetInt32(12); | ||
378 | // item.GroupID = UUID.Parse(reader.GetString(13)); | ||
379 | // item.GroupOwned = reader.GetBoolean(14); | ||
380 | // item.Flags = (uint)reader.GetInt32(15); | ||
381 | // item.ID = UUID.Parse(reader.GetString(16)); | ||
382 | // item.Folder = UUID.Parse(reader.GetString(17)); | ||
383 | // item.GroupPermissions = (uint)reader.GetInt32(18); | ||
384 | |||
385 | // inventory.Items.Add(item.ID, item); | ||
386 | // } | ||
387 | 288 | ||
388 | // ret = BackendResponse.Success; | 289 | ret = BackendResponse.Success; |
389 | // } | ||
390 | // catch (MySqlException ex) | ||
391 | // { | ||
392 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
393 | // ret = BackendResponse.Failure; | ||
394 | // } | ||
395 | // } | ||
396 | // } | ||
397 | // else | ||
398 | // { | ||
399 | // ret = BackendResponse.NotFound; | ||
400 | // } | ||
401 | //} | ||
402 | 290 | ||
403 | //m_server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now); | 291 | } |
404 | //return ret; | 292 | else |
405 | return BackendResponse.Success; | 293 | { |
294 | ret = BackendResponse.NotFound; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | m_server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now); | ||
299 | return ret; | ||
406 | } | 300 | } |
407 | 301 | ||
408 | public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures) | 302 | public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures) |
409 | { | 303 | { |
410 | gestures = null; | 304 | gestures = null; |
411 | //BackendResponse ret; | 305 | BackendResponse ret; |
412 | //UUID ownerID; | 306 | UUID ownerID; |
413 | |||
414 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
415 | //{ | ||
416 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
417 | // { | ||
418 | // IDataReader reader; | ||
419 | |||
420 | // try | ||
421 | // { | ||
422 | // dbConnection.Open(); | ||
423 | |||
424 | // MySqlCommand command = new MySqlCommand("SELECT assetID,inventoryName,inventoryDescription,inventoryNextPermissions," + | ||
425 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | ||
426 | // "creationDate,groupID,groupOwned,inventoryID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE " + | ||
427 | // "avatarId=?uuid AND assetType=?type AND flags=1", dbConnection); | ||
428 | // command.Parameters.AddWithValue("?uuid", ownerID.ToString()); | ||
429 | // command.Parameters.AddWithValue("?type", (int)AssetType.Gesture); | ||
430 | // reader = command.ExecuteReader(); | ||
431 | |||
432 | // while (reader.Read()) | ||
433 | // { | ||
434 | // InventoryItemBase item = new InventoryItemBase(); | ||
435 | // item.Owner = ownerID; | ||
436 | // item.AssetType = (int)AssetType.Gesture; | ||
437 | // item.Flags = (uint)1; | ||
438 | // item.AssetID = UUID.Parse(reader.GetString(0)); | ||
439 | // item.Name = reader.GetString(1); | ||
440 | // item.Description = reader.GetString(2); | ||
441 | // item.NextPermissions = (uint)reader.GetInt32(3); | ||
442 | // item.CurrentPermissions = (uint)reader.GetInt32(4); | ||
443 | // item.InvType = reader.GetInt32(5); | ||
444 | // item.Creator = UUID.Parse(reader.GetString(6)); | ||
445 | // item.BasePermissions = (uint)reader.GetInt32(7); | ||
446 | // item.EveryOnePermissions = (uint)reader.GetInt32(8); | ||
447 | // item.SalePrice = reader.GetInt32(9); | ||
448 | // item.SaleType = reader.GetByte(10); | ||
449 | // item.CreationDate = reader.GetInt32(11); | ||
450 | // item.GroupID = UUID.Parse(reader.GetString(12)); | ||
451 | // item.GroupOwned = reader.GetBoolean(13); | ||
452 | // item.ID = UUID.Parse(reader.GetString(14)); | ||
453 | // item.Folder = UUID.Parse(reader.GetString(15)); | ||
454 | // item.GroupPermissions = (uint)reader.GetInt32(16); | ||
455 | |||
456 | // gestures.Add(item); | ||
457 | // } | ||
458 | 307 | ||
459 | // ret = BackendResponse.Success; | 308 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
460 | // } | 309 | { |
461 | // catch (MySqlException ex) | 310 | gestures = m_inventoryService.GetActiveGestures(ownerID); |
462 | // { | 311 | ret = BackendResponse.Success; |
463 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | 312 | } |
464 | // ret = BackendResponse.Failure; | 313 | else |
465 | // } | 314 | { |
466 | // } | 315 | ret = BackendResponse.NotFound; |
467 | //} | 316 | } |
468 | //else | ||
469 | //{ | ||
470 | // ret = BackendResponse.NotFound; | ||
471 | //} | ||
472 | 317 | ||
473 | //m_server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now); | 318 | m_server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now); |
474 | //return ret; | 319 | return ret; |
475 | return BackendResponse.Success; | ||
476 | } | 320 | } |
477 | 321 | ||
478 | public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item) | 322 | public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item) |
@@ -494,103 +338,60 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
494 | 338 | ||
495 | public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder) | 339 | public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder) |
496 | { | 340 | { |
497 | //BackendResponse ret; | 341 | BackendResponse ret; |
498 | |||
499 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
500 | //{ | ||
501 | // try | ||
502 | // { | ||
503 | // dbConnection.Open(); | ||
504 | |||
505 | // MySqlCommand command = new MySqlCommand( | ||
506 | // "REPLACE INTO inventoryfolders (folderName,type,version,folderID,agentID,parentFolderID) VALUES " + | ||
507 | // "(?folderName,?type,?version,?folderID,?agentID,?parentFolderID)", dbConnection); | ||
508 | |||
509 | // command.Parameters.AddWithValue("?folderName", folder.Name); | ||
510 | // command.Parameters.AddWithValue("?type", folder.Type); | ||
511 | // command.Parameters.AddWithValue("?version", folder.Version); | ||
512 | // command.Parameters.AddWithValue("?folderID", folder.ID); | ||
513 | // command.Parameters.AddWithValue("?agentID", folder.Owner); | ||
514 | // command.Parameters.AddWithValue("?parentFolderID", folder.ParentID); | ||
515 | 342 | ||
516 | // int rowsAffected = command.ExecuteNonQuery(); | 343 | if (m_inventoryService.AddFolder(folder)) |
517 | // if (rowsAffected == 1) | 344 | { |
518 | // { | 345 | ret = BackendResponse.Success; |
519 | // ret = BackendResponse.Success; | 346 | } |
520 | // } | 347 | else |
521 | // else if (rowsAffected == 2) | 348 | { |
522 | // { | 349 | ret = BackendResponse.Failure; |
523 | // m_log.Info("[OPENSIMINVENTORYSTORAGE]: Replaced inventory folder " + folder.ID.ToString()); | 350 | } |
524 | // ret = BackendResponse.Success; | ||
525 | // } | ||
526 | // else | ||
527 | // { | ||
528 | // m_log.ErrorFormat("[OPENSIMINVENTORYSTORAGE]: MySQL REPLACE query affected {0} rows", rowsAffected); | ||
529 | // ret = BackendResponse.Failure; | ||
530 | // } | ||
531 | // } | ||
532 | // catch (MySqlException ex) | ||
533 | // { | ||
534 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
535 | // ret = BackendResponse.Failure; | ||
536 | // } | ||
537 | //} | ||
538 | 351 | ||
539 | //m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now); | 352 | m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now); |
540 | //return ret; | 353 | return ret; |
541 | return BackendResponse.Success; | ||
542 | } | 354 | } |
543 | 355 | ||
544 | public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder) | 356 | public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder) |
545 | { | 357 | { |
546 | return TryCreateFolder(owner, rootFolder); | 358 | BackendResponse ret; |
359 | UUID ownerID; | ||
360 | |||
361 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
362 | { | ||
363 | if (m_inventoryService.CreateNewUserInventory(ownerID)) | ||
364 | { | ||
365 | ret = BackendResponse.Success; | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | ret = BackendResponse.Failure; | ||
370 | } | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | ret = BackendResponse.Failure; | ||
375 | } | ||
376 | |||
377 | return ret; | ||
547 | } | 378 | } |
548 | 379 | ||
549 | public BackendResponse TryDeleteItem(Uri owner, UUID itemID) | 380 | public BackendResponse TryDeleteItem(Uri owner, UUID itemID) |
550 | { | 381 | { |
551 | //BackendResponse ret; | 382 | BackendResponse ret; |
552 | //UUID ownerID; | ||
553 | |||
554 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
555 | //{ | ||
556 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
557 | // { | ||
558 | // try | ||
559 | // { | ||
560 | // dbConnection.Open(); | ||
561 | |||
562 | // MySqlCommand command = new MySqlCommand( | ||
563 | // "DELETE FROM inventoryitems WHERE inventoryID=?inventoryID AND avatarID=?avatarID", dbConnection); | ||
564 | |||
565 | // command.Parameters.AddWithValue("?inventoryID", itemID.ToString()); | ||
566 | // command.Parameters.AddWithValue("?avatarID", ownerID.ToString()); | ||
567 | 383 | ||
568 | // int rowsAffected = command.ExecuteNonQuery(); | 384 | if (m_inventoryService.DeleteItem(m_inventoryService.GetInventoryItem(itemID))) |
569 | // if (rowsAffected == 1) | 385 | { |
570 | // { | 386 | ret = BackendResponse.Success; |
571 | // ret = BackendResponse.Success; | 387 | } |
572 | // } | 388 | else |
573 | // else | 389 | { |
574 | // { | 390 | ret = BackendResponse.Failure; |
575 | // m_log.ErrorFormat("[OPENSIMINVENTORYSTORAGE]: MySQL DELETE query affected {0} rows", rowsAffected); | 391 | } |
576 | // ret = BackendResponse.NotFound; | ||
577 | // } | ||
578 | // } | ||
579 | // catch (MySqlException ex) | ||
580 | // { | ||
581 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
582 | // ret = BackendResponse.Failure; | ||
583 | // } | ||
584 | // } | ||
585 | //} | ||
586 | //else | ||
587 | //{ | ||
588 | // ret = BackendResponse.NotFound; | ||
589 | //} | ||
590 | 392 | ||
591 | //m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); | 393 | m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); |
592 | //return ret; | 394 | return ret; |
593 | return BackendResponse.Success; | ||
594 | } | 395 | } |
595 | 396 | ||
596 | public BackendResponse TryDeleteFolder(Uri owner, UUID folderID) | 397 | public BackendResponse TryDeleteFolder(Uri owner, UUID folderID) |