aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid
diff options
context:
space:
mode:
authorMW2007-12-01 18:49:17 +0000
committerMW2007-12-01 18:49:17 +0000
commit5df851761aa796cba70a3b6d8b36d119502c1de2 (patch)
tree4cab0f2d6ea32a6cfb280d74583d8ffce7331c26 /OpenSim/Grid
parentAttempt to fix mantis issue # 65, seems like it is a race condition between t... (diff)
downloadopensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.zip
opensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.tar.gz
opensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.tar.bz2
opensim-SC_OLD-5df851761aa796cba70a3b6d8b36d119502c1de2.tar.xz
Initial working Grid Inventory server. Only been tested on a very small grid, so likely to have problems on a larger grid with more people?
To use , both the user server and Inventory server need to be running this latest revision. (older regions should be able to still be used, just the user won't have inventory on them). Also and HERE IS THE BIG BREAK ISSUE, currently, so that the initial inventory details for a user are added to the inventory db , you need to recreate the accounts using the user server "create user" feature. It should be quite easy to manual populate the inventory database instead but I someone else will need to look into that) Also I've only tested using SQLite as the database provider, there is a Mysql inventory provider but I don't know if it works (SQLite is set as default, so you will need to change it in the inventory server config.xml)
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r--OpenSim/Grid/InventoryServer/GridInventoryService.cs104
-rw-r--r--OpenSim/Grid/InventoryServer/Main.cs34
-rw-r--r--OpenSim/Grid/UserServer/Main.cs19
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs50
4 files changed, 202 insertions, 5 deletions
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
new file mode 100644
index 0000000..dda2f61
--- /dev/null
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -0,0 +1,104 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework;
5using OpenSim.Framework.Communications;
6using libsecondlife;
7
8namespace OpenSim.Grid.InventoryServer
9{
10 public class GridInventoryService : InventoryServiceBase
11 {
12 public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
13 InventoryItemInfo itemCallBack)
14 {
15
16 }
17
18 private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, out List<InventoryItemBase> itemsList)
19 {
20 List<InventoryFolderBase> folders = RequestFirstLevelFolders(userID);
21 List<InventoryItemBase> allItems = new List<InventoryItemBase>();
22
23 if (folders != null)
24 {
25 foreach (InventoryFolderBase folder in folders)
26 {
27 if (folder.parentID != LLUUID.Zero)
28 {
29 List<InventoryItemBase> items = RequestFolderItems(folder.folderID);
30 if (items != null)
31 {
32 allItems.InsertRange(0, items);
33 }
34 }
35 }
36 }
37
38 folderList = folders;
39 itemsList = allItems;
40 if (folderList != null)
41 {
42 return true;
43 }
44 else
45 {
46 return false;
47 }
48 }
49
50 public InventoryCollection GetUserInventory(LLUUID userID)
51 {
52 InventoryCollection invCollection = new InventoryCollection();
53 List<InventoryFolderBase> folders;
54 List<InventoryItemBase> allItems;
55 if (TryGetUsersInventory(userID, out folders, out allItems))
56 {
57 invCollection.AllItems = allItems;
58 invCollection.Folders = folders;
59 invCollection.UserID = userID;
60 }
61 return invCollection;
62 }
63
64 public bool CreateUsersInventory(LLUUID user)
65 {
66 CreateNewUserInventory(user);
67 return true;
68 }
69
70
71 public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
72 {
73 AddFolder(folder);
74 }
75
76 public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
77 {
78 AddItem(item);
79 }
80
81 public bool AddInventoryFolder( InventoryFolderBase folder)
82 {
83 AddNewInventoryFolder(folder.agentID, folder);
84 return true;
85 }
86
87 public bool AddInventoryItem( InventoryItemBase item)
88 {
89 AddNewInventoryItem(item.avatarID, item);
90 return true;
91 }
92
93 public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
94 {
95 DeleteItem(item);
96 }
97
98 public bool DeleteInvItem( InventoryItemBase item)
99 {
100 DeleteInventoryItem(item.avatarID, item);
101 return true;
102 }
103 }
104}
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 1bc396b..8d232c2 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Grid.InventoryServer
47 LogBase m_console; 47 LogBase m_console;
48 InventoryManager m_inventoryManager; 48 InventoryManager m_inventoryManager;
49 InventoryConfig m_config; 49 InventoryConfig m_config;
50 GridInventoryService m_inventoryService;
50 51
51 public const string LogName = "INVENTORY"; 52 public const string LogName = "INVENTORY";
52 53
@@ -69,13 +70,35 @@ namespace OpenSim.Grid.InventoryServer
69 { 70 {
70 MainLog.Instance.Notice("Initialising inventory manager..."); 71 MainLog.Instance.Notice("Initialising inventory manager...");
71 m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); 72 m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
72 73
73 m_inventoryManager = new InventoryManager(); 74 m_inventoryService = new GridInventoryService();
74 m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider); 75 // m_inventoryManager = new InventoryManager();
76 m_inventoryService.AddPlugin(m_config.DatabaseProvider);
77
75 MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); 78 MainLog.Instance.Notice(LogName, "Starting HTTP server ...");
76 BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); 79 BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
80 httpServer.AddStreamHandler(
81 new RestDeserialisehandler<LLUUID, InventoryCollection>("POST", "/GetInventory/",
82 m_inventoryService.GetUserInventory));
83 httpServer.AddStreamHandler(
84 new RestDeserialisehandler<LLUUID, bool>("POST", "/CreateInventory/",
85 m_inventoryService.CreateUsersInventory));
86 httpServer.AddStreamHandler(
87 new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/",
88 m_inventoryService.AddInventoryFolder));
89
90 httpServer.AddStreamHandler(
91 new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/",
92 m_inventoryService.AddInventoryItem));
93 httpServer.AddStreamHandler(
94 new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/",
95 m_inventoryService.DeleteInvItem));
77 96
78 httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); 97 httpServer.AddStreamHandler(
98 new RestDeserialisehandler<LLUUID, List<InventoryFolderBase>>("POST", "/RootFolders/",
99 m_inventoryService.RequestFirstLevelFolders));
100
101 // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
79 102
80 httpServer.Start(); 103 httpServer.Start();
81 MainLog.Instance.Notice(LogName, "Started HTTP server"); 104 MainLog.Instance.Notice(LogName, "Started HTTP server");
@@ -96,6 +119,9 @@ namespace OpenSim.Grid.InventoryServer
96 switch (cmd) 119 switch (cmd)
97 { 120 {
98 case "quit": 121 case "quit":
122 case "add-user":
123 m_inventoryService.CreateUsersInventory(LLUUID.Random());
124 break;
99 case "shutdown": 125 case "shutdown":
100 m_console.Close(); 126 m_console.Close();
101 Environment.Exit(0); 127 Environment.Exit(0);
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 779a72b..b00bb76 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -27,7 +27,9 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
30using System.IO; 31using System.IO;
32using libsecondlife;
31using OpenSim.Framework; 33using OpenSim.Framework;
32using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
33using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
@@ -44,6 +46,7 @@ namespace OpenSim.Grid.UserServer
44 public UserLoginService m_loginService; 46 public UserLoginService m_loginService;
45 47
46 private LogBase m_console; 48 private LogBase m_console;
49 private LLUUID m_lastCreatedUser = LLUUID.Random();
47 50
48 [STAThread] 51 [STAThread]
49 public static void Main(string[] args) 52 public static void Main(string[] args)
@@ -123,7 +126,9 @@ namespace OpenSim.Grid.UserServer
123 126
124 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); 127 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
125 128
126 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); 129 LLUUID userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
130 RestObjectPoster.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "CreateInventory/", userID);
131 m_lastCreatedUser = userID;
127 break; 132 break;
128 } 133 }
129 } 134 }
@@ -145,9 +150,21 @@ namespace OpenSim.Grid.UserServer
145 m_console.Close(); 150 m_console.Close();
146 Environment.Exit(0); 151 Environment.Exit(0);
147 break; 152 break;
153
154 case "test-inventory":
155 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
156 // requester.ReturnResponseVal = TestResponse;
157 // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
158 List<InventoryFolderBase> folders = SyncRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
159 break;
148 } 160 }
149 } 161 }
150 162
163 public void TestResponse(List<InventoryFolderBase> resp)
164 {
165 System.Console.WriteLine("response got");
166 }
167
151 /*private void ConfigDB(IGenericConfig configData) 168 /*private void ConfigDB(IGenericConfig configData)
152 { 169 {
153 try 170 try
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index 0af5790..d3164ad 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -28,12 +28,16 @@
28 28
29using System; 29using System;
30using System.Collections; 30using System.Collections;
31using System.Collections.Generic;
31using System.Net; 32using System.Net;
32using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34using libsecondlife;
33using OpenSim.Framework; 35using OpenSim.Framework;
34using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Servers;
35using OpenSim.Framework.Data; 38using OpenSim.Framework.Data;
36using OpenSim.Framework.UserManagement; 39using OpenSim.Framework.UserManagement;
40using InventoryFolder = OpenSim.Framework.InventoryFolder;
37 41
38namespace OpenSim.Grid.UserServer 42namespace OpenSim.Grid.UserServer
39{ 43{
@@ -189,5 +193,51 @@ namespace OpenSim.Grid.UserServer
189 193
190 } 194 }
191 } 195 }
196
197 protected override InventoryData CreateInventoryData(LLUUID userID)
198 {
199 List<InventoryFolderBase> folders = SyncRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_config.InventoryUrl + "RootFolders/", userID);
200 if (folders.Count > 0)
201 {
202 LLUUID rootID = LLUUID.Zero;
203 ArrayList AgentInventoryArray = new ArrayList();
204 Hashtable TempHash;
205 foreach (InventoryFolderBase InvFolder in folders)
206 {
207 if (InvFolder.parentID == LLUUID.Zero)
208 {
209 rootID = InvFolder.folderID;
210 }
211 TempHash = new Hashtable();
212 TempHash["name"] = InvFolder.name;
213 TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated();
214 TempHash["version"] = (Int32)InvFolder.version;
215 TempHash["type_default"] = (Int32)InvFolder.type;
216 TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated();
217 AgentInventoryArray.Add(TempHash);
218 }
219 return new InventoryData(AgentInventoryArray, rootID);
220 }
221 else
222 {
223 AgentInventory userInventory = new AgentInventory();
224 userInventory.CreateRootFolder(userID, false);
225
226 ArrayList AgentInventoryArray = new ArrayList();
227 Hashtable TempHash;
228 foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
229 {
230 TempHash = new Hashtable();
231 TempHash["name"] = InvFolder.FolderName;
232 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
233 TempHash["version"] = (Int32)InvFolder.Version;
234 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
235 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
236 AgentInventoryArray.Add(TempHash);
237 }
238
239 return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
240 }
241 }
192 } 242 }
193} \ No newline at end of file 243} \ No newline at end of file