aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/AssetInventoryConfig.cs146
-rw-r--r--OpenSim/Framework/PluginLoader.cs48
-rw-r--r--OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs155
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs78
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs11
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs27
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml2
7 files changed, 237 insertions, 230 deletions
diff --git a/OpenSim/Framework/AssetInventoryConfig.cs b/OpenSim/Framework/AssetInventoryConfig.cs
new file mode 100644
index 0000000..9277b5e
--- /dev/null
+++ b/OpenSim/Framework/AssetInventoryConfig.cs
@@ -0,0 +1,146 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29
30namespace OpenSim.Framework
31{
32 /// <summary>
33 /// AssetInventoryConfig -- For AssetInventory Server Configuration
34 /// </summary>
35 public class AssetInventoryConfig
36 {
37 private ConfigurationMember configMember;
38
39 public const uint DefaultHttpPort = 8003;
40 public uint HttpPort = DefaultHttpPort;
41
42 public string AssetStorageProvider = "OpenSimAssetStorage";
43 public string AssetDatabaseConnect = String.Empty;
44 public string InventoryStorageProvider = "OpenSimInventoryStorage";
45 public string InventoryDatabaseConnect = String.Empty;
46
47 public string AuthenticationProvider = "NullAuthentication";
48 public string AuthorizationProvider = "AuthorizeAll";
49 public string MetricsProvider = "NullMetrics";
50 public string Frontends = "OpenSimAssetFrontend,OpenSimInventoryFrontend";
51
52 public AssetInventoryConfig(string description, string filename)
53 {
54 configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
55 configMember.performConfigurationRetrieve();
56 }
57
58 public void loadConfigurationOptions()
59 {
60 configMember.addConfigurationOption("listen_port",
61 ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
62 "HTTP listener port",
63 DefaultHttpPort.ToString(),
64 false);
65
66 configMember.addConfigurationOption("asset_storage_provider",
67 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
68 "Asset storage provider",
69 AssetStorageProvider,
70 false);
71 configMember.addConfigurationOption("asset_database_connect",
72 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
73 "Asset database connection string",
74 AssetDatabaseConnect,
75 false);
76 configMember.addConfigurationOption("inventory_storage_provider",
77 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
78 "Inventory storage provider",
79 InventoryStorageProvider,
80 false);
81 configMember.addConfigurationOption("inventory_database_connect",
82 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
83 "Inventory database connection string",
84 InventoryDatabaseConnect,
85 false);
86
87 configMember.addConfigurationOption("authentication_provider",
88 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
89 "Authentication provider",
90 AuthenticationProvider,
91 false);
92 configMember.addConfigurationOption("authorization_provider",
93 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
94 "Authentication provider",
95 AuthorizationProvider,
96 false);
97 configMember.addConfigurationOption("metrics_provider",
98 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
99 "Metrics provider",
100 MetricsProvider,
101 false);
102 configMember.addConfigurationOption("frontends",
103 ConfigurationOption.ConfigurationTypes.TYPE_STRING,
104 "Comma-separated list of frontends",
105 Frontends,
106 false);
107
108 }
109
110 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
111 {
112 switch (configuration_key)
113 {
114 case "listen_port":
115 HttpPort = (uint) configuration_result;
116 break;
117 case "asset_storage_provider":
118 AssetStorageProvider = (string) configuration_result;
119 break;
120 case "asset_database_connect":
121 AssetDatabaseConnect = (string) configuration_result;
122 break;
123 case "inventory_storage_provider":
124 InventoryStorageProvider = (string) configuration_result;
125 break;
126 case "inventory_database_connect":
127 InventoryDatabaseConnect = (string) configuration_result;
128 break;
129 case "authentication_provider":
130 AuthenticationProvider = (string) configuration_result;
131 break;
132 case "authorization_provider":
133 AuthorizationProvider = (string) configuration_result;
134 break;
135 case "metrics_provider":
136 MetricsProvider = (string) configuration_result;
137 break;
138 case "frontends":
139 Frontends = (string) configuration_result;
140 break;
141 }
142
143 return true;
144 }
145 }
146}
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs
index 15e0b9f..b586fe3 100644
--- a/OpenSim/Framework/PluginLoader.cs
+++ b/OpenSim/Framework/PluginLoader.cs
@@ -278,6 +278,9 @@ namespace OpenSim.Framework
278 public class PluginExtensionNode : ExtensionNode 278 public class PluginExtensionNode : ExtensionNode
279 { 279 {
280 [NodeAttribute] 280 [NodeAttribute]
281 string id = "";
282
283 [NodeAttribute]
281 string provider = ""; 284 string provider = "";
282 285
283 [NodeAttribute] 286 [NodeAttribute]
@@ -285,6 +288,7 @@ namespace OpenSim.Framework
285 288
286 Type typeobj; 289 Type typeobj;
287 290
291 public string ID { get { return id; } }
288 public string Provider { get { return provider; } } 292 public string Provider { get { return provider; } }
289 public string TypeName { get { return type; } } 293 public string TypeName { get { return type; } }
290 294
@@ -349,7 +353,7 @@ namespace OpenSim.Framework
349 } 353 }
350 354
351 /// <summary> 355 /// <summary>
352 /// Filters out which plugin to load based on its the plugin name or names given. Plugin names are contained in 356 /// Filters out which plugin to load based on the plugin name or names given. Plugin names are contained in
353 /// their addin.xml 357 /// their addin.xml
354 /// </summary> 358 /// </summary>
355 public class PluginProviderFilter : IPluginFilter 359 public class PluginProviderFilter : IPluginFilter
@@ -390,4 +394,46 @@ namespace OpenSim.Framework
390 return false; 394 return false;
391 } 395 }
392 } 396 }
397
398 /// <summary>
399 /// Filters plugins according to their ID. Plugin IDs are contained in their addin.xml
400 /// </summary>
401 public class PluginIdFilter : IPluginFilter
402 {
403 private string[] m_filters;
404
405 /// <summary>
406 /// Constructor.
407 /// </summary>
408 /// <param name="p">
409 /// Plugin ID or IDs on which to filter. Multiple names should be separated by commas.
410 /// </param>
411 public PluginIdFilter(string p)
412 {
413 m_filters = p.Split(',');
414
415 for (int i = 0; i < m_filters.Length; i++)
416 {
417 m_filters[i] = m_filters[i].Trim();
418 }
419 }
420
421 /// <summary>
422 /// Apply this filter to <paramref name="plugin" />.
423 /// </summary>
424 /// <param name="plugin">PluginExtensionNode instance to check whether it passes the filter.</param>
425 /// <returns>true if the plugin's ID matches one of the filters, false otherwise.</returns>
426 public bool Apply (PluginExtensionNode plugin)
427 {
428 for (int i = 0; i < m_filters.Length; i++)
429 {
430 if (m_filters[i] == plugin.ID)
431 {
432 return true;
433 }
434 }
435
436 return false;
437 }
438 }
393} 439}
diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
index bd05d59..f6d46e8 100644
--- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
+++ b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
@@ -32,11 +32,6 @@ using System.Collections.Generic;
32using System.IO; 32using System.IO;
33using System.Net; 33using System.Net;
34using System.Reflection; 34using System.Reflection;
35using System.Security.Cryptography.X509Certificates;
36using System.ServiceProcess;
37using ExtensionLoader;
38using ExtensionLoader.Config;
39//using HttpServer;
40using log4net; 35using log4net;
41using OpenSim.Framework; 36using OpenSim.Framework;
42using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
@@ -44,12 +39,11 @@ using OpenSim.Framework.Console;
44 39
45namespace OpenSim.Grid.AssetInventoryServer 40namespace OpenSim.Grid.AssetInventoryServer
46{ 41{
47 public class AssetInventoryServer : BaseOpenSimServer//ServiceBase 42 public class AssetInventoryServer : BaseOpenSimServer
48 { 43 {
49 public const string CONFIG_FILE = "AssetInventoryServer.ini"; 44 public const string CONFIG_FILE = "AssetInventoryServer.ini";
50 45
51 //public WebServer HttpServer; 46 public AssetInventoryConfig ConfigFile;
52 public IniConfigSource ConfigFile;
53 47
54 public IAssetStorageProvider StorageProvider; 48 public IAssetStorageProvider StorageProvider;
55 public IInventoryStorageProvider InventoryProvider; 49 public IInventoryStorageProvider InventoryProvider;
@@ -57,72 +51,39 @@ namespace OpenSim.Grid.AssetInventoryServer
57 public IAuthorizationProvider AuthorizationProvider; 51 public IAuthorizationProvider AuthorizationProvider;
58 public IMetricsProvider MetricsProvider; 52 public IMetricsProvider MetricsProvider;
59 53
60 private List<IAssetInventoryServerPlugin> frontends = new List<IAssetInventoryServerPlugin>(); 54 private List<IAssetInventoryServerPlugin> m_frontends = new List<IAssetInventoryServerPlugin>();
61 private List<IAssetInventoryServerPlugin> backends = new List<IAssetInventoryServerPlugin>(); 55 private List<IAssetInventoryServerPlugin> m_backends = new List<IAssetInventoryServerPlugin>();
62 56
63 public AssetInventoryServer() 57 public AssetInventoryServer()
64 { 58 {
65 m_console = new ConsoleBase("Asset"); 59 m_console = new ConsoleBase("Asset");
66 MainConsole.Instance = m_console; 60 MainConsole.Instance = m_console;
67 //this.ServiceName = "OpenSimAssetInventoryServer";
68 } 61 }
69 62
70 public bool Start() 63 public bool Start()
71 { 64 {
72 Logger.Log.Info("Starting Asset Server"); 65 Logger.Log.Info("Starting Asset Server");
73 List<string> extensionList = null; 66 uint port = 0;
74 int port = 0;
75 X509Certificate2 serverCert = null;
76 67
77 try { ConfigFile = new IniConfigSource(CONFIG_FILE); } 68 try { ConfigFile = new AssetInventoryConfig("AssetInventory Server", (Path.Combine(Util.configDir(), "AssetInventoryServer.ini"))); }
78 catch (Exception) 69 catch (Exception)
79 { 70 {
80 Logger.Log.Error("Failed to load the config file " + CONFIG_FILE); 71 Logger.Log.Error("Failed to load the config file " + CONFIG_FILE);
81 return false; 72 return false;
82 } 73 }
83 74
84 try 75 StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", ConfigFile.AssetStorageProvider) as IAssetStorageProvider;
85 { 76 m_backends.Add(StorageProvider);
86 IConfig extensionConfig = ConfigFile.Configs["Config"];
87
88 // Load the port number to listen on
89 port = extensionConfig.GetInt("ListenPort");
90
91 // Load the server certificate file
92 string certFile = extensionConfig.GetString("SSLCertFile");
93 if (!String.IsNullOrEmpty(certFile))
94 serverCert = new X509Certificate2(certFile);
95 }
96 catch (Exception)
97 {
98 Logger.Log.Error("Failed to load [Config] section from " + CONFIG_FILE);
99 return false;
100 }
101
102 try
103 {
104 // Load the extension list (and ordering) from our config file
105 IConfig extensionConfig = ConfigFile.Configs["Extensions"];
106 extensionList = new List<string>(extensionConfig.GetKeys());
107 }
108 catch (Exception)
109 {
110 Logger.Log.Error("Failed to load [Extensions] section from " + CONFIG_FILE);
111 return false;
112 }
113
114 StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", "OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll") as IAssetStorageProvider;
115 backends.Add(StorageProvider);
116 77
117 InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", "OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll") as IInventoryStorageProvider; 78 InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", ConfigFile.InventoryStorageProvider) as IInventoryStorageProvider;
118 backends.Add(InventoryProvider); 79 m_backends.Add(InventoryProvider);
119 80
120 MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", String.Empty) as IMetricsProvider; 81 MetricsProvider = LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/MetricsProvider", ConfigFile.MetricsProvider) as IMetricsProvider;
121 backends.Add(MetricsProvider); 82 m_backends.Add(MetricsProvider);
122 83
123 try 84 try
124 { 85 {
125 InitHttpServer(port, serverCert); 86 InitHttpServer(ConfigFile.HttpPort);
126 } 87 }
127 catch (Exception ex) 88 catch (Exception ex)
128 { 89 {
@@ -131,13 +92,13 @@ namespace OpenSim.Grid.AssetInventoryServer
131 return false; 92 return false;
132 } 93 }
133 94
134 frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", String.Empty)); 95 AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", ConfigFile.AuthenticationProvider) as IAuthenticationProvider;
96 m_backends.Add(AuthenticationProvider);
135 97
136 AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", String.Empty) as IAuthenticationProvider; 98 AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", ConfigFile.AuthorizationProvider) as IAuthorizationProvider;
137 backends.Add(AuthenticationProvider); 99 m_backends.Add(AuthorizationProvider);
138 100
139 AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", String.Empty) as IAuthorizationProvider; 101 m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", ConfigFile.Frontends));
140 backends.Add(AuthorizationProvider);
141 102
142 return true; 103 return true;
143 } 104 }
@@ -154,7 +115,7 @@ namespace OpenSim.Grid.AssetInventoryServer
154 115
155 public override void ShutdownSpecific() 116 public override void ShutdownSpecific()
156 { 117 {
157 foreach (IAssetInventoryServerPlugin plugin in frontends) 118 foreach (IAssetInventoryServerPlugin plugin in m_frontends)
158 { 119 {
159 Logger.Log.Debug("Disposing plugin " + plugin.Name); 120 Logger.Log.Debug("Disposing plugin " + plugin.Name);
160 try { plugin.Dispose(); } 121 try { plugin.Dispose(); }
@@ -162,7 +123,7 @@ namespace OpenSim.Grid.AssetInventoryServer
162 { Logger.Log.ErrorFormat("Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } 123 { Logger.Log.ErrorFormat("Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); }
163 } 124 }
164 125
165 foreach (IAssetInventoryServerPlugin plugin in backends) 126 foreach (IAssetInventoryServerPlugin plugin in m_backends)
166 { 127 {
167 Logger.Log.Debug("Disposing plugin " + plugin.Name); 128 Logger.Log.Debug("Disposing plugin " + plugin.Name);
168 try { plugin.Dispose(); } 129 try { plugin.Dispose(); }
@@ -174,47 +135,14 @@ namespace OpenSim.Grid.AssetInventoryServer
174 HttpServer.Stop(); 135 HttpServer.Stop();
175 } 136 }
176 137
177 void InitHttpServer(int port, X509Certificate serverCert) 138 void InitHttpServer(uint port)
178 { 139 {
179 //if (serverCert != null) 140 m_httpServer = new BaseHttpServer(port);
180 // HttpServer = new WebServer(IPAddress.Any, port, serverCert, null, false); 141 m_httpServer.Start();
181 //else
182 // HttpServer = new WebServer(IPAddress.Any, port);
183
184 //HttpServer.LogWriter = new log4netLogWriter(Logger.Log);
185
186 //HttpServer.Set404Handler(
187 // delegate(IHttpClientContext client, IHttpRequest request, IHttpResponse response)
188 // {
189 // Logger.Log.Warn("Requested page was not found: " + request.Uri.PathAndQuery);
190
191 // string notFoundString = "<html><head><title>Page Not Found</title></head><body>The requested page or method was not found</body></html>";
192 // byte[] buffer = System.Text.Encoding.UTF8.GetBytes(notFoundString);
193 // response.Body.Write(buffer, 0, buffer.Length);
194 // response.Status = HttpStatusCode.NotFound;
195 // return true;
196 // }
197 //);
198
199 m_httpServer = new BaseHttpServer(8003);
200 HttpServer.Start();
201 142
202 Logger.Log.Info("Asset server is listening on port " + port); 143 Logger.Log.Info("Asset server is listening on port " + port);
203 } 144 }
204 145
205 #region ServiceBase Overrides
206
207 //protected override void OnStart(string[] args)
208 //{
209 // Start();
210 //}
211 //protected override void OnStop()
212 //{
213 // Shutdown();
214 //}
215
216 #endregion
217
218 private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider) 146 private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider)
219 { 147 {
220 PluginLoader<IAssetInventoryServerPlugin> loader = new PluginLoader<IAssetInventoryServerPlugin>(new AssetInventoryServerPluginInitialiser(this)); 148 PluginLoader<IAssetInventoryServerPlugin> loader = new PluginLoader<IAssetInventoryServerPlugin>(new AssetInventoryServerPluginInitialiser(this));
@@ -222,7 +150,7 @@ namespace OpenSim.Grid.AssetInventoryServer
222 if (provider == String.Empty) 150 if (provider == String.Empty)
223 loader.Add(addinPath); 151 loader.Add(addinPath);
224 else 152 else
225 loader.Add(addinPath, new PluginProviderFilter(provider)); 153 loader.Add(addinPath, new PluginIdFilter(provider));
226 //loader.Add(addinPath, new PluginCountConstraint(1)); 154 //loader.Add(addinPath, new PluginCountConstraint(1));
227 155
228 loader.Load(); 156 loader.Load();
@@ -237,7 +165,7 @@ namespace OpenSim.Grid.AssetInventoryServer
237 if (provider == String.Empty) 165 if (provider == String.Empty)
238 loader.Add(addinPath); 166 loader.Add(addinPath);
239 else 167 else
240 loader.Add(addinPath, new PluginProviderFilter(provider)); 168 loader.Add(addinPath, new PluginIdFilter(provider));
241 //loader.Add(addinPath, new PluginCountConstraint(1)); 169 //loader.Add(addinPath, new PluginCountConstraint(1));
242 170
243 loader.Load(); 171 loader.Load();
@@ -245,37 +173,4 @@ namespace OpenSim.Grid.AssetInventoryServer
245 return loader.Plugins; 173 return loader.Plugins;
246 } 174 }
247 } 175 }
248
249 //public class log4netLogWriter : ILogWriter
250 //{
251 // ILog Log;
252
253 // public log4netLogWriter(ILog log)
254 // {
255 // Log = log;
256 // }
257
258 // public void Write(object source, LogPrio prio, string message)
259 // {
260 // switch (prio)
261 // {
262 // case LogPrio.Trace:
263 // case LogPrio.Debug:
264 // Log.DebugFormat("{0}: {1}", source, message);
265 // break;
266 // case LogPrio.Info:
267 // Log.InfoFormat("{0}: {1}", source, message);
268 // break;
269 // case LogPrio.Warning:
270 // Log.WarnFormat("{0}: {1}", source, message);
271 // break;
272 // case LogPrio.Error:
273 // Log.ErrorFormat("{0}: {1}", source, message);
274 // break;
275 // case LogPrio.Fatal:
276 // Log.FatalFormat("{0}: {1}", source, message);
277 // break;
278 // }
279 // }
280 //}
281} 176}
diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs b/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs
deleted file mode 100644
index 78761be..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 * Copyright (c) 2008 Intel Corporation
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * -- Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * -- Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * -- Neither the name of the Intel Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30using System;
31using System.Xml;
32using ExtensionLoader.Config;
33using MySql.Data.MySqlClient;
34
35namespace OpenSim.Grid.AssetInventoryServer.Extensions
36{
37 public static class DBConnString
38 {
39 private static string connectionString;
40
41 /// <summary>
42 /// Parses the MySQL connection string out of either the asset server
43 /// .ini or a OpenSim-style .xml file and caches the result for future
44 /// requests
45 /// </summary>
46 public static string GetConnectionString(IniConfigSource configFile)
47 {
48 if (connectionString == null)
49 {
50 // Try parsing from the ini file
51 try
52 {
53 // Load the extension list (and ordering) from our config file
54 IConfig extensionConfig = configFile.Configs["MySQL"];
55 connectionString = extensionConfig.GetString("database_connect", null);
56 }
57 catch (Exception) { }
58
59 if (connectionString != null)
60 {
61 // Force MySQL's broken connection pooling off
62 MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(connectionString);
63 builder.Pooling = false;
64 if (String.IsNullOrEmpty(builder.Database))
65 Logger.Log.Error("No database selected in the connectionString: " + connectionString);
66 connectionString = builder.ToString();
67 }
68 else
69 {
70 Logger.Log.Error("Database connection string is missing, check that the database_connect line is " +
71 "correct and uncommented in AssetInventoryServer.ini");
72 }
73 }
74
75 return connectionString;
76 }
77 }
78}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
index e35092b..b7aef08 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
@@ -35,7 +35,6 @@ using MySql.Data.MySqlClient;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Grid.AssetInventoryServer.Extensions;
39using OpenSim.Data; 38using OpenSim.Data;
40 39
41namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim 40namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
@@ -58,7 +57,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
58 metadata = null; 57 metadata = null;
59 BackendResponse ret; 58 BackendResponse ret;
60 59
61 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 60 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect))
62 { 61 {
63 IDataReader reader; 62 IDataReader reader;
64 63
@@ -104,7 +103,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
104 assetData = null; 103 assetData = null;
105 BackendResponse ret; 104 BackendResponse ret;
106 105
107 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 106 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect))
108 { 107 {
109 IDataReader reader; 108 IDataReader reader;
110 109
@@ -156,7 +155,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
156 { 155 {
157 BackendResponse ret; 156 BackendResponse ret;
158 157
159 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 158 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect))
160 { 159 {
161 try 160 try
162 { 161 {
@@ -205,7 +204,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
205 { 204 {
206 int rowCount = 0; 205 int rowCount = 0;
207 206
208 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 207 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect))
209 { 208 {
210 MySqlDataReader reader; 209 MySqlDataReader reader;
211 210
@@ -255,7 +254,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
255 254
256 try 255 try
257 { 256 {
258 m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>("OpenSim.Data.MySQL.dll", server.ConfigFile.Configs["MySQL"].GetString("database_connect", null)); 257 m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>("OpenSim.Data.MySQL.dll", server.ConfigFile.AssetDatabaseConnect);
259 if (m_assetProvider == null) 258 if (m_assetProvider == null)
260 { 259 {
261 Logger.Log.Error("[ASSET]: Failed to load a database plugin, server halting."); 260 Logger.Log.Error("[ASSET]: Failed to load a database plugin, server halting.");
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
index a7d2f92..0ad6c80 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
@@ -35,7 +35,6 @@ using MySql.Data.MySqlClient;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Grid.AssetInventoryServer.Extensions;
39using OpenSim.Data; 38using OpenSim.Data;
40 39
41namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim 40namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
@@ -58,7 +57,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
58 item = null; 57 item = null;
59 BackendResponse ret; 58 BackendResponse ret;
60 59
61 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 60 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
62 { 61 {
63 IDataReader reader; 62 IDataReader reader;
64 63
@@ -120,7 +119,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
120 folder = null; 119 folder = null;
121 BackendResponse ret; 120 BackendResponse ret;
122 121
123 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 122 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
124 { 123 {
125 IDataReader reader; 124 IDataReader reader;
126 125
@@ -167,7 +166,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
167 contents = null; 166 contents = null;
168 BackendResponse ret; 167 BackendResponse ret;
169 168
170 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 169 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
171 { 170 {
172 IDataReader reader; 171 IDataReader reader;
173 172
@@ -267,7 +266,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
267 266
268 if (Utils.TryGetOpenSimUUID(owner, out ownerID)) 267 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
269 { 268 {
270 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 269 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
271 { 270 {
272 IDataReader reader; 271 IDataReader reader;
273 272
@@ -333,7 +332,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
333 // Fetch inventory items 332 // Fetch inventory items
334 if (Utils.TryGetOpenSimUUID(owner, out ownerID)) 333 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
335 { 334 {
336 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 335 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
337 { 336 {
338 IDataReader reader; 337 IDataReader reader;
339 338
@@ -405,7 +404,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
405 404
406 if (Utils.TryGetOpenSimUUID(owner, out ownerID)) 405 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
407 { 406 {
408 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 407 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
409 { 408 {
410 IDataReader reader; 409 IDataReader reader;
411 410
@@ -470,7 +469,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
470 { 469 {
471 BackendResponse ret; 470 BackendResponse ret;
472 471
473 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 472 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
474 { 473 {
475 try 474 try
476 { 475 {
@@ -537,7 +536,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
537 { 536 {
538 BackendResponse ret; 537 BackendResponse ret;
539 538
540 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 539 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
541 { 540 {
542 try 541 try
543 { 542 {
@@ -593,7 +592,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
593 592
594 if (Utils.TryGetOpenSimUUID(owner, out ownerID)) 593 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
595 { 594 {
596 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 595 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
597 { 596 {
598 try 597 try
599 { 598 {
@@ -639,7 +638,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
639 638
640 if (Utils.TryGetOpenSimUUID(owner, out ownerID)) 639 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
641 { 640 {
642 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 641 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
643 { 642 {
644 try 643 try
645 { 644 {
@@ -685,7 +684,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
685 684
686 if (Utils.TryGetOpenSimUUID(owner, out ownerID)) 685 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
687 { 686 {
688 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 687 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
689 { 688 {
690 try 689 try
691 { 690 {
@@ -739,7 +738,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
739 { 738 {
740 int rowCount = 0; 739 int rowCount = 0;
741 740
742 using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) 741 using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect))
743 { 742 {
744 MySqlDataReader reader; 743 MySqlDataReader reader;
745 744
@@ -789,7 +788,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
789 788
790 try 789 try
791 { 790 {
792 m_inventoryProvider = DataPluginFactory.LoadDataPlugin<IInventoryDataPlugin>("OpenSim.Data.MySQL.dll", server.ConfigFile.Configs["MySQL"].GetString("database_connect", null)); 791 m_inventoryProvider = DataPluginFactory.LoadDataPlugin<IInventoryDataPlugin>("OpenSim.Data.MySQL.dll", server.ConfigFile.InventoryDatabaseConnect);
793 if (m_inventoryProvider == null) 792 if (m_inventoryProvider == null)
794 { 793 {
795 Logger.Log.Error("[INVENTORY]: Failed to load a database plugin, server halting."); 794 Logger.Log.Error("[INVENTORY]: Failed to load a database plugin, server halting.");
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml
index 67c4cd2..c1e5c4d 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml
@@ -8,7 +8,7 @@
8 </Dependencies> 8 </Dependencies>
9 9
10 <Extension path="/OpenSim/AssetInventoryServer/MetricsProvider"> 10 <Extension path="/OpenSim/AssetInventoryServer/MetricsProvider">
11 <Plugin id="AssetInventoryMetrics" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.NullMetricsPlugin" /> 11 <Plugin id="NullMetrics" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.NullMetricsPlugin" />
12 </Extension> 12 </Extension>
13 <Extension path="/OpenSim/AssetInventoryServer/Frontend"> 13 <Extension path="/OpenSim/AssetInventoryServer/Frontend">
14 <Plugin id="BrowseFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.BrowseFrontendPlugin" /> 14 <Plugin id="BrowseFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.BrowseFrontendPlugin" />