[mapguide-commits] r4739 - in trunk/Tools/Maestro: . Maestro
Maestro/FusionEditor Maestro/LoginForm
Maestro/MaestroEditorInterface Maestro/ResourceBrowser
Maestro/ResourceEditors Maestro/ResourceValidators MaestroAPI
MaestroAPI/PackageBuilder MgCooker MgCooker/MgCookerCommandline
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Apr 6 06:01:30 EDT 2010
Author: jng
Date: 2010-04-06 06:01:29 -0400 (Tue, 06 Apr 2010)
New Revision: 4739
Added:
trunk/Tools/Maestro/MaestroAPI/ConnectionFactory.cs
trunk/Tools/Maestro/MaestroAPI/ConnectionProviderRegistry.cs
trunk/Tools/Maestro/MaestroAPI/ConnectionProviders.xml
Modified:
trunk/Tools/Maestro/
trunk/Tools/Maestro/Maestro/
trunk/Tools/Maestro/Maestro/FusionEditor/
trunk/Tools/Maestro/Maestro/LoginForm/
trunk/Tools/Maestro/Maestro/LoginForm/FormLogin.cs
trunk/Tools/Maestro/Maestro/MaestroEditorInterface/
trunk/Tools/Maestro/Maestro/ResourceBrowser/
trunk/Tools/Maestro/Maestro/ResourceEditors/
trunk/Tools/Maestro/Maestro/ResourceValidators/
trunk/Tools/Maestro/MaestroAPI/
trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs
trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
trunk/Tools/Maestro/MaestroAPI/PackageBuilder/
trunk/Tools/Maestro/MgCooker/
trunk/Tools/Maestro/MgCooker/BatchSettings.cs
trunk/Tools/Maestro/MgCooker/MgCookerCommandline/
trunk/Tools/Maestro/MgCooker/Program.cs
trunk/Tools/Maestro/MgCooker/RenderThread.cs
trunk/Tools/Maestro/MgCooker/SetupRun.cs
Log:
This submission includes the following changes:
- #1305: Change connection creation to a xml-registry based approach. Mark existing ctors as deprecated. All references to existing ctors have been redirected to the new creation method. A ConnectionFactory class has been included to create ServerConnectionI objects the old-fashioned way.
- Set svn ignore flags for commonly generated files and directories.
Property changes on: trunk/Tools/Maestro
___________________________________________________________________
Added: svn:ignore
+ *.suo
Property changes on: trunk/Tools/Maestro/Maestro
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Property changes on: trunk/Tools/Maestro/Maestro/FusionEditor
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Property changes on: trunk/Tools/Maestro/Maestro/LoginForm
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Modified: trunk/Tools/Maestro/Maestro/LoginForm/FormLogin.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/LoginForm/FormLogin.cs 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/Maestro/LoginForm/FormLogin.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -293,7 +293,7 @@
else
con = new OSGeo.MapGuide.MaestroAPI.HttpServerConnection(new Uri(cmbServerUrl.Text), txtUsername.Text, txtPassword.Text, System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName, true);
#else
- OSGeo.MapGuide.MaestroAPI.ServerConnectionI con = new OSGeo.MapGuide.MaestroAPI.HttpServerConnection(new Uri(cmbServerUrl.Text), txtUsername.Text, txtPassword.Text, System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName, true);
+ OSGeo.MapGuide.MaestroAPI.ServerConnectionI con = OSGeo.MapGuide.MaestroAPI.ConnectionFactory.CreateHttpConnection(new Uri(cmbServerUrl.Text), txtUsername.Text, txtPassword.Text, System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName, true);
((OSGeo.MapGuide.MaestroAPI.HttpServerConnection)con).UserAgent = "MapGuide Maestro v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
#endif
if (con.SiteVersion > con.MaxTestedVersion && con.SiteVersion > ps.ApprovedVersion)
Property changes on: trunk/Tools/Maestro/Maestro/MaestroEditorInterface
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Property changes on: trunk/Tools/Maestro/Maestro/ResourceBrowser
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Property changes on: trunk/Tools/Maestro/Maestro/ResourceEditors
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Property changes on: trunk/Tools/Maestro/Maestro/ResourceValidators
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Property changes on: trunk/Tools/Maestro/MaestroAPI
___________________________________________________________________
Added: svn:ignore
+ bin
obj
OSGeo.MapGuide.MaestroAPI.csproj.user
Added: trunk/Tools/Maestro/MaestroAPI/ConnectionFactory.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ConnectionFactory.cs (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/ConnectionFactory.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OSGeo.MapGuide.MaestroAPI
+{
+ /// <summary>
+ /// Helper class to create well known <see cref="ServerConnectionI"/> objects
+ /// </summary>
+ public sealed class ConnectionFactory
+ {
+ /// <summary>
+ /// Creates a HTTP implementation of <see cref="ServerConnectionI"/>
+ /// </summary>
+ /// <param name="hosturl"></param>
+ /// <param name="sessionid"></param>
+ /// <param name="locale"></param>
+ /// <param name="allowUntestedVersion"></param>
+ /// <returns></returns>
+ public static ServerConnectionI CreateHttpConnection(Uri hosturl, string sessionid, string locale, bool allowUntestedVersion)
+ {
+ string connStr = string.Empty;
+ if (string.IsNullOrEmpty(locale))
+ {
+ connStr = string.Format("{0}={1};{2}={3};{4}={5}",
+ HttpServerConnection.PARAM_URL, hosturl.ToString(),
+ HttpServerConnection.PARAM_SESSION, sessionid,
+ HttpServerConnection.PARAM_UNTESTED, allowUntestedVersion);
+ }
+ else
+ {
+ connStr = string.Format("{0}={1};{2}={3};{4}={5};{6}={7}",
+ HttpServerConnection.PARAM_URL, hosturl.ToString(),
+ HttpServerConnection.PARAM_SESSION, sessionid,
+ HttpServerConnection.PARAM_LOCALE, locale,
+ HttpServerConnection.PARAM_UNTESTED, allowUntestedVersion);
+ }
+ return ConnectionProviderRegistry.CreateConnection("Maestro.Http", connStr);
+ }
+
+ /// <summary>
+ /// Creates a HTTP implementation of <see cref="ServerConnectionI"/>
+ /// </summary>
+ /// <param name="hosturl"></param>
+ /// <param name="username"></param>
+ /// <param name="password"></param>
+ /// <param name="locale"></param>
+ /// <param name="allowUntestedVersion"></param>
+ /// <returns></returns>
+ public static ServerConnectionI CreateHttpConnection(Uri hosturl, string username, string password, string locale, bool allowUntestedVersion)
+ {
+ string connStr = string.Empty;
+ if (string.IsNullOrEmpty(locale))
+ {
+ connStr = string.Format("{0}={1};{2}={3};{4}={5};{6}={7}",
+ HttpServerConnection.PARAM_URL, hosturl.ToString(),
+ HttpServerConnection.PARAM_USERNAME, username,
+ HttpServerConnection.PARAM_PASSWORD, password,
+ HttpServerConnection.PARAM_UNTESTED, allowUntestedVersion);
+ }
+ else
+ {
+ connStr = string.Format("{0}={1};{2}={3};{4}={5};{6}={7};{8}={9}",
+ HttpServerConnection.PARAM_URL, hosturl.ToString(),
+ HttpServerConnection.PARAM_USERNAME, username,
+ HttpServerConnection.PARAM_PASSWORD, password,
+ HttpServerConnection.PARAM_LOCALE, locale,
+ HttpServerConnection.PARAM_UNTESTED, allowUntestedVersion);
+ }
+ return ConnectionProviderRegistry.CreateConnection("Maestro.Http", connStr);
+ }
+
+ /// <summary>
+ /// Creates a local native implementation of <see cref="ServerConnectionI"/>
+ /// </summary>
+ /// <param name="configFile"></param>
+ /// <param name="username"></param>
+ /// <param name="password"></param>
+ /// <param name="locale"></param>
+ /// <returns></returns>
+ public static ServerConnectionI CreateLocalNativeConnection(string configFile, string username, string password, string locale)
+ {
+ string connStr = string.Empty;
+ if (string.IsNullOrEmpty(locale))
+ {
+ connStr = string.Format("{0}={1};{2}={3};{4}={5}",
+ LocalNativeConnection.PARAM_CONFIG, configFile,
+ LocalNativeConnection.PARAM_USERNAME, username,
+ LocalNativeConnection.PARAM_PASSWORD, password);
+ }
+ else
+ {
+ connStr = string.Format("{0}={1};{2}={3};{4}={5};{6}={7}",
+ LocalNativeConnection.PARAM_CONFIG, configFile,
+ LocalNativeConnection.PARAM_USERNAME, username,
+ LocalNativeConnection.PARAM_PASSWORD, password,
+ LocalNativeConnection.PARAM_LOCALE, locale);
+ }
+ return ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", connStr);
+ }
+
+ /// <summary>
+ /// Creates a local native implementation of <see cref="ServerConnectionI"/>
+ /// </summary>
+ /// <param name="sessionid"></param>
+ /// <returns></returns>
+ public static ServerConnectionI CreateLocalNativeConnection(string sessionid)
+ {
+ return ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", LocalNativeConnection.PARAM_SESSION + "=" + sessionid);
+ }
+ }
+}
Added: trunk/Tools/Maestro/MaestroAPI/ConnectionProviderRegistry.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ConnectionProviderRegistry.cs (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/ConnectionProviderRegistry.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+using System.Reflection;
+using System.Collections.Specialized;
+
+namespace OSGeo.MapGuide.MaestroAPI
+{
+ public class ConnectionProviderEntry
+ {
+ public string Name { get; private set; }
+ public string Description { get; private set; }
+
+ internal ConnectionProviderEntry(string name, string desc)
+ {
+ this.Name = name;
+ this.Description = desc;
+ }
+ }
+
+ /// <summary>
+ /// The <see cref="ConnectionProviderRegistry"/> supports dynamic creation of <see cref="ServerConnectionI"/> objects given a provider name
+ /// and a connection string, which specifies the initialization parameters of the connection. The connection providers are defined in an XML
+ /// file called ConnectionProviders.xml which contains all the registered providers. Each provider has the following properties:
+ ///
+ /// 1. The name of the provider
+ /// 2. The assembly containing the <see cref="ServerConnectionI"/> implementation
+ /// 3. The name of this <see cref="ServerConnectionI"/> implementation.
+ ///
+ /// The <see cref="ServerConnectionI"/> implementation is expected to have a non-public constructor which takes a single parameter,
+ /// a <see cref="System.Collections.Specialized.NameValueCollection"/> containing the initialization parameters parsed from the given connection
+ /// string.
+ /// </summary>
+ public sealed class ConnectionProviderRegistry
+ {
+ const string PROVIDER_CONFIG = "ConnectionProviders.xml";
+
+ static Dictionary<string, Type> _ctors;
+ static List<ConnectionProviderEntry> _providers;
+
+ static ConnectionProviderRegistry()
+ {
+ _ctors = new Dictionary<string, Type>();
+ _providers = new List<ConnectionProviderEntry>();
+
+ XmlDocument doc = new XmlDocument();
+ doc.Load(PROVIDER_CONFIG);
+
+ XmlNodeList providers = doc.SelectNodes("//ConnectionProviderRegistry/ConnectionProvider");
+ foreach (XmlNode prov in providers)
+ {
+ string name = prov["Name"].InnerText.ToUpper();
+ string desc = prov["Description"].InnerText;
+ string dll = prov["Assembly"].InnerText;
+ string type = prov["Type"].InnerText;
+
+ Assembly asm = Assembly.LoadFrom(dll);
+ Type t = asm.GetType(type);
+
+ _ctors[name] = t;
+ _providers.Add(new ConnectionProviderEntry(name, desc));
+ }
+ }
+
+ private static NameValueCollection ParseConnectionString(string connectionString)
+ {
+ NameValueCollection values = new NameValueCollection();
+ string[] tokens = connectionString.Split(';');
+ foreach (string tok in tokens)
+ {
+ string[] nameValue = tok.Split('=');
+
+ if (nameValue.Length == 2)
+ {
+ values.Add(nameValue[0], nameValue[1]);
+ }
+ }
+ return values;
+ }
+
+ /// <summary>
+ /// Gets a list of registered provider names. The returned names are in upper-case.
+ /// </summary>
+ /// <returns></returns>
+ public static ConnectionProviderEntry[] GetProviders()
+ {
+ return _providers.ToArray();
+ }
+
+ /// <summary>
+ /// Creates an initialized <see cref="ServerConnectionI"/> object given the provider name and connection string
+ /// </summary>
+ /// <param name="provider"></param>
+ /// <param name="connectionString"></param>
+ /// <returns></returns>
+ public static ServerConnectionI CreateConnection(string provider, string connectionString)
+ {
+ string name = provider.ToUpper();
+ if (!_ctors.ContainsKey(name))
+ throw new ArgumentException("Provider not registered: " + provider);
+
+ Type t = _ctors[name];
+
+ NameValueCollection initParams = ParseConnectionString(connectionString);
+
+ BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance;
+ ServerConnectionI conn = (ServerConnectionI)t.InvokeMember(null, flags, null, null, new object[] { initParams });
+ return conn;
+ }
+ }
+}
Added: trunk/Tools/Maestro/MaestroAPI/ConnectionProviders.xml
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ConnectionProviders.xml (rev 0)
+++ trunk/Tools/Maestro/MaestroAPI/ConnectionProviders.xml 2010-04-06 10:01:29 UTC (rev 4739)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ConnectionProviderRegistry>
+ <ConnectionProvider>
+ <Name>Maestro.Http</Name>
+ <Description>Connection using the mapagent http API</Description>
+ <Assembly>OSGeo.MapGuide.MaestroAPI.dll</Assembly>
+ <Type>OSGeo.MapGuide.MaestroAPI.HttpServerConnection</Type>
+ </ConnectionProvider>
+ <ConnectionProvider>
+ <Name>Maestro.LocalNative</Name>
+ <Description>Connection using the MapGuide Web API</Description>
+ <Assembly>OSGeo.MapGuide.MaestroAPI.dll</Assembly>
+ <Type>OSGeo.MapGuide.MaestroAPI.LocalNativeConnection</Type>
+ </ConnectionProvider>
+</ConnectionProviderRegistry>
Modified: trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -46,68 +46,120 @@
}
+ public const string PARAM_URL = "Url";
+ public const string PARAM_SESSION = "SessionId";
+ public const string PARAM_LOCALE = "Locale";
+ public const string PARAM_UNTESTED = "AllowUntestedVersion";
+ public const string PARAM_USERNAME = "Username";
+ public const string PARAM_PASSWORD = "Password";
+
+ private void InitConnection(Uri hosturl, string sessionid, string locale, bool allowUntestedVersion)
+ {
+ m_reqBuilder = new RequestBuilder(hosturl, locale, sessionid);
+ string req = m_reqBuilder.GetSiteVersion();
+ SiteVersion sv = null;
+ try
+ {
+ sv = (SiteVersion)DeserializeObject(typeof(SiteVersion), m_wc.OpenRead(req));
+ }
+ catch (Exception ex)
+ {
+ sv = null;
+ bool ok = false;
+ try
+ {
+ //Retry, and append missing path, if applicable
+ if (!hosturl.ToString().EndsWith("/mapagent/mapagent.fcgi"))
+ {
+ string tmp = hosturl.ToString();
+ if (!tmp.EndsWith("/"))
+ tmp += "/";
+ hosturl = new Uri(tmp + "mapagent/mapagent.fcgi");
+ m_reqBuilder = new RequestBuilder(hosturl, locale, sessionid);
+ req = m_reqBuilder.GetSiteVersion();
+ sv = (SiteVersion)DeserializeObject(typeof(SiteVersion), m_wc.OpenRead(req));
+ ok = true;
+ }
+ }
+ catch { }
+
+ if (!ok) //Report original error
+ throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + ex.Message, ex);
+ }
+ if (!allowUntestedVersion)
+ ValidateVersion(sv);
+ m_siteVersion = new Version(sv.Version);
+ }
+
+ private void InitConnection(Uri hosturl, string username, string password, string locale, bool allowUntestedVersion)
+ {
+ m_reqBuilder = new RequestBuilder(hosturl, locale);
+ m_wc.Credentials = new NetworkCredential(username, password);
+ string req = m_reqBuilder.CreateSession();
+
+ m_username = username;
+ m_password = password;
+
+ try
+ {
+ this.RestartSession();
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Failed to connect, please check network connection and login information.\nExtended error info: " + ex.Message, ex);
+ }
+
+ if (!allowUntestedVersion)
+ ValidateVersion(m_siteVersion);
+ m_username = username;
+ m_password = password;
+ }
+
+ //This is the constructor used by ConnectionProviderRegistry.CreateConnection
+
+ internal HttpServerConnection(NameValueCollection initParams)
+ : this()
+ {
+ if (initParams[PARAM_URL] == null)
+ throw new ArgumentException("Missing required connection parameter: " + PARAM_URL);
+
+ string locale = null;
+ bool allowUntestedVersion = true;
+
+ if (initParams[PARAM_LOCALE] != null)
+ locale = initParams[PARAM_LOCALE];
+ if (initParams[PARAM_UNTESTED] != null)
+ bool.TryParse(initParams[PARAM_UNTESTED], out allowUntestedVersion);
+
+ if (initParams[PARAM_SESSION] != null)
+ {
+ string sessionid = initParams[PARAM_SESSION];
+
+ InitConnection(new Uri(initParams[PARAM_URL]), sessionid, locale, allowUntestedVersion);
+ }
+ else //Assuming username/password combination
+ {
+ if (initParams[PARAM_USERNAME] == null)
+ throw new ArgumentException("Missing required connection parameter: " + PARAM_USERNAME);
+ if (initParams[PARAM_PASSWORD] == null)
+ throw new ArgumentException("Missing required connection parameter: " + PARAM_PASSWORD);
+
+ InitConnection(new Uri(initParams[PARAM_URL]), initParams[PARAM_USERNAME], initParams[PARAM_PASSWORD], locale, allowUntestedVersion);
+ }
+ }
+
+ [Obsolete("This will be removed in the future. Use ConnectionProviderRegistry.CreateConnection() instead")]
public HttpServerConnection(Uri hosturl, string sessionid, string locale, bool allowUntestedVersion)
: this()
{
- m_reqBuilder = new RequestBuilder(hosturl, locale, sessionid);
- string req = m_reqBuilder.GetSiteVersion();
- SiteVersion sv = null;
- try
- {
- sv = (SiteVersion)DeserializeObject(typeof(SiteVersion), m_wc.OpenRead(req));
- }
- catch(Exception ex)
- {
- sv = null;
- bool ok = false;
- try
- {
- //Retry, and append missing path, if applicable
- if (!hosturl.ToString().EndsWith("/mapagent/mapagent.fcgi"))
- {
- string tmp = hosturl.ToString();
- if (!tmp.EndsWith("/"))
- tmp += "/";
- hosturl = new Uri(tmp + "mapagent/mapagent.fcgi");
- m_reqBuilder = new RequestBuilder(hosturl, locale, sessionid);
- req = m_reqBuilder.GetSiteVersion();
- sv = (SiteVersion)DeserializeObject(typeof(SiteVersion), m_wc.OpenRead(req));
- ok = true;
- }
- }
- catch {}
-
- if (!ok) //Report original error
- throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + ex.Message, ex);
- }
- if (!allowUntestedVersion)
- ValidateVersion(sv);
- m_siteVersion = new Version(sv.Version);
+ InitConnection(hosturl, sessionid, locale, allowUntestedVersion);
}
+ [Obsolete("This will be removed in the future. Use ConnectionProviderRegistry.CreateConnection() instead")]
public HttpServerConnection(Uri hosturl, string username, string password, string locale, bool allowUntestedVersion)
: this()
{
- m_reqBuilder = new RequestBuilder(hosturl, locale);
- m_wc.Credentials = new NetworkCredential(username, password);
- string req = m_reqBuilder.CreateSession();
-
- m_username = username;
- m_password = password;
-
- try
- {
- this.RestartSession();
- }
- catch(Exception ex)
- {
- throw new Exception("Failed to connect, please check network connection and login information.\nExtended error info: " + ex.Message, ex);
- }
-
- if (!allowUntestedVersion)
- ValidateVersion(m_siteVersion);
- m_username = username;
- m_password = password;
+ InitConnection(hosturl, username, password, locale, allowUntestedVersion);
}
public override string SessionID
Modified: trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -19,6 +19,7 @@
#endregion
using System;
using OSGeo.MapGuide;
+using System.Collections.Specialized;
namespace OSGeo.MapGuide.MaestroAPI
{
@@ -33,30 +34,79 @@
private string m_sessionId;
private Version m_siteVersion = null;
+ public const string PARAM_SESSION = "SessionId";
+ public const string PARAM_CONFIG = "ConfigFile";
+ public const string PARAM_USERNAME = "Username";
+ public const string PARAM_PASSWORD = "Password";
+ public const string PARAM_LOCALE = "Locale";
+
private LocalNativeConnection()
: base()
{
}
+ //This is the constructor used by ConnectionProviderRegistry.CreateConnection
+
+ internal LocalNativeConnection(NameValueCollection initParams)
+ : this()
+ {
+ if (initParams[PARAM_SESSION] != null)
+ {
+ string sessionid = initParams[PARAM_SESSION];
+
+ InitConnection(sessionid);
+ }
+ else
+ {
+ if (initParams[PARAM_CONFIG] == null)
+ throw new ArgumentException("Missing connection parameter: " + PARAM_CONFIG);
+ if (initParams[PARAM_PASSWORD] == null)
+ throw new ArgumentException("Missing connection parameter: " + PARAM_PASSWORD);
+ if (initParams[PARAM_USERNAME] == null)
+ throw new ArgumentException("Missing connection parameter: " + PARAM_USERNAME);
+
+ string configFile = initParams[PARAM_CONFIG];
+ string password = initParams[PARAM_PASSWORD];
+ string username = initParams[PARAM_USERNAME];
+ string locale = null;
+ if (initParams[PARAM_LOCALE] != null)
+ locale = initParams[PARAM_LOCALE];
+
+ InitConnection(configFile, username, password, locale);
+ }
+ }
+
+ private void InitConnection(string sessionid)
+ {
+ MgUserInformation mgui = new MgUserInformation(sessionid);
+ m_con = new MgSiteConnection();
+ m_con.Open(mgui);
+ m_sessionId = sessionid;
+ }
+
+ private void InitConnection(string configFile, string username, string password, string locale)
+ {
+ m_username = username;
+ m_password = password;
+ m_locale = locale;
+
+ OSGeo.MapGuide.MapGuideApi.MgInitializeWebTier(configFile);
+ //Throws an exception if it fails
+ RestartSession();
+ }
+
+ [Obsolete("This will be removed in the future. Use ConnectionProviderRegistry.CreateConnection() instead")]
public LocalNativeConnection(string sessionid)
: this()
{
- MgUserInformation mgui = new MgUserInformation(sessionid);
- m_con = new MgSiteConnection();
- m_con.Open(mgui);
- m_sessionId = sessionid;
+ InitConnection(sessionid);
}
+ [Obsolete("This will be removed in the future. Use ConnectionProviderRegistry.CreateConnection() instead")]
public LocalNativeConnection(string configFile, string username, string password, string locale)
: this()
{
- m_username = username;
- m_password = password;
- m_locale = locale;
-
- OSGeo.MapGuide.MapGuideApi.MgInitializeWebTier(configFile);
- //Throws an exception if it fails
- RestartSession();
+ InitConnection(configFile, username, password, locale);
}
Modified: trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj 2010-04-06 10:01:29 UTC (rev 4739)
@@ -1,7 +1,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectType>Local</ProjectType>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{290B027E-3649-4A60-A9BF-0544831435E2}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -132,6 +132,8 @@
<Compile Include="BinarySerializer\MgBinarySerializer.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="ConnectionFactory.cs" />
+ <Compile Include="ConnectionProviderRegistry.cs" />
<Compile Include="HttpCoordinateSystem.cs">
<SubType>Code</SubType>
</Compile>
@@ -319,6 +321,9 @@
<Compile Include="XmlValidator.cs">
<SubType>Code</SubType>
</Compile>
+ <Content Include="ConnectionProviders.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
<Content Include="Schemas\ApplicationDefinition-1.0.0.xsd">
<SubType>Designer</SubType>
</Content>
Property changes on: trunk/Tools/Maestro/MaestroAPI/PackageBuilder
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Property changes on: trunk/Tools/Maestro/MgCooker
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Modified: trunk/Tools/Maestro/MgCooker/BatchSettings.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/BatchSettings.cs 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/MgCooker/BatchSettings.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -242,7 +242,7 @@
/// <param name="password">The password to connect with</param>
/// <param name="maps">A list of maps to process, leave empty to process all layers</param>
public BatchSettings(string mapagent, string username, string password, params string[] maps)
- : this(new MaestroAPI.HttpServerConnection(new Uri(mapagent), username, password, null, true), maps)
+ : this(MaestroAPI.ConnectionFactory.CreateHttpConnection(new Uri(mapagent), username, password, null, true), maps)
{
}
Property changes on: trunk/Tools/Maestro/MgCooker/MgCookerCommandline
___________________________________________________________________
Added: svn:ignore
+ bin
obj
Modified: trunk/Tools/Maestro/MgCooker/Program.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Program.cs 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/MgCooker/Program.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -176,11 +176,11 @@
if (connection == null)
{
if (!opts.ContainsKey("native-connection"))
- connection = new OSGeo.MapGuide.MaestroAPI.HttpServerConnection(new Uri(mapagent), username, password, System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, true);
+ connection = OSGeo.MapGuide.MaestroAPI.ConnectionFactory.CreateHttpConnection(new Uri(mapagent), username, password, System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, true);
else
{
string serverconfig = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "webconfig.ini");
- connection = new OSGeo.MapGuide.MaestroAPI.LocalNativeConnection(serverconfig, username, password, System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);
+ connection = OSGeo.MapGuide.MaestroAPI.ConnectionFactory.CreateLocalNativeConnection(serverconfig, username, password, System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);
}
}
Modified: trunk/Tools/Maestro/MgCooker/RenderThread.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/RenderThread.cs 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/MgCooker/RenderThread.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -256,9 +256,9 @@
System.Threading.AutoResetEvent ev = new System.Threading.AutoResetEvent(false);
if (Parent.Connection is HttpServerConnection)
- con = new HttpServerConnection(new Uri(((HttpServerConnection)Parent.Connection).ServerURI), Parent.Connection.SessionID, null, true);
+ con = ConnectionFactory.CreateHttpConnection(new Uri(((HttpServerConnection)Parent.Connection).ServerURI), Parent.Connection.SessionID, null, true);
else
- con = new LocalNativeConnection(Parent.Connection.SessionID);
+ con = ConnectionFactory.CreateLocalNativeConnection(Parent.Connection.SessionID);
while (!Parent.Cancel)
Modified: trunk/Tools/Maestro/MgCooker/SetupRun.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/SetupRun.cs 2010-04-05 17:35:14 UTC (rev 4738)
+++ trunk/Tools/Maestro/MgCooker/SetupRun.cs 2010-04-06 10:01:29 UTC (rev 4739)
@@ -161,7 +161,7 @@
try
{
- con = new MaestroAPI.LocalNativeConnection(webconfig, Username.Text, Password.Text, null);
+ con = OSGeo.MapGuide.MaestroAPI.ConnectionFactory.CreateLocalNativeConnection(webconfig, Username.Text, Password.Text, null);
}
catch (Exception ex)
{
@@ -173,7 +173,7 @@
{
try
{
- con = new MaestroAPI.HttpServerConnection(new Uri(MapAgent.Text), Username.Text, Password.Text, null, true);
+ con = OSGeo.MapGuide.MaestroAPI.ConnectionFactory.CreateHttpConnection(new Uri(MapAgent.Text), Username.Text, Password.Text, null, true);
}
catch (Exception ex)
{
@@ -493,4 +493,4 @@
m_coordinateOverrides[root.Text].MaxY = d;
}
}
-}
\ No newline at end of file
+}
More information about the mapguide-commits
mailing list