From fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Thu, 1 May 2008 16:41:01 +0000
Subject: * Cleaning code still.
---
.../Grid/InventoryServer/GridInventoryService.cs | 50 ++++++++---------
OpenSim/Grid/InventoryServer/InventoryManager.cs | 18 +++---
OpenSim/Grid/InventoryServer/Main.cs | 65 +++++++++++-----------
3 files changed, 70 insertions(+), 63 deletions(-)
(limited to 'OpenSim/Grid/InventoryServer')
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index db9a864..c3e3a28 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Grid.InventoryServer
///
public class GridInventoryService : InventoryServiceBase
{
- private static readonly ILog m_log
+ private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback)
@@ -55,7 +55,7 @@ namespace OpenSim.Grid.InventoryServer
///
/// true if the inventory was retrieved, false otherwise
private bool GetUsersInventory(LLUUID userID, out List folderList,
- out List itemsList)
+ out List itemsList)
{
List allFolders = GetInventorySkeleton(userID);
List allItems = new List();
@@ -109,28 +109,28 @@ namespace OpenSim.Grid.InventoryServer
{
// uncomment me to simulate an overloaded inventory server
//Thread.Sleep(20000);
-
+
LLUUID userID = new LLUUID(rawUserID);
- m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
+ m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
InventoryCollection invCollection = new InventoryCollection();
-
+
List allFolders = GetInventorySkeleton(userID);
-
+
if (null == allFolders)
{
m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID);
-
+
return invCollection;
}
-
+
List allItems = new List();
foreach (InventoryFolderBase folder in allFolders)
{
List items = RequestFolderItems(folder.ID);
-
+
if (items != null)
{
allItems.InsertRange(0, items);
@@ -138,9 +138,9 @@ namespace OpenSim.Grid.InventoryServer
}
invCollection.UserID = userID;
- invCollection.Folders = allFolders;
- invCollection.Items = allItems;
-
+ invCollection.Folders = allFolders;
+ invCollection.Items = allItems;
+
// foreach (InventoryFolderBase folder in invCollection.Folders)
// {
// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID);
@@ -150,14 +150,14 @@ namespace OpenSim.Grid.InventoryServer
// {
// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder);
// }
-
+
m_log.InfoFormat(
"[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items",
- invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count);
-
+ invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count);
+
return invCollection;
}
-
+
///
/// Guid to UUID wrapper for same name IInventoryServices method
///
@@ -166,10 +166,10 @@ namespace OpenSim.Grid.InventoryServer
public List GetInventorySkeleton(Guid rawUserID)
{
//Thread.Sleep(10000);
-
+
LLUUID userID = new LLUUID(rawUserID);
return GetInventorySkeleton(userID);
- }
+ }
///
/// Create an inventory for the given user.
@@ -196,11 +196,11 @@ namespace OpenSim.Grid.InventoryServer
{
MoveFolder(folder);
}
-
+
public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
- PurgeFolder(folder);
- }
+ PurgeFolder(folder);
+ }
public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
{
@@ -230,15 +230,15 @@ namespace OpenSim.Grid.InventoryServer
MoveExistingInventoryFolder(folder);
return true;
}
-
+
public bool PurgeInventoryFolder(InventoryFolderBase folder)
{
m_log.InfoFormat(
"[GRID AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID);
-
+
PurgeInventoryFolder(folder.Owner, folder);
return true;
- }
+ }
public bool AddInventoryItem(InventoryItemBase item)
{
@@ -267,4 +267,4 @@ namespace OpenSim.Grid.InventoryServer
return true;
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs
index 5c65317..350a618 100644
--- a/OpenSim/Grid/InventoryServer/InventoryManager.cs
+++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Grid.InventoryServer
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
- "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
+ "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
@@ -68,7 +68,7 @@ namespace OpenSim.Grid.InventoryServer
plug.Initialise(dbconnect);
_databasePlugin = plug;
m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
- "Invenstorage: Added IInventoryData Interface");
+ "Invenstorage: Added IInventoryData Interface");
break;
}
}
@@ -136,10 +136,12 @@ namespace OpenSim.Grid.InventoryServer
return fixupFolder(inventory.root, null);
}
+ #region Nested type: GetInventory
+
public class GetInventory : BaseStreamHandler
{
- private SerializableInventory _inventory;
- private InventoryManager _manager;
+ private readonly SerializableInventory _inventory;
+ private readonly InventoryManager _manager;
public GetInventory(InventoryManager manager)
: base("GET", "/inventory")
@@ -181,7 +183,7 @@ namespace OpenSim.Grid.InventoryServer
{
byte[] result = new byte[] {};
- string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
+ string[] parms = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if (parms.Length > 1)
{
if (string.Compare(parms[1], "library", true) == 0)
@@ -190,7 +192,7 @@ namespace OpenSim.Grid.InventoryServer
saveInventoryToStream(_inventory, ms);
result = ms.GetBuffer();
- Array.Resize(ref result, (int) ms.Length);
+ Array.Resize(ref result, (int) ms.Length);
}
else if (string.Compare(parms[1], "user", true) == 0)
{
@@ -203,5 +205,7 @@ namespace OpenSim.Grid.InventoryServer
return result;
}
}
+
+ #endregion
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 870997b..453d64d 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -40,13 +40,38 @@ namespace OpenSim.Grid.InventoryServer
{
public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback
{
+ public const string LogName = "INVENTORY";
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private InventoryManager m_inventoryManager;
private InventoryConfig m_config;
+ private InventoryManager m_inventoryManager;
private GridInventoryService m_inventoryService;
- public const string LogName = "INVENTORY";
+ public OpenInventory_Main()
+ {
+ m_console = new ConsoleBase(LogName, this);
+ MainConsole.Instance = m_console;
+ }
+
+ #region conscmd_callback Members
+
+ public override void RunCmd(string cmd, string[] cmdparams)
+ {
+ base.RunCmd(cmd, cmdparams);
+
+ switch (cmd)
+ {
+ case "add-user":
+ m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID);
+ break;
+ case "shutdown":
+ m_console.Close();
+ Environment.Exit(0);
+ break;
+ }
+ }
+
+ #endregion
[STAThread]
public static void Main(string[] args)
@@ -59,12 +84,6 @@ namespace OpenSim.Grid.InventoryServer
theServer.Work();
}
- public OpenInventory_Main()
- {
- m_console = new ConsoleBase(LogName, this);
- MainConsole.Instance = m_console;
- }
-
public void Startup()
{
m_log.Info("Initialising inventory manager...");
@@ -75,7 +94,7 @@ namespace OpenSim.Grid.InventoryServer
m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
m_log.Info("[" + LogName + "]: Starting HTTP server ...");
-
+
m_httpServer = new BaseHttpServer(m_config.HttpPort);
AddHttpHandlers();
m_httpServer.Start();
@@ -88,11 +107,11 @@ namespace OpenSim.Grid.InventoryServer
m_httpServer.AddStreamHandler(
new RestDeserialisehandler(
"POST", "/GetInventory/", m_inventoryService.GetUserInventory));
-
+
m_httpServer.AddStreamHandler(
new RestDeserialisehandler(
"POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory));
-
+
m_httpServer.AddStreamHandler(
new RestDeserialisehandler(
"POST", "/NewFolder/", m_inventoryService.AddInventoryFolder));
@@ -100,15 +119,15 @@ namespace OpenSim.Grid.InventoryServer
m_httpServer.AddStreamHandler(
new RestDeserialisehandler(
"POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder));
-
+
m_httpServer.AddStreamHandler(
new RestDeserialisehandler(
- "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder));
+ "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler(
"POST", "/NewItem/", m_inventoryService.AddInventoryItem));
-
+
m_httpServer.AddStreamHandler(
new RestDeserialisehandler(
"POST", "/DeleteItem/", m_inventoryService.DeleteInvItem));
@@ -134,21 +153,5 @@ namespace OpenSim.Grid.InventoryServer
m_console.Prompt();
}
}
-
- public override void RunCmd(string cmd, string[] cmdparams)
- {
- base.RunCmd(cmd, cmdparams);
-
- switch (cmd)
- {
- case "add-user":
- m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID);
- break;
- case "shutdown":
- m_console.Close();
- Environment.Exit(0);
- break;
- }
- }
}
-}
+}
\ No newline at end of file
--
cgit v1.1