[mapguide-commits] r4823 - in trunk/Tools/Maestro: MaestroAPI MgCooker

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue May 4 00:57:34 EDT 2010


Author: jng
Date: 2010-05-04 00:57:34 -0400 (Tue, 04 May 2010)
New Revision: 4823

Modified:
   trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
   trunk/Tools/Maestro/MaestroAPI/RequestBuilder.cs
   trunk/Tools/Maestro/MgCooker/Program.cs
   trunk/Tools/Maestro/MgCooker/RenderThread.cs
   trunk/Tools/Maestro/MgCooker/SetupRun.cs
Log:
This submission includes two fixes:

#1342: Propagate login to MgCooker UI, previously only the mapagent URL was only propagated.

#1334: Support sessionID-less GetTile requests for HttpServerConnection. This request method is only used when the connection is initialised with the Anonymous login. If initialised any other way, it will use a sessionID-based method. The thread setup has also been updated so that the sessionID-less method is used for all rendering threads.

Modified: trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs	2010-05-04 04:51:52 UTC (rev 4822)
+++ trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs	2010-05-04 04:57:34 UTC (rev 4823)
@@ -38,6 +38,8 @@
 		private Hashtable m_cachedProviderCapabilities = null;
 		private Version m_siteVersion;
 
+        private bool mAnonymousUser = false;
+
 		internal HttpServerConnection()
 			: base()
 		{
@@ -46,6 +48,12 @@
 
 		}
 
+        /// <summary>
+        /// Gets whether this connection was initialised with an Anonymous login. If it was, it will return true. 
+        /// If this was not, or it was initialised from an existing session id, then it will return false.
+        /// </summary>
+        public bool IsAnonymous { get { return mAnonymousUser; } }
+
         public const string PARAM_URL = "Url";
         public const string PARAM_SESSION = "SessionId";
         public const string PARAM_LOCALE = "Locale";
@@ -100,6 +108,8 @@
             m_username = username;
             m_password = password;
 
+            mAnonymousUser = (username == "Anonymous");
+
             try
             {
                 this.RestartSession();
@@ -1437,7 +1447,11 @@
 
         public override System.IO.Stream GetTile(string mapdefinition, string baselayergroup, int col, int row, int scaleindex, string format)
         {
-            string req = m_reqBuilder.GetTile(mapdefinition, baselayergroup, row, col, scaleindex, format, m_wc.Credentials == null);
+            string req = string.Empty;
+            if (mAnonymousUser)
+                req = m_reqBuilder.GetTileAnonymous(mapdefinition, baselayergroup, row, col, scaleindex, format);
+            else
+                req = m_reqBuilder.GetTile(mapdefinition, baselayergroup, row, col, scaleindex, format, m_wc.Credentials == null);
             return this.OpenRead(req);
         }
 

Modified: trunk/Tools/Maestro/MaestroAPI/RequestBuilder.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/RequestBuilder.cs	2010-05-04 04:51:52 UTC (rev 4822)
+++ trunk/Tools/Maestro/MaestroAPI/RequestBuilder.cs	2010-05-04 04:57:34 UTC (rev 4823)
@@ -1151,6 +1151,24 @@
             return m_hosturi + "?" + EncodeParameters(param);
         }
 
