diff options
author | Adam Frisby | 2008-05-01 16:41:01 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-01 16:41:01 +0000 |
commit | fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8 (patch) | |
tree | 90a4799fa43e3761ffbe669d1d87837933d8db53 /OpenSim/Grid/InventoryServer | |
parent | * Deletes my EventReader ScriptRewriter. It isn't required to rewrite the sc... (diff) | |
download | opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.zip opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.gz opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.bz2 opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.xz |
* Cleaning code still.
Diffstat (limited to 'OpenSim/Grid/InventoryServer')
-rw-r--r-- | OpenSim/Grid/InventoryServer/GridInventoryService.cs | 50 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryManager.cs | 18 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/Main.cs | 65 |
3 files changed, 70 insertions, 63 deletions
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 | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class GridInventoryService : InventoryServiceBase | 41 | public class GridInventoryService : InventoryServiceBase |
42 | { | 42 | { |
43 | private static readonly ILog m_log | 43 | private static readonly ILog m_log |
44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback) | 46 | public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback) |
@@ -55,7 +55,7 @@ namespace OpenSim.Grid.InventoryServer | |||
55 | /// <param name="itemsList"></param> | 55 | /// <param name="itemsList"></param> |
56 | /// <returns>true if the inventory was retrieved, false otherwise</returns> | 56 | /// <returns>true if the inventory was retrieved, false otherwise</returns> |
57 | private bool GetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, | 57 | private bool GetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, |
58 | out List<InventoryItemBase> itemsList) | 58 | out List<InventoryItemBase> itemsList) |
59 | { | 59 | { |
60 | List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); | 60 | List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); |
61 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | 61 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); |
@@ -109,28 +109,28 @@ namespace OpenSim.Grid.InventoryServer | |||
109 | { | 109 | { |
110 | // uncomment me to simulate an overloaded inventory server | 110 | // uncomment me to simulate an overloaded inventory server |
111 | //Thread.Sleep(20000); | 111 | //Thread.Sleep(20000); |
112 | 112 | ||
113 | LLUUID userID = new LLUUID(rawUserID); | 113 | LLUUID userID = new LLUUID(rawUserID); |
114 | 114 | ||
115 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); | 115 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); |
116 | 116 | ||
117 | InventoryCollection invCollection = new InventoryCollection(); | 117 | InventoryCollection invCollection = new InventoryCollection(); |
118 | 118 | ||
119 | List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); | 119 | List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); |
120 | 120 | ||
121 | if (null == allFolders) | 121 | if (null == allFolders) |
122 | { | 122 | { |
123 | m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID); | 123 | m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID); |
124 | 124 | ||
125 | return invCollection; | 125 | return invCollection; |
126 | } | 126 | } |
127 | 127 | ||
128 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | 128 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); |
129 | 129 | ||
130 | foreach (InventoryFolderBase folder in allFolders) | 130 | foreach (InventoryFolderBase folder in allFolders) |
131 | { | 131 | { |
132 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); | 132 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); |
133 | 133 | ||
134 | if (items != null) | 134 | if (items != null) |
135 | { | 135 | { |
136 | allItems.InsertRange(0, items); | 136 | allItems.InsertRange(0, items); |
@@ -138,9 +138,9 @@ namespace OpenSim.Grid.InventoryServer | |||
138 | } | 138 | } |
139 | 139 | ||
140 | invCollection.UserID = userID; | 140 | invCollection.UserID = userID; |
141 | invCollection.Folders = allFolders; | 141 | invCollection.Folders = allFolders; |
142 | invCollection.Items = allItems; | 142 | invCollection.Items = allItems; |
143 | 143 | ||
144 | // foreach (InventoryFolderBase folder in invCollection.Folders) | 144 | // foreach (InventoryFolderBase folder in invCollection.Folders) |
145 | // { | 145 | // { |
146 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); | 146 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); |
@@ -150,14 +150,14 @@ namespace OpenSim.Grid.InventoryServer | |||
150 | // { | 150 | // { |
151 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); | 151 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); |
152 | // } | 152 | // } |
153 | 153 | ||
154 | m_log.InfoFormat( | 154 | m_log.InfoFormat( |
155 | "[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items", | 155 | "[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items", |
156 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); | 156 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); |
157 | 157 | ||
158 | return invCollection; | 158 | return invCollection; |
159 | } | 159 | } |
160 | 160 | ||
161 | /// <summary> | 161 | /// <summary> |
162 | /// Guid to UUID wrapper for same name IInventoryServices method | 162 | /// Guid to UUID wrapper for same name IInventoryServices method |
163 | /// </summary> | 163 | /// </summary> |
@@ -166,10 +166,10 @@ namespace OpenSim.Grid.InventoryServer | |||
166 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) | 166 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) |
167 | { | 167 | { |
168 | //Thread.Sleep(10000); | 168 | //Thread.Sleep(10000); |
169 | 169 | ||
170 | LLUUID userID = new LLUUID(rawUserID); | 170 | LLUUID userID = new LLUUID(rawUserID); |
171 | return GetInventorySkeleton(userID); | 171 | return GetInventorySkeleton(userID); |
172 | } | 172 | } |
173 | 173 | ||
174 | /// <summary> | 174 | /// <summary> |
175 | /// Create an inventory for the given user. | 175 | /// Create an inventory for the given user. |
@@ -196,11 +196,11 @@ namespace OpenSim.Grid.InventoryServer | |||
196 | { | 196 | { |
197 | MoveFolder(folder); | 197 | MoveFolder(folder); |
198 | } | 198 | } |
199 | 199 | ||
200 | public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder) | 200 | public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder) |
201 | { | 201 | { |
202 | PurgeFolder(folder); | 202 | PurgeFolder(folder); |
203 | } | 203 | } |
204 | 204 | ||
205 | public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) | 205 | public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) |
206 | { | 206 | { |
@@ -230,15 +230,15 @@ namespace OpenSim.Grid.InventoryServer | |||
230 | MoveExistingInventoryFolder(folder); | 230 | MoveExistingInventoryFolder(folder); |
231 | return true; | 231 | return true; |
232 | } | 232 | } |
233 | 233 | ||
234 | public bool PurgeInventoryFolder(InventoryFolderBase folder) | 234 | public bool PurgeInventoryFolder(InventoryFolderBase folder) |
235 | { | 235 | { |
236 | m_log.InfoFormat( | 236 | m_log.InfoFormat( |
237 | "[GRID AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); | 237 | "[GRID AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); |
238 | 238 | ||
239 | PurgeInventoryFolder(folder.Owner, folder); | 239 | PurgeInventoryFolder(folder.Owner, folder); |
240 | return true; | 240 | return true; |
241 | } | 241 | } |
242 | 242 | ||
243 | public bool AddInventoryItem(InventoryItemBase item) | 243 | public bool AddInventoryItem(InventoryItemBase item) |
244 | { | 244 | { |
@@ -267,4 +267,4 @@ namespace OpenSim.Grid.InventoryServer | |||
267 | return true; | 267 | return true; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } \ 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 | |||
54 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 54 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); |
55 | 55 | ||
56 | m_log.Info("[" + OpenInventory_Main.LogName + "]: " + | 56 | m_log.Info("[" + OpenInventory_Main.LogName + "]: " + |
57 | "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | 57 | "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); |
58 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 58 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
59 | { | 59 | { |
60 | if (!pluginType.IsAbstract) | 60 | if (!pluginType.IsAbstract) |
@@ -68,7 +68,7 @@ namespace OpenSim.Grid.InventoryServer | |||
68 | plug.Initialise(dbconnect); | 68 | plug.Initialise(dbconnect); |
69 | _databasePlugin = plug; | 69 | _databasePlugin = plug; |
70 | m_log.Info("[" + OpenInventory_Main.LogName + "]: " + | 70 | m_log.Info("[" + OpenInventory_Main.LogName + "]: " + |
71 | "Invenstorage: Added IInventoryData Interface"); | 71 | "Invenstorage: Added IInventoryData Interface"); |
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | } | 74 | } |
@@ -136,10 +136,12 @@ namespace OpenSim.Grid.InventoryServer | |||
136 | return fixupFolder(inventory.root, null); | 136 | return fixupFolder(inventory.root, null); |
137 | } | 137 | } |
138 | 138 | ||
139 | #region Nested type: GetInventory | ||
140 | |||
139 | public class GetInventory : BaseStreamHandler | 141 | public class GetInventory : BaseStreamHandler |
140 | { | 142 | { |
141 | private SerializableInventory _inventory; | 143 | private readonly SerializableInventory _inventory; |
142 | private InventoryManager _manager; | 144 | private readonly InventoryManager _manager; |
143 | 145 | ||
144 | public GetInventory(InventoryManager manager) | 146 | public GetInventory(InventoryManager manager) |
145 | : base("GET", "/inventory") | 147 | : base("GET", "/inventory") |
@@ -181,7 +183,7 @@ namespace OpenSim.Grid.InventoryServer | |||
181 | { | 183 | { |
182 | byte[] result = new byte[] {}; | 184 | byte[] result = new byte[] {}; |
183 | 185 | ||
184 | string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); | 186 | string[] parms = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries); |
185 | if (parms.Length > 1) | 187 | if (parms.Length > 1) |
186 | { | 188 | { |
187 | if (string.Compare(parms[1], "library", true) == 0) | 189 | if (string.Compare(parms[1], "library", true) == 0) |
@@ -190,7 +192,7 @@ namespace OpenSim.Grid.InventoryServer | |||
190 | saveInventoryToStream(_inventory, ms); | 192 | saveInventoryToStream(_inventory, ms); |
191 | 193 | ||
192 | result = ms.GetBuffer(); | 194 | result = ms.GetBuffer(); |
193 | Array.Resize<byte>(ref result, (int) ms.Length); | 195 | Array.Resize(ref result, (int) ms.Length); |
194 | } | 196 | } |
195 | else if (string.Compare(parms[1], "user", true) == 0) | 197 | else if (string.Compare(parms[1], "user", true) == 0) |
196 | { | 198 | { |
@@ -203,5 +205,7 @@ namespace OpenSim.Grid.InventoryServer | |||
203 | return result; | 205 | return result; |
204 | } | 206 | } |
205 | } | 207 | } |
208 | |||
209 | #endregion | ||
206 | } | 210 | } |
207 | } | 211 | } \ 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 | |||
40 | { | 40 | { |
41 | public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback | 41 | public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback |
42 | { | 42 | { |
43 | public const string LogName = "INVENTORY"; | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 45 | ||
45 | private InventoryManager m_inventoryManager; | ||
46 | private InventoryConfig m_config; | 46 | private InventoryConfig m_config; |
47 | private InventoryManager m_inventoryManager; | ||
47 | private GridInventoryService m_inventoryService; | 48 | private GridInventoryService m_inventoryService; |
48 | 49 | ||
49 | public const string LogName = "INVENTORY"; | 50 | public OpenInventory_Main() |
51 | { | ||
52 | m_console = new ConsoleBase(LogName, this); | ||
53 | MainConsole.Instance = m_console; | ||
54 | } | ||
55 | |||
56 | #region conscmd_callback Members | ||
57 | |||
58 | public override void RunCmd(string cmd, string[] cmdparams) | ||
59 | { | ||
60 | base.RunCmd(cmd, cmdparams); | ||
61 | |||
62 | switch (cmd) | ||
63 | { | ||
64 | case "add-user": | ||
65 | m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID); | ||
66 | break; | ||
67 | case "shutdown": | ||
68 | m_console.Close(); | ||
69 | Environment.Exit(0); | ||
70 | break; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | #endregion | ||
50 | 75 | ||
51 | [STAThread] | 76 | [STAThread] |
52 | public static void Main(string[] args) | 77 | public static void Main(string[] args) |
@@ -59,12 +84,6 @@ namespace OpenSim.Grid.InventoryServer | |||
59 | theServer.Work(); | 84 | theServer.Work(); |
60 | } | 85 | } |
61 | 86 | ||
62 | public OpenInventory_Main() | ||
63 | { | ||
64 | m_console = new ConsoleBase(LogName, this); | ||
65 | MainConsole.Instance = m_console; | ||
66 | } | ||
67 | |||
68 | public void Startup() | 87 | public void Startup() |
69 | { | 88 | { |
70 | m_log.Info("Initialising inventory manager..."); | 89 | m_log.Info("Initialising inventory manager..."); |
@@ -75,7 +94,7 @@ namespace OpenSim.Grid.InventoryServer | |||
75 | m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); | 94 | m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); |
76 | 95 | ||
77 | m_log.Info("[" + LogName + "]: Starting HTTP server ..."); | 96 | m_log.Info("[" + LogName + "]: Starting HTTP server ..."); |
78 | 97 | ||
79 | m_httpServer = new BaseHttpServer(m_config.HttpPort); | 98 | m_httpServer = new BaseHttpServer(m_config.HttpPort); |
80 | AddHttpHandlers(); | 99 | AddHttpHandlers(); |
81 | m_httpServer.Start(); | 100 | m_httpServer.Start(); |
@@ -88,11 +107,11 @@ namespace OpenSim.Grid.InventoryServer | |||
88 | m_httpServer.AddStreamHandler( | 107 | m_httpServer.AddStreamHandler( |
89 | new RestDeserialisehandler<Guid, InventoryCollection>( | 108 | new RestDeserialisehandler<Guid, InventoryCollection>( |
90 | "POST", "/GetInventory/", m_inventoryService.GetUserInventory)); | 109 | "POST", "/GetInventory/", m_inventoryService.GetUserInventory)); |
91 | 110 | ||
92 | m_httpServer.AddStreamHandler( | 111 | m_httpServer.AddStreamHandler( |
93 | new RestDeserialisehandler<Guid, bool>( | 112 | new RestDeserialisehandler<Guid, bool>( |
94 | "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory)); | 113 | "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory)); |
95 | 114 | ||
96 | m_httpServer.AddStreamHandler( | 115 | m_httpServer.AddStreamHandler( |
97 | new RestDeserialisehandler<InventoryFolderBase, bool>( | 116 | new RestDeserialisehandler<InventoryFolderBase, bool>( |
98 | "POST", "/NewFolder/", m_inventoryService.AddInventoryFolder)); | 117 | "POST", "/NewFolder/", m_inventoryService.AddInventoryFolder)); |
@@ -100,15 +119,15 @@ namespace OpenSim.Grid.InventoryServer | |||
100 | m_httpServer.AddStreamHandler( | 119 | m_httpServer.AddStreamHandler( |
101 | new RestDeserialisehandler<InventoryFolderBase, bool>( | 120 | new RestDeserialisehandler<InventoryFolderBase, bool>( |
102 | "POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder)); | 121 | "POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder)); |
103 | 122 | ||
104 | m_httpServer.AddStreamHandler( | 123 | m_httpServer.AddStreamHandler( |
105 | new RestDeserialisehandler<InventoryFolderBase, bool>( | 124 | new RestDeserialisehandler<InventoryFolderBase, bool>( |
106 | "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder)); | 125 | "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder)); |
107 | 126 | ||
108 | m_httpServer.AddStreamHandler( | 127 | m_httpServer.AddStreamHandler( |
109 | new RestDeserialisehandler<InventoryItemBase, bool>( | 128 | new RestDeserialisehandler<InventoryItemBase, bool>( |
110 | "POST", "/NewItem/", m_inventoryService.AddInventoryItem)); | 129 | "POST", "/NewItem/", m_inventoryService.AddInventoryItem)); |
111 | 130 | ||
112 | m_httpServer.AddStreamHandler( | 131 | m_httpServer.AddStreamHandler( |
113 | new RestDeserialisehandler<InventoryItemBase, bool>( | 132 | new RestDeserialisehandler<InventoryItemBase, bool>( |
114 | "POST", "/DeleteItem/", m_inventoryService.DeleteInvItem)); | 133 | "POST", "/DeleteItem/", m_inventoryService.DeleteInvItem)); |
@@ -134,21 +153,5 @@ namespace OpenSim.Grid.InventoryServer | |||
134 | m_console.Prompt(); | 153 | m_console.Prompt(); |
135 | } | 154 | } |
136 | } | 155 | } |
137 | |||
138 | public override void RunCmd(string cmd, string[] cmdparams) | ||
139 | { | ||
140 | base.RunCmd(cmd, cmdparams); | ||
141 | |||
142 | switch (cmd) | ||
143 | { | ||
144 | case "add-user": | ||
145 | m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID); | ||
146 | break; | ||
147 | case "shutdown": | ||
148 | m_console.Close(); | ||
149 | Environment.Exit(0); | ||
150 | break; | ||
151 | } | ||
152 | } | ||
153 | } | 156 | } |
154 | } | 157 | } \ No newline at end of file |