aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/InventoryServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/InventoryServer')
-rw-r--r--OpenSim/Grid/InventoryServer/GridInventoryService.cs50
-rw-r--r--OpenSim/Grid/InventoryServer/InventoryManager.cs18
-rw-r--r--OpenSim/Grid/InventoryServer/Main.cs65
3 files changed, 63 insertions, 70 deletions
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index c3e3a28..db9a864 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} \ No newline at end of file 270}
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs
index 350a618..5c65317 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,12 +136,10 @@ 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
141 public class GetInventory : BaseStreamHandler 139 public class GetInventory : BaseStreamHandler
142 { 140 {
143 private readonly SerializableInventory _inventory; 141 private SerializableInventory _inventory;
144 private readonly InventoryManager _manager; 142 private InventoryManager _manager;
145 143
146 public GetInventory(InventoryManager manager) 144 public GetInventory(InventoryManager manager)
147 : base("GET", "/inventory") 145 : base("GET", "/inventory")
@@ -183,7 +181,7 @@ namespace OpenSim.Grid.InventoryServer
183 { 181 {
184 byte[] result = new byte[] {}; 182 byte[] result = new byte[] {};
185 183
186 string[] parms = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries); 184 string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
187 if (parms.Length > 1) 185 if (parms.Length > 1)
188 { 186 {
189 if (string.Compare(parms[1], "library", true) == 0) 187 if (string.Compare(parms[1], "library", true) == 0)
@@ -192,7 +190,7 @@ namespace OpenSim.Grid.InventoryServer
192 saveInventoryToStream(_inventory, ms); 190 saveInventoryToStream(_inventory, ms);
193 191
194 result = ms.GetBuffer(); 192 result = ms.GetBuffer();
195 Array.Resize(ref result, (int) ms.Length); 193 Array.Resize<byte>(ref result, (int) ms.Length);
196 } 194 }
197 else if (string.Compare(parms[1], "user", true) == 0) 195 else if (string.Compare(parms[1], "user", true) == 0)
198 { 196 {
@@ -205,7 +203,5 @@ namespace OpenSim.Grid.InventoryServer
205 return result; 203 return result;
206 } 204 }
207 } 205 }
208
209 #endregion
210 } 206 }
211} \ No newline at end of file 207}
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 453d64d..870997b 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -40,38 +40,13 @@ 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";
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 44
46 private InventoryConfig m_config;
47 private InventoryManager m_inventoryManager; 45 private InventoryManager m_inventoryManager;
46 private InventoryConfig m_config;
48 private GridInventoryService m_inventoryService; 47 private GridInventoryService m_inventoryService;
49 48
50 public OpenInventory_Main() 49 public const string LogName = "INVENTORY";
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
75 50
76 [STAThread] 51 [STAThread]
77 public static void Main(string[] args) 52 public static void Main(string[] args)
@@ -84,6 +59,12 @@ namespace OpenSim.Grid.InventoryServer
84 theServer.Work(); 59 theServer.Work();
85 } 60 }
86 61
62 public OpenInventory_Main()
63 {
64 m_console = new ConsoleBase(LogName, this);
65 MainConsole.Instance = m_console;
66 }
67
87 public void Startup() 68 public void Startup()
88 { 69 {
89 m_log.Info("Initialising inventory manager..."); 70 m_log.Info("Initialising inventory manager...");
@@ -94,7 +75,7 @@ namespace OpenSim.Grid.InventoryServer
94 m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); 75 m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
95 76
96 m_log.Info("[" + LogName + "]: Starting HTTP server ..."); 77 m_log.Info("[" + LogName + "]: Starting HTTP server ...");
97 78
98 m_httpServer = new BaseHttpServer(m_config.HttpPort); 79 m_httpServer = new BaseHttpServer(m_config.HttpPort);
99 AddHttpHandlers(); 80 AddHttpHandlers();
100 m_httpServer.Start(); 81 m_httpServer.Start();
@@ -107,11 +88,11 @@ namespace OpenSim.Grid.InventoryServer
107 m_httpServer.AddStreamHandler( 88 m_httpServer.AddStreamHandler(
108 new RestDeserialisehandler<Guid, InventoryCollection>( 89 new RestDeserialisehandler<Guid, InventoryCollection>(
109 "POST", "/GetInventory/", m_inventoryService.GetUserInventory)); 90 "POST", "/GetInventory/", m_inventoryService.GetUserInventory));
110 91
111 m_httpServer.AddStreamHandler( 92 m_httpServer.AddStreamHandler(
112 new RestDeserialisehandler<Guid, bool>( 93 new RestDeserialisehandler<Guid, bool>(
113 "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory)); 94 "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory));
114 95
115 m_httpServer.AddStreamHandler( 96 m_httpServer.AddStreamHandler(
116 new RestDeserialisehandler<InventoryFolderBase, bool>( 97 new RestDeserialisehandler<InventoryFolderBase, bool>(
117 "POST", "/NewFolder/", m_inventoryService.AddInventoryFolder)); 98 "POST", "/NewFolder/", m_inventoryService.AddInventoryFolder));
@@ -119,15 +100,15 @@ namespace OpenSim.Grid.InventoryServer
119 m_httpServer.AddStreamHandler( 100 m_httpServer.AddStreamHandler(
120 new RestDeserialisehandler<InventoryFolderBase, bool>( 101 new RestDeserialisehandler<InventoryFolderBase, bool>(
121 "POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder)); 102 "POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder));
122 103
123 m_httpServer.AddStreamHandler( 104 m_httpServer.AddStreamHandler(
124 new RestDeserialisehandler<InventoryFolderBase, bool>( 105 new RestDeserialisehandler<InventoryFolderBase, bool>(
125 "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder)); 106 "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder));
126 107
127 m_httpServer.AddStreamHandler( 108 m_httpServer.AddStreamHandler(
128 new RestDeserialisehandler<InventoryItemBase, bool>( 109 new RestDeserialisehandler<InventoryItemBase, bool>(
129 "POST", "/NewItem/", m_inventoryService.AddInventoryItem)); 110 "POST", "/NewItem/", m_inventoryService.AddInventoryItem));
130 111
131 m_httpServer.AddStreamHandler( 112 m_httpServer.AddStreamHandler(
132 new RestDeserialisehandler<InventoryItemBase, bool>( 113 new RestDeserialisehandler<InventoryItemBase, bool>(
133 "POST", "/DeleteItem/", m_inventoryService.DeleteInvItem)); 114 "POST", "/DeleteItem/", m_inventoryService.DeleteInvItem));
@@ -153,5 +134,21 @@ namespace OpenSim.Grid.InventoryServer
153 m_console.Prompt(); 134 m_console.Prompt();
154 } 135 }
155 } 136 }
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 }
156 } 153 }
157} \ No newline at end of file 154}