+        public string GetTileAnonymous(string mapdefinition, string groupname, int row, int col, int scaleindex, string format)
+        {
+            NameValueCollection param = new NameValueCollection();
+            param.Add("OPERATION", "GETTILEIMAGE");
+            param.Add("VERSION", "1.2.0");
+            param.Add("USERNAME", "Anonymous");
+            param.Add("PASSWORD", "");
+            param.Add("SCALEINDEX", scaleindex.ToString());
+            param.Add("MAPDEFINITION", mapdefinition);
+            param.Add("FORMAT", format);
+            param.Add("BASEMAPLAYERGROUPNAME", groupname);
+            param.Add("TILECOL", row.ToString());
+            param.Add("TILEROW", col.ToString());
+            param.Add("CLIENTAGENT", m_userAgent);
+
+            return m_hosturi + "?" + EncodeParameters(param);
+        }
+
         public System.Net.WebRequest ApplyPackage(System.IO.Stream filestream, Utility.StreamCopyProgressDelegate callback)
         {
             if (m_sessionID == null)

Modified: trunk/Tools/Maestro/MgCooker/Program.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Program.cs	2010-05-04 04:51:52 UTC (rev 4822)
+++ trunk/Tools/Maestro/MgCooker/Program.cs	2010-05-04 04:57:34 UTC (rev 4823)
@@ -160,6 +160,9 @@
 
             MaestroAPI.ServerConnectionI connection = null;
 
+            string[] maps = mapdefinitions.Split(',');
+
+            SetupRun sr = null;
             if (!opts.ContainsKey("username") || (!opts.ContainsKey("mapagent")))
             {
                 if (largs.IndexOf("/commandline") < 0 && largs.IndexOf("commandline") < 0)
@@ -170,6 +173,8 @@
 
                     connection = frm.Connection;
                     mapagent = ((MaestroAPI.HttpServerConnection)connection).ServerURI;
+
+                    sr = new SetupRun(frm.Username, frm.Password, connection, maps, opts);
                 }
             }
 
@@ -184,11 +189,13 @@
                 }
             }
 
-            string[] maps = mapdefinitions.Split(',');
+            
 
             if (largs.IndexOf("batch") < 0 && largs.IndexOf("/batch") < 0)
             {
-                SetupRun sr = new SetupRun(connection, maps, opts);
+                if (sr == null)
+                    sr = new SetupRun(connection, maps, opts);
+
                 sr.ShowDialog();
                 return;
             }

Modified: trunk/Tools/Maestro/MgCooker/RenderThread.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/RenderThread.cs	2010-05-04 04:51:52 UTC (rev 4822)
+++ trunk/Tools/Maestro/MgCooker/RenderThread.cs	2010-05-04 04:57:34 UTC (rev 4823)
@@ -256,9 +256,17 @@
                 System.Threading.AutoResetEvent ev = new System.Threading.AutoResetEvent(false);
 
                 if (Parent.Connection is HttpServerConnection)
-                    con = ConnectionFactory.CreateHttpConnection(new Uri(((HttpServerConnection)Parent.Connection).ServerURI), Parent.Connection.SessionID, null, true);
+                {
+                    HttpServerConnection hc = Parent.Connection as HttpServerConnection;
+                    if (hc.IsAnonymous)
+                        con = ConnectionFactory.CreateHttpConnection(new Uri(hc.ServerURI), "Anonymous", "", null, true);
+                    else
+                        con = ConnectionFactory.CreateHttpConnection(new Uri(hc.ServerURI), Parent.Connection.SessionID, null, true);
+                }
                 else
+                {
                     con = ConnectionFactory.CreateLocalNativeConnection(Parent.Connection.SessionID);
+                }
 
 
                 while (!Parent.Cancel)

Modified: trunk/Tools/Maestro/MgCooker/SetupRun.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/SetupRun.cs	2010-05-04 04:51:52 UTC (rev 4822)
+++ trunk/Tools/Maestro/MgCooker/SetupRun.cs	2010-05-04 04:57:34 UTC (rev 4823)
@@ -39,6 +39,12 @@
             InitializeComponent();
         }
 
+        internal SetupRun(string userName, string password, MaestroAPI.ServerConnectionI connection, string[] maps, Dictionary<string, string> args)
+            : this(connection, maps, args)
+        {
+            Username.Text = userName;
+            Password.Text = password;
+        }
 
         public SetupRun(MaestroAPI.ServerConnectionI connection, string[] maps, Dictionary<string, string> args)
             : this()



More information about the mapguide-commits mailing list