aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/InventoryServer
diff options
context:
space:
mode:
authorlbsa712007-12-27 21:41:48 +0000
committerlbsa712007-12-27 21:41:48 +0000
commitefd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch)
treebf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Grid/InventoryServer
parent* removed always true if (diff)
downloadopensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz
* Optimized usings
* shortened references * Removed redundant 'this' * Normalized EOF
Diffstat (limited to 'OpenSim/Grid/InventoryServer')
-rw-r--r--OpenSim/Grid/InventoryServer/GridInventoryService.cs45
-rw-r--r--OpenSim/Grid/InventoryServer/InventoryManager.cs43
-rw-r--r--OpenSim/Grid/InventoryServer/Main.cs34
3 files changed, 59 insertions, 63 deletions
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index ca2e526..d36a915 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -28,23 +28,22 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using libsecondlife;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using libsecondlife;
36 35
37namespace OpenSim.Grid.InventoryServer 36namespace OpenSim.Grid.InventoryServer
38{ 37{
39 public class GridInventoryService : InventoryServiceBase 38 public class GridInventoryService : InventoryServiceBase
40 { 39 {
41 public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, 40 public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
42 InventoryItemInfo itemCallBack) 41 InventoryItemInfo itemCallBack)
43 { 42 {
44
45 } 43 }
46 44
47 private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, out List<InventoryItemBase> itemsList) 45 private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList,
46 out List<InventoryItemBase> itemsList)
48 { 47 {
49 List<InventoryFolderBase> rootFolders = RequestFirstLevelFolders(userID); 48 List<InventoryFolderBase> rootFolders = RequestFirstLevelFolders(userID);
50 List<InventoryItemBase> allItems = new List<InventoryItemBase>(); 49 List<InventoryItemBase> allItems = new List<InventoryItemBase>();
@@ -107,10 +106,10 @@ namespace OpenSim.Grid.InventoryServer
107 public InventoryCollection GetUserInventory(Guid rawUserID) 106 public InventoryCollection GetUserInventory(Guid rawUserID)
108 { 107 {
109 LLUUID userID = new LLUUID(rawUserID); 108 LLUUID userID = new LLUUID(rawUserID);
110 109
111 // We get enough verbose messages later on for diagnostics 110 // We get enough verbose messages later on for diagnostics
112 //MainLog.Instance.Verbose("INVENTORY", "Request for inventory for " + userID.ToString()); 111 //MainLog.Instance.Verbose("INVENTORY", "Request for inventory for " + userID.ToString());
113 112
114 InventoryCollection invCollection = new InventoryCollection(); 113 InventoryCollection invCollection = new InventoryCollection();
115 List<InventoryFolderBase> folders; 114 List<InventoryFolderBase> folders;
116 List<InventoryItemBase> allItems; 115 List<InventoryItemBase> allItems;
@@ -126,14 +125,14 @@ namespace OpenSim.Grid.InventoryServer
126 public bool CreateUsersInventory(Guid rawUserID) 125 public bool CreateUsersInventory(Guid rawUserID)
127 { 126 {
128 LLUUID userID = new LLUUID(rawUserID); 127 LLUUID userID = new LLUUID(rawUserID);
129 128
130 MainLog.Instance.Verbose( 129 MainLog.Instance.Verbose(
131 "INVENTORY", "Creating new set of inventory folders for " + userID.ToString()); 130 "INVENTORY", "Creating new set of inventory folders for " + userID.ToString());
132 131
133 CreateNewUserInventory(userID); 132 CreateNewUserInventory(userID);
134 return true; 133 return true;
135 } 134 }
136 135
137 136
138 public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) 137 public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
139 { 138 {
@@ -156,30 +155,30 @@ namespace OpenSim.Grid.InventoryServer
156 MainLog.Instance.Verbose( 155 MainLog.Instance.Verbose(
157 "INVENTORY", 156 "INVENTORY",
158 "Updating in " + folder.parentID.ToString() 157 "Updating in " + folder.parentID.ToString()
159 + ", folder " + folder.name); 158 + ", folder " + folder.name);
160 159
161 AddNewInventoryFolder(folder.agentID, folder); 160 AddNewInventoryFolder(folder.agentID, folder);
162 return true; 161 return true;
163 } 162 }
164 163
165 public bool MoveInventoryFolder(InventoryFolderBase folder) 164 public bool MoveInventoryFolder(InventoryFolderBase folder)
166 { 165 {
167 MainLog.Instance.Verbose( 166 MainLog.Instance.Verbose(
168 "INVENTORY", 167 "INVENTORY",
169 "Moving folder " + folder.folderID 168 "Moving folder " + folder.folderID
170 + " to " + folder.parentID.ToString()); 169 + " to " + folder.parentID.ToString());
171 170
172 MoveExistingInventoryFolder(folder); 171 MoveExistingInventoryFolder(folder);
173 return true; 172 return true;
174 } 173 }
175 174
176 public bool AddInventoryItem( InventoryItemBase item) 175 public bool AddInventoryItem(InventoryItemBase item)
177 { 176 {
178 // Right now, this actions act more like an update/insert combination than a simple create. 177 // Right now, this actions act more like an update/insert combination than a simple create.
179 MainLog.Instance.Verbose( 178 MainLog.Instance.Verbose(
180 "INVENTORY", 179 "INVENTORY",
181 "Updating in " + item.parentFolderID.ToString() 180 "Updating in " + item.parentFolderID.ToString()
182 + ", item " + item.inventoryName); 181 + ", item " + item.inventoryName);
183 182
184 AddNewInventoryItem(item.avatarID, item); 183 AddNewInventoryItem(item.avatarID, item);
185 return true; 184 return true;
@@ -191,15 +190,15 @@ namespace OpenSim.Grid.InventoryServer
191 MainLog.Instance.Verbose( 190 MainLog.Instance.Verbose(
192 "INVENTORY", 191 "INVENTORY",
193 "Deleting in " + item.parentFolderID.ToString() 192 "Deleting in " + item.parentFolderID.ToString()
194 + ", item " + item.inventoryName); 193 + ", item " + item.inventoryName);
195 194
196 DeleteItem(item); 195 DeleteItem(item);
197 } 196 }
198 197
199 public bool DeleteInvItem( InventoryItemBase item) 198 public bool DeleteInvItem(InventoryItemBase item)
200 { 199 {
201 DeleteInventoryItem(item.avatarID, item); 200 DeleteInventoryItem(item.avatarID, item);
202 return true; 201 return true;
203 } 202 }
204 } 203 }
205} 204} \ No newline at end of file
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs
index 1070bcf..a003ce3 100644
--- a/OpenSim/Grid/InventoryServer/InventoryManager.cs
+++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs
@@ -25,26 +25,23 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28
28using System; 29using System;
29using System.IO; 30using System.IO;
30using System.Text;
31using System.Reflection; 31using System.Reflection;
32using System.Collections; 32using System.Text;
33using System.Collections.Generic;
34using System.Xml; 33using System.Xml;
35using System.Xml.Serialization; 34using System.Xml.Serialization;
36using libsecondlife; 35using libsecondlife;
37
38using OpenSim.Framework; 36using OpenSim.Framework;
39using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
41 39
42namespace OpenSim.Grid.InventoryServer 40namespace OpenSim.Grid.InventoryServer
43{ 41{
44
45 public class InventoryManager 42 public class InventoryManager
46 { 43 {
47 IInventoryData _databasePlugin; 44 private IInventoryData _databasePlugin;
48 45
49 /// <summary> 46 /// <summary>
50 /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. 47 /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
@@ -55,7 +52,8 @@ namespace OpenSim.Grid.InventoryServer
55 MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName); 52 MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName);
56 Assembly pluginAssembly = Assembly.LoadFrom(FileName); 53 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
57 54
58 MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); 55 MainLog.Instance.Verbose(OpenInventory_Main.LogName,
56 "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
59 foreach (Type pluginType in pluginAssembly.GetTypes()) 57 foreach (Type pluginType in pluginAssembly.GetTypes())
60 { 58 {
61 if (!pluginType.IsAbstract) 59 if (!pluginType.IsAbstract)
@@ -64,10 +62,12 @@ namespace OpenSim.Grid.InventoryServer
64 62
65 if (typeInterface != null) 63 if (typeInterface != null)
66 { 64 {
67 IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 65 IInventoryData plug =
66 (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
68 plug.Initialise(); 67 plug.Initialise();
69 _databasePlugin = plug; 68 _databasePlugin = plug;
70 MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Added IInventoryData Interface"); 69 MainLog.Instance.Verbose(OpenInventory_Main.LogName,
70 "Invenstorage: Added IInventoryData Interface");
71 break; 71 break;
72 } 72 }
73 73
@@ -82,8 +82,8 @@ namespace OpenSim.Grid.InventoryServer
82 { 82 {
83 FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); 83 FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
84 XmlReader reader = new XmlTextReader(fs); 84 XmlReader reader = new XmlTextReader(fs);
85 XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); 85 XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
86 SerializableInventory inventory = (SerializableInventory)x.Deserialize(reader); 86 SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader);
87 fs.Close(); 87 fs.Close();
88 fs.Dispose(); 88 fs.Dispose();
89 return inventory; 89 return inventory;
@@ -93,11 +93,12 @@ namespace OpenSim.Grid.InventoryServer
93 { 93 {
94 XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8); 94 XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8);
95 writer.Formatting = Formatting.Indented; 95 writer.Formatting = Formatting.Indented;
96 XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); 96 XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
97 x.Serialize(writer, inventory); 97 x.Serialize(writer, inventory);
98 } 98 }
99 99
100 protected static bool fixupFolder(SerializableInventory.SerializableFolder f, SerializableInventory.SerializableFolder parent) 100 protected static bool fixupFolder(SerializableInventory.SerializableFolder f,
101 SerializableInventory.SerializableFolder parent)
101 { 102 {
102 bool modified = false; 103 bool modified = false;
103 104
@@ -142,6 +143,7 @@ namespace OpenSim.Grid.InventoryServer
142 { 143 {
143 private SerializableInventory _inventory; 144 private SerializableInventory _inventory;
144 private InventoryManager _manager; 145 private InventoryManager _manager;
146
145 public GetInventory(InventoryManager manager) 147 public GetInventory(InventoryManager manager)
146 : base("GET", "/inventory") 148 : base("GET", "/inventory")
147 { 149 {
@@ -165,23 +167,24 @@ namespace OpenSim.Grid.InventoryServer
165 private byte[] GetUserInventory(LLUUID userID) 167 private byte[] GetUserInventory(LLUUID userID)
166 { 168 {
167 MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString()); 169 MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString());
168 byte[] result = new byte[] { }; 170 byte[] result = new byte[] {};
169 171
170 InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID); 172 InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID);
171 if (fb == null) 173 if (fb == null)
172 { 174 {
173 MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", userID.ToString()); 175 MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new",
176 userID.ToString());
174 CreateDefaultInventory(userID); 177 CreateDefaultInventory(userID);
175 } 178 }
176 179
177 return result; 180 return result;
178 } 181 }
179 182
180 override public byte[] Handle(string path, Stream request) 183 public override byte[] Handle(string path, Stream request)
181 { 184 {
182 byte[] result = new byte[] { }; 185 byte[] result = new byte[] {};
183 186
184 string[] parms = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); 187 string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
185 if (parms.Length > 1) 188 if (parms.Length > 1)
186 { 189 {
187 if (string.Compare(parms[1], "library", true) == 0) 190 if (string.Compare(parms[1], "library", true) == 0)
@@ -190,7 +193,7 @@ namespace OpenSim.Grid.InventoryServer
190 saveInventoryToStream(_inventory, ms); 193 saveInventoryToStream(_inventory, ms);
191 194
192 result = ms.GetBuffer(); 195 result = ms.GetBuffer();
193 Array.Resize<byte>(ref result, (int)ms.Length); 196 Array.Resize<byte>(ref result, (int) ms.Length);
194 } 197 }
195 else if (string.Compare(parms[1], "user", true) == 0) 198 else if (string.Compare(parms[1], "user", true) == 0)
196 { 199 {
@@ -204,4 +207,4 @@ namespace OpenSim.Grid.InventoryServer
204 } 207 }
205 } 208 }
206 } 209 }
207} 210} \ No newline at end of file
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index df854f9..ce371bf 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -25,29 +25,23 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28
28using System; 29using System;
29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
32using System.IO; 31using System.IO;
33using System.Text;
34
35using libsecondlife; 32using libsecondlife;
36
37using OpenSim.Framework; 33using OpenSim.Framework;
38using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
39using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
40 36
41using InventoryManager = OpenSim.Grid.InventoryServer.InventoryManager;
42
43namespace OpenSim.Grid.InventoryServer 37namespace OpenSim.Grid.InventoryServer
44{ 38{
45 public class OpenInventory_Main : conscmd_callback 39 public class OpenInventory_Main : conscmd_callback
46 { 40 {
47 LogBase m_console; 41 private LogBase m_console;
48 InventoryManager m_inventoryManager; 42 private InventoryManager m_inventoryManager;
49 InventoryConfig m_config; 43 private InventoryConfig m_config;
50 GridInventoryService m_inventoryService; 44 private GridInventoryService m_inventoryService;
51 45
52 public const string LogName = "INVENTORY"; 46 public const string LogName = "INVENTORY";
53 47
@@ -72,20 +66,20 @@ namespace OpenSim.Grid.InventoryServer
72 m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); 66 m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
73 67
74 m_inventoryService = new GridInventoryService(); 68 m_inventoryService = new GridInventoryService();
75 // m_inventoryManager = new InventoryManager(); 69 // m_inventoryManager = new InventoryManager();
76 m_inventoryService.AddPlugin(m_config.DatabaseProvider); 70 m_inventoryService.AddPlugin(m_config.DatabaseProvider);
77 71
78 MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); 72 MainLog.Instance.Notice(LogName, "Starting HTTP server ...");
79 BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); 73 BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
80 httpServer.AddStreamHandler( 74 httpServer.AddStreamHandler(
81 new RestDeserialisehandler<Guid, InventoryCollection>("POST", "/GetInventory/", 75 new RestDeserialisehandler<Guid, InventoryCollection>("POST", "/GetInventory/",
82 m_inventoryService.GetUserInventory)); 76 m_inventoryService.GetUserInventory));
83 httpServer.AddStreamHandler( 77 httpServer.AddStreamHandler(
84 new RestDeserialisehandler<Guid, bool>("POST", "/CreateInventory/", 78 new RestDeserialisehandler<Guid, bool>("POST", "/CreateInventory/",
85 m_inventoryService.CreateUsersInventory)); 79 m_inventoryService.CreateUsersInventory));
86 httpServer.AddStreamHandler( 80 httpServer.AddStreamHandler(
87 new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/", 81 new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/",
88 m_inventoryService.AddInventoryFolder)); 82 m_inventoryService.AddInventoryFolder));
89 83
90 httpServer.AddStreamHandler( 84 httpServer.AddStreamHandler(
91 new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/MoveFolder/", 85 new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/MoveFolder/",
@@ -93,16 +87,16 @@ namespace OpenSim.Grid.InventoryServer
93 87
94 httpServer.AddStreamHandler( 88 httpServer.AddStreamHandler(
95 new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/", 89 new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/",
96 m_inventoryService.AddInventoryItem)); 90 m_inventoryService.AddInventoryItem));
97 httpServer.AddStreamHandler( 91 httpServer.AddStreamHandler(
98 new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/", 92 new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/",
99 m_inventoryService.DeleteInvItem)); 93 m_inventoryService.DeleteInvItem));
100 94
101 httpServer.AddStreamHandler( 95 httpServer.AddStreamHandler(
102 new RestDeserialisehandler<Guid, List<InventoryFolderBase>>("POST", "/RootFolders/", 96 new RestDeserialisehandler<Guid, List<InventoryFolderBase>>("POST", "/RootFolders/",
103 m_inventoryService.RequestFirstLevelFolders)); 97 m_inventoryService.RequestFirstLevelFolders));
104 98
105 // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); 99 // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
106 100
107 httpServer.Start(); 101 httpServer.Start();
108 MainLog.Instance.Notice(LogName, "Started HTTP server"); 102 MainLog.Instance.Notice(LogName, "Started HTTP server");
@@ -137,4 +131,4 @@ namespace OpenSim.Grid.InventoryServer
137 { 131 {
138 } 132 }
139 } 133 }
140} 134} \ No newline at end of file